File: post_distupgrade_base_cleanup

package info (click to toggle)
piuparts 1.6.0
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 72,532 kB
  • sloc: python: 8,240; sh: 4,367; makefile: 171
file content (88 lines) | stat: -rwxr-xr-x 2,053 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/bin/sh
set -e

is_installed()
{
	local pkg="$1"
	dpkg-query -s "$pkg" >/dev/null 2>&1 || return 1
	local status="$(dpkg-query -W -f '${Status}' $pkg)"
	test "$status" != "unknown ok not-installed" || return 1
	test "$status" != "deinstall ok config-files" || return 1
	return 0
}

#
# Remove obsolete base packages from the reference chroot.
#
# These packages are part of a minimal chroot in release R, but no
# longer exist in release R+1.
# Package dependencies will cause removal of the obsolete packages
# during a subset of upgrade paths. Since these packages cannot be
# reinstalled in release R+1 ensure they are always gone from the
# final reference chroot.
#

# Only while creating the reference chroot.
test "$PIUPARTS_PHASE" = "" || exit 0

PURGE=

mark_for_purge()
{
	pkg="$1"

	# skip if the package is not installed
	is_installed "$pkg" || return 0

	case ${PIUPARTS_OBJECTS%%=*} in
		$pkg)
			# keep it while testing it
			;;
		*)
			PURGE="$PURGE $pkg"
	esac
}


if	[ "$PIUPARTS_DISTRIBUTION" = "wheezy" ] ; then

	mark_for_purge libdb4.8

	# gcc-4.4-base is part of the minimal squeeze chroot
	# but it no longer exists in wheezy
	mark_for_purge gcc-4.4-base

fi

if	[ "$PIUPARTS_DISTRIBUTION" = "jessie" ] ; then

	mark_for_purge libdb5.1

fi

if	[ "$PIUPARTS_DISTRIBUTION" = "stretch" ] || \
	[ "$PIUPARTS_DISTRIBUTION" = "stretch-next" ] ; then

	mark_for_purge libprocps3
	mark_for_purge sysvinit

	# pulled in during dist-upgrade of the reference chroot with --install-recommends
	# can cause problems if the tested upgrade path installs a different pinentry-*
	# because apt may fail to properly switch during removal (seen on e.g.
	# plasma-desktop, plasma-netbook, kdeutils, print-manager, science-chemistry)
	mark_for_purge pinentry-curses

fi

if	[ "$PIUPARTS_DISTRIBUTION" = "buster" ] || \
	[ "$PIUPARTS_DISTRIBUTION" = "buster-next" ] ; then

	mark_for_purge libcryptsetup4
	mark_for_purge libprocps6

fi

if [ -n "$PURGE" ]; then
	echo "Removing packages from base system:$PURGE"
	apt-get -y remove --purge $PURGE
fi