self-upgrading upgrader... getting too meta

This commit is contained in:
ed 2020-12-14 03:45:59 +01:00
parent 580a42dec7
commit 5c18d12cbf
2 changed files with 19 additions and 6 deletions

25
scripts/copyparty-repack.sh Normal file → Executable file
View file

@ -1,4 +1,5 @@
#!/bin/bash #!/bin/bash
repacker=1
set -e set -e
# -- download latest copyparty (source.tgz and sfx), # -- download latest copyparty (source.tgz and sfx),
@ -38,10 +39,10 @@ dl_files() {
export -f dl_files export -f dl_files
# debug: if cache exists, use that instead of bothering github # if cache exists, use that instead of bothering github
cache="$od/.copyparty-repack.cache" cache="$od/.copyparty-repack.cache"
[ -e "$cache" ] && [ -e "$cache" ] &&
tar -xvf "$cache" || tar -xf "$cache" ||
{ {
# get download links from github # get download links from github
dl_text https://api.github.com/repos/9001/copyparty/releases/latest | dl_text https://api.github.com/repos/9001/copyparty/releases/latest |
@ -56,8 +57,7 @@ cache="$od/.copyparty-repack.cache"
tr -d '\r' | tr '\n' '\0' | tr -d '\r' | tr '\n' '\0' |
xargs -0 bash -c 'dl_files "$@"' _ xargs -0 bash -c 'dl_files "$@"' _
# debug: create cache tar -czf "$cache" *
#tar -czvf "$cache" *
} }
@ -70,10 +70,21 @@ mv copyparty-*.tar.gz copyparty-extras/
# unpack the source code # unpack the source code
( cd copyparty-extras/ ( cd copyparty-extras/
tar -xvf *.tar.gz 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 # fix permissions
chmod 755 \ chmod 755 \
copyparty-extras/sfx-full/* \ copyparty-extras/sfx-full/* \
@ -101,7 +112,9 @@ rm -rf copyparty-{0..9}*.*.*{0..9}
# and include the repacker itself too # and include the repacker itself too
cp -pv "$od/$0" copyparty-extras/ cp -av "$od/$0" copyparty-extras/ ||
cp -av "$0" copyparty-extras/ ||
true
# create the bundle # create the bundle

0
scripts/make-sfx.sh Normal file → Executable file
View file