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
This commit is contained in:
JeremyStar™ 2023-11-07 20:54:57 +01:00
parent 2045b4a52c
commit 8e0e3f63a1
6 changed files with 144 additions and 60 deletions

17
Makefile Normal file
View file

@ -0,0 +1,17 @@
help:
@echo "make help - display tasks"
@echo " check - check androot scripts"
@echo " ensureexec - ensure all scripts are executable"
@echo " run - execute androot locally"
@echo " test - execute androot locally with diagnostic log output"
@echo " log - follow androot's log file"
check:
shellcheck *.sh
ensureexec:
chmod +x *.sh
run: ensureexec check
sudo ./androot.sh --local
test: ensureexec check
sudo env DIAG=true ./androot.sh --local
log:
@PS4='';if [ -d "/tmp/androot" ]; then set -x; tail -f /tmp/androot/androot.log; elif [ -d "/data/tmp/androot" ]; then set -x; tail -f /data/tmp/androot/androot.log; else echo ":: Error: androot's log directory could not be determined (start androot first)"; exit 1; fi

View file

@ -2,16 +2,16 @@
Chroot and systemd-nspawn rootfs installer Chroot and systemd-nspawn rootfs installer
# Experimental # Experimental
androot is experimental software and can lead to breakage! \ **androot** is experimental software and can lead to breakage! \
Only run these scripts with extensive knowledge of Linux (and Android if using Termux)! Only run these scripts with extensive knowledge of Linux (and Android if using Termux)!
# How to use # How to use
## Termux ## Termux
### WARNING ### WARNING
If you want to use **androot** under Android you need a working Magisk or KernelSU installation. \ If you want to use **androot** under Android you need a working Magisk or KernelSU installation. \
If you wish to install a (more limited) Linux distribution without root access use [Andronix](https://play.google.com/store/apps/details?id=studio.com.techriz.andronix) instead. If you wish to install a (more limited) Linux distribution without root access use [*Andronix*](https://play.google.com/store/apps/details?id=studio.com.techriz.andronix) instead.
### Dependencies ### Dependencies
- Magisk/KernelSU - [*Magisk*](https://github.com/topjohnwu/Magisk)/[*Magisk Delta*](https://github.com/HuskyDG/magisk-files)/[*KernelSU*](https://kernelsu.org)
- curl - curl
- bash - bash
- chroot - chroot
@ -49,7 +49,7 @@ If you wish to install a (more limited) Linux distribution without root access u
# How does this work? # How does this work?
## tldr ## tldr
We download & decompress a rootfs, apply some magic and make it useable with the help of `chroot` or `systemd-nspawn`. We download & decompress a rootfs, apply some magic and make it "bootable" with the help of `chroot` or `systemd-nspawn`.
## The short answer ## The short answer
1. check architecture 1. check architecture
2. ask for target architecture, execution architecture(s) and distribution 2. ask for target architecture, execution architecture(s) and distribution
@ -65,7 +65,12 @@ We download & decompress a rootfs, apply some magic and make it useable with the
Just read the source code. Just read the source code.
# How to test # How to test
`if shellcheck *.sh; then sudo env DIAG=true ./androot.sh --local; else echo ":: shellcheck failed, please resolve these errors"; fi` `make test` to run it, `make log` to view the log file.
## Recommendation
We recommend using */dev/shm* as a install location during development. Although using temporary directories \
is disallowed for normal installations we highly recommend using */dev/shm* during development as you will \
be wearing out your disk very fast otherwise. Just make sure that you have enough memory available and that you \
use */dev/shm* instead of */tmp* as your install location (*/tmp* uses your disk while */dev/shm* uses your computer memory).
# Annotations # Annotations
```plain ```plain

View file

@ -1,5 +1,6 @@
#!/bin/bash #!/bin/bash
# shellcheck disable=SC2181 disable=SC1091 disable=SC2236 # shellcheck disable=SC2181 disable=SC1091 disable=SC2236
# shellcheck disable=SC2068
### TOBECHANGED ### TOBECHANGED
# shellcheck disable=SC2317 # shellcheck disable=SC2317
### TOBECHANGED_END ### TOBECHANGED_END
@ -85,12 +86,14 @@ function log_askyn() {
} }
# Global variables # Global variables
## $BRANCH
export "BRANCH=develop"
## $DOWNLOADSERVER_ROOTFS ## $DOWNLOADSERVER_ROOTFS
export "DOWNLOADSERVER_ROOTFS=https://fs.staropensource.de/rootfs/" export "DOWNLOADSERVER_ROOTFS=https://fs.staropensource.de/rootfs/"
## $DOWNLOADSERVER_QEMUSTATIC ## $DOWNLOADSERVER_QEMUSTATIC
export "DOWNLOADSERVER_QEMUSTATIC=https://fs.staropensource.de/qemu-static/" export "DOWNLOADSERVER_QEMUSTATIC=https://fs.staropensource.de/qemu-static/"
## $DOWNLOADSERVER_BOOTSCRIPTS ## $DOWNLOADSERVER_BOOTSCRIPTS
export "DOWNLOADSERVER_BOOTSCRIPTS=https://git.staropensource.de/StarOpenSource/androot/raw/branch/develop/" export "DOWNLOADSERVER_BOOTSCRIPTS=https://git.staropensource.de/StarOpenSource/androot.git"
## $ARCH ## $ARCH
case "$(uname -m)" in case "$(uname -m)" in
# 64-bit architectures (supported) # 64-bit architectures (supported)
@ -168,35 +171,43 @@ case "${ARCH}" in
;; ;;
esac esac
if [ "${1}" == "--local" ]; then function run_script() {
env "TMPDIR=${TMPDIR}" $@
if [ ! "${?}" == "0" ]; then
exit 1
fi
}
case "${1}" in
"--local")
log_diag "Using local mode" log_diag "Using local mode"
env "TMPDIR=${TMPDIR}" ./prepare.sh run_script ./prepare.sh
env "TMPDIR=${TMPDIR}" ./rootfsinstall.sh --download run_script ./rootfsinstall.sh --download
env "TMPDIR=${TMPDIR}" ./rootfsinstall.sh --decompress run_script ./rootfsinstall.sh --decompress
env "TMPDIR=${TMPDIR}" ./mount.sh --mount run_script ./mount.sh --mount
env "TMPDIR=${TMPDIR}" ./bootscriptdl.sh --download run_script ./bootscriptdl.sh --download
run_script ./bootscriptdl.sh --configure
run_script ./bootscriptdl.sh --install-qemu
exit 0 exit 0
env "TMPDIR=${TMPDIR}" ./bootscriptdl.sh --configure run_script ./installsystem.sh --configure
env "TMPDIR=${TMPDIR}" ./bootscriptdl.sh --download-qemu run_script ./installsystem.sh --update
env "TMPDIR=${TMPDIR}" ./installsystem.sh --configure run_script ./patch.sh
env "TMPDIR=${TMPDIR}" ./installsystem.sh --update run_script ./mount.sh --unmount
env "TMPDIR=${TMPDIR}" ./patch.sh run_script ./finish.sh;;
env "TMPDIR=${TMPDIR}" ./mount.sh --unmount "--download")
env "TMPDIR=${TMPDIR}" ./finish.sh
elif [ "${1}" == "--download" ]; then
log_diag "Using download mode" log_diag "Using download mode"
### UNIMPLEMENTED ### UNIMPLEMENTED
log_exec Downloading files log_exec Downloading files
log_fail log_fail
exit 1 exit 1;;
### UNIMPLEMENTED_END ### UNIMPLEMENTED_END
elif [ "${1}" == "--help" ]; then "--help"|"-h")
log_diag "Displaying help" log_diag "Displaying help"
log_info "Available arguments:" log_info "Available arguments:"
log_info "--local [execute androot from cwd] --download [download androot scripts and execute] --help [display args and vars]" log_info "--local [execute androot from cwd] --download [download androot scripts and execute] --help [display args and vars]"
log_info "Available environment variables:" log_info "Available environment variables:"
log_info "DIAG [displays or hides diagnostic messages, true/false]" log_info "DIAG [displays diagnostic messages, true/false] ALLOW_SHM [allows using /dev/shm as a location, true/false]";;
else *)
log_diag "i thought putting a little \"advertisement parody\" in here would be funny" log_diag "i thought putting a little \"advertisement parody\" in here would be funny"
log_error "StarOpenSource is happy to present the latest and greatest version of --help! --help now uses cutting edge technology to display the most useful help to you, and that for only zero dollars!" log_error "StarOpenSource is happy to present the latest and greatest version of --help! --help now uses cutting edge technology to display the most useful help to you, and that for only zero dollars!";;
fi esac

View file

@ -9,13 +9,8 @@ case "${1}" in
"--download") "--download")
log_diag "Using download mode" log_diag "Using download mode"
log_exec "Downloading bootscripts" log_exec "Downloading bootscripts"
cd "${LOCATION}/bootscripts"||{ log_error "cd failed";exit 1; } echo "#### download bootscripts repository" &>> "${TMPDIR}/androot.log"
git clone "${DOWNLOADSERVER_BOOTSCRIPTS}" . &>> "${TMPDIR}/androot.log" git clone --quiet --verbose -b "${BRANCH}-bootscripts" "${DOWNLOADSERVER_BOOTSCRIPTS}" "${LOCATION}/bootscripts" &>> "${TMPDIR}/androot.log"
if [ ! "${?}" == "0" ]; then
log_fail
exit 1
fi
git checkout develop-bootscripts &>> "${TMPDIR}/androot.log"
if [ ! "${?}" == "0" ]; then if [ ! "${?}" == "0" ]; then
log_fail log_fail
exit 1 exit 1
@ -25,18 +20,36 @@ case "${1}" in
log_diag "Using configure mode" log_diag "Using configure mode"
log_exec "Configuring bootscript scripts" log_exec "Configuring bootscript scripts"
cd "${LOCATION}/bootscripts/"||{ log_error "cd failed";exit 1; } cd "${LOCATION}/bootscripts/"||{ log_error "cd failed";exit 1; }
echo "#### writing bootscripts config.env" &>> "${TMPDIR}/androot.log"
cat << EOF >> "${LOCATION}/bootscripts/config.env" cat << EOF >> "${LOCATION}/bootscripts/config.env"
COMMIT=$(git rev-parse HEAD) COMMIT=$(git rev-parse HEAD)
LOCATION=${LOCATION} LOCATION=${LOCATION}
IS_ANDROID=${IS_ANDROID} IS_ANDROID=${IS_ANDROID}
EOF EOF
log_ok;; log_ok;;
"--download-qemu") "--install-qemu")
log_diag "Using download qemu mode" log_diag "Using install-qemu mode"
### UNIMPLEMENTED for ARCH_DOWNLOAD in ${ARCH_EXECUTORS}; do
log_exec "Downloading qemu-static binaries" log_exec "Installing qemu-static for ${ARCH_DOWNLOAD}"
log_fail;; echo "#### download qemu-static for ${ARCH_DOWNLOAD}" &>> "${TMPDIR}/androot.log"
### UNIMPLEMENTED wget "${DOWNLOADSERVER_QEMUSTATIC}${ARCH_DOWNLOAD}.tar.gz" -qqq -O "${TMPDIR}/${ARCH_DOWNLOAD}.tar.gz" &>> "${TMPDIR}/androot.log"
if [ ! "${?}" == "0" ]; then
log_fail;
exit 1
fi
echo "#### extract qemu-static for ${ARCH_DOWNLOAD}" &>> "${TMPDIR}/androot.log"
mkdir -p "${LOCATION}/bootscripts/qemu-static/${ARCH_DOWNLOAD}"
if [ ! "${?}" == "0" ]; then
log_fail;
exit 1
fi
bsdtar -xf "${TMPDIR}/${ARCH_DOWNLOAD}.tar.gz" -C "${LOCATION}/bootscripts/qemu-static/${ARCH_DOWNLOAD}/" &>> "${TMPDIR}/andronix.log"
if [ ! "${?}" == "0" ]; then
log_fail;
exit 1
fi
log_ok
done;;
*) *)
log_error "--download or --decompress required" log_error "--download or --decompress required"
exit 1;; exit 1;;

View file

@ -22,7 +22,7 @@ function arch_target() {
esac esac
echo "ARCH_TARGET=${ANSWER,,}" > "${TMPDIR}/androot.env" echo "ARCH_TARGET=${ANSWER,,}" > "${TMPDIR}/androot.env"
} }
function arch_executers() { function arch_executors() {
log_info "" log_info ""
log_info "Please specify the execution architecture(s)" log_info "Please specify the execution architecture(s)"
log_info "Note: A qemu-static binary is downloaded for each execution" log_info "Note: A qemu-static binary is downloaded for each execution"
@ -42,11 +42,11 @@ function arch_executers() {
;; ;;
*) *)
log_error "Invalid execution architecture \"${ANSWER,,}\", please retry." log_error "Invalid execution architecture \"${ANSWER,,}\", please retry."
arch_executers arch_executors
return;; return;;
esac esac
### MISIMPLEMENTED ### MISIMPLEMENTED
echo "ARCH_EXECUTERS=${ANSWER}" >> "${TMPDIR}/androot.env" echo "ARCH_EXECUTORS=${ANSWER}" >> "${TMPDIR}/androot.env"
} }
function distribution() { function distribution() {
log_info "" log_info ""
@ -73,18 +73,53 @@ function location() {
### TOBECHANGED_END ### TOBECHANGED_END
log_ask "Location: " log_ask "Location: "
case "${ANSWER}" in case "${ANSWER}" in
/tmp*|/dev/shm/*) "")
log_error "Using /tmp or /dev/shm is unsupported as you may run into disk space issues very quickly, please retry." log_error "Please enter something >.<"
location location
return;; return;;
/tmp*)
log_error "Using /tmp is unsupported as you may run into disk space issues very quickly, please retry."
location
return;;
/dev/shm/*)
if [ ! "${DIAG}" == "true" ]; then
log_error "Using /dev/shm is unsupported as you may run into disk space issues very quickly, please retry."
location
return
fi;;
/dev|/proc|/run|/sys|/dev/*|/proc/*|/run/*|/sys/*) /dev|/proc|/run|/sys|/dev/*|/proc/*|/run/*|/sys/*)
log_error "Are you really trying that?" log_error "Are you really trying that?"
location location
return ;; return;;
/) /)
log_error "you're making a recipe for desaster." log_error "you're making a recipe for desaster."
location location
return ;; return;;
"uwu")
log_error "eww!"
location
return;;
"I'd like to interject for a moment")
echo "#### $(whoami) wants to interject for a moment" &>> "${TMPDIR}/androot.log"
log_info "I'd just like to interject for a moment. What you're referring to as Linux,"
log_info "is in fact, GNU/Linux, or as I've recently taken to calling it, GNU plus Linux."
log_info "Linux is not an operating system unto itself, but rather another free component"
log_info "of a fully functioning GNU system made useful by the GNU corelibs, shell"
log_info "utilities and vital system components comprising a full OS as defined by POSIX."
log_info "Many computer users run a modified version of the GNU system every day,"
log_info "without realizing it. Through a peculiar turn of events, the version of GNU"
log_info "which is widely used today is often called \"Linux\", and many of its users are"
log_info "not aware that it is basically the GNU system, developed by the GNU Project."
log_info "There really is a Linux, and these people are using it, but it is just a"
log_info "part of the system they use. Linux is the kernel: the program in the system"
log_info "that allocates the machine's resources to the other programs that you run."
log_info "The kernel is an essential part of an operating system, but useless by itself;"
log_info "it can only function in the context of a complete operating system. Linux is"
log_info "normally used in combination with the GNU operating system: the whole system"
log_info "is basically GNU with Linux added, or GNU/Linux. All the so-called \"Linux\""
log_info "distributions are really distributions of GNU/Linux."
location
return;;
esac esac
if [ -a "${ANSWER}" ] && [ ! -d "${ANSWER}" ]; then if [ -a "${ANSWER}" ] && [ ! -d "${ANSWER}" ]; then
log_error "The location exists but is not a directory." log_error "The location exists but is not a directory."
@ -99,13 +134,17 @@ function location() {
fi fi
else else
log_info "Creating location directory" log_info "Creating location directory"
mkdir -p "${ANSWER}/rootfs" "${ANSWER}/bootscripts" mkdir -p "${ANSWER}/rootfs"
if [ ! "${?}" == "0" ]; then
log_fail;
exit 1
fi
fi fi
echo "LOCATION=${ANSWER}" >> "${TMPDIR}/androot.env" echo "LOCATION=${ANSWER}" >> "${TMPDIR}/androot.env"
} }
arch_target arch_target
arch_executers arch_executors
distribution distribution
location location

View file

@ -58,7 +58,6 @@ case "${1}" in
echo "#### decompress rootfs" &>> "${TMPDIR}/androot.log" echo "#### decompress rootfs" &>> "${TMPDIR}/androot.log"
bsdtar -xpf "${TMPDIR}/rootfs.tar.gz" -C "${LOCATION}/rootfs" &>> "${TMPDIR}/androot.log" bsdtar -xpf "${TMPDIR}/rootfs.tar.gz" -C "${LOCATION}/rootfs" &>> "${TMPDIR}/androot.log"
if [ ! "${?}" == "0" ]; then if [ ! "${?}" == "0" ]; then
echo "#### bsdtar failed" &>> "${TMPDIR}/androot.log"
log_fail log_fail
exit 1 exit 1
fi fi