From 8b66d99e73cf865758e54b9a28d2abc04e912465 Mon Sep 17 00:00:00 2001 From: DemonWav Date: Fri, 1 Apr 2016 22:55:54 -0500 Subject: [PATCH 1/6] Cleanup and restructure the project --- .gitignore | 17 +++-- .gitmodules | 22 +++--- Paperclip | 1 - build.sh | 9 --- paperclip.sh | 15 ---- applyPatches.sh => scripts/applyPatches.sh | 24 ++++--- scripts/build.sh | 11 +++ decompile.sh => scripts/decompile.sh | 14 ++-- scripts/envSetup.sh | 70 +++++++++++++++++++ importmcdev.sh => scripts/importmcdev.sh | 14 ++-- init.sh => scripts/init.sh | 23 +++--- makemcdevsrc.sh => scripts/makemcdevsrc.sh | 16 ++--- scripts/paperclip.sh | 17 +++++ .../rebuildPatches.sh | 19 ++--- remap.sh => scripts/remap.sh | 28 ++++---- upstreamMerge.sh => scripts/upstreamMerge.sh | 7 +- BuildData => work/BuildData | 0 Bukkit => work/Bukkit | 0 CraftBukkit => work/CraftBukkit | 0 work/Paperclip | 1 + Spigot => work/Spigot | 0 21 files changed, 193 insertions(+), 115 deletions(-) delete mode 160000 Paperclip delete mode 100755 build.sh delete mode 100755 paperclip.sh rename applyPatches.sh => scripts/applyPatches.sh (78%) create mode 100755 scripts/build.sh rename decompile.sh => scripts/decompile.sh (60%) create mode 100644 scripts/envSetup.sh rename importmcdev.sh => scripts/importmcdev.sh (79%) rename init.sh => scripts/init.sh (57%) rename makemcdevsrc.sh => scripts/makemcdevsrc.sh (52%) create mode 100755 scripts/paperclip.sh rename rebuildPatches.sh => scripts/rebuildPatches.sh (65%) rename remap.sh => scripts/remap.sh (54%) rename upstreamMerge.sh => scripts/upstreamMerge.sh (66%) rename BuildData => work/BuildData (100%) rename Bukkit => work/Bukkit (100%) rename CraftBukkit => work/CraftBukkit (100%) create mode 160000 work/Paperclip rename Spigot => work/Spigot (100%) diff --git a/.gitignore b/.gitignore index 658890931..143c73b2a 100644 --- a/.gitignore +++ b/.gitignore @@ -22,7 +22,16 @@ build/ bin/ dist/ manifest.mf -work/ + +work/1.* +work/BuildData +work/Bukkit +work/CraftBukkit +work/Paperclip +work/Spigot +work/Spigot-Server +work/Spigot-API +work/*.jar # Mac filesystem dust .DS_Store/ @@ -37,15 +46,11 @@ work/ *~ # other stuff -Spigot-API -Spigot-Server + Paper-Server Paper-API PaperSpigot-Server PaperSpigot-API -Bukkit -CraftBukkit -Paperclip Paperclip.jar paperclip.jar paperclip-*.jar diff --git a/.gitmodules b/.gitmodules index f8d5e238f..758536e06 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,15 +1,15 @@ -[submodule "Bukkit"] - path = Bukkit +[submodule "work/Bukkit"] + path = work/Bukkit url = https://hub.spigotmc.org/stash/scm/spigot/bukkit.git -[submodule "CraftBukkit"] - path = CraftBukkit +[submodule "work/CraftBukkit"] + path = work/CraftBukkit url = https://hub.spigotmc.org/stash/scm/spigot/craftbukkit.git -[submodule "BuildData"] - path = BuildData +[submodule "work/BuildData"] + path = work/BuildData url = https://hub.spigotmc.org/stash/scm/spigot/builddata.git -[submodule "Paperclip"] - path = Paperclip - url = https://github.com/PaperMC/Paperclip.git -[submodule "Spigot"] - path = Spigot +[submodule "work/Spigot"] + path = work/Spigot url = https://hub.spigotmc.org/stash/scm/spigot/spigot.git +[submodule "work/Paperclip"] + path = work/Paperclip + url = https://github.com/PaperMC/Paperclip.git diff --git a/Paperclip b/Paperclip deleted file mode 160000 index 6bff72410..000000000 --- a/Paperclip +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 6bff72410effad0b2b0b0d8471a477f42bd484ff diff --git a/build.sh b/build.sh deleted file mode 100755 index 00eb9131e..000000000 --- a/build.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/bash - -(git submodule update --init && ./remap.sh && ./decompile.sh && ./init.sh && ./applyPatches.sh) || ( - echo "Failed to build Paper" - exit 1 -) || exit 1 -if [ "$1" == "--jar" ]; then - (mvn clean install && ./paperclip.sh) || exit 1 -fi diff --git a/paperclip.sh b/paperclip.sh deleted file mode 100755 index fe255bfa9..000000000 --- a/paperclip.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash -basedir=`pwd` -workdir=$basedir/work -mcver=$(cat BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) - -cd ./Paperclip -mvn clean package -cd .. -cp ./Paperclip/target/paperclip-${mcver}.jar ./paperclip.jar - -echo "" -echo "" -echo "" -echo "Build success!" -echo "Copied final jar to $(pwd)/paperclip.jar" diff --git a/applyPatches.sh b/scripts/applyPatches.sh similarity index 78% rename from applyPatches.sh rename to scripts/applyPatches.sh index 62b82e5b2..3c4d3a2a2 100755 --- a/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -1,12 +1,13 @@ -#!/bin/bash +#!/usr/bin/env bash PS1="$" -basedir=`pwd` +basedir="$1" +workdir="$basedir/work" echo "Rebuilding Forked projects.... " function applyPatch { what=$1 - what_name=$(basename $what) + what_name=$(basename "$what") target=$2 branch=$3 @@ -21,7 +22,7 @@ function applyPatch { cd "$basedir/$target" echo "Resetting $target to $what_name..." git remote rm upstream > /dev/null 2>&1 - git remote add upstream $basedir/$what >/dev/null 2>&1 + git remote add upstream "$basedir/$what" >/dev/null 2>&1 git checkout master 2>/dev/null || git checkout -b master git fetch upstream >/dev/null 2>&1 git reset --hard upstream/upstream @@ -39,8 +40,8 @@ function applyPatch { } # Move into spigot dir -pushd Spigot -basedir=$basedir/Spigot +cd "$workdir/Spigot" +basedir=$(pwd) # Apply Spigot ( applyPatch ../Bukkit Spigot-API HEAD && @@ -50,17 +51,18 @@ basedir=$basedir/Spigot exit 1 ) || exit 1 # Move out of Spigot -popd -basedir=$(dirname "$basedir") +basedir="$1" +cd "$basedir" echo "Importing MC Dev" -./importmcdev.sh +./scripts/importmcdev.sh "$basedir" # Apply paper +cd "$basedir" ( - applyPatch Spigot/Spigot-API Paper-API HEAD && - applyPatch Spigot/Spigot-Server Paper-Server HEAD + applyPatch "work/Spigot/Spigot-API" Paper-API HEAD && + applyPatch "work/Spigot/Spigot-Server" Paper-Server HEAD ) || ( echo "Failed to apply Paper Patches" exit 1 diff --git a/scripts/build.sh b/scripts/build.sh new file mode 100755 index 000000000..e5281754b --- /dev/null +++ b/scripts/build.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +basedir="$1" + +(git submodule update --init && ./scripts/remap.sh "$basedir" && ./scripts/decompile.sh "$basedir" && ./scripts/init.sh "$basedir" && ./scripts/applyPatches.sh "$basedir") || ( + echo "Failed to build Paper" + exit 1 +) || exit 1 +if [ "$2" == "--jar" ]; then + (mvn clean install && ./scripts/paperclip.sh "$basedir") || exit 1 +fi diff --git a/decompile.sh b/scripts/decompile.sh similarity index 60% rename from decompile.sh rename to scripts/decompile.sh index 81947e1c7..9dc969169 100755 --- a/decompile.sh +++ b/scripts/decompile.sh @@ -1,11 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash PS1="$" -basedir=`pwd` -workdir=$basedir/work -minecraftversion=$(cat BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) -decompiledir=$workdir/$minecraftversion -classdir=$decompiledir/classes +basedir="$1" +workdir="$basedir/work" +minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) +decompiledir="$workdir/$minecraftversion" +classdir="$decompiledir/classes" echo "Extracting NMS classes..." if [ ! -d "$classdir" ]; then @@ -22,7 +22,7 @@ fi echo "Decompiling classes..." if [ ! -d "$decompiledir/net/minecraft/server" ]; then cd "$basedir" - java -jar BuildData/bin/fernflower.jar -dgs=1 -hdc=0 -asc=1 -udv=0 "$classdir" "$decompiledir" + java -jar "$workdir/BuildData/bin/fernflower.jar" -dgs=1 -hdc=0 -asc=1 -udv=0 "$classdir" "$decompiledir" if [ "$?" != "0" ]; then echo "Failed to decompile classes." exit 1 diff --git a/scripts/envSetup.sh b/scripts/envSetup.sh new file mode 100644 index 000000000..b2cd3d61c --- /dev/null +++ b/scripts/envSetup.sh @@ -0,0 +1,70 @@ +#!/usr/bin/env bash + +# Set root project directory +CWD=$(pwd) + +rbp() { + NEW_CWD=$(pwd) + cd "$CWD" + scripts/rebuildPatches.sh "$CWD" + cd "$NEW_CWD" +} + +rebuildPatches() { + rbp +} + +lunch() { + NEW_CWD=$(pwd) + cd "$CWD" + + if [[ "$1" = "jar" ]] || [[ "$1" = "--jar" ]] ; then + ARG="--jar" + fi + + scripts/build.sh "$CWD" "$ARG" + ARG="" + + cd "$NEW_CWD" +} + +root() { + cd "$CWD" +} + +LAST_EDIT="" + +edit() { + if [[ "$1" = "server" ]] ; then + cd "$CWD/Paper-Server" + LAST_EDIT=$(pwd) + + stash + git rebase -i upstream/upstream + unstash + elif [[ "$1" = "api" ]] ; then + cd "$CWD/Paper-API" + LAST_EDIT=$(pwd) + + stash + git rebase -i upstream/upstream + unstash + elif [[ "$1" = "continue" ]] ; then + cd "$LAST_EDIT" + git add . + git commit --amend + git rebase --continue + else + echo "You must edit either the api or server." + fi +} + +stash() { + STASHED=$(git stash) +} + +unstash() { + if [[ "$STASHED" != "No local changes to save" ]] ; then + git stash pop + fi +} \ No newline at end of file diff --git a/importmcdev.sh b/scripts/importmcdev.sh similarity index 79% rename from importmcdev.sh rename to scripts/importmcdev.sh index 9900c11dc..829a5ea1a 100755 --- a/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -3,17 +3,17 @@ nms="net/minecraft/server" export MODLOG="" PS1="$" -basedir=`pwd` +basedir="$1" -workdir=$basedir/work -minecraftversion=$(cat BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) -decompiledir=$workdir/$minecraftversion +workdir="$basedir/work" +minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) +decompiledir="$workdir/$minecraftversion" export importedmcdev="" function import { export importedmcdev="$importedmcdev $1" file="${1}.java" - target="$basedir/Spigot/Spigot-Server/src/main/java/$nms/$file" + target="$workdir/Spigot/Spigot-Server/src/main/java/$nms/$file" base="$decompiledir/$nms/$file" if [[ ! -f "$target" ]]; then @@ -24,7 +24,7 @@ function import { } ( - cd Spigot/Spigot-Server/ + cd "$workdir/Spigot/Spigot-Server/" lastlog=$(git log -1 --oneline) if [[ "$lastlog" = *"mc-dev Imports"* ]]; then git reset --hard HEAD^ @@ -60,7 +60,7 @@ import PersistentVillage import TileEntityEnderChest ( - cd Spigot/Spigot-Server/ + cd "$workdir/Spigot/Spigot-Server/" git add src -A echo -e "mc-dev Imports\n\n$MODLOG" | git commit src -F - ) diff --git a/init.sh b/scripts/init.sh similarity index 57% rename from init.sh rename to scripts/init.sh index 95dc3b37c..af9b1b903 100755 --- a/init.sh +++ b/scripts/init.sh @@ -1,32 +1,27 @@ -#!/bin/bash +#!/usr/bin/env bash PS1="$" -basedir=`pwd` +basedir="$1" workdir="$basedir/work" -minecraftversion=$(cat BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) +minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) decompiledir="$workdir/$minecraftversion" nms="$decompiledir/net/minecraft/server" -cb=src/main/java/net/minecraft/server - -paperjar="Paper-Server/target/paper-${minecraftversion}.jar" -vanillajar="work/${minecraftversion}/${minecraftversion}.jar" - -echo -e "mcver=${minecraftversion}\npaperjar=../${paperjar}\nvanillajar=../${vanillajar}\n" > paperclip.properties +cb="src/main/java/net/minecraft/server" patch=$(which patch 2>/dev/null) if [ "x$patch" == "x" ]; then - patch=$basedir/hctap.exe + patch="$basedir/hctap.exe" fi echo "Applying CraftBukkit patches to NMS..." -cd "$basedir/CraftBukkit" +cd "$workdir/CraftBukkit" git checkout -B patched HEAD >/dev/null 2>&1 -rm -rf $cb -mkdir -p $cb +rm -rf "$cb" +mkdir -p "$cb" for file in $(ls nms-patches) do patchFile="nms-patches/$file" - file="$(echo $file | cut -d. -f1).java" + file="$(echo "$file" | cut -d. -f1).java" echo "Patching $file < $patchFile" sed -i 's/\r//' "$nms/$file" > /dev/null diff --git a/makemcdevsrc.sh b/scripts/makemcdevsrc.sh similarity index 52% rename from makemcdevsrc.sh rename to scripts/makemcdevsrc.sh index 375127b05..b5ea7daea 100755 --- a/makemcdevsrc.sh +++ b/scripts/makemcdevsrc.sh @@ -1,14 +1,14 @@ -#!/bin/bash +#!/usr/bin/env bash PS1="$" -workdir=work -minecraftversion=$(cat BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) -decompiledir=$workdir/$minecraftversion -nms=$decompiledir/net/minecraft/server -cb=src/main/java/net/minecraft/server -papernms=Paper-Server/src/main/java/net/minecraft/server -mcdevsrc=${decompiledir}/src/net/minecraft/server +basedir="$1" +workdir="$basedir/work" +minecraftversion=$(cat "$basedir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) +decompiledir="$workdir/$minecraftversion" +nms="$decompiledir/net/minecraft/server" +papernms="Paper-Server/src/main/java/net/minecraft/server" +mcdevsrc="${decompiledir}/src/net/minecraft/server" rm -rf "${mcdevsrc}" mkdir -p "${mcdevsrc}" cp ${nms}/*.java "${mcdevsrc}/" diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh new file mode 100755 index 000000000..9840f3c94 --- /dev/null +++ b/scripts/paperclip.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +basedir="$1" +workdir="$basedir/work" +mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) +paperjar="../../Paper-Server/target/paper-$mcver.jar" +vanillajar="../$mcver/$mcver.jar" + +cd "$workdir/Paperclip" +mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar" +cd .. +cp "$workdir/Paperclip/target/paperclip-${mcver}.jar" "$basedir/paperclip.jar" + +echo "" +echo "" +echo "" +echo "Build success!" +echo "Copied final jar to $basedir/paperclip.jar" diff --git a/rebuildPatches.sh b/scripts/rebuildPatches.sh similarity index 65% rename from rebuildPatches.sh rename to scripts/rebuildPatches.sh index 003269f6a..6416e42e8 100755 --- a/rebuildPatches.sh +++ b/scripts/rebuildPatches.sh @@ -1,7 +1,8 @@ -#!/bin/bash +#!/usr/bin/env bash PS1="$" -basedir=`pwd` +basedir="$1" +workdir="$basedir/work" echo "Rebuilding patch files from current fork state..." git config core.safecrlf false @@ -9,8 +10,8 @@ function cleanupPatches { cd "$1" for patch in *.patch; do echo "$patch" - gitver=$(tail -n 2 $patch | grep -ve "^$" | tail -n 1) - diffs=$(git diff --staged $patch | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index)") + gitver=$(tail -n 2 "$patch" | grep -ve "^$" | tail -n 1) + diffs=$(git diff --staged "$patch" | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index)") testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver") if [ "x$testver" != "x" ]; then @@ -18,15 +19,15 @@ function cleanupPatches { fi if [ "x$diffs" == "x" ] ; then - git reset HEAD $patch >/dev/null - git checkout -- $patch >/dev/null + git reset HEAD "$patch" >/dev/null + git checkout -- "$patch" >/dev/null fi done } function savePatches { what=$1 - what_name=$(basename $what) + what_name=$(basename "$what") target=$2 echo "Formatting patches for $what..." @@ -42,5 +43,5 @@ function savePatches { echo " Patches saved for $what to $what_name-Patches/" } -savePatches Spigot/Spigot-API Paper-API -savePatches Spigot/Spigot-Server Paper-Server +savePatches "$workdir/Spigot/Spigot-API" "Paper-API" +savePatches "$workdir/Spigot/Spigot-Server" "Paper-Server" diff --git a/remap.sh b/scripts/remap.sh similarity index 54% rename from remap.sh rename to scripts/remap.sh index 3bd79f3ba..abfde02e6 100755 --- a/remap.sh +++ b/scripts/remap.sh @@ -1,15 +1,15 @@ -#!/bin/bash +#!/usr/bin/env bash PS1="$" -basedir=`pwd` -workdir=$basedir/work -minecraftversion=$(cat BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) -minecrafthash=$(cat BuildData/info.json | grep minecraftHash | cut -d '"' -f 4) -accesstransforms=BuildData/mappings/$(cat BuildData/info.json | grep accessTransforms | cut -d '"' -f 4) -classmappings=BuildData/mappings/$(cat BuildData/info.json | grep classMappings | cut -d '"' -f 4) -membermappings=BuildData/mappings/$(cat BuildData/info.json | grep memberMappings | cut -d '"' -f 4) -packagemappings=BuildData/mappings/$(cat BuildData/info.json | grep packageMappings | cut -d '"' -f 4) -jarpath=$workdir/$minecraftversion/$minecraftversion +basedir="$1" +workdir="$basedir/work" +minecraftversion=$(cat ${workdir}/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) +minecrafthash=$(cat ${workdir}/BuildData/info.json | grep minecraftHash | cut -d '"' -f 4) +accesstransforms="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep accessTransforms | cut -d '"' -f 4) +classmappings="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep classMappings | cut -d '"' -f 4) +membermappings="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep memberMappings | cut -d '"' -f 4) +packagemappings="$workdir/BuildData/mappings/"$(cat ${workdir}/BuildData/info.json | grep packageMappings | cut -d '"' -f 4) +jarpath="$workdir/$minecraftversion/$minecraftversion" echo "Downloading unmapped vanilla jar..." if [ ! -f "$jarpath.jar" ]; then @@ -36,7 +36,7 @@ fi echo "Applying class mappings..." if [ ! -f "$jarpath-cl.jar" ]; then - java -jar BuildData/bin/SpecialSource-2.jar map -i "$jarpath.jar" -m "$classmappings" -o "$jarpath-cl.jar" 1>/dev/null + java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map -i "$jarpath.jar" -m "$classmappings" -o "$jarpath-cl.jar" 1>/dev/null if [ "$?" != "0" ]; then echo "Failed to apply class mappings." exit 1 @@ -45,7 +45,7 @@ fi echo "Applying member mappings..." if [ ! -f "$jarpath-m.jar" ]; then - java -jar BuildData/bin/SpecialSource-2.jar map -i "$jarpath-cl.jar" -m "$membermappings" -o "$jarpath-m.jar" 1>/dev/null + java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map -i "$jarpath-cl.jar" -m "$membermappings" -o "$jarpath-m.jar" 1>/dev/null if [ "$?" != "0" ]; then echo "Failed to apply member mappings." exit 1 @@ -54,7 +54,7 @@ fi echo "Creating remapped jar..." if [ ! -f "$jarpath-mapped.jar" ]; then - java -jar BuildData/bin/SpecialSource.jar --kill-lvt -i "$jarpath-m.jar" --access-transformer "$accesstransforms" -m "$packagemappings" -o "$jarpath-mapped.jar" 1>/dev/null + java -jar "$workdir/BuildData/bin/SpecialSource.jar" --kill-lvt -i "$jarpath-m.jar" --access-transformer "$accesstransforms" -m "$packagemappings" -o "$jarpath-mapped.jar" 1>/dev/null if [ "$?" != "0" ]; then echo "Failed to create remapped jar." exit 1 @@ -62,7 +62,7 @@ if [ ! -f "$jarpath-mapped.jar" ]; then fi echo "Installing remapped jar..." -cd CraftBukkit # Need to be in a directory with a valid POM at the time of install. +cd "$workdir/CraftBukkit" # Need to be in a directory with a valid POM at the time of install. mvn install:install-file -q -Dfile="$jarpath-mapped.jar" -Dpackaging=jar -DgroupId=org.spigotmc -DartifactId=minecraft-server -Dversion="$minecraftversion-SNAPSHOT" if [ "$?" != "0" ]; then echo "Failed to install remapped jar." diff --git a/upstreamMerge.sh b/scripts/upstreamMerge.sh similarity index 66% rename from upstreamMerge.sh rename to scripts/upstreamMerge.sh index c3d5db20a..16dfaf48d 100755 --- a/upstreamMerge.sh +++ b/scripts/upstreamMerge.sh @@ -1,10 +1,11 @@ -#!/bin/bash +#!/usr/bin/env bash PS1="$" -basedir=`pwd` +basedir="$1" +workdir="$basedir/work" function update { - cd "$basedir/$1" + cd "$workdir/$1" git fetch && git reset --hard origin/master cd ../ git add $1 diff --git a/BuildData b/work/BuildData similarity index 100% rename from BuildData rename to work/BuildData diff --git a/Bukkit b/work/Bukkit similarity index 100% rename from Bukkit rename to work/Bukkit diff --git a/CraftBukkit b/work/CraftBukkit similarity index 100% rename from CraftBukkit rename to work/CraftBukkit diff --git a/work/Paperclip b/work/Paperclip new file mode 160000 index 000000000..1fb6fefbe --- /dev/null +++ b/work/Paperclip @@ -0,0 +1 @@ +Subproject commit 1fb6fefbe36461552cd263092d7700a57bb1f7c3 diff --git a/Spigot b/work/Spigot similarity index 100% rename from Spigot rename to work/Spigot From 5479e7ab804ad75bd4b75b276e7599cd0734b1db Mon Sep 17 00:00:00 2001 From: DemonWav Date: Fri, 1 Apr 2016 23:20:56 -0500 Subject: [PATCH 2/6] Update Paperclip --- work/Paperclip | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/work/Paperclip b/work/Paperclip index 1fb6fefbe..90e566f21 160000 --- a/work/Paperclip +++ b/work/Paperclip @@ -1 +1 @@ -Subproject commit 1fb6fefbe36461552cd263092d7700a57bb1f7c3 +Subproject commit 90e566f21456fb83ba33a8910ee99c2e426c6de7 From 51af958804e8b3151ec0bf167febc74aa1eb3c2d Mon Sep 17 00:00:00 2001 From: DemonWav Date: Sat, 2 Apr 2016 00:01:58 -0500 Subject: [PATCH 3/6] New paper command runner --- paper | 100 +++++++++++++++++++++++++++++++++++++++++++ scripts/envSetup.sh | 70 ------------------------------ scripts/paperclip.sh | 2 +- 3 files changed, 101 insertions(+), 71 deletions(-) create mode 100755 paper delete mode 100644 scripts/envSetup.sh diff --git a/paper b/paper new file mode 100755 index 000000000..bac5d89e6 --- /dev/null +++ b/paper @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +# 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 +done +SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}") +basedir=$(dirname "$SOURCE") + +paperstash() { + STASHED=$(git stash) +} + +paperunstash() { + if [[ "$STASHED" != "No local changes to save" ]] ; then + git stash pop + fi +} + +case "$1" in + "rbp" | "rebuild") + ( + cd "$basedir" + scripts/rebuildPatches.sh "$basedir" + ) + ;; + "a" | "apply") + ( + cd "$basedir" + scripts/build.sh "$basedir" + ) + ;; + "j" | "jar") + ( + cd "$basedir" + scripts/build.sh "$basedir" "--jar" + ) + ;; + "r" | "root") + cd "$basedir" + ;; + "api") + cd "$basedir/Paper-API" + ;; + "serv" | "server") + cd "$basedir" + ;; + "e" | "edit") + if [[ "$2" = "server" ]] ; then + cd "$basedir/Paper-Server" + export LAST_EDIT=$(pwd) + + paperstash + git rebase -i upstream/upstream + paperunstash + elif [[ "$2" = "api" ]] ; then + cd "$basedir/Paper-API" + export LAST_EDIT=$(pwd) + + paperstash + git rebase -i upstream/upstream + paperunstash + elif [[ "$2" = "continue" ]] ; then + cd "$LAST_EDIT" + git add . + git rebase --continue + unset LAST_EDIT + scripts/rebuildPatches.sh "$basedir" + else + echo "You must edit either the api or server." + fi + ;; + "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." + 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." + ;; +esac + +unset -f paperstash +unset -f paperunstash diff --git a/scripts/envSetup.sh b/scripts/envSetup.sh deleted file mode 100644 index b2cd3d61c..000000000 --- a/scripts/envSetup.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -# Set root project directory -CWD=$(pwd) - -rbp() { - NEW_CWD=$(pwd) - cd "$CWD" - scripts/rebuildPatches.sh "$CWD" - cd "$NEW_CWD" -} - -rebuildPatches() { - rbp -} - -lunch() { - NEW_CWD=$(pwd) - cd "$CWD" - - if [[ "$1" = "jar" ]] || [[ "$1" = "--jar" ]] ; then - ARG="--jar" - fi - - scripts/build.sh "$CWD" "$ARG" - ARG="" - - cd "$NEW_CWD" -} - -root() { - cd "$CWD" -} - -LAST_EDIT="" - -edit() { - if [[ "$1" = "server" ]] ; then - cd "$CWD/Paper-Server" - LAST_EDIT=$(pwd) - - stash - git rebase -i upstream/upstream - unstash - elif [[ "$1" = "api" ]] ; then - cd "$CWD/Paper-API" - LAST_EDIT=$(pwd) - - stash - git rebase -i upstream/upstream - unstash - elif [[ "$1" = "continue" ]] ; then - cd "$LAST_EDIT" - git add . - git commit --amend - git rebase --continue - else - echo "You must edit either the api or server." - fi -} - -stash() { - STASHED=$(git stash) -} - -unstash() { - if [[ "$STASHED" != "No local changes to save" ]] ; then - git stash pop - fi -} \ No newline at end of file diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh index 9840f3c94..4be65ac26 100755 --- a/scripts/paperclip.sh +++ b/scripts/paperclip.sh @@ -6,7 +6,7 @@ paperjar="../../Paper-Server/target/paper-$mcver.jar" vanillajar="../$mcver/$mcver.jar" cd "$workdir/Paperclip" -mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar" +mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar" || exit 1 cd .. cp "$workdir/Paperclip/target/paperclip-${mcver}.jar" "$basedir/paperclip.jar" From 7effde04b101e875c050904b4852816d3c44f10a Mon Sep 17 00:00:00 2001 From: DemonWav Date: Sat, 2 Apr 2016 18:34:27 -0500 Subject: [PATCH 4/6] Rebuild patches after we continue from a paper edit. --- paper | 50 +++++++++++++++++++++++---------------- scripts/applyPatches.sh | 2 +- scripts/build.sh | 2 +- scripts/decompile.sh | 2 +- scripts/importmcdev.sh | 2 +- scripts/init.sh | 2 +- scripts/makemcdevsrc.sh | 2 +- scripts/paperclip.sh | 11 +++++---- scripts/rebuildPatches.sh | 2 +- scripts/remap.sh | 2 +- scripts/upstreamMerge.sh | 2 +- 11 files changed, 44 insertions(+), 35 deletions(-) diff --git a/paper b/paper index bac5d89e6..9d0e260c3 100755 --- a/paper +++ b/paper @@ -49,29 +49,37 @@ case "$1" in cd "$basedir" ;; "e" | "edit") - if [[ "$2" = "server" ]] ; then - cd "$basedir/Paper-Server" - export LAST_EDIT=$(pwd) + case "$2" in + "server") + cd "$basedir/Paper-Server" + export LAST_EDIT=$(pwd) - paperstash - git rebase -i upstream/upstream - paperunstash - elif [[ "$2" = "api" ]] ; then - cd "$basedir/Paper-API" - export LAST_EDIT=$(pwd) + paperstash + git rebase -i upstream/upstream + paperunstash + ;; + "api") + cd "$basedir/Paper-API" + export LAST_EDIT=$(pwd) - paperstash - git rebase -i upstream/upstream - paperunstash - elif [[ "$2" = "continue" ]] ; then - cd "$LAST_EDIT" - git add . - git rebase --continue - unset LAST_EDIT - scripts/rebuildPatches.sh "$basedir" - else - echo "You must edit either the api or server." - fi + paperstash + git rebase -i upstream/upstream + paperunstash + ;; + "continue") + cd "$LAST_EDIT" + git add . + git rebase --continue + unset LAST_EDIT + ( + cd "$basedir" + scripts/rebuildPatches.sh "$basedir" + ) + ;; + *) + echo "You must edit either the api or server." + ;; + esac ;; "setup") if [[ -f ~/.bashrc ]] ; then diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index 3c4d3a2a2..ef40406c9 100755 --- a/scripts/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" echo "Rebuilding Forked projects.... " diff --git a/scripts/build.sh b/scripts/build.sh index e5281754b..4fee2815d 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -basedir="$1" +basedir=$(realpath "$1") (git submodule update --init && ./scripts/remap.sh "$basedir" && ./scripts/decompile.sh "$basedir" && ./scripts/init.sh "$basedir" && ./scripts/applyPatches.sh "$basedir") || ( echo "Failed to build Paper" diff --git a/scripts/decompile.sh b/scripts/decompile.sh index 9dc969169..7acd0a881 100755 --- a/scripts/decompile.sh +++ b/scripts/decompile.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) decompiledir="$workdir/$minecraftversion" diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 829a5ea1a..e95d06deb 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -3,7 +3,7 @@ nms="net/minecraft/server" export MODLOG="" PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) diff --git a/scripts/init.sh b/scripts/init.sh index af9b1b903..e2f3354c8 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) decompiledir="$workdir/$minecraftversion" diff --git a/scripts/makemcdevsrc.sh b/scripts/makemcdevsrc.sh index b5ea7daea..a689356c4 100755 --- a/scripts/makemcdevsrc.sh +++ b/scripts/makemcdevsrc.sh @@ -2,7 +2,7 @@ PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" minecraftversion=$(cat "$basedir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) decompiledir="$workdir/$minecraftversion" diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh index 4be65ac26..0e2a4e80b 100755 --- a/scripts/paperclip.sh +++ b/scripts/paperclip.sh @@ -1,17 +1,18 @@ #!/usr/bin/env bash -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) paperjar="../../Paper-Server/target/paper-$mcver.jar" vanillajar="../$mcver/$mcver.jar" -cd "$workdir/Paperclip" -mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar" || exit 1 -cd .. +( + cd "$workdir/Paperclip" + mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar" || exit 1 +) cp "$workdir/Paperclip/target/paperclip-${mcver}.jar" "$basedir/paperclip.jar" echo "" echo "" echo "" echo "Build success!" -echo "Copied final jar to $basedir/paperclip.jar" +echo "Copied final jar to "$(realpath "$basedir/paperclip.jar") diff --git a/scripts/rebuildPatches.sh b/scripts/rebuildPatches.sh index 6416e42e8..f4848b208 100755 --- a/scripts/rebuildPatches.sh +++ b/scripts/rebuildPatches.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" echo "Rebuilding patch files from current fork state..." git config core.safecrlf false diff --git a/scripts/remap.sh b/scripts/remap.sh index abfde02e6..8e6b21ad1 100755 --- a/scripts/remap.sh +++ b/scripts/remap.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" minecraftversion=$(cat ${workdir}/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecrafthash=$(cat ${workdir}/BuildData/info.json | grep minecraftHash | cut -d '"' -f 4) diff --git a/scripts/upstreamMerge.sh b/scripts/upstreamMerge.sh index 16dfaf48d..7b3620507 100755 --- a/scripts/upstreamMerge.sh +++ b/scripts/upstreamMerge.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash PS1="$" -basedir="$1" +basedir=$(realpath "$1") workdir="$basedir/work" function update { From 0394633734e7ec8bffe9cf7d042105c016a19e1b Mon Sep 17 00:00:00 2001 From: DemonWav Date: Sun, 3 Apr 2016 02:23:19 -0500 Subject: [PATCH 5/6] Use `set -e` to handle errors better in the build scripts --- paper | 114 +++++++++++++++++++++++++------------- scripts/applyPatches.sh | 4 +- scripts/build.sh | 5 +- scripts/decompile.sh | 3 + scripts/importmcdev.sh | 9 +-- scripts/init.sh | 11 +++- scripts/makemcdevsrc.sh | 3 + scripts/paperclip.sh | 6 +- scripts/rebuildPatches.sh | 5 ++ scripts/remap.sh | 3 + scripts/upstreamMerge.sh | 3 + 11 files changed, 118 insertions(+), 48 deletions(-) diff --git a/paper b/paper index 9d0e260c3..340acf43d 100755 --- a/paper +++ b/paper @@ -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 diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index ef40406c9..697cec183 100755 --- a/scripts/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -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 - +) diff --git a/scripts/build.sh b/scripts/build.sh index 4fee2815d..606668748 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -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 +) diff --git a/scripts/decompile.sh b/scripts/decompile.sh index 7acd0a881..2e6cd50d3 100755 --- a/scripts/decompile.sh +++ b/scripts/decompile.sh @@ -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 +) diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index e95d06deb..95cf07547 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -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 - ) diff --git a/scripts/init.sh b/scripts/init.sh index e2f3354c8..cf66b387b 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -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 +) diff --git a/scripts/makemcdevsrc.sh b/scripts/makemcdevsrc.sh index a689356c4..cbe17f920 100755 --- a/scripts/makemcdevsrc.sh +++ b/scripts/makemcdevsrc.sh @@ -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"; +) diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh index 0e2a4e80b..c8d55bd84 100755 --- a/scripts/paperclip.sh +++ b/scripts/paperclip.sh @@ -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") +) diff --git a/scripts/rebuildPatches.sh b/scripts/rebuildPatches.sh index f4848b208..af7ed88f0 100755 --- a/scripts/rebuildPatches.sh +++ b/scripts/rebuildPatches.sh @@ -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" +) diff --git a/scripts/remap.sh b/scripts/remap.sh index 8e6b21ad1..a5200a915 100755 --- a/scripts/remap.sh +++ b/scripts/remap.sh @@ -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 +) diff --git a/scripts/upstreamMerge.sh b/scripts/upstreamMerge.sh index 7b3620507..77781b302 100755 --- a/scripts/upstreamMerge.sh +++ b/scripts/upstreamMerge.sh @@ -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 +) From 4108dc5b6881973a946e1b02f203a10e5c2220e1 Mon Sep 17 00:00:00 2001 From: DemonWav Date: Sun, 3 Apr 2016 03:35:51 -0500 Subject: [PATCH 6/6] Workaround for OSX not having the realpath command. --- scripts/applyPatches.sh | 2 +- scripts/build.sh | 2 +- scripts/decompile.sh | 2 +- scripts/importmcdev.sh | 2 +- scripts/init.sh | 2 +- scripts/makemcdevsrc.sh | 2 +- scripts/paperclip.sh | 4 ++-- scripts/rebuildPatches.sh | 2 +- scripts/remap.sh | 2 +- scripts/upstreamMerge.sh | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh index 697cec183..d4ab2fbef 100755 --- a/scripts/applyPatches.sh +++ b/scripts/applyPatches.sh @@ -3,7 +3,7 @@ ( set -e PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" echo "Rebuilding Forked projects.... " diff --git a/scripts/build.sh b/scripts/build.sh index 606668748..0d0827982 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,7 +2,7 @@ ( set -e -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" (git submodule update --init && ./scripts/remap.sh "$basedir" && ./scripts/decompile.sh "$basedir" && ./scripts/init.sh "$basedir" && ./scripts/applyPatches.sh "$basedir") || ( echo "Failed to build Paper" diff --git a/scripts/decompile.sh b/scripts/decompile.sh index 2e6cd50d3..e56736beb 100755 --- a/scripts/decompile.sh +++ b/scripts/decompile.sh @@ -3,7 +3,7 @@ ( set -e PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) decompiledir="$workdir/$minecraftversion" diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh index 95cf07547..398e9a740 100755 --- a/scripts/importmcdev.sh +++ b/scripts/importmcdev.sh @@ -5,7 +5,7 @@ set -e nms="net/minecraft/server" export MODLOG="" PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) diff --git a/scripts/init.sh b/scripts/init.sh index cf66b387b..51110efb7 100755 --- a/scripts/init.sh +++ b/scripts/init.sh @@ -3,7 +3,7 @@ ( set -e PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) decompiledir="$workdir/$minecraftversion" diff --git a/scripts/makemcdevsrc.sh b/scripts/makemcdevsrc.sh index cbe17f920..a83515abe 100755 --- a/scripts/makemcdevsrc.sh +++ b/scripts/makemcdevsrc.sh @@ -4,7 +4,7 @@ set -e PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" minecraftversion=$(cat "$basedir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) decompiledir="$workdir/$minecraftversion" diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh index c8d55bd84..071fe06cc 100755 --- a/scripts/paperclip.sh +++ b/scripts/paperclip.sh @@ -2,7 +2,7 @@ ( set -e -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) paperjar="../../Paper-Server/target/paper-$mcver.jar" @@ -18,5 +18,5 @@ echo "" echo "" echo "" echo "Build success!" -echo "Copied final jar to "$(realpath "$basedir/paperclip.jar") +echo "Copied final jar to $(cd "$basedir" && pwd -P)/paperclip.jar" ) diff --git a/scripts/rebuildPatches.sh b/scripts/rebuildPatches.sh index af7ed88f0..0bc21a87a 100755 --- a/scripts/rebuildPatches.sh +++ b/scripts/rebuildPatches.sh @@ -3,7 +3,7 @@ ( set -e PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" echo "Rebuilding patch files from current fork state..." git config core.safecrlf false diff --git a/scripts/remap.sh b/scripts/remap.sh index a5200a915..5bccafb0c 100755 --- a/scripts/remap.sh +++ b/scripts/remap.sh @@ -3,7 +3,7 @@ ( set -e PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" minecraftversion=$(cat ${workdir}/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecrafthash=$(cat ${workdir}/BuildData/info.json | grep minecraftHash | cut -d '"' -f 4) diff --git a/scripts/upstreamMerge.sh b/scripts/upstreamMerge.sh index 77781b302..9b05f170e 100755 --- a/scripts/upstreamMerge.sh +++ b/scripts/upstreamMerge.sh @@ -3,7 +3,7 @@ ( set -e PS1="$" -basedir=$(realpath "$1") +basedir="$(cd "$1" && pwd -P)" workdir="$basedir/work" function update {