androot/bootscriptdl.sh

59 lines
1.9 KiB
Bash
Raw Normal View History

2023-11-07 17:23:39 +01:00
#!/bin/bash
2023-11-08 19:47:37 +01:00
# disable errors regarding androot.source as
# it is created and loaded at runtime
# shellcheck disable=SC1091
2023-11-07 17:23:39 +01:00
source "${TMPDIR}/androot.source"
source "${TMPDIR}/androot.env"
log_diag "rootfsinstall is now executing, with arguments \"${*}\""
case "${1}" in
"--download")
log_diag "Using download mode"
2023-11-08 19:47:37 +01:00
indicate_exec "Downloading bootscripts"
log_write "#### download bootscripts repository"
if ! log_execute git clone --quiet --verbose -b "${BRANCH}-bootscripts" "${DOWNLOADSERVER_BOOTSCRIPTS}" "${LOCATION}/bootscripts"; then
indicate_fail
2023-11-07 17:23:39 +01:00
exit 1
fi
2023-11-08 19:47:37 +01:00
indicate_ok
;;
2023-11-07 17:23:39 +01:00
"--configure")
log_diag "Using configure mode"
2023-11-08 19:47:37 +01:00
indicate_exec "Configuring bootscript scripts"
log_execute cd "${LOCATION}/bootscripts/" ||{ indicate_fail; exit 1; }
log_write "#### writing bootscripts config.env"
2023-11-07 17:23:39 +01:00
cat << EOF >> "${LOCATION}/bootscripts/config.env"
COMMIT=$(git rev-parse HEAD)
LOCATION=${LOCATION}
2023-11-08 19:47:37 +01:00
ARCHITECTURE=${ARCH_TARGET}
2023-11-07 17:23:39 +01:00
IS_ANDROID=${IS_ANDROID}
EOF
2023-11-08 19:47:37 +01:00
indicate_ok
;;
"--install-qemu")
log_diag "Using install-qemu mode"
for ARCH_DOWNLOAD in ${ARCH_EXECUTORS}; do
2023-11-08 19:47:37 +01:00
indicate_exec "Installing qemu-static for ${ARCH_DOWNLOAD}"
log_write "#### download qemu-static for ${ARCH_DOWNLOAD}"
if ! log_execute wget "${DOWNLOADSERVER_QEMUSTATIC}${ARCH_DOWNLOAD}.tar.gz" --no-verbose -O "${TMPDIR}/${ARCH_DOWNLOAD}.tar.gz"; then
indicate_fail;
exit 1
fi
2023-11-08 19:47:37 +01:00
log_write "#### extract qemu-static for ${ARCH_DOWNLOAD}"
if ! log_execute mkdir -p "${LOCATION}/bootscripts/qemu-static/${ARCH_DOWNLOAD}"; then
indicate_fail;
exit 1
fi
2023-11-08 19:47:37 +01:00
if ! log_execute bsdtar -xf "${TMPDIR}/${ARCH_DOWNLOAD}.tar.gz" -C "${LOCATION}/bootscripts/qemu-static/${ARCH_DOWNLOAD}/"; then
indicate_fail;
exit 1
fi
2023-11-08 19:47:37 +01:00
indicate_ok
done
;;
2023-11-07 17:23:39 +01:00
*)
log_error "--download or --decompress required"
2023-11-08 19:47:37 +01:00
exit 1
;;
2023-11-07 17:23:39 +01:00
esac