summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--po/es/libretools.po20
-rw-r--r--src/chroot-tools/chcleanup.in34
2 files changed, 41 insertions, 13 deletions
diff --git a/po/es/libretools.po b/po/es/libretools.po
index 8efbe99..1db6950 100644
--- a/po/es/libretools.po
+++ b/po/es/libretools.po
@@ -525,27 +525,35 @@ msgstr "chroot '%s' no está a la versión %s. Por favor reconstruir."
msgid "(chcleanup): Must be run inside of a chroot"
msgstr "(chcleanup): Debe ser ejecutado dentro de un chroot"
-#: src/chroot-tools/chcleanup:92
+#: src/chroot-tools/chcleanup:94
msgid "Cleaning chroot..."
msgstr "Limpiando un chroot..."
-#: src/chroot-tools/chcleanup:105
+#: src/chroot-tools/chcleanup:107
msgid "Creating a full list of packages..."
msgstr "Creando una lista completa de paquetes..."
-#: src/chroot-tools/chcleanup:119
+#: src/chroot-tools/chcleanup:127
+msgid "Could not create a full list of packages, exiting."
+msgstr "No se pudo crear una lista completa de paquetes, saliendo."
+
+#: src/chroot-tools/chcleanup:128
+msgid "This is likely caused by a dependency that could not be found."
+msgstr ""
+
+#: src/chroot-tools/chcleanup:139
msgid "No packages to remove"
msgstr "No hay paquetes para remover"
-#: src/chroot-tools/chcleanup:121
+#: src/chroot-tools/chcleanup:141
msgid "Removing %d packages"
msgstr "Removiendo %d paquetes"
-#: src/chroot-tools/chcleanup:134
+#: src/chroot-tools/chcleanup:154
msgid "No packages to add"
msgstr ""
-#: src/chroot-tools/chcleanup:136
+#: src/chroot-tools/chcleanup:156
msgid "Adding %d packages"
msgstr ""
diff --git a/src/chroot-tools/chcleanup.in b/src/chroot-tools/chcleanup.in
index d114080..0326716 100644
--- a/src/chroot-tools/chcleanup.in
+++ b/src/chroot-tools/chcleanup.in
@@ -50,6 +50,8 @@ if [[ ! -f /.arch-chroot ]] && ! ${DRYRUN}; then
exit 1
fi
+# Figure out which packages we want
+CHROOTPKG=(base-devel)
# Note: the in-chroot pkgconfdir is non-configurable, this is
# intentionally hard-coded.
source /etc/libretools.d/chroot.conf
@@ -78,13 +80,31 @@ pkglist="${TEMPDIR}"/pkglist.txt
# Get the full list of packages needed by dependencies, including the base system
msg2 "Creating a full list of packages..."
-pacman --dbpath="$TEMPDIR" --hookdir=/var/empty -Sq --needed --dbonly --noconfirm -- base-devel >/dev/null
-if (( ${#CHROOTEXTRAPKG[@]} > 0 )); then
- pacman --dbpath="$TEMPDIR" --hookdir=/var/empty -Sq --needed --dbonly --noconfirm -- "${CHROOTEXTRAPKG[@]}" >/dev/null
-fi
-if (( ${#DEPENDS[@]} > 0 )); then
- pacman --dbpath="$TEMPDIR" --hookdir=/var/empty -Sq --needed --dbonly --noconfirm -- "${DEPENDS[@]}" >/dev/null
-fi
+mkdir "$TEMPDIR/hooks"
+{ echo /usr/share/libalpm/hooks; pacman-conf HookDir; } | while read -r dir; do
+ for hook in "$dir"/*.hook; do
+ ln -sfT -- /dev/null "$TEMPDIR/hooks/${hook##*/}"
+ done
+done
+for var in CHROOTPKG CHROOTEXTRAPKG DEPENDS; do
+ declare -n fullpkgs="$var"
+ mapfile -t missingpkgs < <(pacman --dbpath="$TEMPDIR" -T -- "${fullpkgs[@]}")
+ if (( ${#missingpkgs[@]} == 0 )); then
+ continue
+ fi
+ # Even though `pacman -T` filtered installed packages out,
+ # if still if use --needed because of groups.
+ pacman \
+ --dbpath="$TEMPDIR" --hookdir="$TEMPDIR/hooks" \
+ -S --dbonly --noscriptlet --needed --noconfirm -- "${missingpkgs[@]}" \
+ <&- &>"$TEMPDIR/pacman.txt" || ret=$?
+ if (( ret != 0 )); then
+ error "Could not create a full list of packages, exiting."
+ plain "This is likely caused by a dependency that could not be found."
+ sed 's/^/ > /' <"$TEMPDIR/pacman.txt" >&2
+ exit $ret
+ fi
+done
pacman --dbpath="$TEMPDIR" -Qq >"$pkglist"
# Diff installed packages against a clean chroot then remove leftovers