Improve bootstrap() function in common script
* Tidy up and simplify function code * Allow to pass extra arguments to debootstrap, e.g. `--variant minbase` * Preserve compatibility with existing function calls
This commit is contained in:
parent
3961bff8a4
commit
3b90b7ffed
|
@ -4,21 +4,22 @@ log (){
|
||||||
export -f log
|
export -f log
|
||||||
|
|
||||||
bootstrap(){
|
bootstrap(){
|
||||||
local ARCH
|
local BOOTSTRAP_CMD=debootstrap
|
||||||
ARCH=$(dpkg --print-architecture)
|
local BOOTSTRAP_ARGS=()
|
||||||
|
|
||||||
export http_proxy=${APT_PROXY}
|
export http_proxy=${APT_PROXY}
|
||||||
|
|
||||||
if [ "$ARCH" != "armhf" ]; then
|
if [ "$(dpkg --print-architecture)" != "armhf" ]; then
|
||||||
local BOOTSTRAP_CMD=qemu-debootstrap
|
BOOTSTRAP_CMD=qemu-debootstrap
|
||||||
else
|
|
||||||
local BOOTSTRAP_CMD=debootstrap
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
capsh --drop=cap_setfcap -- "${BOOTSTRAP_CMD}" --components=main,contrib,non-free \
|
BOOTSTRAP_ARGS+=(--arch armhf)
|
||||||
--arch armhf \
|
BOOTSTRAP_ARGS+=(--components "main,contrib,non-free")
|
||||||
--keyring "${STAGE_DIR}/files/raspberrypi.gpg" \
|
BOOTSTRAP_ARGS+=(--keyring "${STAGE_DIR}/files/raspberrypi.gpg")
|
||||||
"$1" "$2" "$3" || true
|
BOOTSTRAP_ARGS+=("$@")
|
||||||
|
|
||||||
|
capsh --drop=cap_setfcap -- "${BOOTSTRAP_CMD}" "${BOOTSTRAP_ARGS[@]}" || true
|
||||||
|
|
||||||
if [ -d "$2/debootstrap" ]; then
|
if [ -d "$2/debootstrap" ]; then
|
||||||
rmdir "$2/debootstrap"
|
rmdir "$2/debootstrap"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in New Issue
Block a user