diff options
-rwxr-xr-x | src/selfstrap | 38 |
1 files changed, 26 insertions, 12 deletions
diff --git a/src/selfstrap b/src/selfstrap index fc2ae5d..9c43f2d 100755 --- a/src/selfstrap +++ b/src/selfstrap | |||
@@ -186,6 +186,9 @@ populate_rootfs() | |||
186 | 186 | ||
187 | touch "$TARGET"/var/lib/dpkg/status | 187 | touch "$TARGET"/var/lib/dpkg/status |
188 | 188 | ||
189 | [ -d "$TARGET"/usr/bin ] || mkdir -p "$TARGET"/usr/bin | ||
190 | [ -e "$TARGET/usr/bin/awk" -o -L "$TARGET/usr/bin/awk" ] || ln -s mawk "$TARGET/usr/bin/awk" | ||
191 | |||
189 | write_lines_once "$TARGET"/var/lib/dpkg/arch "$target_arch" | 192 | write_lines_once "$TARGET"/var/lib/dpkg/arch "$target_arch" |
190 | write_lines_once "$TARGET"/etc/apt/sources.list \ | 193 | write_lines_once "$TARGET"/etc/apt/sources.list \ |
191 | "deb $debian_mirror $target_release main contrib non-free" \ | 194 | "deb $debian_mirror $target_release main contrib non-free" \ |
@@ -242,6 +245,15 @@ EOF | |||
242 | sed 's?^\.??; s?^/$?/.?; s?/$??' > "$TARGET/var/lib/dpkg/info/$PKG.list" | 245 | sed 's?^\.??; s?^/$?/.?; s?/$??' > "$TARGET/var/lib/dpkg/info/$PKG.list" |
243 | } | 246 | } |
244 | 247 | ||
248 | verbosely() | ||
249 | { | ||
250 | if [ "$VERBOSE" ]; then | ||
251 | (set -x; "$@") | ||
252 | else | ||
253 | "$@" | ||
254 | fi | ||
255 | } | ||
256 | |||
245 | dpkg_configure_from_apt_actions() | 257 | dpkg_configure_from_apt_actions() |
246 | { | 258 | { |
247 | while read line; do | 259 | while read line; do |
@@ -255,14 +267,14 @@ dpkg_configure_from_apt_actions() | |||
255 | export DPKG_MAINTSCRIPT_NAME=preinst | 267 | export DPKG_MAINTSCRIPT_NAME=preinst |
256 | preinst=/var/lib/dpkg/info/${package}${multiarch}.preinst | 268 | preinst=/var/lib/dpkg/info/${package}${multiarch}.preinst |
257 | if [ -x "$TARGET"/"$preinst" ]; then | 269 | if [ -x "$TARGET"/"$preinst" ]; then |
258 | ${CHROOT_PROG:-chroot} "$TARGET" "$preinst" install | 270 | verbosely ${CHROOT_PROG:-chroot} "$TARGET" "$preinst" install |
259 | fi | 271 | fi |
260 | ;; | 272 | ;; |
261 | Conf) | 273 | Conf) |
262 | export DPKG_MAINTSCRIPT_NAME=postinst | 274 | export DPKG_MAINTSCRIPT_NAME=postinst |
263 | postinst=/var/lib/dpkg/info/${package}${multiarch}.postinst | 275 | postinst=/var/lib/dpkg/info/${package}${multiarch}.postinst |
264 | if [ -x "$TARGET"/"$postinst" ]; then | 276 | if [ -x "$TARGET"/"$postinst" ]; then |
265 | ${CHROOT_PROG:-chroot} "$TARGET" "$postinst" configure | 277 | verbosely ${CHROOT_PROG:-chroot} "$TARGET" "$postinst" configure |
266 | fi | 278 | fi |
267 | ;; | 279 | ;; |
268 | Remv) ;; | 280 | Remv) ;; |
@@ -302,11 +314,13 @@ dpkg_unpack_from_apt_actions() | |||
302 | case "$action" in | 314 | case "$action" in |
303 | Inst) | 315 | Inst) |
304 | printf 'Unpacking %s\n' "${deb##*/}" >&2 | 316 | printf 'Unpacking %s\n' "${deb##*/}" >&2 |
305 | 317 | if [ "$REAL_APT_INSTALL" ]; then | |
306 | is_multiarch_same "$package" && multiarch=":$arch" || multiarch= | 318 | dpkg --extract "$deb" "$TARGET" || die 'dpkg' |
307 | [ "$UNPACK_ONLY" ] && set_status=unpacked || set_status=installed | 319 | else |
308 | dpkg_unpack "$deb" "$multiarch" "$set_status" || die "dpkg_unpack" | 320 | is_multiarch_same "$package" && multiarch=":$arch" || multiarch= |
309 | 321 | [ "$UNPACK_ONLY" ] && set_status=unpacked || set_status=installed | |
322 | dpkg_unpack "$deb" "$multiarch" "$set_status" || die "dpkg_unpack" | ||
323 | fi | ||
310 | ;; | 324 | ;; |
311 | Conf) ;; | 325 | Conf) ;; |
312 | Remv) ;; | 326 | Remv) ;; |
@@ -364,7 +378,7 @@ generate_apt_config | |||
364 | populate_rootfs | 378 | populate_rootfs |
365 | [ "$SKIP_UPDATE" ] || apt_get update | 379 | [ "$SKIP_UPDATE" ] || apt_get update |
366 | 380 | ||
367 | packages=$(required_packages) && [ "$packages" ] || die 'failed to determine list of required packages' | 381 | required_packages=$(required_packages) && [ "$required_packages" ] || die 'failed to determine list of required packages' |
368 | 382 | ||
369 | export LC_ALL=C | 383 | export LC_ALL=C |
370 | export DEBIAN_FRONTEND=noninteractive | 384 | export DEBIAN_FRONTEND=noninteractive |
@@ -377,15 +391,15 @@ if [ "$REAL_APT_INSTALL" ]; then | |||
377 | # 2. /etc/passwd and /etc/group so that 'chown' works | 391 | # 2. /etc/passwd and /etc/group so that 'chown' works |
378 | 392 | ||
379 | # Unpack required packages. Handles (1) | 393 | # Unpack required packages. Handles (1) |
380 | UNPACK_ONLY=y apt_extract $packages | 394 | # Note: populate_rootfs() already created a necessary symlink /usr/bin/awk -> /usr/bin/mawk |
395 | apt_extract $required_packages | ||
381 | 396 | ||
382 | # This handles (2). | 397 | # This handles (2). |
383 | # An alternative (used by debootstrap) is to configure base-passwd | 398 | # An alternative (used by debootstrap) is to configure base-passwd |
384 | install_etc_passwd | 399 | install_etc_passwd |
385 | 400 | ||
386 | dpkg --root="$TARGET" --configure -a | 401 | apt_get install -y $required_packages $EXTRA_PACKAGES |
387 | apt_get install -y $EXTRA_PACKAGES | ||
388 | else | 402 | else |
389 | apt_extract $packages | 403 | apt_extract $required_packages |
390 | apt_extract $EXTRA_PACKAGES | 404 | apt_extract $EXTRA_PACKAGES |
391 | fi | 405 | fi |