Update byof scripts

This commit is contained in:
William Blake Galbreath
2020-07-02 20:35:42 -05:00
parent 7a778f7212
commit 140a58f451
9 changed files with 271 additions and 266 deletions

199
purpur
View File

@@ -3,137 +3,106 @@
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ "$SOURCE" != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
SOURCE=$([[ "$SOURCE" == /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE")
. "$basedir"/scripts/init.sh
purpurstash() {
STASHED=$(git stash)
STASHED=$(git stash)
}
purpurunstash() {
if [[ "$STASHED" != "No local changes to save" ]]; then
git stash pop
fi
if [[ "$STASHED" != "No local changes to save" ]]; then
git stash pop
fi
}
case "$1" in
"am" | "amend")
(
cd "$basedir"/Purpur-API/
git add .
git commit --amend --no-edit
cd "$basedir"/Purpur-Server/
git add .
git commit --amend --no-edit
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"rb" | "rbp" | "rebuild")
(
set -e
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"p" | "patch" | "apply")
(
set -e
cd "$basedir"
scripts/apply.sh "$basedir"
)
;;
"b" | "bu" | "build")
(
basedir
mvn -N install
cd Purpur-API
mvn -e clean install
cd ../Purpur-Server
mvn -e clean install
)
;;
"jar" | "purpurclip")
(
basedir
cd "$basedir"
if [ "$2" != "fast" ]; then
scripts/upstream.sh
fi
./scripts/apply.sh "$basedir"
./scripts/purpurclip.sh
)
;;
"d" | "de" | "deploy")
(
basedir
mvn -N install
cd Purpur-API
mvn clean deploy
cd ../Purpur-Server
mvn clean install
)
;;
"up" | "upstream")
(
cd "$basedir"
scripts/upstream.sh "$2"
)
;;
"r" | "root")
(
set -e
cd "$basedir"
;;
"a" | "api")
cd "$basedir/Purpur-API"
;;
"s" | "server")
cd "$basedir/Purpur-Server"
;;
"setup")
if [[ -f ~/.bashrc ]]; then
NAME="purpur"
if [[ -n "${2+x}" ]]; then
NAME="$2"
fi
(grep "alias $NAME=" ~/.bashrc >/dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >>~/.bashrc)
alias "$NAME=. $SOURCE"
echo "You can now just type '$NAME' at any time to access the purpur tool."
if [ "$2" != "fast" ]; then
scripts/upstream.sh
fi
;;
scripts/apply.sh "$basedir"
)
;;
"b" | "bu" | "build")
(
basedir
mvn -N install
cd Purpur-API
mvn -e clean install
cd ../Paper/Paper-MojangAPI
mvn -e clean install
cd ../../Purpur-Server
mvn -e clean install
)
;;
"rb" | "rbp" | "rebuild")
(
set -e
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"am" | "amend")
(
cd "$basedir"/Purpur-API/
git add .
git commit --amend --no-edit
cd "$basedir"/Purpur-Server/
git add .
git commit --amend --no-edit
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"up" | "upstream")
(
cd "$basedir"
scripts/upstream.sh "$2"
)
;;
"jar" | "purpurclip")
(
basedir
cd "$basedir"
if [ "$2" != "fast" ]; then
scripts/upstream.sh
fi
./scripts/apply.sh "$basedir"
cd "$basedir"
mvn -N install
cd Purpur-API
mvn -e clean install
cd ../Paper/Paper-MojangAPI
mvn -e clean install
cd ../../Purpur-Server
mvn -e clean install
cd "$basedir"
./scripts/purpurclip.sh
)
;;
*)
echo "Purpur build tool command. This provides a variety of commands to build and manage the Purpur build"
echo "environment. For all of the functionality of this command to be available, you must first run the"
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
echo ""
echo " Normal commands:"
echo " * am, amend | Amend current edits to last patches"
echo " * rb, rebuild | Rebuild patches, can be called from anywhere."
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere."
echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere."
echo " * b, build | Build API and Server but no deploy. Can be ran anywhere."
echo " * d, deploy | Build and Deploy API jar and build Server. Can be ran anywhere."
echo ""
echo " These commands require the setup command before use:"
echo " * r, root | Change directory to the root of the project."
echo " * a. api | Move to the Purpur-API directory."
echo " * s, server | Move to the Purpur-Server directory."
echo " * e, edit | Use to edit a specific patch, give it the argument \"server\" or \"api\""
echo " | respectively to edit the correct project. Use the argument \"continue\" after"
echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere."
echo ""
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
echo " | . ./purpur setup"
echo " | After you run this command you'll be able to just run 'purpur' from anywhere."
echo " | The default name for the resulting alias is 'purpur', you can give an argument to override"
echo " | this default, such as:"
echo " | . ./purpur setup example"
echo " | Which will allow you to run 'example' instead."
;;
echo "Purpur build tool command. This provides a variety of commands to build and manage the Purpur build"
echo "environment. For all of the functionality of this command to be available, you must first run the"
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
echo ""
echo " Normal commands:"
echo " * p, patch | Apply all patches to top of Paper without building it"
echo " * b, build | Build Purpur API and Server"
echo " * rb, rebuild | Rebuild patches"
echo " * am, amend | Amend current edits to last patches"
echo " * up, upstream | Build Paper upstream, pass arg up to update paper"
echo " * jar, purpurclip | Apply all patches and build the project, purpurclip.jar will be output"
;;
esac
unset -f purpurstash