mirror of
https://github.com/moparisthebest/pacman
synced 2024-08-13 17:03:46 -04:00
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>
This commit is contained in:
parent
df99495b82
commit
ccbef232c9
@ -174,9 +174,9 @@ Environment Variables
|
|||||||
---------------------
|
---------------------
|
||||||
*PACMAN*::
|
*PACMAN*::
|
||||||
The command that will be used to check for missing dependencies and to
|
The command that will be used to check for missing dependencies and to
|
||||||
install and remove packages. Pacman's -U, -T, -S and -Rns operations
|
install and remove packages. Pacman's -Qq, -Rns, -S, -T, and -U
|
||||||
must be supported by this command. If the variable is not set or
|
operations must be supported by this command. If the variable is not
|
||||||
empty, makepkg will fall back to `pacman'.
|
set or empty, makepkg will fall back to `pacman'.
|
||||||
|
|
||||||
**PKGDEST=**"/path/to/folder"::
|
**PKGDEST=**"/path/to/folder"::
|
||||||
Folder where the resulting packages will be stored. Overrides the
|
Folder where the resulting packages will be stored. Overrides the
|
||||||
|
@ -344,7 +344,7 @@ download_file() {
|
|||||||
|
|
||||||
run_pacman() {
|
run_pacman() {
|
||||||
local ret=0
|
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=$?
|
sudo $PACMAN $PACMAN_OPTS "$@" || ret=$?
|
||||||
else
|
else
|
||||||
$PACMAN $PACMAN_OPTS "$@" || ret=$?
|
$PACMAN $PACMAN_OPTS "$@" || ret=$?
|
||||||
@ -399,7 +399,6 @@ handle_deps() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
resolve_deps() {
|
resolve_deps() {
|
||||||
# $pkgdeps is a GLOBAL variable, used by remove_deps()
|
|
||||||
local R_DEPS_SATISFIED=0
|
local R_DEPS_SATISFIED=0
|
||||||
local R_DEPS_MISSING=1
|
local R_DEPS_MISSING=1
|
||||||
|
|
||||||
@ -409,7 +408,6 @@ resolve_deps() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if handle_deps $deplist; then
|
if handle_deps $deplist; then
|
||||||
pkgdeps="$pkgdeps $deplist"
|
|
||||||
# check deps again to make sure they were resolved
|
# check deps again to make sure they were resolved
|
||||||
deplist="$(check_deps $*)"
|
deplist="$(check_deps $*)"
|
||||||
[[ -z $deplist ]] && return $R_DEPS_SATISFIED
|
[[ -z $deplist ]] && return $R_DEPS_SATISFIED
|
||||||
@ -426,23 +424,24 @@ resolve_deps() {
|
|||||||
return $R_DEPS_MISSING
|
return $R_DEPS_MISSING
|
||||||
}
|
}
|
||||||
|
|
||||||
# fix flyspray bug #5923
|
|
||||||
remove_deps() {
|
remove_deps() {
|
||||||
# $pkgdeps is a GLOBAL variable, set by resolve_deps()
|
|
||||||
(( ! RMDEPS )) && return
|
(( ! RMDEPS )) && return
|
||||||
[[ -z $pkgdeps ]] && return
|
|
||||||
|
|
||||||
local dep depstrip deplist
|
# check for packages removed during dependency install (e.g. due to conflicts)
|
||||||
deplist=""
|
# removing all installed packages is risky in this case
|
||||||
for dep in $pkgdeps; do
|
if [[ -n $(comm -23 <(printf "%s\n" "${original_pkglist[@]}") \
|
||||||
depstrip="${dep%%[<=>]*}"
|
<(printf "%s\n" "${current_pkglist[@]}")) ]]; then
|
||||||
deplist="$deplist $depstrip"
|
warning "$(gettext "Failed to remove installed dependencies.")"
|
||||||
done
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
local deplist=($(comm -13 <(printf "%s\n" "${original_pkglist[@]}") \
|
||||||
|
<(printf "%s\n" "${current_pkglist[@]}")))
|
||||||
|
(( ${#deplist[@]} == 0 )) && return
|
||||||
|
|
||||||
msg "Removing installed dependencies..."
|
msg "Removing installed dependencies..."
|
||||||
|
|
||||||
# exit cleanly on failure to remove deps as package has been built successfully
|
# 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.")"
|
warning "$(gettext "Failed to remove installed dependencies.")"
|
||||||
return 0
|
return 0
|
||||||
fi
|
fi
|
||||||
@ -1866,14 +1865,15 @@ if (( SOURCEONLY )); then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# fix flyspray bug #5973
|
|
||||||
if (( NODEPS || NOBUILD || REPKG )); then
|
if (( NODEPS || NOBUILD || REPKG )); then
|
||||||
# no warning message needed for nobuild, repkg
|
# no warning message needed for nobuild, repkg
|
||||||
if (( NODEPS )); then
|
if (( NODEPS )); then
|
||||||
warning "$(gettext "Skipping dependency checks.")"
|
warning "$(gettext "Skipping dependency checks.")"
|
||||||
fi
|
fi
|
||||||
elif [ $(type -p "${PACMAN%% *}") ]; then
|
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
|
deperr=0
|
||||||
|
|
||||||
msg "$(gettext "Checking Runtime Dependencies...")"
|
msg "$(gettext "Checking Runtime Dependencies...")"
|
||||||
@ -1882,6 +1882,10 @@ elif [ $(type -p "${PACMAN%% *}") ]; then
|
|||||||
msg "$(gettext "Checking Buildtime Dependencies...")"
|
msg "$(gettext "Checking Buildtime Dependencies...")"
|
||||||
resolve_deps ${makedepends[@]} || deperr=1
|
resolve_deps ${makedepends[@]} || deperr=1
|
||||||
|
|
||||||
|
if (( RMDEPS )); then
|
||||||
|
current_pkglist=($(run_pacman -Qq | sort)) # required by remove_deps
|
||||||
|
fi
|
||||||
|
|
||||||
if (( deperr )); then
|
if (( deperr )); then
|
||||||
error "$(gettext "Could not resolve all dependencies.")"
|
error "$(gettext "Could not resolve all dependencies.")"
|
||||||
exit 1
|
exit 1
|
||||||
|
Loading…
Reference in New Issue
Block a user