File: post_setup_disable_usr_share_doc

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 (49 lines) | stat: -rwxr-xr-x 1,400 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
#!/bin/sh
set -e

log_debug() {
	echo "Debug: piuparts exception for package $PIUPARTS_OBJECTS"
}

case ${PIUPARTS_OBJECTS%%=*} in
	TARBALL)
		# skip while creating the tarball
		exit 0
		;;
esac

# clear out /usr/share/doc
# but keep the directories (and symlinks) as well as the copyright files
cat << EOF > /etc/dpkg/dpkg.cfg.d/piuparts-path-exclude
path-exclude=/usr/share/doc/*/*
path-include=/usr/share/doc/*/copyright
EOF

# switching init systems forth and back will clean out /usr/share/doc
# reinstalling the affected packages beforehand makes the files disappear
# before the snapshot of the reference system is created
CANDIDATES="systemd systemd-sysv sysv-rc"
CANDIDATES=$(dpkg-query -W $CANDIDATES | awk '{ if ($2) { print $1 } }')
if [ -n "$CANDIDATES" ]; then
	echo "Reinstalling $(echo $CANDIDATES)..."
	# workaround apt bug #770291 - do it one by one, not all at once
	for package in $CANDIDATES
	do
		apt-get -u --reinstall install $package
	done
fi

case ${PIUPARTS_OBJECTS%%=*} in
	localepurge)
		case ${PIUPARTS_DISTRIBUTION} in
			lenny*|squeeze*) ;;
			*)
				# reinstall packages that will be reinstalled after purge
				# to not record their /usr/share/doc content that is about to disappear
				log_debug
				EXTRA=""
				apt-get -u --reinstall --fix-missing install $(dpkg -S LC_MESSAGES 'man/??/man' | cut -d: -f1 | tr ', ' '\n' | sort -u) $EXTRA
				;;
		esac
		;;
esac