Skip to content

Commit

Permalink
Merge pull request #31 from 23xvx/add-support-platform-termux
Browse files Browse the repository at this point in the history
Add zst compression type
  • Loading branch information
SaicharanKandukuri authored Jan 9, 2024
2 parents 7ed2441 + f14ae35 commit 16aaa62
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
2 changes: 1 addition & 1 deletion build-jammy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,4 @@ do_unmount "${frn}-armhf"
do_unmount "${frn}-amd64"

shout "Build Complete.."
ls ${frn}*tar*
ls ${frn}*.*
2 changes: 1 addition & 1 deletion cook.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ do_unmount "${frn}-armhf"
do_unmount "${frn}-amd64"

shout "Build Complete.."
ls ${frn}*tar*
ls ${frn}*.*
16 changes: 16 additions & 0 deletions plugins/envsetup
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,7 @@ setup_user() {
}

do_chroot_proot_ae() {
dpkg_depends_on proot
local chroot_dir=$1
shift
local cmd_string=$*
Expand Down Expand Up @@ -495,6 +496,7 @@ do_compress() {
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"
Expand Down Expand Up @@ -548,6 +550,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"
Expand Down
2 changes: 1 addition & 1 deletion plugins/j-packer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tar \
--exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/mnt/*,/media/*,/lost+found/*} \
--exclude="*.l2s.*" \
--exclude=/${0} \
--exclude="/${target}.tar.gz" \
--exclude="/${target}.tar.xz" \
--exclude-caches-all \
--one-file-system \
-cpf \
Expand Down
2 changes: 1 addition & 1 deletion plugins/lz-packer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ tar \
--exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/mnt/*,/media/*,/lost+found/*} \
--exclude="*.l2s.*" \
--exclude=/${0} \
--exclude="/${target}.tar.gz" \
--exclude="/${target}.tar.lz" \
--exclude-caches-all \
--one-file-system \
-cpf \
Expand Down
16 changes: 16 additions & 0 deletions plugins/zst-packer.sh
Original file line number Diff line number Diff line change
@@ -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}".zst
2 changes: 1 addition & 1 deletion setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
if [ "$(uname -o)" = "Android" ]; then
echo "Running in Termux"
apt update
apt install debootstrap which -y
apt install debootstrap which proot -y
else
if [ "$(id -u)" != "0" ]; then
if ! command -v sudo >/dev/null 2>&1; then
Expand Down

0 comments on commit 16aaa62

Please sign in to comment.