diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fe3674c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "scripts/corrupy"] + path = scripts/corrupy + url = git@github.com:CensoredUsername/corrupy.git diff --git a/scripts/corrupy b/scripts/corrupy new file mode 160000 index 0000000..82ecacb --- /dev/null +++ b/scripts/corrupy @@ -0,0 +1 @@ +Subproject commit 82ecacb1a81cdd726748a8fc2aa4b72f6d3a33a6 diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index 405eee0..5756ec3 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -150,12 +150,15 @@ unc="$HOME/dev/copyparty/scripts/uncomment.py" tr '\n' '\0' | xargs -0 $pybin $unc 1 +echo +echo minimizing files +$pybin ../scripts/squish.py $(find site-packages/r0c -type f) + echo echo creating tar args=(--owner=1000 --group=1000) [ "$OSTYPE" = msys ] && args=() - (for d in clients site-packages; do find $d -type f; done) | diff --git a/scripts/squish.py b/scripts/squish.py new file mode 100644 index 0000000..7710cec --- /dev/null +++ b/scripts/squish.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 + +import sys + +PY2 = sys.version_info < (3,) + +from corrupy import minimize + +def main(): + if len(sys.argv) < 2: + raise ValueError("No command line arguments given. Expected one or more filenames") + + for filename in sys.argv[1:]: + print("minimizing {}".format(filename)) + + if PY2: + with open(filename, "rb") as f: + data = f.read() + else: + with open(filename, "r", encoding="utf-8") as f: + data = f.read() + + output = minimize.minimize( + data, + remove_docs=True, obfuscate_globals=False, + obfuscate_builtins=False, obfuscate_imports=False + ) + + if PY2: + with open(filename, "wb") as f: + f.write(output) + else: + with open(filename, "w", encoding="utf-8") as f: + f.write(output) + +if __name__ == '__main__': + main()