Update code
CHANGES - [androot.sh] Improve code quality - [androot.sh] Modify DOWNLOADSERVER* variables - [patch.sh] Implement rootfs patching - [prepare.sh] Squashed bugs - [rootfsbuilder/archlinux-x86_64.sh] Remove "copy pacman config" flag causing some issues - [systeminstall.sh] Implement rootfs configuration and update script BUGS - [systeminstall.sh|patch.sh] Scripts only work on the same architecture as the host
This commit is contained in:
parent
3d7c819321
commit
3f0f0e0113
9 changed files with 124 additions and 37 deletions
45
androot.sh
45
androot.sh
|
@ -30,37 +30,37 @@ mkdir -p "${TMPDIR}"
|
|||
# write source file
|
||||
cat << EOF > "${TMPDIR}/androot.source"
|
||||
# Functions
|
||||
## Indicate failure
|
||||
## indicate failure
|
||||
function indicate_fail() {
|
||||
echo -e "\r\e[0m[\e[0;31mFAIL\e[0m]"
|
||||
}
|
||||
## Indicate success
|
||||
## indicate success
|
||||
function indicate_ok() {
|
||||
echo -e "\r\e[0m[\e[0;32m OK \e[0m]"
|
||||
}
|
||||
## Indicate running execution
|
||||
## indicate running execution
|
||||
function indicate_exec() {
|
||||
echo -ne "\e[0m[\e[0;34m....\e[0m] \${*}"
|
||||
}
|
||||
## Log diagnostic message to term
|
||||
## log diagnostic message to term
|
||||
function log_diag() {
|
||||
if [ "\$DIAG" == "true" ]; then
|
||||
echo -e "\e[0m[\e[0;35mDIAG\e[0m] \${*}"
|
||||
fi
|
||||
}
|
||||
## Log informational message to term
|
||||
## log informational message to term
|
||||
function log_info() {
|
||||
echo -e "\r\e[0m[\e[0;32mINFO\e[0m] \${*}"
|
||||
}
|
||||
## Log warning message to term
|
||||
## log warning message to term
|
||||
function log_warn() {
|
||||
echo -e "\r\e[0m[\e[0;33mWARN\e[0m] \${*}"
|
||||
}
|
||||
## Log error message to term
|
||||
## log error message to term
|
||||
function log_error() {
|
||||
echo -e "\r\e[0m[\e[0;31mERR!\e[0m] \${*}"
|
||||
}
|
||||
## Log message to log file
|
||||
## log message to log file
|
||||
function log_write() {
|
||||
echo -e "\${*}" &>> "\${TMPDIR}/androot.log"
|
||||
}
|
||||
|
@ -71,18 +71,18 @@ function log_execute() {
|
|||
log_write "Exited with code \${EXITCODE}"
|
||||
return \${EXITCODE}
|
||||
}
|
||||
## Ask a question
|
||||
## ask a question
|
||||
function log_ask() {
|
||||
echo -ne "\e[0m[\e[0;36mASKQ\e[0m] \${*}"
|
||||
read -r ANSWER
|
||||
}
|
||||
## Ask for password
|
||||
## ask for password
|
||||
function log_askpasswd() {
|
||||
echo -ne "\e[0m[\e[0;36mASKP\e[0m] \${*}"
|
||||
read -rs ANSWER
|
||||
echo ""
|
||||
}
|
||||
## Ask for yes or no (agreement)
|
||||
## ask for yes or no (agreement)
|
||||
function log_askyn() {
|
||||
if [ -z "\${2}" ]; then
|
||||
log_error "log_askyn requires at least two arguments"
|
||||
|
@ -100,6 +100,13 @@ function log_askyn() {
|
|||
export "ANSWER=\$ANSWER_FALLBACK"
|
||||
fi
|
||||
}
|
||||
## chroot into rootfs
|
||||
function chroot_env() {
|
||||
CHROOTDIR=\${1}
|
||||
shift
|
||||
log_execute env LD_PRELOAD= chroot "\${CHROOTDIR}" env TMPDIR=/tmp PATH=/usr/sbin:/usr/sbin/vendor_perl:/usr/local/sbin:/usr/local/sbin/vendor_perl:/usr/bin:/usr/bin/vendor_perl:/usr/local/bin:/usr/local/bin/vendor_perl:/usr/local/games ANDROID_ROOT= ANDROID_DATA= PREFIX= \${@}
|
||||
return ${?}
|
||||
}
|
||||
|
||||
# Language
|
||||
## set language to C, useful for bug reports
|
||||
|
@ -133,13 +140,11 @@ export "UNSAFE_COMMITS_LIST=https://fs.staropensource.de/vinf/unsafe/androot-\${
|
|||
|
||||
# Download URLs
|
||||
## rootfs archives
|
||||
export "DOWNLOADSERVER_ROOTFS=https://fs.staropensource.de/rootfs/"
|
||||
## qemu-static archives
|
||||
export "DOWNLOADSERVER_QEMUSTATIC=https://fs.staropensource.de/qemu-static/"
|
||||
export "DOWNLOADSERVER=https://fs.staropensource.de/androot"
|
||||
## bootscripts repository
|
||||
export "DOWNLOADSERVER_BOOTSCRIPTS=https://git.staropensource.de/StarOpenSource/androot.git"
|
||||
## installer scripts url
|
||||
export "DOWNLOADSERVER_RAW=https://git.staropensource.de/StarOpenSource/androot/raw/branch/\${BRANCH}/"
|
||||
export "DOWNLOADSERVER_RAW=https://git.staropensource.de/StarOpenSource/androot/raw/branch/\${BRANCH}"
|
||||
|
||||
# Function variables
|
||||
## get architecture
|
||||
|
@ -194,9 +199,9 @@ if [ "${DIAG}" == "true" ]; then log_write "\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
|
|||
log_write "#### System information"
|
||||
log_write "architecture ${ARCH}"
|
||||
log_write "is_android ${IS_ANDROID}"
|
||||
log_write "download_server_rootfs ${DOWNLOADSERVER_ROOTFS}"
|
||||
log_write "download_server_qemustatic ${DOWNLOADSERVER_QEMUSTATIC}"
|
||||
log_write "download_server ${DOWNLOADSERVER}"
|
||||
log_write "download_server_bootscripts ${DOWNLOADSERVER_BOOTSCRIPTS}"
|
||||
log_write "download_server_raw ${DOWNLOADSERVER_RAW}"
|
||||
log_write "args ${*}"
|
||||
log_write "diag ${DIAG}"
|
||||
log_write "#### System information"
|
||||
|
@ -237,10 +242,10 @@ case "${1}" in
|
|||
run_script ./bootscriptdl.sh --download
|
||||
run_script ./bootscriptdl.sh --configure
|
||||
run_script ./bootscriptdl.sh --install-qemu
|
||||
exit 0
|
||||
run_script ./installsystem.sh --configure
|
||||
run_script ./installsystem.sh --update
|
||||
run_script ./systeminstall.sh --configure
|
||||
run_script ./systeminstall.sh --update
|
||||
run_script ./patch.sh
|
||||
exit 0
|
||||
run_script ./mount.sh --unmount
|
||||
run_script ./finish.sh
|
||||
;;
|
||||
|
|
|
@ -36,7 +36,7 @@ EOF
|
|||
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
|
||||
if ! log_execute wget "${DOWNLOADSERVER}/qemu-static/${ARCH_DOWNLOAD}.tar.gz" --no-verbose -O "${TMPDIR}/${ARCH_DOWNLOAD}.tar.gz"; then
|
||||
indicate_fail;
|
||||
exit 1
|
||||
fi
|
||||
|
|
38
patch.sh
Executable file
38
patch.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/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 "patch is now executing, with arguments \"${*}\""
|
||||
|
||||
case "${ARCH_TARGET}" in
|
||||
"x86_64") ;;
|
||||
"arm64") ;;
|
||||
"powerpc64") ;;
|
||||
"mips64") ;;
|
||||
*)
|
||||
log_error "Internal inconsistency detected: Invalid target architecture \"${ARCH_TARGET}\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
indicate_exec "Patching rootfs"
|
||||
case "${DISTRIBUTION}" in
|
||||
"archlinux")
|
||||
if ! log_execute wget "${DOWNLOADSERVER}/patches/archlinux/fakeroot-tcp-${ARCH_TARGET}.pkg.tar.zst" --no-verbose -O "${LOCATION}/mountdir/fakeroot-tcp-${ARCH_TARGET}.pkg.tar.zst"; then
|
||||
indicate_fail;
|
||||
exit 1
|
||||
fi
|
||||
if ! chroot_env "${LOCATION}/mountdir" "pacman -U --noconfirm /fakeroot-tcp-${ARCH_TARGET}.pkg.tar.zst"; then
|
||||
indicate_fail
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
indicate_fail
|
||||
log_error "Internal inconsistency detected: Invalid distribution \"${DISTRIBUTION}\""
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
indicate_ok
|
16
prepare.sh
16
prepare.sh
|
@ -15,16 +15,16 @@ function arch_target() {
|
|||
log_info " a slight performance penality)."
|
||||
log_info "Available target architectures: x86_64, arm64"
|
||||
log_ask "Target architecture: "
|
||||
case "${ANSWER,,}" in
|
||||
case "${ANSWER}" in
|
||||
"x86_64") ;;
|
||||
"arm64") ;;
|
||||
*)
|
||||
log_error "Invalid target architecture \"${ANSWER,,}\", please retry."
|
||||
log_error "Invalid target architecture \"${ANSWER}\", please retry."
|
||||
arch_target
|
||||
return
|
||||
;;
|
||||
esac
|
||||
echo "ARCH_TARGET=${ANSWER,,}" > "${TMPDIR}/androot.env"
|
||||
echo "ARCH_TARGET=\"${ANSWER}\"" > "${TMPDIR}/androot.env"
|
||||
}
|
||||
|
||||
# ask for execution architecture(s)
|
||||
|
@ -57,7 +57,7 @@ function arch_executors() {
|
|||
if [[ "${ANSWER}" == *"${ARCH_TARGET}"* ]]; then
|
||||
export "ANSWER=x86_64 ${ANSWER}"
|
||||
fi
|
||||
echo "ARCH_EXECUTORS=${ANSWER}" >> "${TMPDIR}/androot.env"
|
||||
echo "ARCH_EXECUTORS=\"${ANSWER}\"" >> "${TMPDIR}/androot.env"
|
||||
}
|
||||
|
||||
# ask for target distribution
|
||||
|
@ -68,15 +68,15 @@ function distribution() {
|
|||
log_info " with every target architecture, unless noted."
|
||||
log_info "Available distributions: archlinux"
|
||||
log_ask "Target distribution: "
|
||||
case "${ANSWER,,}" in
|
||||
case "${ANSWER}" in
|
||||
"archlinux") ;;
|
||||
*)
|
||||
log_error "Invalid distribution \"${ANSWER,,}\", please retry."
|
||||
log_error "Invalid distribution \"${ANSWER}\", please retry."
|
||||
distribution
|
||||
return
|
||||
;;
|
||||
esac
|
||||
echo "DISTRIBUTION=${ANSWER,,}" >> "${TMPDIR}/androot.env"
|
||||
echo "DISTRIBUTION=\"${ANSWER}\"" >> "${TMPDIR}/androot.env"
|
||||
}
|
||||
|
||||
# ask for install location
|
||||
|
@ -171,7 +171,7 @@ function location() {
|
|||
fi
|
||||
indicate_ok
|
||||
fi
|
||||
echo "LOCATION=${ANSWER}" >> "${TMPDIR}/androot.env"
|
||||
echo "LOCATION=\"${ANSWER}\"" >> "${TMPDIR}/androot.env"
|
||||
}
|
||||
|
||||
arch_target
|
||||
|
|
|
@ -23,7 +23,7 @@ fi
|
|||
mkdir -p "./${DISTRIBUTION}-${ARCH}"
|
||||
cd "./${DISTRIBUTION}-${ARCH}"
|
||||
echo ":: Installing system"
|
||||
pacstrap -c -G -K -M -P . base
|
||||
pacstrap -c -G -K -M . base archlinux-keyring
|
||||
echo ":: Unmounting (safety measure)"
|
||||
bash -c "umount ./{dev/pts,dev/shm,dev,sys,proc,run};exit 0"
|
||||
echo ":: Archiving rootfs"
|
||||
|
|
|
@ -59,8 +59,7 @@ case "${1}" in
|
|||
;;
|
||||
esac
|
||||
# download rootfs from download server
|
||||
log_write "#### download rootfs (${DOWNLOADSERVER_ROOTFS}${DISTRIBUTION}-${ARCH_TARGET}.tar.gz)"
|
||||
if ! log_execute wget "${DOWNLOADSERVER_ROOTFS}${DISTRIBUTION}-${ARCH_TARGET}.tar.gz" --no-verbose -O "${TMPDIR}/rootfs.tar.gz"; then
|
||||
if ! log_execute wget "${DOWNLOADSERVER}/rootfs/${DISTRIBUTION}-${ARCH_TARGET}.tar.gz" --no-verbose -O "${TMPDIR}/rootfs.tar.gz"; then
|
||||
indicate_fail
|
||||
exit 1
|
||||
fi
|
||||
|
|
45
systeminstall.sh
Executable file
45
systeminstall.sh
Executable file
|
@ -0,0 +1,45 @@
|
|||
#!/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 "systeminstall is now executing, with arguments \"${*}\""
|
||||
|
||||
case "${1}" in
|
||||
"--configure")
|
||||
log_diag "Using configure mode"
|
||||
indicate_exec "Configuring rootfs"
|
||||
if ! log_execute rm -rf "${LOCATION}/rootfs/etc/resolv.conf"; then indicate_fail; exit 1; fi
|
||||
echo "nameserver 1.1.1.1" > "${LOCATION}/rootfs/etc/resolv.conf"
|
||||
if [ "${DISTRIBUTION}" == "archlinux" ]; then
|
||||
if ! chroot_env "${LOCATION}/mountdir" "pacman-key --init"; then
|
||||
indicate_fail
|
||||
exit 1
|
||||
fi
|
||||
if ! chroot_env "${LOCATION}/mountdir" "pacman-key --populate"; then
|
||||
indicate_fail
|
||||
exit 1
|
||||
fi
|
||||
OUTPUT=$(sed "s/\#Server \= https\:\/\/geo\.mirror\.pkgbuild\.com\/\\\$repo\/os\/\\\$arch/Server \= https\:\/\/geo\.mirror\.pkgbuild\.com\/\\\$repo\/os\/\\\$arch/g" < "${LOCATION}/rootfs/etc/pacman.d/mirrorlist")
|
||||
echo "${OUTPUT}" &> "${LOCATION}/rootfs/etc/pacman.d/mirrorlist"
|
||||
fi
|
||||
indicate_ok
|
||||
;;
|
||||
"--update")
|
||||
log_diag "Using update mode"
|
||||
indicate_exec "Updating rootfs"
|
||||
if [ "${DISTRIBUTION}" == "archlinux" ]; then
|
||||
if ! chroot_env "${LOCATION}/mountdir" "pacman -Syu --noconfirm"; then
|
||||
indicate_fail
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
indicate_ok
|
||||
;;
|
||||
*)
|
||||
log_error "--configure or --update required"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
Loading…
Reference in a new issue