Revision 448a829f snf-image-host/common.sh.in
b/snf-image-host/common.sh.in | ||
---|---|---|
253 | 253 |
|
254 | 254 |
} |
255 | 255 |
|
256 |
do_debootstrap() { |
|
257 |
local target=$1 |
|
258 |
|
|
259 |
echo "Debootstraping to create a new root filesystem:" |
|
260 |
|
|
261 |
# Create a policy-rc.d file to deny init script execution |
|
262 |
mkdir -p "$target/usr/sbin" |
|
263 |
cat > "$target/usr/sbin/policy-rc.d" <<EOF |
|
264 |
#!/bin/sh |
|
265 |
exit 101 |
|
266 |
EOF |
|
267 |
chmod +x "$target/usr/sbin/policy-rc.d" |
|
268 |
|
|
269 |
debootstrap --arch $(dpkg --print-architecture) \ |
|
270 |
--include "$HELPER_EXTRA_PKGS" --variant=minbase stable "$target" \ |
|
271 |
"$HELPER_MIRROR" 2>&1 | sed -e 's/^/DEBOOTSTRAP: /g' |
|
272 |
|
|
273 |
rm "$target/usr/sbin/policy-rc.d" |
|
274 |
|
|
275 |
# remove the downloaded debs, as they are no longer needed |
|
276 |
find "$target/var/cache/apt/archives" -type f -name '*.deb' -print0 | \ |
|
277 |
xargs -r0 rm -f |
|
278 |
|
|
279 |
local tmp_cache=$(mktemp "$CACHE_FILE.XXXXXX") |
|
280 |
tar cf "$tmp_cache" --one-file-system -C "$target" . || \ |
|
281 |
{ rm "$tmp_cache"; false; } |
|
282 |
# Overwrite the default cache file. Not the user specified if present. |
|
283 |
mv -f "$tmp_cache" "$HELPER_CACHE_FILE" |
|
284 |
} |
|
285 |
|
|
256 | 286 |
cleanup() { |
257 | 287 |
# if something fails here, it souldn't call cleanup again... |
258 | 288 |
trap - EXIT |
Also available in: Unified diff