From f870cf3c0514de95c2c3ae5cb0f4e1123de91724 Mon Sep 17 00:00:00 2001 From: ed Date: Sat, 5 Sep 2026 22:49:01 +0000 Subject: [PATCH] sfx: prefer ~/.cache/; closes #1517 --- scripts/copyparty-repack.sh | 173 ----------------------------------- scripts/docker/innvikler.sh | 2 +- scripts/docker/make.sh | 2 +- scripts/make-sfx.sh | 2 + scripts/pyinstaller/build.sh | 1 + scripts/rls.sh | 2 + scripts/sfx.py | 12 ++- 7 files changed, 17 insertions(+), 177 deletions(-) delete mode 100755 scripts/copyparty-repack.sh diff --git a/scripts/copyparty-repack.sh b/scripts/copyparty-repack.sh deleted file mode 100755 index c4de5d23e..000000000 --- a/scripts/copyparty-repack.sh +++ /dev/null @@ -1,173 +0,0 @@ -#!/bin/bash -repacker=1 -set -e - -# -- download latest copyparty (source.tgz and sfx), -# -- build minimal sfx versions, -# -- create a .tar.gz bundle -# -# convenient for deploying updates to inconvenient locations -# (and those are usually linux so bash is good inaff) -# (but that said this even has macos support) -# -# output summary (filesizes and contents): -# -# 550760 copyparty-extras/sfx-full/copyparty-sfx.py -# `- original unmodified sfx from github -# -# 572923 copyparty-extras/sfx-full/copyparty-sfx-gz.py -# `- unmodified but recompressed from bzip2 to gzip -# -# 353975 copyparty-extras/sfx-ent/copyparty-sfx.py -# 376934 copyparty-extras/sfx-ent/copyparty-sfx-gz.py -# `- removed iOS ogg/opus/vorbis audio decoder, -# removed the audio tray mouse cursor, -# "enterprise edition" -# -# 270004 copyparty-extras/sfx-lite/copyparty-sfx.py -# 293159 copyparty-extras/sfx-lite/copyparty-sfx-gz.py -# `- also removed the codemirror markdown editor -# and the text-viewer syntax hilighting, -# only essential features remaining -# -# 646297 copyparty-extras/copyparty-1.0.14.tar.gz -# 4823 copyparty-extras/copyparty-repack.sh -# `- source files from github -# -# 23663 copyparty-extras/u2c.py -# `- standalone utility to upload or search for files -# -# 32280 copyparty-extras/partyfuse.py -# `- standalone to mount a URL as a local read-only filesystem -# -# 270004 copyparty -# `- minimal binary, same as sfx-lite/copyparty-sfx.py - - -command -v gnutar && tar() { gnutar "$@"; } -command -v gtar && tar() { gtar "$@"; } -command -v gsed && sed() { gsed "$@"; } -td="$(mktemp -d)" -od="$(pwd)" -cd "$td" -pwd - - -dl_text() { - command -v curl >/dev/null && exec curl "$@" - exec wget -O- "$@" -} -dl_files() { - command -v curl >/dev/null && exec curl -L --remote-name-all "$@" - exec wget "$@" -} -export -f dl_files - - -# if cache exists, use that instead of bothering github -cache="$od/.copyparty-repack.cache" -[ -e "$cache" ] && - tar -xf "$cache" || -{ - # get download links from github - dl_text https://api.github.com/repos/9001/copyparty/releases/latest | - ( - # prefer jq if available - jq -r '.assets[]|select(.name|test("-sfx|tar.gz")).browser_download_url' || - - # fallback to awk (sorry) - awk -F\" '/"browser_download_url".*(\.tar\.gz|-sfx\.)/ {print$4}' - ) | - grep -E '(sfx\.py|tar\.gz)$' | - tee /dev/stderr | - tr -d '\r' | tr '\n' '\0' | - xargs -0 bash -c 'dl_files "$@"' _ - - tar -czf "$cache" * -} - - -# move src into copyparty-extras/, -# move sfx into copyparty-extras/sfx-full/ -mkdir -p copyparty-extras/sfx-{full,ent,lite} -mv copyparty-sfx.* copyparty-extras/sfx-full/ -mv copyparty-*.tar.gz copyparty-extras/ - - -# unpack the source code -( cd copyparty-extras/ -tar -xf *.tar.gz -) - - -# use repacker from release if that is newer -p_other=copyparty-extras/copyparty-*/scripts/copyparty-repack.sh -other=$(awk -F= 'BEGIN{v=-1} NR<10&&/^repacker=/{v=$NF} END{print v}' <$p_other) -[ $repacker -lt $other ] && - cat $p_other >"$od/$0" && cd "$od" && rm -rf "$td" && exec "$0" "$@" - - -# now drop the cache -rm -f "$cache" - - -# fix permissions -chmod 755 \ - copyparty-extras/sfx-full/* \ - copyparty-extras/copyparty-*/{scripts,bin}/* - - -# extract the sfx -( cd copyparty-extras/sfx-full/ -./copyparty-sfx.py --version -) - - -repack() { - - # do the repack - (cd copyparty-extras/copyparty-*/ - ./scripts/make-sfx.sh $2 - ) - - # put new sfx into copyparty-extras/$name/, - ( cd copyparty-extras/ - mv copyparty-*/dist/* $1/ - ) -} - -repack sfx-full "re gz" -repack sfx-ent "re" -repack sfx-ent "re gz" -repack sfx-lite "re no-cm no-hl" -repack sfx-lite "re no-cm no-hl gz" - - -# move fuse and up2k clients into copyparty-extras/, -# copy lite-sfx.py to ./copyparty, -# delete extracted source code -( cd copyparty-extras/ -mv copyparty-*/bin/u2c.py . -mv copyparty-*/bin/partyfuse.py . -cp -pv sfx-lite/copyparty-sfx.py ../copyparty -rm -rf copyparty-{0..9}*.*.*{0..9} -) - - -# and include the repacker itself too -cp -av "$od/$0" copyparty-extras/ || -cp -av "$0" copyparty-extras/ || -true - - -# create the bundle -printf '\n\n' -fn=copyparty-$(date +%Y-%m%d-%H%M%S).tgz -tar -czvf "$od/$fn" * -cd "$od" -rm -rf "$td" - - -echo -echo "done, here's your bundle:" -ls -al "$fn" diff --git a/scripts/docker/innvikler.sh b/scripts/docker/innvikler.sh index 4495e7406..db75345d5 100644 --- a/scripts/docker/innvikler.sh +++ b/scripts/docker/innvikler.sh @@ -72,7 +72,7 @@ exec /usr/bin/python3 -m copyparty "$@" EOF # unpack sfx and dive in -python3 copyparty-sfx.py --version +PRTY_XD=/tmp python3 copyparty-sfx.py --version cd /tmp/pe-copyparty.0 # steal the stuff we need diff --git a/scripts/docker/make.sh b/scripts/docker/make.sh index bdf7b9b62..6f4a693a9 100755 --- a/scripts/docker/make.sh +++ b/scripts/docker/make.sh @@ -29,7 +29,7 @@ done getver() { ver=$( - python3 ../../dist/copyparty-sfx.py --version 2>/dev/null | + PRTY_XD=/tmp python3 ../../dist/copyparty-sfx.py --version 2>/dev/null | awk '/^copyparty v/{sub(/-.*/,"");sub(/v/,"");print$2;exit}' ) echo $ver | grep -E '[0-9]\.[0-9]' || { diff --git a/scripts/make-sfx.sh b/scripts/make-sfx.sh index 5cf923645..fb7ffb628 100755 --- a/scripts/make-sfx.sh +++ b/scripts/make-sfx.sh @@ -193,6 +193,8 @@ tmpdir="$( printf '%s\n' "$TMPDIR" /tmp | awk '/./ {print; exit}' )" +[ -e ~/.cache ] && tmpdir=~/.cache +[ "$PRTY_XD" ] && tmpdir="$PRTY_XD" necho() { printf '\033[G%s ... \033[K' "$*" diff --git a/scripts/pyinstaller/build.sh b/scripts/pyinstaller/build.sh index 0d9d37f90..d2f80a5ff 100644 --- a/scripts/pyinstaller/build.sh +++ b/scripts/pyinstaller/build.sh @@ -42,6 +42,7 @@ dl https://192.168.123.1:3923/cpp/scripts/pyinstaller/loader.rc [ $st_en ] && [ $st_en -ge $st_sfx ] || sfx=sfx } +export PRTY_XD=$TEMP rm -rf $TEMP/pe-copyparty* python copyparty-$sfx.py --version diff --git a/scripts/rls.sh b/scripts/rls.sh index a7cd9e7cc..7dc664a09 100755 --- a/scripts/rls.sh +++ b/scripts/rls.sh @@ -19,6 +19,8 @@ v=$1; shift [ "$v" = sfx ] && rls= || rls=1 +export PRTY_XD=/tmp + [ $rls ] && { printf '%s\n' "$v" | grep -qE '^[0-9\.]+$' || exit 1 grep -E "(${v//./, })" ../copyparty/__version__.py || exit 1 diff --git a/scripts/sfx.py b/scripts/sfx.py index 26e76316b..5c360f316 100644 --- a/scripts/sfx.py +++ b/scripts/sfx.py @@ -270,7 +270,7 @@ def hashfile(fn): return h.hexdigest()[:24] -def unpack(): +def unpack(top): """extracts the archive""" name = "pe-copyparty" try: @@ -281,6 +281,8 @@ def unpack(): tag = "v%s" % STAMP opj = OP.join ofe = OP.exists + if not ofe(top): + os.mkdir(top) final = opj(top, name) san = opj(final, "copyparty/up2k.py") for suf in range(0, 9001): @@ -482,7 +484,13 @@ def main(): # skip 0 - tmp = os.path.realpath(unpack()) + try: + if WINDOWS: + x + z = unpack(ENV.get("PRTY_XD") or OP.expanduser("~/.cache")) + except: + z = unpack(tempfile.gettempdir()) + tmp = OP.realpath(z) try: from jinja2 import __version__ as j2