diff --git a/.github/scripts/build-kinetic.sh b/.github/scripts/build-kinetic.sh
deleted file mode 100755
index 9f43b1e..0000000
--- a/.github/scripts/build-kinetic.sh
+++ /dev/null
@@ -1,98 +0,0 @@
-#!/usr/bin/env bash
-
-source plugins/envsetup
-
-export OVERRIDER_COMPRESSION_TYPE
-export ENABLE_EXIT
-export ENABLE_USER_SETUP
-
-SUITE="kinetic"
-frn="out/$SUITE-raw"
-OVERRIDER_COMPRESSION_TYPE="gzip"
-ENABLE_EXIT=true
-ENABLE_USER_SETUP=false
-PREFIX="${frn}"
-
-additional_setup() {
-
-# GitHub workflow specific
-# try to add permissions to $chroot_dir/etc/apt/sources.list
-sudo chmod +r+w $chroot_dir/etc/apt/sources.list
-
-cat <<- EOF > $chroot_dir/etc/apt/sources.list
-# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
-# newer versions of the distribution.
-deb $MIRROR $SUITE main restricted
-# deb-src $MIRROR $SUITE main restricted
-
-## Major bug fix updates produced after the final release of the
-## distribution.
-deb $MIRROR $SUITE-updates main restricted
-# deb-src $MIRROR $SUITE-updates main restricted
-
-## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
-## team. Also, please note that software in universe WILL NOT receive any
-## review or updates from the Ubuntu security team.
-deb $MIRROR $SUITE universe
-# deb-src $MIRROR $SUITE universe
-deb $MIRROR $SUITE-updates universe
-# deb-src $MIRROR $SUITE-updates universe
-
-## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
-## team, and may not be under a free licence. Please satisfy yourself as to
-## your rights to use the software. Also, please note that software in
-## multiverse WILL NOT receive any review or updates from the Ubuntu
-## security team.
-deb $MIRROR $SUITE multiverse
-# deb-src $MIRROR $SUITE multiverse
-deb $MIRROR $SUITE-updates multiverse
-# deb-src $MIRROR $SUITE-updates multiverse
-
-## N.B. software from this repository may not have been tested as
-## extensively as that contained in the main release, although it includes
-## newer versions of some applications which may provide useful features.
-## Also, please note that software in backports WILL NOT receive any review
-## or updates from the Ubuntu security team.
-deb $MIRROR $SUITE-backports main restricted universe multiverse
-# deb-src $MIRROR $SUITE-backports main restricted universe multiverse
-
-EOF
-
-# set up pv
-lshout "Setting up pv..."
-cp $ROOT_DIR/core/pv/pv-${t_arch}.deb $chroot_dir
-run_cmd "dpkg -i /pv-${t_arch}.deb"
-run_cmd "rm /pv-${t_arch}.deb"
-
-# clean any archive if exits
-apt-get clean
-
-}
-
-do_build "$PREFIX-arm64" arm64
-do_build "$PREFIX-armhf" armhf
-do_build "$PREFIX-amd64" amd64
-
-do_compress "$PREFIX-arm64"
-do_compress "$PREFIX-armhf"
-do_compress "$PREFIX-amd64"
-
-do_unmount "$PREFIX-arm64"
-do_unmount "$PREFIX-armhf"
-do_unmount "$PREFIX-amd64"
-
-shout "setting up artifacts for GitHub"
-msg "creating $SUITE-{arm64,amd64,armhf} directories"
-mkdir -pv $SUITE-{arm64,amd64,armhf}
-
-msg "copying tarballs to directories"
-cp -rv $frn-arm64*tar* $SUITE-arm64
-cp -rv $frn-armhf*tar* $SUITE-armhf
-cp -rv $frn-amd64*tar* $SUITE-amd64
-
-msg "calculating sha256sums"
-sha256sum $frn-arm64*tar* > $SUITE-arm64/SHA256SUM
-sha256sum $frn-armhf*tar* > $SUITE-armhf/SHA256SUM
-sha256sum $frn-amd64*tar* > $SUITE-amd64/SHA256SUM
-
-shout "done"
diff --git a/.github/workflows/build-udroid.yml b/.github/workflows/build-udroid.yml
index 887a8d7..051e658 100644
--- a/.github/workflows/build-udroid.yml
+++ b/.github/workflows/build-udroid.yml
@@ -42,36 +42,3 @@ jobs:
with:
name: jammy-raw-amd64
path: jammy-amd64
- BuildKineticRaw:
- name: build Kinetc (22.10)
- runs-on: ubuntu-latest
- steps:
- - name: checkout repository
- uses: actions/checkout@v3
-
- - name: Docker Setup QEMU
- uses: docker/setup-qemu-action@v2
-
- - name: Satify Dependencies
- run: sudo apt-get update; sudo apt-get install git build-essential binfmt-support qemu-user-static debootstrap -y
-
- - name: Trigger fs-cook
- run: sudo bash .github/scripts/build-kinetic.sh
-
- - name: save arm64 builds
- uses: actions/upload-artifact@v2
- with:
- name: kinetic-raw-arm64
- path: kinetic-arm64
-
- - name: save armhf builds
- uses: actions/upload-artifact@v2
- with:
- name: kinetic-raw-armhf
- path: kinetic-armhf
-
- - name: save amd64 builds
- uses: actions/upload-artifact@v2
- with:
- name: kinetic-raw-amd64
- path: kinetic-amd64
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 1d640eb..7314721 100755
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -8,8 +8,7 @@ fs-cooks uses debootstrap to pull core Linux packages to build linux traballs, a
the top-level contains some example build scripts which are lightweight to build and beginning of directories
```
.
-├── build-hirsute-raw.sh -> cook.sh
-├── build-impish-raw.sh
+├── build-jammy.sh -> cook.sh
├── cook.sh
├── build
├── core
@@ -26,8 +25,6 @@ here:
**important files/folders to notice**
-###### `~/core/defaults`
-defaults folder contains some heavy templates to build DE ready tarballs like mate,xfce4,kde
###### `~/plugins/envsetup`
contains functions that can be used for cmd line building and integrating in scripts
- useful functions in `envsetup`:
@@ -50,12 +47,11 @@ do_build "out/udroid-test" "arm64"
```bash
source plugins/envsetup
-SUITE=impish
+SUITE=jammy
do_build "out/fs" "arm64"
```
### Quick build scripts
-- `build-impish-raw.sh`: to build raw ubuntu 21.10 tarballs
-- `build-hirsute-raw.sh`: to build raw ubuntu 21.04 tarballs
+- `build-jammy.sh`: to build raw ubuntu 22.04 tarballs
> others are experimental ( may break things )
### functions ( v1.0 )
@@ -74,11 +70,15 @@ do_build "out/fs" "arm64"
- `do_second_stage()`: if foreign arch triggers second stage
- - `do_qemu_user_emulation()` sets up qemu binaries in chroot
- `do_chroot_ae()`: to run command in chroot
-- - `run_cmd()`: alternative for `do_chroot_are()`
+- - `do_chroot_proot_ae` : use **proot** instead of chroot in termux
+- - `run_cmd()`: alternative for `do_chroot_ae()`
+- - `run_shell_script()` : to run a specific script, alternative for `do_chroot_ae()`
+- - `install_pkg()` : to install a specific package inside chroot, alternative for `do_chroot_ae()`
- `do_compress()`: takes care of compressing tarballs without messy device file
- - `do_tar_gzip()`: to compress in gzip format
- - `do_tar_bzip()`: to compress in bzip format
- - `do_tar_lz4()`: to compress in lzip/lz4 format
+- - `do_tar_zstd()` : to compress in zstd format
- `arch_translate()`: takes care of translating arch to find qemu static builds
- `COPY()`: to copy files to target filesystem
- `die()`: to echo an error message & exit if `ENABLE_EXIT` is set to true
diff --git a/build-jammy.sh b/build-jammy.sh
index 6b12ca4..87ecbe1 100755
--- a/build-jammy.sh
+++ b/build-jammy.sh
@@ -76,4 +76,4 @@ do_unmount "${frn}-armhf"
do_unmount "${frn}-amd64"
shout "Build Complete.."
-ls ${frn}*tar*
+ls ${frn}*.*
diff --git a/build-kinetic.sh b/build-kinetic.sh
deleted file mode 100755
index cd3ba55..0000000
--- a/build-kinetic.sh
+++ /dev/null
@@ -1,82 +0,0 @@
-#!/usr/bin/env bash
-#shellcheck disable=SC1091
-
-# this is an example file to BUILD raw file system
-# export variable SUITE to set debootstrap suite name (default: hirsute)
-
-source plugins/envsetup
-
-export OVERRIDER_COMPRESSION_TYPE
-export SUITE
-export ENABLE_EXIT
-export ENABLE_USER_SETUP
-
-SUITE="kinetic"
-frn="out/$SUITE-raw"
-OVERRIDER_COMPRESSION_TYPE="gzip"
-ENABLE_EXIT=true
-ENABLE_USER_SETUP=false
-
-additional_setup() {
-cat <<- EOF > $chroot_dir/etc/apt/sources.list
-# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
-# newer versions of the distribution.
-deb $MIRROR $SUITE main restricted
-# deb-src $MIRROR $SUITE main restricted
-## Major bug fix updates produced after the final release of the
-## distribution.
-deb $MIRROR $SUITE-updates main restricted
-# deb-src $MIRROR $SUITE-updates main restricted
-## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
-## team. Also, please note that software in universe WILL NOT receive any
-## review or updates from the Ubuntu security team.
-deb $MIRROR $SUITE universe
-# deb-src $MIRROR $SUITE universe
-deb $MIRROR $SUITE-updates universe
-# deb-src $MIRROR $SUITE-updates universe
-## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
-## team, and may not be under a free licence. Please satisfy yourself as to
-## your rights to use the software. Also, please note that software in
-## multiverse WILL NOT receive any review or updates from the Ubuntu
-## security team.
-deb $MIRROR $SUITE multiverse
-# deb-src $MIRROR $SUITE multiverse
-deb $MIRROR $SUITE-updates multiverse
-# deb-src $MIRROR $SUITE-updates multiverse
-## N.B. software from this repository may not have been tested as
-## extensively as that contained in the main release, although it includes
-## newer versions of some applications which may provide useful features.
-## Also, please note that software in backports WILL NOT receive any review
-## or updates from the Ubuntu security team.
-deb $MIRROR $SUITE-backports main restricted universe multiverse
-# deb-src $MIRROR $SUITE-backports main restricted universe multiverse
-EOF
-
-# TODO: FOLLOW latest udroid version system ( Add props to /etc/os-release )
-
-# set up pv
-lshout "Setting up pv..."
-cp $ROOT_DIR/core/pv/pv-${t_arch}.deb $chroot_dir
-run_cmd "dpkg -i /pv-${t_arch}.deb"
-run_cmd "rm /pv-${t_arch}.deb"
-
-}
-
-shout "Bootstrapping $SUITE...."
-do_build "${frn}-arm64" arm64
-do_build "${frn}-armhf" armhf
-do_build "${frn}-amd64" amd64
-
-shout "packing up the raw file systems..."
-do_compress "${frn}-arm64"
-do_compress "${frn}-armhf"
-do_compress "${frn}-amd64"
-
-shout "unmounting the raw file systems from host..."
-do_unmount "${frn}-arm64"
-do_unmount "${frn}-armhf"
-do_unmount "${frn}-amd64"
-
-shout "Build Complete.."
-ls ${frn}*tar*
-
diff --git a/cook.sh b/cook.sh
index fb22104..be39d53 100755
--- a/cook.sh
+++ b/cook.sh
@@ -72,4 +72,4 @@ do_unmount "${frn}-armhf"
do_unmount "${frn}-amd64"
shout "Build Complete.."
-ls ${frn}*tar*
+ls ${frn}*.*
diff --git a/plugins/envsetup b/plugins/envsetup
index 98becc5..cfc84bf 100755
--- a/plugins/envsetup
+++ b/plugins/envsetup
@@ -24,22 +24,7 @@
# SOFTWARE.
export ROOT_DIR
-
-if [ -z $ENABLE_USER_SETUP ]; then
- export ENABLE_USER_SETUP=false
-fi
-
-ROOT_DIR="$(git rev-parse --show-toplevel)"
-
-# sudo check
-if [ "$(id -u)" != "0" ]; then
- if ! command -v sudo >/dev/null 2>&1; then
- echo "This script requires sudo or root privileges but none present."
- exit 1
- else
- SUDO="$(command -v sudo)"
- fi
-fi
+export BUILD_PLATFORM="linux"
_c_magneta="\e[95m"
_c_green="\e[32m"
@@ -53,6 +38,30 @@ shout() { echo -e "${_c_blue}[-] ${*}${RST}";:;}
lshout() { echo -e "${_c_blue}-> ${*}${RST}";:;}
msg() { echo -e "${*} \e[0m" >&2;:;}
+# Check if environment is Termux
+if [ "$(uname -o)" = "Android" ]; then
+ export BUILD_PLATFORM="termux"
+fi
+
+# sudo check
+if [ "$(id -u)" != "0" ]; then
+ if [ "$BUILD_PLATFORM" == "termux" ]; then
+ SUDO=""
+ else
+ if command -v sudo &>/dev/null; then
+ SUDO="sudo"
+ else
+ die "This script requires root privileges"
+ fi
+ fi
+fi
+
+if [ -z $ENABLE_USER_SETUP ]; then
+ export ENABLE_USER_SETUP=false
+fi
+
+ROOT_DIR="$(git rev-parse --show-toplevel)"
+
trim_quotes() {
# Usage: trim_quotes "string"
: "${1//\'}"
@@ -102,24 +111,28 @@ do_mount() {
do_unmount()
{
- local chroot_dir=$1
- points="$chroot_dir/dev $chroot_dir/sys $chroot_dir/proc"
- see_for_directory "$points"
- if is_mounted "$chroot_dir/dev"; then
- shout "unmounting: $chroot_dir/dev"
- $SUDO umount "$chroot_dir"/dev/pts
- $SUDO umount "$chroot_dir"/dev
- fi
-
- if is_mounted "$chroot_dir"/proc; then
- shout "unmounting: $chroot_dir/proc"
- $SUDO umount $chroot_dir/proc
- fi
-
- if is_mounted "$chroot_dir"/sys; then
- shout "unmounting: $chroot_dir/sys"
- $SUDO umount "$chroot_dir"/sys
- fi
+ if [ "$BUILD_PLATFORM" == "termux" ]; then
+ lshout "Skip unmount for termux"
+ else
+ local chroot_dir=$1
+ points="$chroot_dir/dev $chroot_dir/sys $chroot_dir/proc"
+ see_for_directory "$points"
+ if is_mounted "$chroot_dir/dev"; then
+ shout "unmounting: $chroot_dir/dev"
+ $SUDO umount "$chroot_dir"/dev/pts
+ $SUDO umount "$chroot_dir"/dev
+ fi
+
+ if is_mounted "$chroot_dir"/proc; then
+ shout "unmounting: $chroot_dir/proc"
+ $SUDO umount $chroot_dir/proc
+ fi
+
+ if is_mounted "$chroot_dir"/sys; then
+ shout "unmounting: $chroot_dir/sys"
+ $SUDO umount "$chroot_dir"/sys
+ fi
+ fi
}
is_mounted() {
@@ -208,7 +221,9 @@ see_for_directory() {
no_to_directory() {
dir="$1"
if [ -d "$dir" ]; then
- if ! $NO_DIR_CHECK_OVERRIDE; then
+ if [ "$NO_DIR_CHECK_OVERRIDE" == "true" ]; then
+ return 0
+ else
die "directory exits: $dir"
fi
fi
@@ -226,12 +241,12 @@ foreign_arch() {
includes_packages() {
# comma sperated values
- includes="bzip2 pv ${INCLUDE_PACKAGES}"
+ includes="bzip2 pv openssl ${INCLUDE_PACKAGES}"
# environment variable INCLUDE_PACKAGES
export includes
x=0
for item in $includes; do
- include_final="$item"
+ #include_final="$item"
((x = x + 1))
done
shout "$x includes processed "
@@ -248,8 +263,25 @@ do_build() {
export DISABLE_USER_SETUP=false
fi
- includes_packages
foreign_arch "$arch"
+
+ #Disable cross architecture building in Termux
+ if [ "$BUILD_PLATFORM" == "termux" ]; then
+ case $worker_arch in
+ aarch64) termux_arch="arm64" ;;
+ arm*) termux_arch="armhf" ;;
+ amd64|x86_64) termux_arch="amd64" ;;
+ *) die "Unknown architecture" ;;
+ esac
+ if [ "$termux_arch" != "$arch" ]; then
+ lshout "Skip building $target_dir for termux"
+ return 0
+ else
+ lshout "Building on Termux"
+ fi
+ fi
+
+ includes_packages
no_to_directory "$target_dir"
export chroot_dir
@@ -290,20 +322,31 @@ do_build() {
_debootstrap=$(which debootstrap)
fi
+ if [ "$BUILD_PLATFORM" == "termux" ]; then
+ dpkg_depends_on debootstrap
+ _debootstrap="$(which debootstrap)"
+ FOREIGN=""
+ fi
+
(
$SUDO $_debootstrap \
$FOREIGN \
--arch="$arch" \
--no-check-gpg \
- --include="${include_final}" \
+ --include="${includes}" \
"$suite" \
"$target_dir" \
$MIRROR
) || die "Couldn't debootstrap..."
- do_second_stage "$target_dir" "$arch"
+ if [ "$BUILD_PLATFORM" == "termux" ]; then
+ lshout "Skipping second stage for termux"
+ arch_translate "$arch"
+ else
+ do_second_stage "$target_dir" "$arch"
+ fi
- if $ENABLE_USER_SETUP; then
+ if [ "$ENABLE_USER_SETUP" == "true" ]; then
setup_user
fi
@@ -362,7 +405,56 @@ do_qemu_user_emulation() {
fi
}
-do_chroot_ae() {
+setup_user() {
+ shout "Setting up user"
+ cp plugins/setup-user.sh $chroot_dir
+ sed -i s/'$FS_USER'/$FS_USER/g $chroot_dir/setup-user.sh
+ sed -i s/'$FS_PASS'/$FS_PASS/g $chroot_dir/setup-user.sh
+ run_cmd "chmod +x /setup-user.sh"
+ run_cmd "/bin/bash /setup-user.sh"
+ run_cmd "rm -rf /setup-user.sh"
+}
+
+do_chroot_proot_ae() {
+ dpkg_depends_on proot
+ local chroot_dir=$1
+ shift
+ local cmd_string=$*
+ local root_fs_path=${chroot_dir}
+
+ unset LD_PRELOAD
+ proot \
+ --link2symlink \
+ --sysvipc \
+ --kill-on-exit \
+ -b /system \
+ -b /sys \
+ -b /proc \
+ -b /dev \
+ -b /dev/urandom:/dev/random \
+ -b /proc/self/fd/1:/dev/stdout \
+ -b /proc/self/fd/2:/dev/stderr \
+ -b /proc/self/fd/0:/dev/stdin \
+ -b /proc/self/fd:/dev/fd \
+ -b /data/data/com.termux/files/usr \
+ -b /data/data/com.termux/files/home \
+ -b /data/data/com.termux/cache \
+ -b /storage/self/primary:/sdcard \
+ -b "${root_fs_path}"/tmp:/dev/shm \
+ --root-id \
+ --cwd=/root -L \
+ --kernel-release=5.4.0-faked \
+ --rootfs="${root_fs_path}" \
+ /usr/bin/env -i \
+ HOME=/root \
+ PATH=/usr/local/sbin:/usr/local/bin:/bin:/usr/bin:/sbin:/usr/sbin \
+ TERM="$TERM" \
+ LANG=C.UTF-8 \
+ $cmd_string
+
+}
+
+do_chroot_root_ae() {
local chroot_dir=$1
shift
local command=$*
@@ -376,20 +468,36 @@ do_chroot_ae() {
fi
}
+do_chroot_ae() {
+ if [ $BUILD_PLATFORM == "termux" ]; then
+ do_chroot_proot_ae "$@"
+ else
+ do_chroot_root_ae "$@"
+ fi
+}
+
do_compress() {
#compression
export TARGET_FILE
export chroot_dir=$1
TARGET_FILE="$(basename ${chroot_dir})"
+
+ if [ "$BUILD_PLATFORM" == "termux" ]; then
+ if [ ! -d "$chroot_dir" ]; then
+ lshout "Skip compressing $chroot_dir "
+ return 0
+ fi
+ fi
if [ -n "$OVERRIDER_COMPRESSION_TYPE" ]; then
case $OVERRIDER_COMPRESSION_TYPE in
bzip2) do_tar_bzip ;;
gzip) do_tar_gzip ;;
lz) do_tar_lz4 ;;
+ zstd) do_tar_zstd ;;
*)
shout "Unknown compression type"
- shout "all compression: lz,gzip,bzip2"
+ shout "all compression: lz,gzip,bzip2,zstd"
die "Giving up!!"
;;
esac
@@ -440,6 +548,20 @@ do_tar_bzip() {
$SUDO cp "${chroot_dir}/${TARGET_FILE}.tar.xz" out
}
+do_tar_zstd() {
+ shout "installing zstd..."
+ install_pkg "zstd"
+ shout "starting compression..."
+ $SUDO cp "plugins/zst-packer.sh" "${chroot_dir}"
+ do_chroot_ae \
+ "$chroot_dir" \
+ "chmod +x /zst-packer.sh"
+ do_chroot_ae \
+ "$chroot_dir" \
+ "/bin/bash /zst-packer.sh ${TARGET_FILE}"
+ $SUDO cp "${chroot_dir}/${TARGET_FILE}.zst" out
+}
+
run_cmd() {
local command=$*
do_chroot_ae "$chroot_dir" "$command"
@@ -480,3 +602,8 @@ install_pkg()
}
banner
+
+if [ "$BUILD_PLATFORM" == "termux" ]; then
+ lshout "Running on termux"
+fi
+
diff --git a/plugins/gz-packer.sh b/plugins/gz-packer.sh
index ae27b9a..72e7be1 100755
--- a/plugins/gz-packer.sh
+++ b/plugins/gz-packer.sh
@@ -1,19 +1,16 @@
#!/usr/bin/env bash
target=$1
-target_source=/
-# target_source=
tar \
- --exclude="${target_source}"dev/* \
- --exclude="${target_source}"run/* \
- --exclude="${target_source}"proc/* \
- --exclude="${target_source}"sys/* \
- --exclude="${target_source}"tmp/* \
- --exclude="${target_source}"${0} \
- --exclude="${target_source}${target}.tar.gz" \
+ --exclude={/data,/apex,/vendor,/system,/sdcard} \
+ --exclude={/dev,/proc,/sys,/tmp/*,/mnt/*,/media/*,/lost+found/*} \
+ --exclude="*.l2s.*" \
+ --exclude=/${0} \
+ --exclude="/${target}.tar.gz" \
--exclude-caches-all \
+ --one-file-system \
-cpf \
- - "${target_source}" -P \
- | pv -s $(($(du -skx "${target_source}" | awk '{print $1}') * 1024)) |\
- gzip --best > "${target}".tar.gz
+ - / -P \
+ | pv -s $(($(du -skx / | awk '{print $1}') * 1024)) |\
+ gzip --best > /"${target}".tar.gz
diff --git a/plugins/j-packer.sh b/plugins/j-packer.sh
index 0cfac83..452c225 100755
--- a/plugins/j-packer.sh
+++ b/plugins/j-packer.sh
@@ -1,18 +1,16 @@
#!/usr/bin/env bash
target=$1
-target_source=/
tar \
- --exclude="${target_source}"dev/* \
- --exclude="${target_source}"run/* \
- --exclude="${target_source}"proc/* \
- --exclude="${target_source}"sys/* \
- --exclude="${target_source}"tmp/* \
- --exclude="${target_source}"${0} \
- --exclude="${target_source}${target}.tar.xz" \
+ --exclude={/data,/apex,/vendor,/system,/sdcard} \
+ --exclude={/dev,/proc,/sys,/tmp/*,/mnt/*,/media/*,/lost+found/*} \
+ --exclude="*.l2s.*" \
+ --exclude=/${0} \
+ --exclude="/${target}.tar.xz" \
--exclude-caches-all \
+ --one-file-system \
-cpf \
- - "${target_source}" -P \
- | pv -s $(($(du -skx "${target_source}" | awk '{print $1}') * 1024)) |\
- bzip2 --best > "${target}".tar.xz
+ - / -P \
+ | pv -s $(($(du -skx / | awk '{print $1}') * 1024)) |\
+ bzip2 --best > /"${target}".tar.xz
diff --git a/plugins/lz-packer.sh b/plugins/lz-packer.sh
index 2260821..5603e38 100755
--- a/plugins/lz-packer.sh
+++ b/plugins/lz-packer.sh
@@ -1,19 +1,16 @@
#!/usr/bin/env bash
target=$1
-target_source=/
-# target_source=
tar \
- --exclude="${target_source}"dev/* \
- --exclude="${target_source}"run/* \
- --exclude="${target_source}"proc/* \
- --exclude="${target_source}"sys/* \
- --exclude="${target_source}"tmp/* \
- --exclude="${target_source}"${0} \
- --exclude="${target_source}${target}.tar.lz" \
+ --exclude={/data,/apex,/vendor,/system,/sdcard} \
+ --exclude={/dev,/proc,/sys,/tmp/*,/mnt/*,/media/*,/lost+found/*} \
+ --exclude="*.l2s.*" \
+ --exclude=/${0} \
+ --exclude="/${target}.tar.lz" \
--exclude-caches-all \
+ --one-file-system \
-cpf \
- - "${target_source}" -P \
- | pv -s $(($(du -skx "${target_source}" | awk '{print $1}') * 1024)) |\
- lz4 -9 > "${target}".tar.lz # use high compression
+ - / -P \
+ | pv -s $(($(du -skx / | awk '{print $1}') * 1024)) |\
+ lz4 -9 > /"${target}".tar.lz # use high compression
diff --git a/plugins/setup-user.sh b/plugins/setup-user.sh
new file mode 100755
index 0000000..42edc47
--- /dev/null
+++ b/plugins/setup-user.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+# FS_USER = username
+# FS_PASS = password
+
+useradd -m \
+ -p "$(openssl passwd -1 $FS_PASS)" \
+ -G sudo \
+ -d /home/$FS_USER \
+ -k /etc/skel \
+ -s /bin/bash \
+ $FS_USER
+echo $FS_USER ALL=\(root\) ALL > /etc/sudoers.d/$FS_USER
+chmod 0440 /etc/sudoers.d/$FS_USER
diff --git a/plugins/zst-packer.sh b/plugins/zst-packer.sh
new file mode 100755
index 0000000..1e23ba0
--- /dev/null
+++ b/plugins/zst-packer.sh
@@ -0,0 +1,16 @@
+#!/usr/bin/env bash
+
+target=$1
+
+tar \
+ --exclude={/data,/apex,/vendor,/system,/sdcard} \
+ --exclude={/dev,/proc,/sys,/tmp/*,/mnt/*,/media/*,/lost+found/*} \
+ --exclude="*.l2s.*" \
+ --exclude=/${0} \
+ --exclude="/${target}.zst" \
+ --exclude-caches-all \
+ --one-file-system \
+ -cpf \
+ - / -P \
+ | pv -s $(($(du -skx / | awk '{print $1}') * 1024)) |\
+ zstd > /"${target}".tar.zst
diff --git a/setup.sh b/setup.sh
index cd89a7d..2293fee 100755
--- a/setup.sh
+++ b/setup.sh
@@ -1,15 +1,19 @@
#!/usr/bin/env bash
# sudo check
-if [ "$(id -u)" != "0" ]; then
- if ! command -v sudo >/dev/null 2>&1; then
- echo "This script requires sudo or root privileges but none present."
- exit 1
- else
- SUDO="$(command -v sudo)"
+if [ "$(uname -o)" = "Android" ]; then
+ echo "Running in Termux"
+ apt update
+ apt install debootstrap which proot -y
+else
+ if [ "$(id -u)" != "0" ]; then
+ if ! command -v sudo >/dev/null 2>&1; then
+ echo "This script requires sudo or root privileges but none present."
+ exit 1
+ else
+ SUDO="$(command -v sudo)"
+ fi
fi
+ $SUDO apt update
+ $SUDO apt install -y qemu-user-static binfmt-support
fi
-
-deps="qemu-user-static binfmt-support"
-
-$SUDO apt install -y "$deps"