Debian Codegraph @

scripts/.debootstrap-scripts/potato

raw
1 #
2 # This script was taken from debootstrap version 1.0.125 and then hacked to avoid invoking "init u" in postinst scripts (which tries to send SIGHUP to PID 1).
3 #
4
5 mirror_style release
6 download_style apt var-state
7 default_mirror http://archive.debian.org/debian
8 force_md5
9
10 LIBC=libc6
11 if [ "$ARCH" = alpha ]; then
12 LIBC="libc6.1"
13 fi
14
15 work_out_debs () {
16 required="base-files base-passwd bash bsdutils debconf-tiny debianutils diff dpkg e2fsprogs fileutils findutils grep gzip hostname ldso libc6 libdb2 libgdbmg1 libncurses5 libnewt0 libpam-modules libpam-runtime libpam0g libpopt0 libreadline4 libstdc++2.10 login makedev mawk modutils mount ncurses-base ncurses-bin passwd perl-5.005-base perl-base procps sed shellutils slang1 sysklogd sysvinit tar textutils update util-linux whiptail"
17
18 base="adduser ae apt base-config elvis-tiny fbset fdutils gettext-base console-data console-tools console-tools-libs libdb2 libwrap0 locales modconf netbase ftp ppp pppconfig pump tasksel tcpd textutils telnet xviddetect"
19
20 without_package () {
21 echo "$2" | tr ' ' '\n' | grep -v "^$1$" | tr '\n' ' '
22 }
23
24 case $ARCH in
25 "alpha")
26 required="$(without_package "libc6" "$required") libc6.1"
27 ;;
28 "i386")
29 base="$base fdflush isapnptools lilo mbr pciutils pcmcia-cs psmisc setserial syslinux"
30 ;;
31 *)
32 # other arches may have special needs not yet represented here
33 # oh well, Potato is old
34 esac
35 }
36
37 first_stage_install () {
38 extract $required
39
40 :> "$TARGET/var/lib/dpkg/status"
41 echo > "$TARGET/var/lib/dpkg/available"
42
43 setup_etc
44 echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
45 chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
46
47 x_feign_install () {
48 local pkg=$1
49 local deb="$(debfor $pkg)"
50 local ver="$(extract_deb_field "$TARGET/$deb" Version)"
51
52 mkdir -p "$TARGET/var/lib/dpkg/info"
53
54 echo \
55 "Package: $pkg
56 Version: $ver
57 Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
58
59 touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
60 }
61
62 setup_devices
63
64 x_feign_install dpkg
65
66 if [ -e "$TARGET/usr/bin/perl-5.005.dist" ]; then
67 mv "$TARGET/usr/bin/perl-5.005.dist" "$TARGET/usr/bin/perl-5.005"
68 fi
69 if [ ! -e "$TARGET/usr/bin/perl" ]; then
70 ln -sf perl-5.005 "$TARGET/usr/bin/perl"
71 fi
72 }
73
74 second_stage_install () {
75 x_core_install () {
76 in_target dpkg --force-depends --install $(debfor "$@")
77 }
78
79 export DEBIAN_FRONTEND=Noninteractive
80
81 setup_proc
82 ln "$TARGET/sbin/ldconfig.new" "$TARGET/sbin/ldconfig"
83 in_target /sbin/ldconfig
84
85 x_core_install base-files base-passwd ldso
86 x_core_install dpkg
87
88 ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
89
90 # the libc6 and sysvinit postinst scripts want to run "init u" to re-exec sysvinit, but that sends SIGHUP to PID 1, which is undesirable (for hopefully obvious reasons), so we have to get a little bit clever while installing libc6 and later before configuring the rest of the system
91 x_hack_avoid_postinst_init() {
92 local postinst
93 for postinst in "$TARGET"/var/lib/dpkg/info/*.postinst; do
94 if grep -qE '^[[:space:]]*init[[:space:]]' "$postinst" 2>/dev/null; then
95 sed -ri -e 's/^([[:space:]]*)(init[[:space:]])/\1: # \2/' "$postinst"
96 fi
97 done
98 }
99 in_target dpkg --force-depends --unpack $(debfor $LIBC)
100 x_hack_avoid_postinst_init
101 in_target dpkg --force-depends --configure $LIBC
102
103 smallyes '' | x_core_install perl-5.005-base
104 x_core_install mawk
105 x_core_install debconf-tiny
106
107 in_target dpkg-preconfigure $(debfor $required $base)
108
109 repeatn 5 in_target dpkg --force-depends --unpack $(debfor $required)
110
111 # see above
112 x_hack_avoid_postinst_init
113
114 mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
115 cp "$TARGET/bin/true" "$TARGET/sbin/start-stop-daemon"
116
117 setup_dselect_method apt
118
119 in_target dpkg --configure --pending --force-configure-any --force-depends
120
121 smallyes '' | repeatn 5 in_target dpkg --force-auto-select --force-overwrite --skip-same-version --install $(debfor $base)
122
123 mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
124 }