Skip to content
Snippets Groups Projects
Commit 1b5c906d authored by Simon McVittie's avatar Simon McVittie
Browse files

platformize: Clean up packages with config files remaining

parent d1aaa017
No related branches found
No related tags found
No related merge requests found
......@@ -63,6 +63,22 @@ list_packages_ignore_arch () {
in_chroot dpkg-query --show -f '${Package}\n' | LC_ALL=C sort -u
}
is_installed () {
local status
if ! status="$(in_chroot dpkg-query --show -f '${Status}\n' "$@")"; then
return 1
fi
case "$status" in
(*\ not-installed)
return 1
;;
(*\ config-files)
return 1
;;
esac
return 0
}
declare -a unwanted=()
echo "Packages installed at the moment:"
......@@ -73,7 +89,7 @@ for package in \
fakeroot \
libfakeroot \
; do \
if chroot "$sysroot" dpkg-query --show "$package" >/dev/null; then
if is_installed "$package"; then
unwanted+=("$package")
fi
done
......@@ -113,12 +129,12 @@ for package in \
plymouth \
tcpd \
; do \
if chroot "$sysroot" dpkg-query --show "$package" >/dev/null; then
if is_installed "$package"; then
unwanted+=("$package")
fi
done
if ! chroot "$sysroot" dpkg-query --show python; then
if ! is_installed python; then
unwanted+=(python-minimal python2.7-minimal)
fi
......@@ -157,12 +173,12 @@ for package in \
udev \
upstart \
; do \
if chroot "$sysroot" dpkg-query --show "$package" >/dev/null; then
if is_installed "$package"; then
unwanted+=("$package")
fi
done
if ! chroot "$sysroot" dpkg-query --show perl; then
if ! is_installed perl; then
unwanted+=(perl-base)
fi
......@@ -175,3 +191,22 @@ if [ -n "${unwanted[*]}" ]; then
in_chroot dpkg --purge --force-remove-essential --force-depends \
"${unwanted[@]}"
fi
unwanted=()
echo "Purging leftover configuration files:"
in_chroot dpkg-query --show -f '${Status}:${Package}\n' \
| while read -r line; do
case "$line" in
(*\ config-files:*)
p="${line##*:}"
echo "- $p"
unwanted+=("$p")
;;
esac
done
if [ -n "${unwanted[*]}" ]; then
in_chroot dpkg --purge --force-remove-essential --force-depends \
"${unwanted[@]}"
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment