Use `set -e` to handle errors better in the build scripts

This commit is contained in:
DemonWav 2016-04-03 02:23:19 -05:00
parent 7effde04b1
commit 0394633734
11 changed files with 118 additions and 48 deletions

114
paper
View File

@ -22,59 +22,81 @@ paperunstash() {
case "$1" in
"rbp" | "rebuild")
(
(
set -e
cd "$basedir"
scripts/rebuildPatches.sh "$basedir"
)
)
;;
"a" | "apply")
(
"p" | "patch")
(
set -e
cd "$basedir"
scripts/build.sh "$basedir"
)
)
;;
"j" | "jar")
(
cd "$basedir"
(
set -e
cd "$basedir"
scripts/build.sh "$basedir" "--jar"
)
)
;;
"make")
(
if [[ "$2" = "bacon" ]] ; then
set -e
cd "$basedir"
scripts/build.sh "$basedir" "--jar"
fi
)
;;
"r" | "root")
cd "$basedir"
;;
"api")
"a" | "api")
cd "$basedir/Paper-API"
;;
"serv" | "server")
"s" | "server")
cd "$basedir"
;;
"e" | "edit")
case "$2" in
"server")
cd "$basedir/Paper-Server"
export LAST_EDIT=$(pwd)
"s" | "server")
export LAST_EDIT="$basedir/Paper-Server"
cd "$basedir/Paper-Server"
(
set -e
paperstash
git rebase -i upstream/upstream
paperunstash
)
;;
"api")
cd "$basedir/Paper-API"
export LAST_EDIT=$(pwd)
"a" | "api")
export LAST_EDIT="$basedir/Paper-API"
cd "$basedir/Paper-API"
(
set -e
paperstash
git rebase -i upstream/upstream
paperunstash
)
;;
"continue")
cd "$LAST_EDIT"
"c" | "continue")
cd "$LAST_EDIT"
unset LAST_EDIT
(
set -e
git add .
git commit --amend
git rebase --continue
unset LAST_EDIT
(
cd "$basedir"
scripts/rebuildPatches.sh "$basedir"
)
cd "$basedir"
scripts/rebuildPatches.sh "$basedir"
)
;;
*)
echo "You must edit either the api or server."
@ -83,24 +105,40 @@ case "$1" in
;;
"setup")
if [[ -f ~/.bashrc ]] ; then
(grep "alias paper=" ~/.bashrc > /dev/null) && (sed -i "s|alias paper=.*|alias paper='. $SOURCE'|g" ~/.bashrc) || (echo "alias paper='. $SOURCE'" >> ~/.bashrc)
alias paper=". $SOURCE"
echo "You can now just type 'paper' at any time to access the paper tool."
NAME="paper"
if [[ ! -z "${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 paper tool."
fi
;;
*)
echo "rbp, rebuild | Rebuild patches, can be called from anywhere."
echo "p, patch | Apply all patches to the project without building it. Can be run from anywhere."
echo "j, jar | Apply all patches and build the project, paperclip.jar will be output. Can be run from anywhere."
echo "r, root | Change directory to the root of the project."
echo "api | Move to the Paper-API directory."
echo "serv, server | Move to the Paper-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 "setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
echo " | . ./paper setup"
echo " | After you run this command you'll be able to just run 'paper' from anywhere."
echo "PaperMC build tool command. This provides a variety of commands to build and manage the PaperMC 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 " * rbp, rebuild | Rebuild patches, can be called from anywhere."
echo " * p, patch | Apply all patches to the project without building it. Can be run from anywhere."
echo " * j, jar | Apply all patches and build the project, paperclip.jar will be output. Can be run from 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 Paper-API directory."
echo " * s, server | Move to the Paper-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 " | . ./paper setup"
echo " | After you run this command you'll be able to just run 'paper' from anywhere."
echo " | The default name for the resulting alias is 'paper', you can give an argument to override"
echo " | this default, such as:"
echo " | . ./paper setup example"
echo " | Which will allow you to run 'example' instead."
;;
esac

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
PS1="$"
basedir=$(realpath "$1")
workdir="$basedir/work"
@ -67,4 +69,4 @@ cd "$basedir"
echo "Failed to apply Paper Patches"
exit 1
) || exit 1
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
basedir=$(realpath "$1")
(git submodule update --init && ./scripts/remap.sh "$basedir" && ./scripts/decompile.sh "$basedir" && ./scripts/init.sh "$basedir" && ./scripts/applyPatches.sh "$basedir") || (
@ -7,5 +9,6 @@ basedir=$(realpath "$1")
exit 1
) || exit 1
if [ "$2" == "--jar" ]; then
(mvn clean install && ./scripts/paperclip.sh "$basedir") || exit 1
mvn clean install && ./scripts/paperclip.sh "$basedir"
fi
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
PS1="$"
basedir=$(realpath "$1")
workdir="$basedir/work"
@ -28,3 +30,4 @@ if [ ! -d "$decompiledir/net/minecraft/server" ]; then
exit 1
fi
fi
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
nms="net/minecraft/server"
export MODLOG=""
PS1="$"
@ -59,8 +61,7 @@ import PathfinderGoalFloat
import PersistentVillage
import TileEntityEnderChest
(
cd "$workdir/Spigot/Spigot-Server/"
git add src -A
echo -e "mc-dev Imports\n\n$MODLOG" | git commit src -F -
cd "$workdir/Spigot/Spigot-Server/"
git add src -A
echo -e "mc-dev Imports\n\n$MODLOG" | git commit src -F -
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
PS1="$"
basedir=$(realpath "$1")
workdir="$basedir/work"
@ -24,12 +26,15 @@ do
file="$(echo "$file" | cut -d. -f1).java"
echo "Patching $file < $patchFile"
set +e
sed -i 's/\r//' "$nms/$file" > /dev/null
set -e
cp "$nms/$file" "$cb/$file"
"$patch" -s -d src/main/java/ "net/minecraft/server/$file" < "$patchFile"
done
git add src >/dev/null 2>&1 || exit 1
git commit -m "CraftBukkit $ $(date)" >/dev/null 2>&1 || exit 1
git checkout -f HEAD^ >/dev/null 2>&1 || exit 1
git add src >/dev/null 2>&1
git commit -m "CraftBukkit $ $(date)" >/dev/null 2>&1
git checkout -f HEAD^ >/dev/null 2>&1
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
PS1="$"
basedir=$(realpath "$1")
@ -23,3 +25,4 @@ do
fi
done
echo "Built $decompiledir/src to be included in your project for src access";
)

View File

@ -1,4 +1,7 @@
#!/usr/bin/env bash
(
set -e
basedir=$(realpath "$1")
workdir="$basedir/work"
mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
@ -7,7 +10,7 @@ vanillajar="../$mcver/$mcver.jar"
(
cd "$workdir/Paperclip"
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar" || exit 1
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar"
)
cp "$workdir/Paperclip/target/paperclip-${mcver}.jar" "$basedir/paperclip.jar"
@ -16,3 +19,4 @@ echo ""
echo ""
echo "Build success!"
echo "Copied final jar to "$(realpath "$basedir/paperclip.jar")
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
PS1="$"
basedir=$(realpath "$1")
workdir="$basedir/work"
@ -15,7 +17,9 @@ function cleanupPatches {
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
if [ "x$testver" != "x" ]; then
set +e
diffs=$(echo "$diffs" | sed 'N;$!P;$!D;$d')
set -e
fi
if [ "x$diffs" == "x" ] ; then
@ -45,3 +49,4 @@ function savePatches {
savePatches "$workdir/Spigot/Spigot-API" "Paper-API"
savePatches "$workdir/Spigot/Spigot-Server" "Paper-Server"
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
PS1="$"
basedir=$(realpath "$1")
workdir="$basedir/work"
@ -68,3 +70,4 @@ if [ "$?" != "0" ]; then
echo "Failed to install remapped jar."
exit 1
fi
)

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
(
set -e
PS1="$"
basedir=$(realpath "$1")
workdir="$basedir/work"
@ -14,3 +16,4 @@ function update {
update Bukkit
update CraftBukkit
update Spigot
)