File: 40cdrom

package info (click to toggle)
apt-setup 1%3A0.53%2Bsqueeze2
  • links: PTS
  • area: main
  • in suites: squeeze
  • size: 2,032 kB
  • ctags: 17
  • sloc: sh: 982; makefile: 2
file content (126 lines) | stat: -rwxr-xr-x 3,063 bytes parent folder | download
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#!/bin/sh
set -e

. /usr/share/debconf/confmodule
. /lib/chroot-setup.sh

# This code is copied from chroot-setup.sh, and is needed until after a d-i
# release whose initrds contain a sufficiently new version of di-utils.
if ! type chroot_cleanup_localmounts >/dev/null 2>&1; then
	# Variant of chroot_cleanup that only cleans up chroot_setup's mounts.
	chroot_cleanup_localmounts () {
		rm -f /target/usr/sbin/policy-rc.d
		mv /target/sbin/start-stop-daemon.REAL /target/sbin/start-stop-daemon
		if [ -x /target/sbin/initctl.REAL ]; then
			mv /target/sbin/initctl.REAL /target/sbin/initctl
		fi

		# Undo the mounts done by the packages during installation.
		# Reverse sorting to umount the deepest mount points first.
		# Items with count of 1 are new.
		for dir in $( (cat /tmp/mount.pre /tmp/mount.pre /tmp/mount.post ) | \
			     sort -r | uniq -c | grep "^[[:space:]]*1[[:space:]]" | \
			     sed "s/^[[:space:]]*[0-9][[:space:]]//"); do
			if ! umount $dir; then
				logger -t $0 "warning: Unable to umount '$dir'"
			fi
		done
		rm -f /tmp/mount.pre /tmp/mount.post

		rm -f /var/run/chroot-setup.lock
	}
fi

file="$1"

if [ ! -e /cdrom/.disk/base_installable ]; then
	exit 0
fi

cd_mountable=1
db_get cdrom-detect/hybrid || true
if [ "$RET" = true ] || [ -d /hd-media ]; then
	cd_mountable=""
else
	db_get cdrom-detect/usb-hdd || true
	if [ "$RET" = true ]; then
		cd_mountable=""
	fi
fi

remount_cd() {
	if [ "$ROOT" ] && [ "$cd_mountable" ]; then
		fs=iso9660
		if db_get cdrom-detect/cdrom_fs && [ "$RET" ]; then
			fs="$RET"
		fi
		db_get cdrom-detect/cdrom_device
		$logoutput mount -t "$fs" -o ro,exec $RET /cdrom || true
	fi
}

bail_out() {
	remount_cd
	rm -f $ROOT$tmp $ROOT$tmp~
	rm -f /var/lib/install-cd.id

	db_input critical apt-setup/cdrom/failed || true
	db_go || exit 10
	exit 1
}

# Save identification of installation CD
save_label() {
	local ident

	if ! ident="$(LC_ALL=C $logoutput_pass $chroot $ROOT apt-cdrom ident)"; then
		bail_out
	fi
	echo "$ident" | grep "^Identifying" | head -n1 | cut -d" " -f2 \
		>/var/lib/install-cd.id
	echo "$ident" | grep "^Stored label:" | head -n1 | sed "s/^[^:]*: //" \
		>>/var/lib/install-cd.id
}

logoutput=""
logoutput_pass=""
if [ "$CATCHLOG" ]; then
	logoutput="log-output -t apt-setup"
	logoutput_pass="$logoutput --pass-stdout"
fi

chroot=
if [ "$ROOT" ]; then
	chroot=chroot

	# Allow apt-cdrom to manage mounting/unmounting CDs in /target
	if [ "$cd_mountable" ]; then
		rm -f $ROOT/etc/apt/apt.conf.d/00NoMountCDROM

		# Also removes the bind-mount in /target
		$logoutput umount /cdrom || true
	fi

	chroot_setup
	# Needed until after a d-i release with new enough di-utils.
	mountpoints > /tmp/mount.post
	trap chroot_cleanup_localmounts EXIT HUP INT QUIT TERM
fi

tmp=$($chroot $ROOT tempfile)

# apt-cdrom can be interactive, avoid that
if $logoutput $chroot $ROOT apt-cdrom add \
   -o Dir::Etc::SourceList=$tmp \
   </dev/null; then
	cat $ROOT$tmp >> $file

	if [ "$ROOT" ] && [ "$cd_mountable" ]; then
		save_label
	fi
else
	bail_out
fi

remount_cd
rm -f $ROOT$tmp $ROOT$tmp~