summaryrefslogtreecommitdiff
path: root/scripts/makepkg.sh.in
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2009-10-23 15:30:47 +1000
committerDan McGee <dan@archlinux.org>2010-05-05 19:26:06 -0500
commitccbef232c97fda061eee54a96bcd60b13a77f5d1 (patch)
tree7b8c713f8a07fc042a894763074269d9a71743c4 /scripts/makepkg.sh.in
parentdf99495b826eab9f25ceeb8f2643565af8818c20 (diff)
downloadpacman-ccbef232c97fda061eee54a96bcd60b13a77f5d1.tar.xz
makepkg: improve removal of installed dependencies
Compare a list of packages on the system before and after dependency resolution in order to get a complete list of packages to remove. This allows makepkg to remove packages installed due to provides. Bail in cases where packages that were on the system originally have been removed as there is a risk of breaking the system when removing the new packages. Fixes FS#15144. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts/makepkg.sh.in')
-rw-r--r--scripts/makepkg.sh.in36
1 files changed, 20 insertions, 16 deletions
diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index a2db90b3..baf47032 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -344,7 +344,7 @@ download_file() {
run_pacman() {
local ret=0
- if (( ! ASROOT )) && [[ $1 != "-T" ]] && sudo -l $PACMAN &>/dev/null; then
+ if (( ! ASROOT )) && [[ $1 != "-T" && $1 != "-Qq" ]] && sudo -l $PACMAN &>/dev/null; then
sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
else
$PACMAN $PACMAN_OPTS "$@" || ret=$?
@@ -399,7 +399,6 @@ handle_deps() {
}
resolve_deps() {
- # $pkgdeps is a GLOBAL variable, used by remove_deps()
local R_DEPS_SATISFIED=0
local R_DEPS_MISSING=1
@@ -409,7 +408,6 @@ resolve_deps() {
fi
if handle_deps $deplist; then
- pkgdeps="$pkgdeps $deplist"
# check deps again to make sure they were resolved
deplist="$(check_deps $*)"
[[ -z $deplist ]] && return $R_DEPS_SATISFIED
@@ -426,23 +424,24 @@ resolve_deps() {
return $R_DEPS_MISSING
}
-# fix flyspray bug #5923
remove_deps() {
- # $pkgdeps is a GLOBAL variable, set by resolve_deps()
(( ! RMDEPS )) && return
- [[ -z $pkgdeps ]] && return
- local dep depstrip deplist
- deplist=""
- for dep in $pkgdeps; do
- depstrip="${dep%%[<=>]*}"
- deplist="$deplist $depstrip"
- done
+ # check for packages removed during dependency install (e.g. due to conflicts)
+ # removing all installed packages is risky in this case
+ if [[ -n $(comm -23 <(printf "%s\n" "${original_pkglist[@]}") \
+ <(printf "%s\n" "${current_pkglist[@]}")) ]]; then
+ warning "$(gettext "Failed to remove installed dependencies.")"
+ return 0
+ fi
- msg "Removing installed dependencies..."
+ local deplist=($(comm -13 <(printf "%s\n" "${original_pkglist[@]}") \
+ <(printf "%s\n" "${current_pkglist[@]}")))
+ (( ${#deplist[@]} == 0 )) && return
+ msg "Removing installed dependencies..."
# exit cleanly on failure to remove deps as package has been built successfully
- if ! run_pacman -Rns $deplist; then
+ if ! run_pacman -Rn ${deplist[@]}; then
warning "$(gettext "Failed to remove installed dependencies.")"
return 0
fi
@@ -1866,14 +1865,15 @@ if (( SOURCEONLY )); then
exit 0
fi
-# fix flyspray bug #5973
if (( NODEPS || NOBUILD || REPKG )); then
# no warning message needed for nobuild, repkg
if (( NODEPS )); then
warning "$(gettext "Skipping dependency checks.")"
fi
elif [ $(type -p "${PACMAN%% *}") ]; then
- unset pkgdeps # Set by resolve_deps() and used by remove_deps()
+ if (( RMDEPS )); then
+ original_pkglist=($(run_pacman -Qq | sort)) # required by remove_dep
+ fi
deperr=0
msg "$(gettext "Checking Runtime Dependencies...")"
@@ -1882,6 +1882,10 @@ elif [ $(type -p "${PACMAN%% *}") ]; then
msg "$(gettext "Checking Buildtime Dependencies...")"
resolve_deps ${makedepends[@]} || deperr=1
+ if (( RMDEPS )); then
+ current_pkglist=($(run_pacman -Qq | sort)) # required by remove_deps
+ fi
+
if (( deperr )); then
error "$(gettext "Could not resolve all dependencies.")"
exit 1