Add minimized builds + code cleanup

This commit is contained in:
zawwz 2020-12-11 13:29:55 +01:00
parent 9bfdb15728
commit d0441d05af
3 changed files with 13 additions and 3 deletions

View file

@ -6,3 +6,12 @@ deploy: build
build: build:
scripts/shcompile src/main.sh > zpkg && chmod +x zpkg scripts/shcompile src/main.sh > zpkg && chmod +x zpkg
# minimized build with lxsh
var_exclude = TMPDIR ZPKG_.* _ZPKG_.* SSH_ADDRESS HTTP_ADDRESS PKG_PATH COMPRESSION ALLOW_ROOT UPDATE_REMOVE
minimal: minimal-deploy
minimal-deploy: minimal-build
scripts/server_deploy.sh
minimal-build:
lxsh -o zpkg -m --minimize-var --exclude-var "$(var_exclude)" --minimize-fct --remove-unused src/main.sh

View file

@ -16,7 +16,7 @@ package()
src="$tmpdir" src="$tmpdir"
fi fi
( (
cd "$src" cd "$src" || exit $?
unset list unset list
[ -f DEPS ] && list=DEPS [ -f DEPS ] && list=DEPS
[ -f DESC ] && list="$list DESC" [ -f DESC ] && list="$list DESC"
@ -43,7 +43,7 @@ deploy_folder()
{ {
if [ -f "$1" ] && echo "$1" | grep -q '\.tar\.'"$extension\$" # file and valid extension if [ -f "$1" ] && echo "$1" | grep -q '\.tar\.'"$extension\$" # file and valid extension
then then
cat "$1" | $pcompress -dc 2>/dev/null | tar -tf - >/dev/null 2>&1|| { echo "File '$1' is not a valid archive" && return 1; } $pcompress -dc 2>/dev/null < "$1" | tar -tf - >/dev/null 2>&1|| { echo "File '$1' is not a valid archive" && return 1; }
deploy_package "$1" "$1" || return $? deploy_package "$1" "$1" || return $?
elif [ -d "$1" ] # folder elif [ -d "$1" ] # folder
then then

View file

@ -4,13 +4,14 @@
unpack() unpack()
{ {
echo "Unpacking $1" echo "Unpacking $1"
cat "$1" | $pcompress -dc 2>/dev/null | tar -xf - $pcompress -dc < "$1" 2>/dev/null | tar -xf -
} }
# $1 = package , $2 = prefix # $1 = package , $2 = prefix
add_package_entry() add_package_entry()
{ {
( (
set -e
cd "$PKG_PATH" cd "$PKG_PATH"
if grep -q "^$1 " installed 2>/dev/null if grep -q "^$1 " installed 2>/dev/null
then then