File: postinst

package info (click to toggle)
live-installer 8
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 652 kB
  • ctags: 17
  • sloc: sh: 1,162; ansic: 17; makefile: 8
file content (143 lines) | stat: -rwxr-xr-x 3,195 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#! /bin/sh
set -e

. /usr/share/debconf/confmodule
db_capb backup

. /usr/lib/base-installer/library.sh

NEWLINE="
"

db_input low live-installer/mode || true
db_go || exit 10 # back to menu
db_get live-installer/mode
mode="$RET"

install_live_system () {
	# Look at
	PLACES=""
	PLACE_FOUND=0

	# Load filesystem support
	for script in $(ls /lib/live-installer/*); do
		. $script
	done

	for place in $PLACES; do
		[ ! -e $place ] && continue

		SUPPORT=$(echo $place | sed 's,.*\.\(.*\)$,\1,g')
		info "Using $SUPPORT support for $place"

		PLACE_FOUND=1

		eval ${SUPPORT}_prepare
		STEPS=$(eval ${SUPPORT}_count)

		db_progress INFO live-installer/progress/copying

		COUNT=0
		OLD_IFS=$IFS
		mkdir -p /target
		# use tar from inside the live filesystem to create
		# the tarball, because busybox tar in d-i does not 
		# support creating tarballs.
		# 
		# The --exclude is a paranoia measure, in case this program
		# is running from the toplevel of a live filesystem,
		# which is not normally the case.
		exec 4>&0
		chroot . tar c . --exclude=target | \
		(chdir /target && tar xv) | \
		(
			while read line; do
				COUNT=$(($COUNT + 1))
				CURRENT=$(($COUNT * 100 / $STEPS))

				[ x$CURRENT = x$LAST_UPDATE ] && continue

				LAST_UPDATE=$CURRENT
				db_progress STEP 1 <&4
			done
		)
		exec 0>&4
		IFS=$OLD_IFS
	done

	if [ ${PLACE_FOUND} -eq 0 ]; then
		error "Could not find any live images"
		exit 1
	fi

	# if we're dumping it, we need to set the boot mode
	if [ "$mode" = live ]; then
		# which init script to use
		if [ -d /cdrom/casper ]; then
			bootmode=casper
		else
			bootmode=live
		fi

		kopts=
		if db_get debian-installer/add-kernel-opts && [ "$RET" ]; then
			kopts="$RET"
			# remove any existing boot= option
			kopts="$(echo "$kopts" | sed -r "s/(^| )boot=[^ ]*//")"
		fi
		db_set debian-installer/add-kernel-opts \
			"${kopts:+$kopts }boot=$bootmode"

		# skip the hooks
		return
	fi

	# run the scripts found in hook directory after copying the system
	partsdir="/usr/lib/live-installer.d"
	if [ -d "$partsdir" ]; then
		for script in $(ls "$partsdir"/*); do
			base=$(basename $script | sed 's/[0-9]*//')
			if ! db_progress INFO live-installer/progress/$base; then
				db_subst live-installer/progress/fallback SCRIPT "$base"
				db_progress INFO live-installer/progress/fallback
			fi

			if [ -x "$script" ] ; then
				# be careful to preserve exit code
				if log-output -t live-installer "$script"; then
					:
				else
					warning "$script returned error code $?"
				fi
			else
				error "Unable to execute $script"
			fi
		done
	fi
}

waypoint 1	check_target
waypoint 1	get_mirror_info
waypoint 100	install_live_system
waypoint 1	pre_install_hooks
#waypoint 1	setup_dev
waypoint 1	configure_apt_preferences
waypoint 1	configure_apt
waypoint 3	apt_update
#waypoint 2	install_filesystems
waypoint 5	post_install_hooks
#waypoint 1	pick_kernel
#waypoint 20	install_linux
#waypoint 10	install_extra
waypoint 0	cleanup

run_waypoints live-installer/progress/installing

# mount /dev and /proc on target otherwise grub-installer will fail
mount -o bind /dev /target/dev

if [ ! -e /target/proc/version ]; then
	mount -o bind /proc /target/proc
fi

exit 0