2023-07-03 13:24:45 +03:00
|
|
|
#!/usr/bin/env ash
|
|
|
|
# shellcheck shell=dash
|
|
|
|
|
|
|
|
WORKDIR=$(pwd)
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
dep () {
|
|
|
|
which "$1" || (echo "$1 not found" && exit 1)
|
|
|
|
}
|
|
|
|
|
|
|
|
clone () {
|
|
|
|
git clone --single-branch --depth 1 "$1" "$2" || exit 2
|
|
|
|
}
|
|
|
|
|
|
|
|
cd_and_exec () {
|
|
|
|
old=$(pwd)
|
|
|
|
cd "$1" || exit 3
|
|
|
|
shift
|
|
|
|
"$@" || exit 4
|
|
|
|
cd "$old" || exit 3
|
|
|
|
}
|
|
|
|
|
|
|
|
try_exec () {
|
|
|
|
"$@"
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
title () {
|
2023-07-03 15:19:58 +03:00
|
|
|
# Newline, Bold text, $1, Normal text, Newline
|
|
|
|
printf '\n\033[1m%s\033[0m\n' "$1"
|
2023-07-03 13:24:45 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
title 'Checking dependencies...'
|
|
|
|
dep git
|
|
|
|
dep java
|
|
|
|
dep cargo
|
|
|
|
dep 7z
|
|
|
|
|
|
|
|
title 'Cloning repositories...'
|
|
|
|
[ -e backend ] || clone https://github.com/TeamPiped/Piped-Backend backend
|
|
|
|
[ -e reqwest4j ] || clone https://github.com/TeamPiped/reqwest4j reqwest4j
|
|
|
|
|
|
|
|
title 'Applying patches...'
|
2023-07-03 15:19:58 +03:00
|
|
|
echo "Hint: if you've already applied patches,"
|
|
|
|
echo "pass \"patched\" as the first argument to the script."
|
|
|
|
if [ "$1" != "patched" ]
|
|
|
|
then
|
|
|
|
cd_and_exec backend git apply ../backend.patch
|
|
|
|
cd_and_exec reqwest4j git apply ../reqwest4j.patch
|
|
|
|
fi
|
2023-07-03 13:24:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
export RUSTFLAGS="-C target-feature=-crt-static"
|
|
|
|
|
|
|
|
title 'Building reqwest4j...'
|
|
|
|
cd_and_exec reqwest4j ./gradlew shadowJar
|
|
|
|
cd_and_exec reqwest4j ./gradlew --stop
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
2023-07-03 15:05:05 +03:00
|
|
|
title 'Copying reqwest4j JAR...'
|
2023-07-03 13:24:45 +03:00
|
|
|
|
|
|
|
REQ4J_NAME="reqwest4j.jar"
|
|
|
|
REQ4J="$WORKDIR/$REQ4J_NAME"
|
2023-07-03 15:05:05 +03:00
|
|
|
|
2023-07-03 13:24:45 +03:00
|
|
|
cd_and_exec reqwest4j/build/libs \
|
|
|
|
find . -maxdepth 1 -name 'reqwest4j-*-all.jar' -exec \
|
|
|
|
cp {} "$REQ4J" \;
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
title 'Adding reqwest4j JAR into Piped...'
|
2023-07-03 15:07:17 +03:00
|
|
|
cd_and_exec backend mkdir -p libs
|
2023-07-03 13:24:45 +03:00
|
|
|
cd_and_exec backend/libs mv "$REQ4J" ./
|
|
|
|
|
|
|
|
title 'Building Piped...'
|
|
|
|
cd_and_exec backend ./gradlew shadowJar
|
|
|
|
cd_and_exec backend ./gradlew --stop
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
|
|
|
title 'Copying Piped JAR...'
|
|
|
|
cd_and_exec backend/build/libs \
|
|
|
|
find . -maxdepth 1 -name 'piped-*-all.jar' -exec \
|
|
|
|
cp {} "$WORKDIR/piped.jar" \;
|
|
|
|
|
|
|
|
title 'Copying config...'
|
|
|
|
cd_and_exec backend cp config.properties "$WORKDIR"
|
|
|
|
|
|
|
|
title 'Cleaning up...'
|
|
|
|
rm -rf backend reqwest4j
|
|
|
|
|
|
|
|
|
|
|
|
# ---
|
2023-07-03 13:27:16 +03:00
|
|
|
echo '*** ************** ***'
|
|
|
|
echo '*** DONE ***'
|
|
|
|
echo '*** ************** ***'
|
|
|
|
|
2023-07-03 13:24:45 +03:00
|
|
|
title 'You need these files:'
|
2023-07-03 13:27:16 +03:00
|
|
|
|
2023-07-03 13:24:45 +03:00
|
|
|
for f in "piped.jar" "config.properties"
|
|
|
|
do
|
|
|
|
echo " $(readlink -f "$f")"
|
|
|
|
done
|