androot/rootfsinstall.sh
JeremyStarTM 8e0e3f63a1 Update files
- [androot.sh] Fix $DOWNLOADSERVER_BOOTSCRIPTS
- [androot.sh] Add $BRANCH variable
- [androot.sh] Introduce run_script() function
- [androot.sh] Use case instead of if
- [prepare.sh] Fix typo (executer -> executor)
- [rootfsinstall.sh] Remove "bsdtar failed" log line
- [bootscriptdl.sh] Trim download mode
- [bootscriptdl.sh] Implement install-qemu mode
- [README.md] Changed wording and added links
- [README.md] Add /dev/shm recommendation
- [Makefile,README.md] Add Makefile
2023-11-07 20:54:57 +01:00

68 lines
No EOL
2.6 KiB
Bash
Executable file

#!/bin/bash
# shellcheck disable=SC2181 disable=SC1091 disable=SC2236
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"
if [ -f "${TMPDIR}/rootfs.env" ]; then
source "${TMPDIR}/rootfs.env"
if [ "${ARCH_TARGET_WRITTEN}" == "${ARCH_TARGET}" ] && [ "${DISTRIBUTION_WRITTEN}" == "${DISTRIBUTION}" ]; then
echo "#### found existing rootfs archive" &>> "${TMPDIR}/androot.log"
log_askyn "true" "androot found a existing rootfs archive matching your configuration, do you want to use it? "
if [ "${ANSWER}" == "true" ]; then
echo "#### skipping download" &>> "${TMPDIR}/androot.log"
exit 0
else
echo "#### removing existing rootfs archive" &>> "${TMPDIR}/androot.log"
rm -rf "${TMPDIR}/rootfs.tar.gz"
fi
else
echo "#### removing existing rootfs archive" &>> "${TMPDIR}/androot.log"
log_diag "Removing existing rootfs archive (not matching)"
rm -rf "${TMPDIR}/rootfs.tar.gz"
fi
fi
log_exec "Downloading rootfs"
case "${ARCH_TARGET}" in
"x86_64") ;;
"arm64") ;;
*)
echo "#### invalid architecture \"${ARCH_TARGET}\"" &>> "${TMPDIR}/androot.log"
log_fail
log_error "Internal inconsistency detected: Invalid target architecture \"${ARCH_TARGET}\""
exit 1;;
esac
case "${DISTRIBUTION}" in
"archlinux") ;;
*)
echo "#### invalid distribution \"${DISTRIBUTION}\"" &>> "${TMPDIR}/androot.log"
log_fail
log_error "Internal inconsistency detected: Invalid distribution \"${DISTRIBUTION}\""
exit 1;;
esac
echo "#### download rootfs (${DOWNLOADSERVER_ROOTFS}${DISTRIBUTION}-${ARCH_TARGET}.tar.gz)" &>> "${TMPDIR}/androot.log"
wget "${DOWNLOADSERVER_ROOTFS}${DISTRIBUTION}-${ARCH_TARGET}.tar.gz" -qqq -O "${TMPDIR}/rootfs.tar.gz" &>> "${TMPDIR}/androot.log"
if [ ! -f "${TMPDIR}/rootfs.tar.gz" ]; then
echo "#### rootfs not present" &>> "${TMPDIR}/androot.log"
log_fail
fi
echo -e "ARCH_TARGET_WRITTEN=${ARCH_TARGET}\nDISTRIBUTION_WRITTEN=${DISTRIBUTION}" > "${TMPDIR}/rootfs.env"
log_ok;;
"--decompress")
log_diag "Using decompress mode"
log_exec "Decompressing archive"
echo "#### decompress rootfs" &>> "${TMPDIR}/androot.log"
bsdtar -xpf "${TMPDIR}/rootfs.tar.gz" -C "${LOCATION}/rootfs" &>> "${TMPDIR}/androot.log"
if [ ! "${?}" == "0" ]; then
log_fail
exit 1
fi
log_ok;;
*)
log_error "--download or --decompress required"
exit 1;;
esac