FFmpeg-Builds/util/repack_latest.sh

73 lines
1.6 KiB
Bash
Raw Permalink Normal View History

2021-12-24 15:49:28 +00:00
#!/bin/bash
set -e
if [[ $# -lt 2 ]]; then
echo "Missing arguments"
exit -1
fi
RELEASE_DIR="$(realpath "$1")"
shift
2022-01-15 01:17:12 +00:00
mkdir -p "$RELEASE_DIR"
2021-12-24 15:49:28 +00:00
rm -rf repack_dir
mkdir repack_dir
trap "rm -rf repack_dir" EXIT
while [[ $# -gt 0 ]]; do
INPUT="$1"
shift
2022-01-15 01:17:12 +00:00
(
set -e
REPACK_DIR="repack_dir/$BASHPID"
rm -rf "$REPACK_DIR"
mkdir "$REPACK_DIR"
2021-12-24 15:49:28 +00:00
2022-01-15 01:17:12 +00:00
if [[ $INPUT == *.zip ]]; then
unzip "$INPUT" -d "$REPACK_DIR"
elif [[ $INPUT == *.tar.xz ]]; then
tar xvaf "$INPUT" -C "$REPACK_DIR"
else
echo "Unknown input file type: $INPUT"
exit 1
fi
2021-12-24 15:49:28 +00:00
2022-01-15 01:17:12 +00:00
cd "$REPACK_DIR"
2021-12-24 15:49:28 +00:00
2022-01-15 01:17:12 +00:00
INAME="$(echo ffmpeg-*)"
TAGNAME="$(cut -d- -f2 <<<"$INAME")"
2022-01-15 01:17:12 +00:00
if [[ $TAGNAME == N ]]; then
TAGNAME="master"
elif [[ $TAGNAME == n* ]]; then
TAGNAME="$(sed -re 's/([0-9]+\.[0-9]+).*/\1/' <<<"$TAGNAME")"
fi
2022-01-15 01:17:12 +00:00
if [[ "$INAME" =~ -[0-9]+-g ]]; then
ONAME="ffmpeg-$TAGNAME-latest-$(cut -d- -f5- <<<"$INAME")"
else
ONAME="ffmpeg-$TAGNAME-latest-$(cut -d- -f3- <<<"$INAME")"
fi
2022-01-14 22:50:28 +00:00
2022-01-15 01:17:12 +00:00
mv "$INAME" "$ONAME"
2021-12-24 15:49:28 +00:00
2022-01-15 01:17:12 +00:00
if [[ $INPUT == *.zip ]]; then
zip -9 -r "$RELEASE_DIR/$ONAME.zip" "$ONAME"
elif [[ $INPUT == *.tar.xz ]]; then
tar cvJf "$RELEASE_DIR/$ONAME.tar.xz" "$ONAME"
fi
2021-12-24 15:49:28 +00:00
2022-01-15 01:17:12 +00:00
rm -rf "$REPACK_DIR"
) &
while [[ $(jobs | wc -l) -gt 3 ]]; do
wait %1
done
done
while [[ $(jobs | wc -l) -gt 0 ]]; do
wait %1
2021-12-24 15:49:28 +00:00
done
2022-01-15 01:17:12 +00:00
rm -rf repack_dir