2020-05-03 22:48:05 +02:00
|
|
|
#!/bin/bash
|
|
|
|
|
set -e
|
|
|
|
|
echo
|
|
|
|
|
|
2021-08-03 20:12:21 +02:00
|
|
|
help() { exec cat <<'EOF'
|
2020-05-06 00:39:21 +02:00
|
|
|
|
|
|
|
|
# optional args:
|
|
|
|
|
#
|
|
|
|
|
# `clean` uses files from git (everything except web/deps),
|
|
|
|
|
# so local changes won't affect the produced sfx
|
|
|
|
|
#
|
|
|
|
|
# `re` does a repack of an sfx which you already executed once
|
|
|
|
|
# (grabs files from the sfx-created tempdir), overrides `clean`
|
|
|
|
|
#
|
2022-09-10 17:33:04 +02:00
|
|
|
# `ox` builds a pyoxidizer exe instead of py
|
|
|
|
|
#
|
2021-06-18 00:30:37 +02:00
|
|
|
# `gz` creates a gzip-compressed python sfx instead of bzip2
|
|
|
|
|
#
|
2022-05-14 23:25:40 +02:00
|
|
|
# `lang` limits which languages/translations to include,
|
|
|
|
|
# for example `lang eng` or `lang eng|nor`
|
|
|
|
|
#
|
2022-11-04 20:50:52 +00:00
|
|
|
# _____________________________________________________________________
|
|
|
|
|
# core features:
|
|
|
|
|
#
|
|
|
|
|
# `no-ftp` saves ~33k by removing the ftp server and filetype detector,
|
|
|
|
|
# disabling --ftpd and --magic
|
|
|
|
|
#
|
|
|
|
|
# `no-smb` saves ~3.5k by removing the smb / cifs server
|
|
|
|
|
#
|
2022-11-13 20:05:16 +00:00
|
|
|
# `no-zm` saves ~k by removing the zeroconf mDNS server
|
|
|
|
|
#
|
2022-11-04 20:50:52 +00:00
|
|
|
# _____________________________________________________________________
|
|
|
|
|
# web features:
|
|
|
|
|
#
|
2021-11-08 21:11:10 +01:00
|
|
|
# `no-cm` saves ~82k by removing easymde/codemirror
|
2020-05-11 01:38:30 +02:00
|
|
|
# (the fancy markdown editor)
|
2021-07-20 00:45:54 +02:00
|
|
|
#
|
2021-11-04 03:10:13 +01:00
|
|
|
# `no-hl` saves ~41k by removing syntax hilighting in the text viewer
|
|
|
|
|
#
|
2021-07-20 00:45:54 +02:00
|
|
|
# `no-fnt` saves ~9k by removing the source-code-pro font
|
2021-09-06 01:04:12 +02:00
|
|
|
# (browsers will try to use 'Consolas' instead)
|
2021-07-20 01:00:28 +02:00
|
|
|
#
|
|
|
|
|
# `no-dd` saves ~2k by removing the mouse cursor
|
2022-08-03 20:01:54 +02:00
|
|
|
#
|
|
|
|
|
# ---------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# if you are on windows, you can use msys2:
|
|
|
|
|
# PATH=/c/Users/$USER/AppData/Local/Programs/Python/Python310:"$PATH" ./make-sfx.sh fast
|
2020-05-06 00:39:21 +02:00
|
|
|
|
2021-08-03 20:12:21 +02:00
|
|
|
EOF
|
|
|
|
|
}
|
2020-05-06 00:39:21 +02:00
|
|
|
|
2022-11-28 21:38:50 +00:00
|
|
|
# port install gnutar findutils gsed gawk coreutils
|
2021-01-23 19:55:24 +01:00
|
|
|
gtar=$(command -v gtar || command -v gnutar) || true
|
|
|
|
|
[ ! -z "$gtar" ] && command -v gfind >/dev/null && {
|
|
|
|
|
tar() { $gtar "$@"; }
|
2022-11-28 21:38:50 +00:00
|
|
|
tr() { gtr "$@"; }
|
2020-05-06 00:39:21 +02:00
|
|
|
sed() { gsed "$@"; }
|
|
|
|
|
find() { gfind "$@"; }
|
|
|
|
|
sort() { gsort "$@"; }
|
2021-08-30 22:27:10 +02:00
|
|
|
shuf() { gshuf "$@"; }
|
2021-09-03 21:20:40 +02:00
|
|
|
nproc() { gnproc; }
|
2021-07-31 12:38:17 +02:00
|
|
|
sha1sum() { shasum "$@"; }
|
2020-05-12 22:36:21 +02:00
|
|
|
unexpand() { gunexpand "$@"; }
|
2021-01-23 19:55:24 +01:00
|
|
|
command -v grealpath >/dev/null &&
|
|
|
|
|
realpath() { grealpath "$@"; }
|
2021-03-21 22:31:07 +01:00
|
|
|
|
|
|
|
|
[ -e /opt/local/bin/bzip2 ] &&
|
|
|
|
|
bzip2() { /opt/local/bin/bzip2 "$@"; }
|
2020-05-06 00:39:21 +02:00
|
|
|
}
|
2021-06-08 23:19:35 +02:00
|
|
|
|
|
|
|
|
gawk=$(command -v gawk || command -v gnuawk || command -v awk)
|
|
|
|
|
awk() { $gawk "$@"; }
|
|
|
|
|
|
2022-09-10 17:33:04 +02:00
|
|
|
targs=(--owner=1000 --group=1000)
|
|
|
|
|
[ "$OSTYPE" = msys ] &&
|
|
|
|
|
targs=()
|
|
|
|
|
|
2021-03-21 20:11:03 +01:00
|
|
|
pybin=$(command -v python3 || command -v python) || {
|
|
|
|
|
echo need python
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
2020-05-06 00:39:21 +02:00
|
|
|
|
|
|
|
|
[ -e copyparty/__main__.py ] || cd ..
|
|
|
|
|
[ -e copyparty/__main__.py ] ||
|
2020-05-03 22:48:05 +02:00
|
|
|
{
|
|
|
|
|
echo "run me from within the project root folder"
|
|
|
|
|
echo
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
2022-08-15 19:11:21 +02:00
|
|
|
[ $CSN ] ||
|
|
|
|
|
CSN=sfx
|
|
|
|
|
|
2022-05-14 23:25:40 +02:00
|
|
|
langs=
|
2021-04-10 18:30:58 +02:00
|
|
|
use_gz=
|
2021-09-07 23:18:54 +02:00
|
|
|
zopf=2560
|
2020-05-06 00:39:21 +02:00
|
|
|
while [ ! -z "$1" ]; do
|
2021-07-20 01:00:28 +02:00
|
|
|
case $1 in
|
|
|
|
|
clean) clean=1 ; ;;
|
|
|
|
|
re) repack=1 ; ;;
|
2022-09-10 17:33:04 +02:00
|
|
|
ox) use_ox=1 ; ;;
|
2021-07-20 01:00:28 +02:00
|
|
|
gz) use_gz=1 ; ;;
|
2022-10-13 20:24:45 +02:00
|
|
|
gzz) shift;use_gzz=$1;use_gz=1; ;;
|
2022-11-04 20:50:52 +00:00
|
|
|
no-ftp) no_ftp=1 ; ;;
|
|
|
|
|
no-smb) no_smb=1 ; ;;
|
2022-11-13 20:05:16 +00:00
|
|
|
no-zm) no_zm=1 ; ;;
|
2021-07-20 01:00:28 +02:00
|
|
|
no-fnt) no_fnt=1 ; ;;
|
2021-11-04 03:10:13 +01:00
|
|
|
no-hl) no_hl=1 ; ;;
|
2021-07-20 01:00:28 +02:00
|
|
|
no-dd) no_dd=1 ; ;;
|
|
|
|
|
no-cm) no_cm=1 ; ;;
|
2022-06-16 01:07:15 +02:00
|
|
|
fast) zopf= ; ;;
|
2022-09-10 17:33:04 +02:00
|
|
|
ultra) ultra=1 ; ;;
|
2022-05-14 23:25:40 +02:00
|
|
|
lang) shift;langs="$1"; ;;
|
2021-08-03 20:12:21 +02:00
|
|
|
*) help ; ;;
|
2021-07-20 01:00:28 +02:00
|
|
|
esac
|
|
|
|
|
shift
|
2020-05-06 00:39:21 +02:00
|
|
|
done
|
2020-05-03 22:48:05 +02:00
|
|
|
|
2020-05-12 00:00:54 +02:00
|
|
|
tmv() {
|
|
|
|
|
touch -r "$1" t
|
|
|
|
|
mv t "$1"
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-31 12:38:17 +02:00
|
|
|
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
|
|
|
|
|
)
|
|
|
|
|
|
2022-08-15 19:11:21 +02:00
|
|
|
rm -rf $CSN/*
|
|
|
|
|
mkdir -p $CSN build
|
|
|
|
|
cd $CSN
|
2020-05-03 22:48:05 +02:00
|
|
|
|
2021-07-31 12:38:17 +02:00
|
|
|
tmpdir="$(
|
|
|
|
|
printf '%s\n' "$TMPDIR" /tmp |
|
|
|
|
|
awk '/./ {print; exit}'
|
|
|
|
|
)"
|
2020-05-06 00:39:21 +02:00
|
|
|
|
2022-12-02 23:42:46 +00:00
|
|
|
necho() {
|
2022-12-03 13:31:00 +00:00
|
|
|
printf '\033[G%s ... \033[K' "$*"
|
2022-12-02 23:42:46 +00:00
|
|
|
}
|
|
|
|
|
|
2021-07-31 12:38:17 +02:00
|
|
|
[ $repack ] && {
|
2022-09-23 20:37:37 +02:00
|
|
|
old="$tmpdir/pe-copyparty.$(id -u)"
|
2020-05-06 00:39:21 +02:00
|
|
|
echo "repack of files in $old"
|
2022-11-13 20:05:16 +00:00
|
|
|
cp -pR "$old/"*{py2,py37,j2,copyparty} .
|
2022-11-04 20:50:52 +00:00
|
|
|
cp -pR "$old/"*ftp . || true
|
2020-05-03 22:48:05 +02:00
|
|
|
}
|
2020-05-06 00:39:21 +02:00
|
|
|
|
|
|
|
|
[ $repack ] || {
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting ipaddress
|
2022-11-13 20:05:16 +00:00
|
|
|
f="../build/ipaddress-1.0.23.tar.gz"
|
|
|
|
|
[ -e "$f" ] ||
|
|
|
|
|
(url=https://files.pythonhosted.org/packages/b9/9a/3e9da40ea28b8210dd6504d3fe9fe7e013b62bf45902b458d1cdc3c34ed9/ipaddress-1.0.23.tar.gz;
|
|
|
|
|
wget -O$f "$url" || curl -L "$url" >$f)
|
|
|
|
|
|
|
|
|
|
tar -zxf $f
|
|
|
|
|
mkdir py37
|
|
|
|
|
mv ipaddress-*/ipaddress.py py37/
|
|
|
|
|
rm -rf ipaddress-*
|
|
|
|
|
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting jinja2
|
2021-02-03 22:32:01 +01:00
|
|
|
f="../build/Jinja2-2.11.3.tar.gz"
|
2020-05-06 00:39:21 +02:00
|
|
|
[ -e "$f" ] ||
|
2021-02-03 22:32:01 +01:00
|
|
|
(url=https://files.pythonhosted.org/packages/4f/e7/65300e6b32e69768ded990494809106f87da1d436418d5f1367ed3966fd7/Jinja2-2.11.3.tar.gz;
|
2020-05-06 00:39:21 +02:00
|
|
|
wget -O$f "$url" || curl -L "$url" >$f)
|
|
|
|
|
|
|
|
|
|
tar -zxf $f
|
2021-02-03 22:32:01 +01:00
|
|
|
mv Jinja2-*/src/jinja2 .
|
|
|
|
|
rm -rf Jinja2-*
|
2020-05-12 22:36:21 +02:00
|
|
|
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting markupsafe
|
2021-02-03 22:32:01 +01:00
|
|
|
f="../build/MarkupSafe-1.1.1.tar.gz"
|
|
|
|
|
[ -e "$f" ] ||
|
|
|
|
|
(url=https://files.pythonhosted.org/packages/b9/2e/64db92e53b86efccfaea71321f597fa2e1b2bd3853d8ce658568f7a13094/MarkupSafe-1.1.1.tar.gz;
|
|
|
|
|
wget -O$f "$url" || curl -L "$url" >$f)
|
|
|
|
|
|
|
|
|
|
tar -zxf $f
|
|
|
|
|
mv MarkupSafe-*/src/markupsafe .
|
|
|
|
|
rm -rf MarkupSafe-* markupsafe/_speedups.c
|
|
|
|
|
|
2022-06-16 01:07:15 +02:00
|
|
|
mkdir j2/
|
|
|
|
|
mv {markupsafe,jinja2} j2/
|
2020-05-06 00:39:21 +02:00
|
|
|
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting pyftpdlib
|
2023-02-14 21:50:14 +00:00
|
|
|
f="../build/pyftpdlib-1.5.7.tar.gz"
|
2022-02-13 03:10:53 +01:00
|
|
|
[ -e "$f" ] ||
|
2023-02-14 21:50:14 +00:00
|
|
|
(url=https://github.com/giampaolo/pyftpdlib/archive/refs/tags/release-1.5.7.tar.gz;
|
2022-02-13 03:10:53 +01:00
|
|
|
wget -O$f "$url" || curl -L "$url" >$f)
|
|
|
|
|
|
|
|
|
|
tar -zxf $f
|
|
|
|
|
mv pyftpdlib-release-*/pyftpdlib .
|
|
|
|
|
rm -rf pyftpdlib-release-* pyftpdlib/test
|
|
|
|
|
|
2022-06-16 01:07:15 +02:00
|
|
|
mkdir ftp/
|
|
|
|
|
mv pyftpdlib ftp/
|
2022-02-13 03:10:53 +01:00
|
|
|
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting asyncore, asynchat
|
2022-03-03 01:16:52 +01:00
|
|
|
for n in asyncore.py asynchat.py; do
|
|
|
|
|
f=../build/$n
|
|
|
|
|
[ -e "$f" ] ||
|
|
|
|
|
(url=https://raw.githubusercontent.com/python/cpython/c4d45ee670c09d4f6da709df072ec80cb7dfad22/Lib/$n;
|
|
|
|
|
wget -O$f "$url" || curl -L "$url" >$f)
|
|
|
|
|
done
|
|
|
|
|
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting python-magic
|
2022-09-18 17:30:57 +02:00
|
|
|
v=0.4.27
|
2022-09-19 00:59:54 +02:00
|
|
|
f="../build/python-magic-$v.tar.gz"
|
2022-09-18 17:30:57 +02:00
|
|
|
[ -e "$f" ] ||
|
|
|
|
|
(url=https://files.pythonhosted.org/packages/da/db/0b3e28ac047452d079d375ec6798bf76a036a08182dbb39ed38116a49130/python-magic-0.4.27.tar.gz;
|
|
|
|
|
wget -O$f "$url" || curl -L "$url" >$f)
|
|
|
|
|
|
|
|
|
|
tar -zxf $f
|
|
|
|
|
mkdir magic
|
|
|
|
|
mv python-magic-*/magic .
|
|
|
|
|
rm -rf python-magic-*
|
|
|
|
|
rm magic/compat.py
|
|
|
|
|
f=magic/__init__.py
|
|
|
|
|
awk '/^def _add_compat/{o=1} !o; /^_add_compat/{o=0}' <$f >t
|
|
|
|
|
tmv "$f"
|
|
|
|
|
mv magic ftp/ # doesn't provide a version label anyways
|
|
|
|
|
|
2022-09-10 17:33:04 +02:00
|
|
|
# enable this to dynamically remove type hints at startup,
|
|
|
|
|
# in case a future python version can use them for performance
|
2022-06-16 01:07:15 +02:00
|
|
|
true || (
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting strip-hints
|
2022-06-16 01:07:15 +02:00
|
|
|
f=../build/strip-hints-0.1.10.tar.gz
|
|
|
|
|
[ -e $f ] ||
|
|
|
|
|
(url=https://files.pythonhosted.org/packages/9c/d4/312ddce71ee10f7e0ab762afc027e07a918f1c0e1be5b0069db5b0e7542d/strip-hints-0.1.10.tar.gz;
|
|
|
|
|
wget -O$f "$url" || curl -L "$url" >$f)
|
|
|
|
|
|
|
|
|
|
tar -zxf $f
|
|
|
|
|
mv strip-hints-0.1.10/src/strip_hints .
|
|
|
|
|
rm -rf strip-hints-* strip_hints/import_hooks*
|
|
|
|
|
sed -ri 's/[a-z].* as import_hooks$/"""a"""/' strip_hints/*.py
|
|
|
|
|
|
|
|
|
|
cp -pR ../scripts/strip_hints/ .
|
|
|
|
|
)
|
2022-11-28 21:38:50 +00:00
|
|
|
cp -pR ../scripts/py2 .
|
2022-06-16 01:07:15 +02:00
|
|
|
|
2020-05-06 00:39:21 +02:00
|
|
|
# msys2 tar is bad, make the best of it
|
2022-12-02 23:42:46 +00:00
|
|
|
necho collecting source
|
|
|
|
|
echo
|
2020-05-06 00:39:21 +02:00
|
|
|
[ $clean ] && {
|
2021-09-07 23:18:54 +02:00
|
|
|
(cd .. && git archive hovudstraum >tar) && tar -xf ../tar copyparty
|
2020-05-06 00:39:21 +02:00
|
|
|
(cd .. && tar -cf tar copyparty/web/deps) && tar -xf ../tar
|
|
|
|
|
}
|
|
|
|
|
[ $clean ] || {
|
|
|
|
|
(cd .. && tar -cf tar copyparty) && tar -xf ../tar
|
|
|
|
|
}
|
|
|
|
|
rm -f ../tar
|
2022-03-03 01:16:52 +01:00
|
|
|
|
2022-11-26 19:47:27 +00:00
|
|
|
# resolve symlinks
|
|
|
|
|
find -type l |
|
|
|
|
|
while IFS= read -r f1; do (
|
|
|
|
|
cd "${f1%/*}"
|
|
|
|
|
f1="./${f1##*/}"
|
|
|
|
|
f2="$(readlink "$f1")"
|
|
|
|
|
[ -e "$f2" ] || f2="../$f2"
|
|
|
|
|
[ -e "$f2" ] || {
|
|
|
|
|
echo could not resolve "$f1"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
rm "$f1"
|
2022-12-02 23:42:46 +00:00
|
|
|
cp -p "$f2" "$f1"
|
2022-11-26 19:47:27 +00:00
|
|
|
); done
|
|
|
|
|
|
2023-01-28 13:35:49 +00:00
|
|
|
# resolve symlinks on windows
|
|
|
|
|
[ "$OSTYPE" = msys ] &&
|
|
|
|
|
(cd ..; git ls-files -s | awk '/^120000/{print$4}') |
|
|
|
|
|
while IFS= read -r x; do
|
|
|
|
|
[ $(wc -l <"$x") -gt 1 ] && continue
|
|
|
|
|
(cd "${x%/*}"; cp -p "../$(cat "${x##*/}")" ${x##*/})
|
|
|
|
|
done
|
|
|
|
|
|
2022-03-03 01:16:52 +01:00
|
|
|
# insert asynchat
|
|
|
|
|
mkdir copyparty/vend
|
|
|
|
|
for n in asyncore.py asynchat.py; do
|
|
|
|
|
awk 'NR<4||NR>27;NR==4{print"# license: https://opensource.org/licenses/ISC\n"}' ../build/$n >copyparty/vend/$n
|
|
|
|
|
done
|
2022-06-16 01:07:15 +02:00
|
|
|
|
2022-11-13 20:05:16 +00:00
|
|
|
rm -f copyparty/stolen/*/README.md
|
|
|
|
|
|
2022-06-16 01:07:15 +02:00
|
|
|
# remove type hints before build instead
|
2022-08-03 20:01:54 +02:00
|
|
|
(cd copyparty; "$pybin" ../../scripts/strip_hints/a.py; rm uh)
|
2020-05-03 22:48:05 +02:00
|
|
|
|
2022-10-13 21:14:42 +02:00
|
|
|
licfile=$(realpath copyparty/res/COPYING.txt)
|
|
|
|
|
(cd ../scripts; ./genlic.sh "$licfile")
|
2022-09-26 22:37:54 +02:00
|
|
|
}
|
|
|
|
|
|
2020-11-28 20:02:20 +01:00
|
|
|
ver=
|
2021-09-03 20:38:41 +02:00
|
|
|
[ -z "$repack" ] &&
|
2020-11-30 03:27:27 +01:00
|
|
|
git describe --tags >/dev/null 2>/dev/null && {
|
2020-11-28 20:02:20 +01:00
|
|
|
git_ver="$(git describe --tags)"; # v0.5.5-2-gb164aa0
|
2021-05-02 09:18:19 +02:00
|
|
|
ver="$(printf '%s\n' "$git_ver" | sed -r 's/^v//')";
|
2020-11-28 20:02:20 +01:00
|
|
|
t_ver=
|
|
|
|
|
|
|
|
|
|
printf '%s\n' "$git_ver" | grep -qE '^v[0-9\.]+$' && {
|
|
|
|
|
# short format (exact version number)
|
|
|
|
|
t_ver="$(printf '%s\n' "$ver" | sed -r 's/\./, /g')";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
printf '%s\n' "$git_ver" | grep -qE '^v[0-9\.]+-[0-9]+-g[0-9a-f]+$' && {
|
|
|
|
|
# long format (unreleased commit)
|
|
|
|
|
t_ver="$(printf '%s\n' "$ver" | sed -r 's/\./, /g; s/(.*) (.*)/\1 "\2"/')"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ -z "$t_ver" ] && {
|
|
|
|
|
printf 'unexpected git version format: [%s]\n' "$git_ver"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
|
2021-03-04 20:30:28 +01:00
|
|
|
dt="$(git log -1 --format=%cd --date=short | sed -E 's/-0?/, /g')"
|
2020-11-28 20:02:20 +01:00
|
|
|
printf 'git %3s: \033[36m%s\033[0m\n' ver "$ver" dt "$dt"
|
|
|
|
|
sed -ri '
|
|
|
|
|
s/^(VERSION =)(.*)/#\1\2\n\1 ('"$t_ver"')/;
|
|
|
|
|
s/^(S_VERSION =)(.*)/#\1\2\n\1 "'"$ver"'"/;
|
|
|
|
|
s/^(BUILD_DT =)(.*)/#\1\2\n\1 ('"$dt"')/;
|
|
|
|
|
' copyparty/__version__.py
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[ -z "$ver" ] &&
|
|
|
|
|
ver="$(awk '/^VERSION *= \(/ {
|
2021-09-04 17:43:49 +02:00
|
|
|
gsub(/[^0-9,a-g-]/,""); gsub(/,/,"."); print; exit}' < copyparty/__version__.py)"
|
2020-05-03 22:48:05 +02:00
|
|
|
|
2020-05-06 00:39:21 +02:00
|
|
|
ts=$(date -u +%s)
|
|
|
|
|
hts=$(date -u +%Y-%m%d-%H%M%S) # --date=@$ts (thx osx)
|
|
|
|
|
|
|
|
|
|
mkdir -p ../dist
|
2022-08-15 19:11:21 +02:00
|
|
|
sfx_out=../dist/copyparty-$CSN
|
2020-05-06 00:39:21 +02:00
|
|
|
|
|
|
|
|
echo cleanup
|
2021-07-31 12:38:17 +02:00
|
|
|
find -name '*.pyc' -delete
|
|
|
|
|
find -name __pycache__ -delete
|
2022-10-09 22:56:27 +02:00
|
|
|
find -name py.typed -delete
|
2020-05-06 00:39:21 +02:00
|
|
|
|
|
|
|
|
# especially prevent osx from leaking your lan ip (wtf apple)
|
2021-07-31 12:38:17 +02:00
|
|
|
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
|
2020-05-06 00:39:21 +02:00
|
|
|
|
2021-06-15 21:06:00 +02:00
|
|
|
rm -f copyparty/web/deps/*.full.* copyparty/web/dbg-* copyparty/web/Makefile
|
2020-05-06 00:39:21 +02:00
|
|
|
|
2021-09-18 15:38:13 +02:00
|
|
|
find copyparty | LC_ALL=C sort | sed 's/\.gz$//;s/$/,/' > have
|
|
|
|
|
cat have | while IFS= read -r x; do
|
|
|
|
|
grep -qF -- "$x" ../scripts/sfx.ls || {
|
|
|
|
|
echo "unexpected file: $x"
|
|
|
|
|
exit 1
|
|
|
|
|
}
|
|
|
|
|
done
|
|
|
|
|
rm have
|
|
|
|
|
|
2022-11-04 20:50:52 +00:00
|
|
|
[ $no_ftp ] &&
|
|
|
|
|
rm -rf copyparty/ftpd.py ftp asyncore.py asynchat.py &&
|
|
|
|
|
sed -ri '/add_argument\("--ftp/d' copyparty/__main__.py &&
|
|
|
|
|
sed -ri '/\.ftp/d' copyparty/svchub.py
|
|
|
|
|
|
|
|
|
|
[ $no_smb ] &&
|
|
|
|
|
rm -f copyparty/smbd.py &&
|
|
|
|
|
sed -ri '/add_argument\("--smb/d' copyparty/__main__.py
|
|
|
|
|
|
2022-11-13 20:05:16 +00:00
|
|
|
[ $no_zm ] &&
|
|
|
|
|
rm -rf copyparty/mdns.py copyparty/stolen/dnslib &&
|
|
|
|
|
sed -ri '/add_argument\("--zm/d' copyparty/__main__.py
|
|
|
|
|
|
2020-05-11 01:38:30 +02:00
|
|
|
[ $no_cm ] && {
|
|
|
|
|
rm -rf copyparty/web/mde.* copyparty/web/deps/easymde*
|
2020-05-11 01:56:26 +02:00
|
|
|
echo h > copyparty/web/mde.html
|
2020-05-12 00:00:54 +02:00
|
|
|
f=copyparty/web/md.html
|
2021-08-03 20:12:21 +02:00
|
|
|
sed -r '/edit2">edit \(fancy/d' <$f >t
|
|
|
|
|
tmv "$f"
|
2020-05-11 01:38:30 +02:00
|
|
|
}
|
|
|
|
|
|
2021-11-04 03:10:13 +01:00
|
|
|
[ $no_hl ] &&
|
|
|
|
|
rm -rf copyparty/web/deps/prism*
|
|
|
|
|
|
2021-07-20 00:45:54 +02:00
|
|
|
[ $no_fnt ] && {
|
|
|
|
|
rm -f copyparty/web/deps/scp.woff2
|
2021-09-05 18:55:28 +02:00
|
|
|
f=copyparty/web/ui.css
|
2021-09-06 01:04:12 +02:00
|
|
|
gzip -d "$f.gz" || true
|
|
|
|
|
sed -r "s/src:.*scp.*\)/src:local('Consolas')/" <$f >t
|
2021-08-03 20:12:21 +02:00
|
|
|
tmv "$f"
|
2021-07-20 00:45:54 +02:00
|
|
|
}
|
|
|
|
|
|
2021-07-20 01:00:28 +02:00
|
|
|
[ $no_dd ] && {
|
|
|
|
|
rm -rf copyparty/web/dd
|
|
|
|
|
f=copyparty/web/browser.css
|
2021-09-06 01:04:12 +02:00
|
|
|
gzip -d "$f.gz" || true
|
2021-10-08 01:33:48 +02:00
|
|
|
sed -r 's/(cursor: ?)url\([^)]+\), ?(pointer)/\1\2/; s/[0-9]+% \{cursor:[^}]+\}//; s/animation: ?cursor[^};]+//' <$f >t
|
2021-08-03 20:12:21 +02:00
|
|
|
tmv "$f"
|
2021-07-20 01:00:28 +02:00
|
|
|
}
|
|
|
|
|
|
2022-05-15 13:20:52 +02:00
|
|
|
[ $langs ] &&
|
|
|
|
|
for f in copyparty/web/{browser.js,splash.js}; do
|
|
|
|
|
gzip -d "$f.gz" || true
|
|
|
|
|
awk '/^\}/{l=0} !l; /^var Ls =/{l=1;next} o; /^\t["}]/{o=0} /^\t"'"$langs"'"/{o=1;print}' <$f >t
|
|
|
|
|
tmv "$f"
|
|
|
|
|
done
|
2022-05-14 23:25:40 +02:00
|
|
|
|
2022-09-10 17:33:04 +02:00
|
|
|
[ ! $repack ] && [ ! $use_ox ] && {
|
|
|
|
|
# uncomment; oxidized drops 45 KiB but becomes undebuggable
|
2022-06-16 01:07:15 +02:00
|
|
|
find | grep -E '\.py$' |
|
|
|
|
|
grep -vE '__version__' |
|
|
|
|
|
tr '\n' '\0' |
|
|
|
|
|
xargs -0 "$pybin" ../scripts/uncomment.py
|
|
|
|
|
|
|
|
|
|
# py2-compat
|
|
|
|
|
#find | grep -E '\.py$' | while IFS= read -r x; do
|
|
|
|
|
# sed -ri '/: TypeAlias = /d' "$x"; done
|
|
|
|
|
}
|
2021-02-04 01:01:11 +01:00
|
|
|
|
2022-06-16 01:07:15 +02:00
|
|
|
f=j2/jinja2/constants.py
|
2021-02-04 01:01:11 +01:00
|
|
|
awk '/^LOREM_IPSUM_WORDS/{o=1;print "LOREM_IPSUM_WORDS = u\"a\"";next} !o; /"""/{o=0}' <$f >t
|
|
|
|
|
tmv "$f"
|
2022-09-18 17:30:57 +02:00
|
|
|
rm -f j2/jinja2/async*
|
2021-02-04 01:01:11 +01:00
|
|
|
|
2022-06-16 01:07:15 +02:00
|
|
|
grep -rLE '^#[^a-z]*coding: utf-8' j2 |
|
2021-09-05 18:48:58 +02:00
|
|
|
while IFS= read -r f; do
|
|
|
|
|
(echo "# coding: utf-8"; cat "$f") >t
|
|
|
|
|
tmv "$f"
|
|
|
|
|
done
|
|
|
|
|
|
2020-05-12 00:00:54 +02:00
|
|
|
# up2k goes from 28k to 22k laff
|
2021-08-09 00:42:21 +02:00
|
|
|
awk 'BEGIN{gensub(//,"",1)}' </dev/null &&
|
|
|
|
|
echo entabbening &&
|
2021-06-08 23:19:35 +02:00
|
|
|
find | grep -E '\.css$' | while IFS= read -r f; do
|
|
|
|
|
awk '{
|
|
|
|
|
sub(/^[ \t]+/,"");
|
|
|
|
|
sub(/[ \t]+$/,"");
|
|
|
|
|
$0=gensub(/^([a-z-]+) *: *(.*[^ ]) *;$/,"\\1:\\2;","1");
|
|
|
|
|
sub(/ +\{$/,"{");
|
|
|
|
|
gsub(/, /,",")
|
|
|
|
|
}
|
|
|
|
|
!/\}$/ {printf "%s",$0;next}
|
|
|
|
|
1
|
2021-10-08 01:33:48 +02:00
|
|
|
' <$f | sed -r 's/;\}$/}/; /\{\}$/d' >t
|
2021-06-08 23:19:35 +02:00
|
|
|
tmv "$f"
|
|
|
|
|
done
|
2021-08-09 00:42:21 +02:00
|
|
|
unexpand -h 2>/dev/null &&
|
2021-06-08 23:19:35 +02:00
|
|
|
find | grep -E '\.(js|html)$' | while IFS= read -r f; do
|
2020-05-12 00:26:40 +02:00
|
|
|
unexpand -t 4 --first-only <"$f" >t
|
2020-05-12 00:00:54 +02:00
|
|
|
tmv "$f"
|
|
|
|
|
done
|
|
|
|
|
|
2021-06-08 23:19:35 +02:00
|
|
|
gzres() {
|
2022-09-10 17:33:04 +02:00
|
|
|
[ $zopf ] && command -v zopfli && pk="zopfli --i$zopf"
|
|
|
|
|
[ $zopf ] && command -v pigz && pk="pigz -11 -I $zopf"
|
|
|
|
|
[ -z "$pk" ] && pk='gzip'
|
2021-07-31 12:38:17 +02:00
|
|
|
|
2021-09-03 21:20:40 +02:00
|
|
|
np=$(nproc)
|
|
|
|
|
echo "$pk #$np"
|
|
|
|
|
|
|
|
|
|
while IFS=' ' read -r _ f; do
|
|
|
|
|
while true; do
|
|
|
|
|
na=$(ps auxwww | grep -F "$pk" | wc -l)
|
|
|
|
|
[ $na -le $np ] && break
|
|
|
|
|
sleep 0.2
|
|
|
|
|
done
|
2021-07-31 12:38:17 +02:00
|
|
|
echo -n .
|
2021-09-03 21:20:40 +02:00
|
|
|
$pk "$f" &
|
|
|
|
|
done < <(
|
|
|
|
|
find -printf '%s %p\n' |
|
|
|
|
|
grep -E '\.(js|css)$' |
|
|
|
|
|
grep -vF /deps/ |
|
|
|
|
|
sort -nr
|
|
|
|
|
)
|
|
|
|
|
wait
|
2021-07-31 12:38:17 +02:00
|
|
|
echo
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-08-15 19:11:21 +02:00
|
|
|
zdir="$tmpdir/cpp-mk$CSN"
|
2021-07-31 12:38:17 +02:00
|
|
|
[ -e "$zdir/$stamp" ] || rm -rf "$zdir"
|
|
|
|
|
mkdir -p "$zdir"
|
|
|
|
|
echo a > "$zdir/$stamp"
|
2022-12-03 13:31:00 +00:00
|
|
|
nf=$(ls -1 "$zdir"/arc.* 2>/dev/null | wc -l)
|
2021-08-01 00:17:05 +02:00
|
|
|
[ $nf -ge 2 ] && [ ! $repack ] && use_zdir=1 || use_zdir=
|
2021-07-31 12:38:17 +02:00
|
|
|
|
|
|
|
|
[ $use_zdir ] || {
|
|
|
|
|
echo "$nf alts += 1"
|
|
|
|
|
gzres
|
|
|
|
|
[ $repack ] ||
|
|
|
|
|
tar -cf "$zdir/arc.$(date +%s)" copyparty/web/*.gz
|
|
|
|
|
}
|
|
|
|
|
[ $use_zdir ] && {
|
|
|
|
|
arcs=("$zdir"/arc.*)
|
2022-06-16 01:07:15 +02:00
|
|
|
n=$(( $RANDOM % ${#arcs[@]} ))
|
|
|
|
|
arc="${arcs[n]}"
|
2021-07-31 12:38:17 +02:00
|
|
|
echo "using $arc"
|
|
|
|
|
tar -xf "$arc"
|
|
|
|
|
for f in copyparty/web/*.gz; do
|
|
|
|
|
rm "${f%.*}"
|
|
|
|
|
done
|
2021-06-08 23:19:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2022-09-10 17:33:04 +02:00
|
|
|
[ $use_ox ] && {
|
|
|
|
|
tgt=x86_64-pc-windows-msvc
|
|
|
|
|
tgt=i686-pc-windows-msvc # 2M smaller (770k after upx)
|
|
|
|
|
bdir=build/$tgt/release/install/copyparty
|
|
|
|
|
|
|
|
|
|
t="res web"
|
2022-09-20 20:11:38 +02:00
|
|
|
(printf "\n\n\nBUT WAIT! THERE'S MORE!!\n\n";
|
|
|
|
|
cat ../$bdir/COPYING.txt) >> copyparty/res/COPYING.txt ||
|
2022-09-10 17:33:04 +02:00
|
|
|
echo "copying.txt 404 pls rebuild"
|
|
|
|
|
|
|
|
|
|
mv ftp/* j2/* copyparty/vend/* .
|
2022-11-13 20:05:16 +00:00
|
|
|
rm -rf ftp j2 py2 py37 copyparty/vend
|
2022-09-10 17:33:04 +02:00
|
|
|
(cd copyparty; tar -cvf z.tar $t; rm -rf $t)
|
|
|
|
|
cd ..
|
|
|
|
|
pyoxidizer build --release --target-triple $tgt
|
|
|
|
|
mv $bdir/copyparty.exe dist/
|
2022-09-20 20:11:38 +02:00
|
|
|
cp -pv "$(for d in '/c/Program Files (x86)/Microsoft Visual Studio/'*'/BuildTools/VC/Redist/MSVC'; do
|
2022-10-13 20:24:45 +02:00
|
|
|
find "$d" -name vcruntime140.dll; done | sort | grep -vE '/x64/|/onecore/' | head -n 1)" dist/
|
2022-09-10 17:33:04 +02:00
|
|
|
dist/copyparty.exe --version
|
|
|
|
|
cp -pv dist/copyparty{,.orig}.exe
|
|
|
|
|
[ $ultra ] && a="--best --lzma" || a=-1
|
|
|
|
|
/bin/time -f %es upx $a dist/copyparty.exe >/dev/null
|
|
|
|
|
ls -al dist/copyparty{,.orig}.exe
|
|
|
|
|
exit 0
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2021-04-24 22:07:09 +02:00
|
|
|
echo gen tarlist
|
2022-11-13 20:05:16 +00:00
|
|
|
for d in copyparty j2 py2 py37 ftp; do find $d -type f; done | # strip_hints
|
2021-04-24 22:07:09 +02:00
|
|
|
sed -r 's/(.*)\.(.*)/\2 \1/' | LC_ALL=C sort |
|
|
|
|
|
sed -r 's/([^ ]*) (.*)/\2.\1/' | grep -vE '/list1?$' > list1
|
|
|
|
|
|
2022-03-20 06:15:57 +01:00
|
|
|
for n in {1..50}; do
|
2022-08-12 16:36:20 +02:00
|
|
|
(grep -vE '\.(gz|br)$' list1; grep -E '\.(gz|br)$' list1 | (shuf||gshuf) ) >list || true
|
|
|
|
|
s=$( (sha1sum||shasum) < list | cut -c-16)
|
2022-03-20 06:15:57 +01:00
|
|
|
grep -q $s "$zdir/h" && continue
|
|
|
|
|
echo $s >> "$zdir/h"
|
|
|
|
|
break
|
|
|
|
|
done
|
|
|
|
|
[ $n -eq 50 ] && exit
|
2021-04-24 22:07:09 +02:00
|
|
|
|
2020-05-06 00:39:21 +02:00
|
|
|
echo creating tar
|
2022-09-10 17:33:04 +02:00
|
|
|
tar -cf tar "${targs[@]}" --numeric-owner -T list
|
2020-05-03 22:48:05 +02:00
|
|
|
|
2022-10-13 20:24:45 +02:00
|
|
|
pc="bzip2 -"; pe=bz2
|
|
|
|
|
[ $use_gz ] && pc="gzip -" && pe=gz
|
|
|
|
|
[ $use_gzz ] && pc="pigz -11 -I$use_gzz" && pe=gz
|
2021-04-10 18:30:58 +02:00
|
|
|
|
2020-05-03 22:48:05 +02:00
|
|
|
echo compressing tar
|
2022-10-13 20:24:45 +02:00
|
|
|
for n in {2..9}; do cp tar t.$n; nice $pc$n t.$n & done; wait
|
|
|
|
|
minf=$(for f in t.*.$pe; do
|
|
|
|
|
s1=$(wc -c <$f)
|
|
|
|
|
s2=$(tr -d '\r\n\0' <$f | wc -c)
|
|
|
|
|
echo "$(( s2+(s1-s2)*3 )) $f"
|
|
|
|
|
done | sort -n | awk '{print$2;exit}')
|
|
|
|
|
mv -v $minf tar.bz2
|
2021-03-21 22:31:07 +01:00
|
|
|
rm t.* || true
|
|
|
|
|
exts=()
|
|
|
|
|
|
2020-05-03 22:48:05 +02:00
|
|
|
|
2022-02-13 20:44:03 +01:00
|
|
|
echo creating sfx
|
2021-03-21 22:31:07 +01:00
|
|
|
|
2022-02-13 20:44:03 +01:00
|
|
|
py=../scripts/sfx.py
|
|
|
|
|
suf=
|
|
|
|
|
[ $use_gz ] && {
|
|
|
|
|
sed -r 's/"r:bz2"/"r:gz"/' <$py >$py.t
|
|
|
|
|
py=$py.t
|
|
|
|
|
suf=-gz
|
|
|
|
|
}
|
2020-05-03 22:48:05 +02:00
|
|
|
|
2022-03-04 21:30:31 +01:00
|
|
|
"$pybin" $py --sfx-make tar.bz2 $ver $ts
|
2022-02-13 20:44:03 +01:00
|
|
|
mv sfx.out $sfx_out$suf.py
|
2021-04-10 18:30:58 +02:00
|
|
|
|
2022-02-13 20:44:03 +01:00
|
|
|
exts+=($suf.py)
|
|
|
|
|
[ $use_gz ] &&
|
|
|
|
|
rm $py
|
2021-03-21 22:31:07 +01:00
|
|
|
|
2020-05-06 00:39:21 +02:00
|
|
|
|
2021-04-10 18:30:58 +02:00
|
|
|
chmod 755 $sfx_out*
|
|
|
|
|
|
2020-05-06 00:39:21 +02:00
|
|
|
printf "done:\n"
|
2021-03-21 22:31:07 +01:00
|
|
|
for ext in ${exts[@]}; do
|
2021-04-10 18:30:58 +02:00
|
|
|
printf " %s\n" "$(realpath $sfx_out)"$ext
|
2021-03-21 22:31:07 +01:00
|
|
|
done
|
2020-05-15 01:02:18 +02:00
|
|
|
|
2021-03-21 18:06:31 +01:00
|
|
|
# apk add bash python3 tar xz bzip2
|
2022-02-13 20:44:03 +01:00
|
|
|
# while true; do ./make-sfx.sh; f=../dist/copyparty-sfx.py; mv $f $f.$(wc -c <$f | awk '{print$1}'); done
|