gutsy 7.29 KB
Newer Older
1
case $ARCH in
2
  amd64|i386)
3 4 5 6 7
	case $SUITE in
	  gutsy|hardy|intrepid|jaunty|karmic|lucid|maverick|natty|oneiric|precise|quantal|raring|saucy|utopic|vivid|wily|yakkety|zesty)
	default_mirror http://old-releases.ubuntu.com/ubuntu
	  ;;
	  *)
8 9
	default_mirror http://archive.ubuntu.com/ubuntu
	;;
Hideki Yamane's avatar
Hideki Yamane committed
10 11
	esac
	;;
12
  sparc)
13 14
	case $SUITE in
	  gutsy)
15
	default_mirror http://old-releases.ubuntu.com/ubuntu
16
	;;
17
	  *)
18 19
	default_mirror http://ports.ubuntu.com/ubuntu-ports
	;;
20 21
	esac
	;;
22
  *)
23 24
	default_mirror http://ports.ubuntu.com/ubuntu-ports
	;;
25
esac
26 27 28
mirror_style release
download_style apt
finddebs_style from-indices
29
variants - buildd fakechroot minbase
30
keyring /usr/share/keyrings/ubuntu-archive-keyring.gpg
31 32

if doing_variant fakechroot; then
33
	test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
34
fi
35

36
case $ARCH in
37
	alpha|ia64) LIBC="libc6.1" ;;
38 39
	kfreebsd-*) LIBC="libc0.1" ;;
	hurd-*)     LIBC="libc0.3" ;;
40
	*)          LIBC="libc6" ;;
41
esac
42

43
work_out_debs () {
44 45
	required="$(get_debs Priority: required)"

46
	if doing_variant - || doing_variant fakechroot; then
47 48 49 50
		#required="$required $(get_debs Priority: important)"
		#  ^^ should be getting debconf here somehow maybe
		base="$(get_debs Priority: important)"
	elif doing_variant buildd; then
51 52
		base="apt build-essential"
	elif doing_variant minbase; then
53 54
		base="apt"
	fi
55

56 57 58 59 60
	if doing_variant fakechroot; then
		# ldd.fake needs binutils
		required="$required binutils"
	fi

61 62
	case $MIRRORS in
	    https://*)
63
		base="$base apt-transport-https ca-certificates"
64 65
		;;
	esac
66 67 68
}

first_stage_install () {
69 70 71 72 73 74 75 76
	case "$CODENAME" in
		etch|etch-m68k|jessie|jessie-kfreebsd|lenny|squeeze|wheezy) ;;
		*)
			EXTRACT_DEB_TAR_OPTIONS="$EXTRACT_DEB_TAR_OPTIONS -k"
			setup_merged_usr
			;;
	esac

77
	extract $required
78

79 80 81
	mkdir -p "$TARGET/var/lib/dpkg"
	: >"$TARGET/var/lib/dpkg/status"
	: >"$TARGET/var/lib/dpkg/available"
82

83 84 85 86 87
	setup_etc
	if [ ! -e "$TARGET/etc/fstab" ]; then
		echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
		chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
	fi
88

89
	setup_devices
90 91 92 93
}

second_stage_install () {
	setup_dynamic_devices
94

95 96 97
	x_feign_install () {
		local pkg="$1"
		local deb="$(debfor $pkg)"
98
		local ver="$(in_target dpkg-deb -f "$deb" Version)"
99

100
		mkdir -p "$TARGET/var/lib/dpkg/info"
101

102
		echo \
103 104
"Package: $pkg
Version: $ver
105
Maintainer: unknown
106 107
Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"

108 109
		touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
	}
110

111
	x_feign_install dpkg
112

113 114 115
	x_core_install () {
		smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
	}
116

117 118 119
	p () {
		baseprog="$(($baseprog + ${1:-1}))"
	}
120

121 122 123 124 125 126
	if doing_variant fakechroot; then
		setup_proc_fakechroot
	else
		setup_proc
		in_target /sbin/ldconfig
	fi
127

128 129 130
	DEBIAN_FRONTEND=noninteractive
	DEBCONF_NONINTERACTIVE_SEEN=true
	export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
131

132 133
	baseprog=0
	bases=7
134

135 136
	p; progress $baseprog $bases INSTCORE "Installing core packages" #1
	info INSTCORE "Installing core packages..."
137

138 139
	p; progress $baseprog $bases INSTCORE "Installing core packages" #2
	ln -sf mawk "$TARGET/usr/bin/awk"
140 141
	x_core_install base-passwd
	x_core_install base-files
142 143
	p; progress $baseprog $bases INSTCORE "Installing core packages" #3
	x_core_install dpkg
144

145
	if [ ! -e "$TARGET/etc/localtime" ]; then
146
		ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
147
	fi
148

149 150 151
	if doing_variant fakechroot; then
		install_fakechroot_tools
	fi
152

153 154
	p; progress $baseprog $bases INSTCORE "Installing core packages" #4
	x_core_install $LIBC
155

156 157
	p; progress $baseprog $bases INSTCORE "Installing core packages" #5
	x_core_install perl-base
158

159 160 161
	p; progress $baseprog $bases INSTCORE "Installing core packages" #6
	rm "$TARGET/usr/bin/awk"
	x_core_install mawk
162

163 164 165 166
	p; progress $baseprog $bases INSTCORE "Installing core packages" #7
	if doing_variant -; then
		x_core_install debconf
	fi
167

168 169
	baseprog=0
	bases=$(set -- $required; echo $#)
170

171
	info UNPACKREQ "Unpacking required packages..."
172

173 174
	exec 7>&1

175 176
	smallyes '' |
		(repeatn 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages.  This will be attempted up to five times." "" \
177 178
		dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 || echo EXITCODE $?) |
		dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING
179

180
	info CONFREQ "Configuring required packages..."
181

182 183 184 185 186 187
	if doing_variant fakechroot && [ -e "$TARGET/var/lib/dpkg/info/initscripts.postinst" ]
	then
		# fix initscripts postinst (no mounting possible, and wrong if condition)
		sed -i '/dpkg.*--compare-versions/ s/\<lt\>/lt-nl/' "$TARGET/var/lib/dpkg/info/initscripts.postinst"
	fi

188 189 190 191 192
	echo \
"#!/bin/sh
exit 101" > "$TARGET/usr/sbin/policy-rc.d"
	chmod 755 "$TARGET/usr/sbin/policy-rc.d"

193 194
	mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
	echo \
195 196 197
"#!/bin/sh
echo
echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
198
	chmod 755 "$TARGET/sbin/start-stop-daemon"
199

200 201 202 203 204 205 206 207 208 209
	if [ -x "$TARGET/sbin/initctl" ]; then
	  mv "$TARGET/sbin/initctl" "$TARGET/sbin/initctl.REAL"
	  echo \
"#!/bin/sh
if [ \"\$1\" = version ]; then exec /sbin/initctl.REAL \"\$@\"; fi
echo
echo \"Warning: Fake initctl called, doing nothing\"" > "$TARGET/sbin/initctl"
	  chmod 755 "$TARGET/sbin/initctl"
	fi

210 211 212 213
	setup_dselect_method apt

	smallyes '' |
		(in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
214 215
		dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 || echo EXITCODE $?) |
		dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235

	baseprog=0
	bases="$(set -- $base; echo $#)"

	info UNPACKBASE "Unpacking the base system..."

	setup_available $required $base
	done_predeps=
	while predep=$(get_next_predep); do
		# We have to resolve dependencies of pre-dependencies manually because
		# dpkg --predep-package doesn't handle this.
		predep=$(without "$(without "$(resolve_deps $predep)" "$required")" "$done_predeps")
		# XXX: progress is tricky due to how dpkg_progress works
		# -- cjwatson 2009-07-29
		p; smallyes '' |
		in_target dpkg --force-overwrite --force-confold --skip-same-version --install $(debfor $predep)
		base=$(without "$base" "$predep")
		done_predeps="$done_predeps $predep"
	done

236 237 238 239 240
	if [ -n "$base" ]; then
		smallyes '' |
			(repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages.  This will be re-attempted up to five times." "" \
			dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 || echo EXITCODE $?) |
			dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING
241

242
		info CONFBASE "Configuring the base system..."
243

244 245 246 247
		smallyes '' |
			(repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages.  This will be re-attempted up to five times." "" \
			dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 || echo EXITCODE $?) |
			dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING
248
	fi
249

250 251 252
	if [ -x "$TARGET/sbin/initctl.REAL" ]; then
		mv "$TARGET/sbin/initctl.REAL" "$TARGET/sbin/initctl"
	fi
253
	mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
254
	rm -f "$TARGET/usr/sbin/policy-rc.d"
255 256 257

	progress $bases $bases CONFBASE "Configuring base system"
	info BASESUCCESS "Base system installed successfully."
258
}