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 <[email protected]>
---

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


Reply via email to