Commit a841e60e authored by Vitaly Lipatov's avatar Vitaly Lipatov Committed by Жора Змейкин

cleanup: add CLEANUP_AUTO_PACKAGES for safe live package removal

Add new variable CLEANUP_AUTO_PACKAGES that marks packages as auto-installed instead of removing them directly. This allows apt-get autoremove to safely remove packages that are not required by user-selected groups during live installation. Implementation uses preinstall hook to ensure correct ordering: 1. preinstall: mark CLEANUP_AUTO_PACKAGES as auto 2. pkg-install: mark .base and selected groups as manual 3. postinstall: autoremove removes only orphaned auto packages
parent 448343f3
......@@ -20,6 +20,7 @@ use/ximper/cleanup:
@$(call add,CLEANUP_BASE_PACKAGES,branding-etersoft-ximper-alterator)
@$(call add,CLEANUP_BASE_PACKAGES,'alterator*' rpm-macros-alterator)
@$(call add,CLEANUP_BASE_PACKAGES,'guile*' libvhttpd autologin-sh-functions)
@$(call add,CLEANUP_AUTO_PACKAGES,$(LIVE_PACKAGES))
use/ximper/cleanup/x11: \
use/ximper/cleanup
......
......@@ -14,5 +14,11 @@ CLEANUP_BASE_PACKAGES.
Для удаления пакетов только из livecd используйте переменную
CLEANUP_LIVE_PACKAGES.
Для пакетов, которые следует пометить как auto-installed при
установке с livecd (будут удалены через autoremove, если не нужны
пользователю), используйте переменную CLEANUP_AUTO_PACKAGES.
Это безопаснее чем CLEANUP_BASE_PACKAGES: пакет не удалится,
если он требуется выбранным пользователем группам.
CAUTION: также удаляет rpm, apt и базу по пакетам из livecd,
если в него не был добавлен инсталятор!
......@@ -5,6 +5,7 @@ use/cleanup:
@$(call xport,CLEANUP_PACKAGES)
@$(call xport,CLEANUP_BASE_PACKAGES)
@$(call xport,CLEANUP_LIVE_PACKAGES)
@$(call xport,CLEANUP_AUTO_PACKAGES)
use/cleanup/live-no-cleanupdb:
@$(call set,LIVE_NO_CLEANUPDB,yes)
......
#!/bin/sh -efu
### create a preinstall hook to mark live-only packages as auto-installed
[ -n "$GLOBAL_CLEANUP_AUTO_PACKAGES" ] || exit 0
[ -x /usr/sbin/install2 ] || [ -x /usr/libexec/install2/install2 ] || exit 0
CLEANUP_AUTO_PACKAGES="$GLOBAL_CLEANUP_AUTO_PACKAGES"
HOOKDIR="/usr/lib/alterator/hooks/pkg-preinstall.d"
mkdir -p "$HOOKDIR"
SCRIPT="$HOOKDIR/01-mark-live-packages-auto"
cat > "$SCRIPT" << EOF
#!/bin/sh -efu
# Mark live-only packages as auto-installed before pkg-install runs.
# pkg-install will then mark .base and selected groups as manual,
# overwriting our auto marks for packages that should be kept.
# Finally, postinstall autoremove will remove orphaned auto packages.
list="\$(rpmquery -a --qf='%{NAME}\n' $CLEANUP_AUTO_PACKAGES 2>/dev/null)" ||:
[ -z "\$list" ] || apt-mark auto \$list 2>/dev/null ||:
EOF
chmod +x "$SCRIPT"
......@@ -7,7 +7,8 @@ if [ -n "$GLOBAL_VERBOSE" ]; then
fi >&2
[ -n "$GLOBAL_CLEANUP_PACKAGES" ] ||
[ -n "$GLOBAL_CLEANUP_BASE_PACKAGES" ] || exit 0
[ -n "$GLOBAL_CLEANUP_BASE_PACKAGES" ] ||
[ -n "$GLOBAL_CLEANUP_AUTO_PACKAGES" ] || exit 0
[ -x /usr/sbin/install2 ] || [ -x /usr/libexec/install2/install2 ] || exit 0
......@@ -27,7 +28,8 @@ echo "removing $CLEANUP_PACKAGES"
list="\$(exec_chroot rpmquery -a --qf='%{NAME}\\n' $CLEANUP_PACKAGES)"
if [ -n "\$list" ]; then
exec_chroot apt-get remove -f -y -- \$list
exec_chroot apt-get autoremove -y
fi
exec_chroot apt-get autoremove -y
EOF
chmod +x "$SCRIPT"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment