appdwarf: improve appimage offset calc, posix printfunc

This commit is contained in:
Phantop 2022-09-09 14:54:24 -04:00
parent 75edd70e37
commit 5129c9894c
1 changed files with 4 additions and 7 deletions

View File

@ -23,15 +23,12 @@ header() {
printfunc() { printfunc() {
echo '#!/bin/sh' echo '#!/bin/sh'
type "$1" | sed 's/^ *//' | tail -n+4 | head -n-1 sed -n "s/^ *//;/^$1() {$/,/^}$/p" "$0" | tail -n+2 | head -n-1
} }
unappimage() { unappimage() {
a=$(readelf -h "$1" | sed '13!d;s/[^0-9]//g') o=$(($(readelf -h "$1" | sed -e 's/[^0-9]//g;13p;18,19p;d' | sed -e 1a+ -e 2a*)))
b=$(readelf -h "$1" | sed '18!d;s/[^0-9]//g') unsquashfs -o "$o" "$@" # calculate offset via ELF header
c=$(readelf -h "$1" | sed '19!d;s/[^0-9]//g')
o=$(echo "$a" + "$b" \* "$c" | bc) # calculate offset via ELF header
unsquashfs -o "$o" "$@"
} }
zzexe() { zzexe() {
@ -79,7 +76,7 @@ case "$1" in
shift shift
zzexe "$@" ;; zzexe "$@" ;;
--version | -v ) --version | -v )
tput setaf 2; echo appdwarf 2022.08.05 tput setaf 2; echo appdwarf 2022.09.09
tput setaf 6; echo Built by July 🏳️‍🌈; exit ;; tput setaf 6; echo Built by July 🏳️‍🌈; exit ;;
-* | '' ) -* | '' )
echo "Usage: appdwarf [option] [APP/FILE/FOLDER/URL] [compression options]" echo "Usage: appdwarf [option] [APP/FILE/FOLDER/URL] [compression options]"