#!/bin/bash # disable errors regarding androot.source as # it is created and loaded at runtime # shellcheck disable=SC1091 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" 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 exit 1 fi indicate_ok ;; "--configure") log_diag "Using configure mode" indicate_exec "Configuring bootscript scripts" log_execute cd "${LOCATION}/bootscripts/" ||{ indicate_fail; exit 1; } log_write "#### writing bootscripts config.env" cat << EOF >> "${LOCATION}/bootscripts/config.env" COMMIT=$(git rev-parse HEAD) LOCATION=${LOCATION} ARCHITECTURE=${ARCH_TARGET} IS_ANDROID=${IS_ANDROID} EOF indicate_ok ;; "--install-qemu") log_diag "Using install-qemu mode" for ARCH_DOWNLOAD in ${ARCH_EXECUTORS}; do 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 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 if ! log_execute bsdtar -xf "${TMPDIR}/${ARCH_DOWNLOAD}.tar.gz" -C "${LOCATION}/bootscripts/qemu-static/${ARCH_DOWNLOAD}/"; then indicate_fail; exit 1 fi indicate_ok done ;; *) log_error "--download or --decompress required" exit 1 ;; esac