blob: 9e08600343002c520360162de264955194b93d01 [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001# based on debootstrap/scripts/natty
2
3case $ARCH in
4 amd64|i386)
5 default_mirror http://archive.ubuntu.com/ubuntu
6 ;;
7 sparc)
8 case $SUITE in
9 gutsy)
10 default_mirror http://archive.ubuntu.com/ubuntu
11 ;;
12 *)
13 default_mirror http://ports.ubuntu.com/ubuntu-ports
14 ;;
15 esac
16 ;;
17 *)
18 default_mirror http://ports.ubuntu.com/ubuntu-ports
19 ;;
20esac
21mirror_style release
22download_style apt
23finddebs_style from-indices
24variants - buildd fakechroot minbase
25
26if doing_variant fakechroot; then
27 test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
28fi
29
30case $ARCH in
31 alpha|ia64) LIBC="libc6.1" ;;
32 *) LIBC="libc6" ;;
33esac
34
35work_out_debs () {
36 required="$(get_debs Priority: required) openssh-server"
37
38 if doing_variant -; then
39 #required="$required $(get_debs Priority: important)"
40 # ^^ should be getting debconf here somehow maybe
41 base="$(get_debs Priority: important)"
42 elif doing_variant buildd; then
43 base="$(get_debs Build-Essential: yes)"
44 elif doing_variant fakechroot || doing_variant minbase; then
45 base="apt"
46 fi
47}
48
49first_stage_install () {
50 extract $required
51
52 mkdir -p "$TARGET/var/lib/dpkg"
53 : >"$TARGET/var/lib/dpkg/status"
54 : >"$TARGET/var/lib/dpkg/available"
55
56 setup_etc
57 if [ ! -e "$TARGET/etc/fstab" ]; then
58 echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
59 chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
60 fi
61
62 if doing_variant fakechroot; then
63 setup_devices_fakechroot
64 else
65 setup_devices
66 fi
67
68 x_feign_install () {
69 local pkg="$1"
70 local deb="$(debfor $pkg)"
71 local ver="$(extract_deb_field "$TARGET/$deb" Version)"
72
73 mkdir -p "$TARGET/var/lib/dpkg/info"
74
75 echo \
76"Package: $pkg
77Version: $ver
78Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
79
80 touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
81 }
82
83 x_feign_install dpkg
84}
85
86second_stage_install () {
87 x_core_install () {
88 smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
89 }
90
91 p () {
92 baseprog="$(($baseprog + ${1:-1}))"
93 }
94
95 if doing_variant fakechroot; then
96 setup_proc_fakechroot
97 else
98 setup_proc
99 in_target /sbin/ldconfig
100 fi
101
102 DEBIAN_FRONTEND=noninteractive
103 DEBCONF_NONINTERACTIVE_SEEN=true
104 export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
105
106 baseprog=0
107 bases=7
108
109 p; progress $baseprog $bases INSTCORE "Installing core packages" #1
110 info INSTCORE "Installing core packages..."
111
112 p; progress $baseprog $bases INSTCORE "Installing core packages" #2
113 ln -sf mawk "$TARGET/usr/bin/awk"
114 x_core_install base-files base-passwd
115 p; progress $baseprog $bases INSTCORE "Installing core packages" #3
116 x_core_install dpkg
117
118 if [ ! -e "$TARGET/etc/localtime" ]; then
119 ln -sf /usr/share/zoneinfo/Etc/UTC "$TARGET/etc/localtime"
120 fi
121
122 if doing_variant fakechroot; then
123 install_fakechroot_tools
124 fi
125
126 p; progress $baseprog $bases INSTCORE "Installing core packages" #4
127 x_core_install $LIBC
128
129 p; progress $baseprog $bases INSTCORE "Installing core packages" #5
130 x_core_install perl-base
131
132 p; progress $baseprog $bases INSTCORE "Installing core packages" #6
133 rm "$TARGET/usr/bin/awk"
134 x_core_install mawk
135
136 p; progress $baseprog $bases INSTCORE "Installing core packages" #7
137 if doing_variant -; then
138 x_core_install debconf
139 fi
140
141 baseprog=0
142 bases=$(set -- $required; echo $#)
143
144 info UNPACKREQ "Unpacking required packages..."
145
146 smallyes '' |
147 (repeatn 5 in_target_failmsg UNPACK_REQ_FAIL_FIVE "Failure while unpacking required packages. This will be attempted up to five times." "" \
148 dpkg --status-fd 8 --force-depends --unpack $(debfor $required) 8>&1 1>&7 |
149 dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING) 7>&1
150
151 info CONFREQ "Configuring required packages..."
152
153 if doing_variant fakechroot; then
154 # fix initscripts postinst (no mounting possible, and wrong if condition)
155 sed -i '/dpkg.*--compare-versions/ s/\<lt\>/lt-nl/' "$TARGET/var/lib/dpkg/info/initscripts.postinst"
156 fi
157
158 mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
159 echo \
160"#!/bin/sh
161echo
162echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
163 chmod 755 "$TARGET/sbin/start-stop-daemon"
164
165 if [ -x "$TARGET/sbin/initctl" ]; then
166 mv "$TARGET/sbin/initctl" "$TARGET/sbin/initctl.REAL"
167 echo \
168"#!/bin/sh
169echo
170echo \"Warning: Fake initctl called, doing nothing\"" > "$TARGET/sbin/initctl"
171 chmod 755 "$TARGET/sbin/initctl"
172 fi
173
174 setup_dselect_method apt
175
176 smallyes '' |
177 (in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
178 dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 |
179 dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING) 7>&1
180
181 baseprog=0
182 bases="$(set -- $base; echo $#)"
183
184 info UNPACKBASE "Unpacking the base system..."
185
186 setup_available $required $base
187 done_predeps=
188 while predep=$(get_next_predep); do
189 # We have to resolve dependencies of pre-dependencies manually because
190 # dpkg --predep-package doesn't handle this.
191 predep=$(without "$(without "$(resolve_deps $predep)" "$required")" "$done_predeps")
192 # XXX: progress is tricky due to how dpkg_progress works
193 # -- cjwatson 2009-07-29
194 p; smallyes '' |
195 in_target dpkg --force-overwrite --force-confold --skip-same-version --install $(debfor $predep)
196 base=$(without "$base" "$predep")
197 done_predeps="$done_predeps $predep"
198 done
199
200 smallyes '' |
201 (repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages. This will be re-attempted up to five times." "" \
202 dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 |
203 dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING) 7>&1
204
205 info CONFBASE "Configuring the base system..."
206
207 smallyes '' |
208 (repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages. This will be re-attempted up to five times." "" \
209 dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 |
210 dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING) 7>&1
211
212 if [ -x "$TARGET/sbin/initctl.REAL" ]; then
213 mv "$TARGET/sbin/initctl.REAL" "$TARGET/sbin/initctl"
214 fi
215 mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
216
217 progress $bases $bases CONFBASE "Configuring base system"
218 info BASESUCCESS "Base system installed successfully."
219}