Bug 248270

Summary: audio/lmms bash completion script stages in PREFIX not STAGEDIR
Product: Ports & Packages Reporter: alt2600
Component: Individual Port(s)Assignee: Rodrigo Osorio <rodrigo>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: vvelox
Priority: --- Flags: bugzilla: maintainer-feedback? (rodrigo)
Version: Latest   
Hardware: Any   
OS: Any   
Description Flags
lmms Makefile diff
audio/lmms/Makefile proposed none

Description alt2600 2020-07-25 22:43:14 UTC
problem seems new after the July 12 portbump, but doesn't appear to come from anything done in that portbump. I know since then at least bash moved to /usr/local prefix but not sure its related. I have version 1.2.1,2 installed in lmms, but it will not longer update due to missing staged files with bash_completion

-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/classic/style.css
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/style.css
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/moog.bin
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/saw.bin
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/sqr.bin
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/tri.bin

Installing bash completion...

Bash completion for lmms has been installed to /usr/local/share/bash-completion/completions/lmms


/usr/ports/audio/lmms|$} ls -l /usr/local/share/bash-completion/completions/lmms 
-rw-r--r--  1 root  wheel  9751 Jul 25 15:43 /usr/local/share/bash-completion/completions/lmms


make install or prefix fails as it is missing the lmms bash_completion script which is already installed into prefix

line 30-51 of /usr/ports/audio/lmms/work/lmms-1.2.1/cmake/modules seems to be the culprit of either falling back to hardcoded path or finding the correct path from pkg-config but that breaks staging as it totally ignores the staging prefix, but not sure why it would have seemingly worked before but not now. 

	# Honor manual override if provided
		# First, use pkg-config, which is the most reliable
			PKG_GET_VARIABLE(BASHCOMP_PKG_PATH bash-completion completionsdir)
			# Second, use cmake (preferred but less common)
			FIND_PACKAGE(bash-completion QUIET)

		# Third, use a hard-coded fallback value
			SET(BASHCOMP_PKG_PATH "/usr/share/bash-completion/completions")

Not sure if I'm the only one having these issues, I'm pretty sure I could update the patch to this file by adding deletions to this code to hardcode the install to staging by forcing the BASHCOMP_PKG_PATH. Although I would likely hard code it to a code of somesort and run a REPLACE_CMD post patch so it would dynamically replace with the correct STAGEDIR during make if the source updates to later versions and doesn't change these cmake modules it would still work. Not sure how else to fix this. I've tried editing the port Makefile giving the  BASHCOMP_PKG_PATH as a CONFIGURE_ENV which breaks the build and setting CMAKE_ARGS to include setting this variable to the stagedir, but that didn't seem to work either.
Comment 1 alt2600 2020-08-07 23:16:15 UTC
Created attachment 217074 [details]
lmms Makefile diff

figured out my syntax added appropriate CMAKE_ARGS to set the BASHCOMP_PKG_PATH variable to stage. this is the diff
Comment 2 alt2600 2020-08-07 23:17:17 UTC
Created attachment 217075 [details]
audio/lmms/Makefile proposed

this is the full fixed Makefile

Comment 3 alt2600 2020-08-07 23:21:36 UTC
must have had poor syntax in my previous tests, added CMAKE_ARGS to set BASHCOMP_PKG_PATH for STAGEDIR/PREFIX it now stages, packages, and it installs fine. I'm using it now. Not sure how to make a correct patch but its a one liner in the Makefile.

-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/vst_plugin_file.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/whatsthis.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/white_key.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/white_key_pressed.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/white_noise_wave_active.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/white_noise_wave_inactive.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/zoom.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/zoom_x.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/zoom_y.png
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/classic/style.css
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/themes/default/style.css
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/moog.bin
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/saw.bin
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/sqr.bin
-- Installing: /usr/ports/audio/lmms/work/stage/usr/local/share/lmms/wavetables/tri.bin

Installing bash completion...

Bash completion for lmms has been installed to /usr/ports/audio/lmms/work/stage/usr/local/share/bash-completion/completions/lmms
====> Compressing man pages (compress-man)

/usr/ports/audio/lmms|$} sudo make package
===>  Building package for lmms-1.2.1_1,2
Comment 4 Rodrigo Osorio freebsd_committer 2020-08-23 13:10:10 UTC

How do you perform the build && install ?
I built lmms in poudriere without issue.

I probably need more details on what you are trying to accomplish :)

-- drigigo
Comment 5 alt2600 2020-08-24 03:32:52 UTC
(In reply to Rodrigo Osorio from comment #4)
I'm just trying to install the program from base ports. In this case actually just upgrade it.

cd /usr/ports/audio/lmms
sudo make install clean


sudo portmaster -GDb lmms

or any upgrade variant of portmaster such as

sudo sh -c 'PAGER=echo portmaster -GDba --no-confirm'

all of these break at the install phase/packaging phase in portmaster as the bash_completion scripts get installed directly into the system not the staging directory, and the referenced files are missing from the pkg-plist to install/package them.

poudriere is not in base, it builds things that don't work in base ports on the regular. don't think poudriere builds as root if I recall correctly from my lost arm64 cross compiling setup, which means I think the cmake files respect prefix of ${STAGEDIR}/${PREFIX} because it detects the non-root build. In this case it uses the CMAKE_INSTALL_PREFIX which I believe is effectively the same staging directory. Not sure why but the completion scripts cmake module ignores the CMAKE_INSTALL_PREFIX by default for root builds, hence it works in poudriere but not ports.

from the bash completion Cmake module
# Always provide a fallback for non-root INSTALL()
        SET(BASHCOMP_USER_PATH "${CMAKE_INSTALL_PREFIX}/share/bash-completion/completions")

        # Cmake doesn't allow easy use of conditional logic at INSTALL() time
        # this is a problem because ${BASHCOMP_PKG_PATH} may not be writable and we
        # need sane fallback behavior for bundled INSTALL() (e.g. .AppImage, etc).
        # The reason this can't be detected by cmake is that it's fairly common to
        # run "cmake" as a one user (i.e. non-root) and "make install" as another user
        # (i.e. root).
        # - Creates a script called "install_${SCRIPT_NAME}_completion.sh" into the
        #   working binary directory and invokes this script at install.
        # - Script handles INSTALL()-time conditional logic for sane ballback behavior
        #   when ${BASHCOMP_PKG_PATH} is unwritable (i.e. non-root); Something cmake
        #   can't handle on its own at INSTALL() time)
Comment 6 Zane C. Bowers-Hadley 2020-12-29 13:33:55 UTC
Actually it does not work in poudriere.

Bash completion for lmms has been installed to /usr/local/share/bash-completion/completions/lmms
====> Compressing man pages (compress-man)
=======================<phase: package        >============================
===>  Building package for lmms-1.2.1_2,2
pkg-static: Unable to access file /wrkdirs/usr/ports/audio/lmms/work/stage/usr/local/share/bash-completion/completions/lmms:No such file or directory
*** Error code 1
Comment 7 alt2600 2020-12-31 23:36:55 UTC
(In reply to Zane C. Bowers-Hadley from comment #6)
This port has been bumped a few times, and so I've done the edits a couple of times to the Makefile and confirm things work fine outside poudriere so they should work in it

try making a copy of the port Makefile to back it up
edit it and under the CMAKE_ON=QT5 add this line, all on one line incase its getting split up. You can copy and paste for the proposed Makefile attachment above.

CMAKE_ARGS+=	-DBASHCOMP_PKG_PATH=${STAGEDIR}${PREFIX}/share/bash-completion/completions

to avoid all confusion for others as to what I am talking about
cd /usr/ports/audio/lmms
sudo cp Makefile Makefile.old
sudo ee Makefile
(add the line in, or use the editor of your choice to do the same thing like with mousepad or copy paste whatever)
(save the Makefile)

it should then build and package fine. It has been for me since I posted the bug report.
Comment 8 Rodrigo Osorio freebsd_committer 2021-01-14 14:51:46 UTC
Fixed in 1.2.2 release