Skip to content

Commit 52773d9

Browse files
feat: Add debootstrap-scripts directory
1 parent 7bdd196 commit 52773d9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+3763
-0
lines changed

core/debootstrap-scripts/functions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../debootstrap/functions
Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
mirror_style release
2+
download_style apt
3+
finddebs_style from-indices
4+
variants - buildd fakechroot minbase
5+
keyring /usr/share/keyrings/tanglu-archive-keyring.gpg
6+
default_mirror http://archive.tanglu.org/tanglu
7+
8+
if doing_variant fakechroot; then
9+
test "$FAKECHROOT" = "true" || error 1 FAKECHROOTREQ "This variant requires fakechroot environment to be started"
10+
fi
11+
12+
case $ARCH in
13+
alpha|ia64) LIBC="libc6.1" ;;
14+
kfreebsd-*) LIBC="libc0.1" ;;
15+
hurd-*) LIBC="libc0.3" ;;
16+
*) LIBC="libc6" ;;
17+
esac
18+
19+
work_out_debs () {
20+
required="$(get_debs Priority: required)"
21+
22+
if doing_variant - || doing_variant fakechroot; then
23+
#required="$required $(get_debs Priority: important)"
24+
# ^^ should be getting debconf here somehow maybe
25+
base="$(get_debs Priority: important)"
26+
27+
# we want the Tanglu minimal dependency set to be installed
28+
base="$base tanglu-minimal"
29+
elif doing_variant buildd; then
30+
base="apt build-essential"
31+
elif doing_variant minbase; then
32+
base="apt"
33+
fi
34+
35+
if doing_variant fakechroot; then
36+
# ldd.fake needs binutils
37+
required="$required binutils"
38+
fi
39+
40+
case $MIRRORS in
41+
https://*)
42+
base="$base apt-transport-https ca-certificates"
43+
;;
44+
esac
45+
}
46+
47+
first_stage_install () {
48+
extract $required
49+
50+
mkdir -p "$TARGET/var/lib/dpkg"
51+
: >"$TARGET/var/lib/dpkg/status"
52+
: >"$TARGET/var/lib/dpkg/available"
53+
54+
setup_etc
55+
if [ ! -e "$TARGET/etc/fstab" ]; then
56+
echo '# UNCONFIGURED FSTAB FOR BASE SYSTEM' > "$TARGET/etc/fstab"
57+
chown 0:0 "$TARGET/etc/fstab"; chmod 644 "$TARGET/etc/fstab"
58+
fi
59+
60+
setup_devices
61+
62+
x_feign_install () {
63+
local pkg="$1"
64+
local deb="$(debfor $pkg)"
65+
local ver="$(extract_deb_field "$TARGET/$deb" Version)"
66+
67+
mkdir -p "$TARGET/var/lib/dpkg/info"
68+
69+
echo \
70+
"Package: $pkg
71+
Version: $ver
72+
Maintainer: unknown
73+
Status: install ok installed" >> "$TARGET/var/lib/dpkg/status"
74+
75+
touch "$TARGET/var/lib/dpkg/info/${pkg}.list"
76+
}
77+
78+
x_feign_install dpkg
79+
}
80+
81+
second_stage_install () {
82+
setup_dynamic_devices
83+
84+
x_core_install () {
85+
smallyes '' | in_target dpkg --force-depends --install $(debfor "$@")
86+
}
87+
88+
p () {
89+
baseprog="$(($baseprog + ${1:-1}))"
90+
}
91+
92+
if doing_variant fakechroot || [ "$CONTAINER" = "docker" ]; then
93+
setup_proc_symlink
94+
else
95+
setup_proc
96+
in_target /sbin/ldconfig
97+
fi
98+
99+
DEBIAN_FRONTEND=noninteractive
100+
DEBCONF_NONINTERACTIVE_SEEN=true
101+
export DEBIAN_FRONTEND DEBCONF_NONINTERACTIVE_SEEN
102+
103+
baseprog=0
104+
bases=7
105+
106+
p; progress $baseprog $bases INSTCORE "Installing core packages" #1
107+
info INSTCORE "Installing core packages..."
108+
109+
p; progress $baseprog $bases INSTCORE "Installing core packages" #2
110+
ln -sf mawk "$TARGET/usr/bin/awk"
111+
x_core_install base-passwd
112+
x_core_install base-files
113+
p; progress $baseprog $bases INSTCORE "Installing core packages" #3
114+
x_core_install dpkg
115+
116+
if [ ! -e "$TARGET/etc/localtime" ]; then
117+
ln -sf /usr/share/zoneinfo/UTC "$TARGET/etc/localtime"
118+
fi
119+
120+
if doing_variant fakechroot; then
121+
install_fakechroot_tools
122+
fi
123+
124+
p; progress $baseprog $bases INSTCORE "Installing core packages" #4
125+
x_core_install $LIBC
126+
127+
p; progress $baseprog $bases INSTCORE "Installing core packages" #5
128+
x_core_install perl-base
129+
130+
p; progress $baseprog $bases INSTCORE "Installing core packages" #6
131+
rm "$TARGET/usr/bin/awk"
132+
x_core_install mawk
133+
134+
p; progress $baseprog $bases INSTCORE "Installing core packages" #7
135+
if doing_variant -; then
136+
x_core_install debconf
137+
fi
138+
139+
baseprog=0
140+
bases=$(set -- $required; echo $#)
141+
142+
info UNPACKREQ "Unpacking required packages..."
143+
144+
exec 7>&1
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 || echo EXITCODE $?) |
149+
dpkg_progress $baseprog $bases UNPACKREQ "Unpacking required packages" UNPACKING
150+
151+
info CONFREQ "Configuring required packages..."
152+
153+
mv "$TARGET/sbin/start-stop-daemon" "$TARGET/sbin/start-stop-daemon.REAL"
154+
echo \
155+
"#!/bin/sh
156+
echo
157+
echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/start-stop-daemon"
158+
chmod 755 "$TARGET/sbin/start-stop-daemon"
159+
160+
setup_dselect_method apt
161+
162+
smallyes '' |
163+
(in_target_failmsg CONF_REQ_FAIL "Failure while configuring required packages." "" \
164+
dpkg --status-fd 8 --configure --pending --force-configure-any --force-depends 8>&1 1>&7 || echo EXITCODE $?) |
165+
dpkg_progress $baseprog $bases CONFREQ "Configuring required packages" CONFIGURING
166+
167+
baseprog=0
168+
bases="$(set -- $base; echo $#)"
169+
170+
info UNPACKBASE "Unpacking the base system..."
171+
172+
setup_available $required $base
173+
done_predeps=
174+
while predep=$(get_next_predep); do
175+
# We have to resolve dependencies of pre-dependencies manually because
176+
# dpkg --predep-package doesn't handle this.
177+
predep=$(without "$(without "$(resolve_deps $predep)" "$required")" "$done_predeps")
178+
# XXX: progress is tricky due to how dpkg_progress works
179+
# -- cjwatson 2009-07-29
180+
p; smallyes '' |
181+
in_target dpkg --force-overwrite --force-confold --skip-same-version --install $(debfor $predep)
182+
base=$(without "$base" "$predep")
183+
done_predeps="$done_predeps $predep"
184+
done
185+
186+
smallyes '' |
187+
(repeatn 5 in_target_failmsg INST_BASE_FAIL_FIVE "Failure while installing base packages. This will be re-attempted up to five times." "" \
188+
dpkg --status-fd 8 --force-overwrite --force-confold --skip-same-version --unpack $(debfor $base) 8>&1 1>&7 || echo EXITCODE $?) |
189+
dpkg_progress $baseprog $bases UNPACKBASE "Unpacking base system" UNPACKING
190+
191+
info CONFBASE "Configuring the base system..."
192+
193+
smallyes '' |
194+
(repeatn 5 in_target_failmsg CONF_BASE_FAIL_FIVE "Failure while configuring base packages. This will be re-attempted up to five times." "" \
195+
dpkg --status-fd 8 --force-confold --skip-same-version --configure -a 8>&1 1>&7 || echo EXITCODE $?) |
196+
dpkg_progress $baseprog $bases CONFBASE "Configuring base system" CONFIGURING
197+
198+
mv "$TARGET/sbin/start-stop-daemon.REAL" "$TARGET/sbin/start-stop-daemon"
199+
200+
progress $bases $bases CONFBASE "Configuring base system"
201+
info BASESUCCESS "Base system installed successfully."
202+
}

0 commit comments

Comments
 (0)