mirror of
https://github.com/9001/copyparty.git
synced 2025-08-17 17:12:13 -06:00
optimize make-sfx
This commit is contained in:
parent
cfa36fd279
commit
44e76d5eeb
|
@ -34,6 +34,7 @@ gtar=$(command -v gtar || command -v gnutar) || true
|
||||||
sed() { gsed "$@"; }
|
sed() { gsed "$@"; }
|
||||||
find() { gfind "$@"; }
|
find() { gfind "$@"; }
|
||||||
sort() { gsort "$@"; }
|
sort() { gsort "$@"; }
|
||||||
|
sha1sum() { shasum "$@"; }
|
||||||
unexpand() { gunexpand "$@"; }
|
unexpand() { gunexpand "$@"; }
|
||||||
command -v grealpath >/dev/null &&
|
command -v grealpath >/dev/null &&
|
||||||
realpath() { grealpath "$@"; }
|
realpath() { grealpath "$@"; }
|
||||||
|
@ -81,16 +82,23 @@ tmv() {
|
||||||
mv t "$1"
|
mv t "$1"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stamp=$(
|
||||||
|
for d in copyparty scripts; do
|
||||||
|
find $d -type f -printf '%TY-%Tm-%Td %TH:%TM:%TS %p\n'
|
||||||
|
done | sort | tail -n 1 | sha1sum | cut -c-16
|
||||||
|
)
|
||||||
|
|
||||||
rm -rf sfx/*
|
rm -rf sfx/*
|
||||||
mkdir -p sfx build
|
mkdir -p sfx build
|
||||||
cd sfx
|
cd sfx
|
||||||
|
|
||||||
[ $repack ] && {
|
tmpdir="$(
|
||||||
old="$(
|
printf '%s\n' "$TMPDIR" /tmp |
|
||||||
printf '%s\n' "$TMPDIR" /tmp |
|
awk '/./ {print; exit}'
|
||||||
awk '/./ {print; exit}'
|
)"
|
||||||
)/pe-copyparty"
|
|
||||||
|
|
||||||
|
[ $repack ] && {
|
||||||
|
old="$tmpdir/pe-copyparty"
|
||||||
echo "repack of files in $old"
|
echo "repack of files in $old"
|
||||||
cp -pR "$old/"*{dep-j2,copyparty} .
|
cp -pR "$old/"*{dep-j2,copyparty} .
|
||||||
}
|
}
|
||||||
|
@ -172,12 +180,12 @@ mkdir -p ../dist
|
||||||
sfx_out=../dist/copyparty-sfx
|
sfx_out=../dist/copyparty-sfx
|
||||||
|
|
||||||
echo cleanup
|
echo cleanup
|
||||||
find .. -name '*.pyc' -delete
|
find -name '*.pyc' -delete
|
||||||
find .. -name __pycache__ -delete
|
find -name __pycache__ -delete
|
||||||
|
|
||||||
# especially prevent osx from leaking your lan ip (wtf apple)
|
# especially prevent osx from leaking your lan ip (wtf apple)
|
||||||
find .. -type f \( -name .DS_Store -or -name ._.DS_Store \) -delete
|
find -type f \( -name .DS_Store -or -name ._.DS_Store \) -delete
|
||||||
find .. -type f -name ._\* | while IFS= read -r f; do cmp <(printf '\x00\x05\x16') <(head -c 3 -- "$f") && rm -f -- "$f"; done
|
find -type f -name ._\* | while IFS= read -r f; do cmp <(printf '\x00\x05\x16') <(head -c 3 -- "$f") && rm -f -- "$f"; done
|
||||||
|
|
||||||
echo use smol web deps
|
echo use smol web deps
|
||||||
rm -f copyparty/web/deps/*.full.* copyparty/web/dbg-* copyparty/web/Makefile
|
rm -f copyparty/web/deps/*.full.* copyparty/web/dbg-* copyparty/web/Makefile
|
||||||
|
@ -241,20 +249,42 @@ find | grep -E '\.(js|html)$' | while IFS= read -r f; do
|
||||||
tmv "$f"
|
tmv "$f"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
gzres() {
|
gzres() {
|
||||||
command -v pigz &&
|
command -v pigz &&
|
||||||
pk='pigz -11 -J 34 -I 100' ||
|
pk='pigz -11 -J 34 -I 256' ||
|
||||||
pk='gzip'
|
pk='gzip'
|
||||||
|
|
||||||
echo "$pk"
|
echo "$pk"
|
||||||
find | grep -E '\.(js|css)$' | grep -vF /deps/ | while IFS= read -r f; do
|
find | grep -E '\.(js|css)$' | grep -vF /deps/ | while IFS= read -r f; do
|
||||||
echo -n .
|
echo -n .
|
||||||
$pk "$f"
|
$pk "$f"
|
||||||
done
|
done
|
||||||
echo
|
echo
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
zdir="$tmpdir/cpp-mksfx"
|
||||||
|
[ -e "$zdir/$stamp" ] || rm -rf "$zdir"
|
||||||
|
mkdir -p "$zdir"
|
||||||
|
echo a > "$zdir/$stamp"
|
||||||
|
nf=$(ls -1 "$zdir"/arc.* | wc -l)
|
||||||
|
[ $nf -ge 10 ] && [ ! $repack ] && use_zdir=1 || use_zdir=
|
||||||
|
|
||||||
|
[ $use_zdir ] || {
|
||||||
|
echo "$nf alts += 1"
|
||||||
|
gzres
|
||||||
|
[ $repack ] ||
|
||||||
|
tar -cf "$zdir/arc.$(date +%s)" copyparty/web/*.gz
|
||||||
|
}
|
||||||
|
[ $use_zdir ] && {
|
||||||
|
arcs=("$zdir"/arc.*)
|
||||||
|
arc="${arcs[$RANDOM % ${#arcs[@]} ] }"
|
||||||
|
echo "using $arc"
|
||||||
|
tar -xf "$arc"
|
||||||
|
for f in copyparty/web/*.gz; do
|
||||||
|
rm "${f%.*}"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
gzres
|
|
||||||
|
|
||||||
|
|
||||||
echo gen tarlist
|
echo gen tarlist
|
||||||
|
|
Loading…
Reference in a new issue