[pacman-dev] [PATCH] Use absolute path for pacman and pacman-conf in makepkg

Allan McRae allan at archlinux.org
Mon May 11 02:42:00 UTC 2020


On 8/5/20 4:13 am, Wouter Wijsman wrote:
> Currently makepkg requires pacman and pacman-conf to be in the path of
> the user. Since these executables should never move, it should be safe
> to add the full paths to the scripts at compile time, assuming the user
> uses the install command as well.
> 
> This change works for both autotools and meson.
> 
> Signed-off-by: Wouter Wijsman <wwijsman at live.nl>
> ---

Hi,

Can you let us know more detail about the use case for this patch?  Why
would the user not add the directory pacman and scripts are installed in
to their path?

I have concerns that hardcoding paths on build will lead to difficulty
when in the future we have a test suite for makepkg.

Allan


>  build-aux/edit-script.sh.in | 1 +
>  meson.build                 | 1 +
>  scripts/Makefile.am         | 3 ++-
>  scripts/makepkg.sh.in       | 6 ++++--
>  4 files changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/build-aux/edit-script.sh.in b/build-aux/edit-script.sh.in
> index 661c22d5..44103f08 100644
> --- a/build-aux/edit-script.sh.in
> +++ b/build-aux/edit-script.sh.in
> @@ -20,6 +20,7 @@ mode=$3
>    -e "s|@DEBUGSUFFIX[@]|@DEBUGSUFFIX@|g" \
>    -e "s|@INODECMD[@]|@INODECMD@|g" \
>    -e "s|@FILECMD[@]|@FILECMD@|g" \
> +  -e "s|@fullbindir[@]|@FULLBINDIR@|g" \
>    "$input" >"$output"
>  
>  if [[ $mode ]]; then
> diff --git a/meson.build b/meson.build
> index 680cf62b..92e8a9a5 100644
> --- a/meson.build
> +++ b/meson.build
> @@ -257,6 +257,7 @@ substs.set('LOCALEDIR', LOCALEDIR)
>  substs.set('sysconfdir', SYSCONFDIR)
>  substs.set('localstatedir', LOCALSTATEDIR)
>  substs.set('PKGDATADIR', PKGDATADIR)
> +substs.set('FULLBINDIR', '@0@/@1@'.format(PREFIX, get_option('bindir')))
>  substs.set('PREFIX', PREFIX)
>  substs.set('BASH', BASH.path())
>  substs.set('PACKAGE_VERSION', PACKAGE_VERSION)
> diff --git a/scripts/Makefile.am b/scripts/Makefile.am
> index 47455ed2..a79e9389 100644
> --- a/scripts/Makefile.am
> +++ b/scripts/Makefile.am
> @@ -182,7 +182,8 @@ edit = sed \
>  	-e 's|@DEBUGSUFFIX[@]|$(DEBUGSUFFIX)|g' \
>  	-e "s|@INODECMD[@]|$(INODECMD)|g" \
>  	-e "s|@FILECMD[@]|$(FILECMD)|g" \
> -	-e 's|@SCRIPTNAME[@]|$@|g'
> +	-e 's|@SCRIPTNAME[@]|$@|g' \
> +	-e 's|@fullbindir[@]|$(FULLBINDIR)|g'
>  
>  ## All the scripts depend on Makefile so that they are rebuilt when the
>  ## prefix etc. changes. Use chmod -w to prevent people from editing the
> diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
> index d1416d15..2f7b838e 100644
> --- a/scripts/makepkg.sh.in
> +++ b/scripts/makepkg.sh.in
> @@ -44,6 +44,8 @@ declare -r makepkg_version='@PACKAGE_VERSION@'
>  declare -r confdir='@sysconfdir@'
>  declare -r BUILDSCRIPT='@BUILDSCRIPT@'
>  declare -r startdir="$(pwd -P)"
> +declare -r PACMAN_EXECUTABLE='@fullbindir@/pacman'
> +declare -r PACMAN_CONF_EXECUTABLE='@fullbindir@/pacman-conf'
>  
>  LIBRARY=${LIBRARY:-'@libmakepkgdir@'}
>  
> @@ -235,7 +237,7 @@ run_pacman() {
>  		else
>  			cmd=(su root -c "$(printf '%q ' "${cmd[@]}")")
>  		fi
> -		local lockfile="$(pacman-conf DBPath)/db.lck"
> +		local lockfile="$(${PACMAN_CONF_EXECUTABLE} DBPath)/db.lck"
>  		while [[ -f $lockfile ]]; do
>  			local timer=0
>  			msg "$(gettext "Pacman is currently in use, please wait...")"
> @@ -1123,7 +1125,7 @@ unset var
>  PACKAGER=${PACKAGER:-"Unknown Packager"}
>  
>  # set pacman command if not already defined
> -PACMAN=${PACMAN:-pacman}
> +PACMAN=${PACMAN:-${PACMAN_EXECUTABLE}}
>  # save full path to command as PATH may change when sourcing /etc/profile
>  PACMAN_PATH=$(type -P $PACMAN)
>  
> 


More information about the pacman-dev mailing list