[pacman-dev] [PATCH] [makepkg] fix -r and --needed conflict
In makepkg, passing -sr --needed causes there to be a conflict when pacman goes to remove the dependencies, as the --needed flag is not an option for pacman -R. This patch sanitizes the PACMAN_OPTS in the remove_deps() function so that it can still run even with the --needed option passed to makepkg. (Useful when doing `makepkg -sir --needed` to get rid of unneeded {make,check}depends automatically). At the end of the remove_deps() function, PACMAN_OPTS is restored to its original value. Signed-off-by: William Giokas <1007380@gmail.com> --- Noticed this today when building a series of git packges on my system. Sorry for not catching this earlier. scripts/makepkg.sh.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c464ec7..fc1976a 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -984,10 +984,23 @@ remove_deps() { msg "Removing installed dependencies..." # exit cleanly on failure to remove deps as package has been built successfully + + opts_backup="${PACMAN_OPTS[@]}" + for i in ${PACMAN_OPTS[@]}; do + if [[ $i == "--needed" ]]; then + opts2=("${rm_opts[@]}") + else + opts2=("${rm_opts[@]}" "$i") + fi + done + PACMAN_OPTS="${rm_opts[@]}" + if ! run_pacman -Rn ${deplist[@]}; then warning "$(gettext "Failed to remove installed dependencies.")" return 0 fi + + PACMAN_OPTS="${opts_backup[@]}" } get_integlist() { -- 1.8.1.3.535.ga923c31
On Sat, 9 Feb 2013 01:54:42 -0600 William Giokas <1007380@gmail.com> wrote:
In makepkg, passing -sr --needed causes there to be a conflict when pacman goes to remove the dependencies, as the --needed flag is not an option for pacman -R. This patch sanitizes the PACMAN_OPTS in the remove_deps() function so that it can still run even with the --needed option passed to makepkg. (Useful when doing `makepkg -sir --needed` to get rid of unneeded {make,check}depends automatically). At the end of the remove_deps() function, PACMAN_OPTS is restored to its original value.
Signed-off-by: William Giokas <1007380@gmail.com> ---
If --needed is only useful for the installation of the built package, why not treat it like --asdeps and only add it to the pacman opts for that one step rather than add it globally and remove it later?
On 09/02/13 23:49, Andrew Gregory wrote:
On Sat, 9 Feb 2013 01:54:42 -0600 William Giokas <1007380@gmail.com> wrote:
In makepkg, passing -sr --needed causes there to be a conflict when pacman goes to remove the dependencies, as the --needed flag is not an option for pacman -R. This patch sanitizes the PACMAN_OPTS in the remove_deps() function so that it can still run even with the --needed option passed to makepkg. (Useful when doing `makepkg -sir --needed` to get rid of unneeded {make,check}depends automatically). At the end of the remove_deps() function, PACMAN_OPTS is restored to its original value.
Signed-off-by: William Giokas <1007380@gmail.com> ---
If --needed is only useful for the installation of the built package, why not treat it like --asdeps and only add it to the pacman opts for that one step rather than add it globally and remove it later?
Agreed. Just follow exactly what ASDEP does. Allan
On Sun, Feb 10, 2013 at 01:09:03AM +1000, Allan McRae wrote:
On 09/02/13 23:49, Andrew Gregory wrote:
If --needed is only useful for the installation of the built package, why not treat it like --asdeps and only add it to the pacman opts for that one step rather than add it globally and remove it later?
Agreed. Just follow exactly what ASDEP does.
Ah, hadn't noticed that. v2 incoming soon. Thanks, -- William Giokas | KaiSforza GnuPG Key: 0xE99A7F0F Fingerprint: F078 CFF2 45E8 1E72 6D5A 8653 CDF5 E7A5 E99A 7F0F
In makepkg, passing -sr --needed causes there to be a conflict when pacman goes to remove the dependencies, as the --needed flag is not an option for pacman -R. This patch makes --needed not get added to the PACMAN_OPTS array, but it acts like ASDEPS, and is only added to an install function. Signed-off-by: William Giokas <1007380@gmail.com> --- After the emails from Andrew and Allan, fixed up and made a whole lot less wasteful. Thanks for the feedback. scripts/makepkg.sh.in | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index c464ec7..c41d325 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -54,6 +54,7 @@ readonly -a packaging_options other_options splitpkg_overrides # Options ASDEPS=0 +NEEDED=0 ASROOT=0 CLEANUP=0 DEP_BIN=0 @@ -1983,6 +1984,7 @@ install_package() { local fullver pkgarch pkg pkglist (( ASDEPS )) && pkglist+=('--asdeps') + (( NEEDED )) && pkglist+=('--needed') for pkg in ${pkgname[@]}; do fullver=$(get_full_version $pkg) @@ -2469,7 +2471,7 @@ while true; do # Pacman Options --asdeps) ASDEPS=1;; --noconfirm) PACMAN_OPTS+=" --noconfirm" ;; - --needed) PACMAN_OPTS+=" --needed" ;; + --needed) NEEDED=1;; --noprogressbar) PACMAN_OPTS+=" --noprogressbar" ;; # Makepkg Options -- 1.8.1.3.535.ga923c31
participants (3)
-
Allan McRae
-
Andrew Gregory
-
William Giokas