Bug 248270 - audio/lmms bash completion script stages in PREFIX not STAGEDIR
Summary: audio/lmms bash completion script stages in PREFIX not STAGEDIR
Status: New
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: Rodrigo Osorio
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-25 22:43 UTC by alt2600
Modified: 2020-08-24 03:32 UTC (History)
0 users

See Also:
bugzilla: maintainer-feedback? (rodrigo)


Attachments
lmms Makefile diff (417 bytes, text/plain)
2020-08-07 23:16 UTC, alt2600
no flags Details
audio/lmms/Makefile proposed (2.78 KB, text/plain)
2020-08-07 23:17 UTC, alt2600
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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. 

ELSE()
	INCLUDE(FindUnixCommands)
	# Honor manual override if provided
	IF(NOT BASHCOMP_PKG_PATH)
		# First, use pkg-config, which is the most reliable
		FIND_PACKAGE(PkgConfig QUIET)
		IF(PKGCONFIG_FOUND)
			PKG_CHECK_MODULES(BASH_COMPLETION bash-completion)
			PKG_GET_VARIABLE(BASHCOMP_PKG_PATH bash-completion completionsdir)
		ELSE()
			# Second, use cmake (preferred but less common)
			FIND_PACKAGE(bash-completion QUIET)
			IF(BASH_COMPLETION_FOUND)
				SET(BASHCOMP_PKG_PATH "${BASH_COMPLETION_COMPLETIONSDIR}")
			ENDIF()
		ENDIF()

		# Third, use a hard-coded fallback value
		IF("${BASHCOMP_PKG_PATH}" STREQUAL "")
			SET(BASHCOMP_PKG_PATH "/usr/share/bash-completion/completions")
		ENDIF()
	ENDIF()

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

audio/lmms/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
Hi,

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 :)

Regards
-- 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

or 

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)