Update scripts

This commit is contained in:
William Blake Galbreath
2020-03-27 01:36:19 -05:00
parent 8abc38c01d
commit d748256635
10 changed files with 306 additions and 350 deletions

139
purpur
View File

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

View File

@@ -22,69 +22,69 @@ while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symli
SOURCE="$(readlink "$SOURCE")" 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 [[ "$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 done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
PS1="$" PS1="$"
paperVer=$(cat current-paper) paperVer=$(cat current-paper)
gpgsign="$(git config commit.gpgsign || echo "false")" gpgsign="$(git config commit.gpgsign || echo "false")"
echo "Rebuilding Forked projects.... " echo "Rebuilding Forked projects.... "
function applyPatch { function applyPatch {
what=$1 what=$1
what_name=$(basename $what) what_name=$(basename "$what")
target=$2 target=$2
branch=$3 branch=$3
patch_folder=$4 patch_folder=$4
cd "$basedir/$what" cd "$basedir/$what" || exit
git fetch --all git fetch --all
git branch -f upstream "$branch" >/dev/null git branch -f upstream "$branch" >/dev/null
cd "$basedir" cd "$basedir" || exit
if [ ! -d "$basedir/$target" ]; then if [ ! -d "$basedir/$target" ]; then
mkdir "$basedir/$target" mkdir "$basedir/$target"
cd "$basedir/$target" cd "$basedir/$target" || exit
git init git init
git remote add origin $5 git remote add origin "$5"
cd "$basedir" cd "$basedir" || exit
fi fi
cd "$basedir/$target" cd "$basedir/$target" || exit
# Disable GPG signing before AM, slows things down and doesn't play nicely. # Disable GPG signing before AM, slows things down and doesn't play nicely.
# There is also zero rational or logical reason to do so for these sub-repo AMs. # There is also zero rational or logical reason to do so for these sub-repo AMs.
# Calm down kids, it's re-enabled (if needed) immediately after, pass or fail. # Calm down kids, it's re-enabled (if needed) immediately after, pass or fail.
git config commit.gpgsign false git config commit.gpgsign false
echo "Resetting $target to $what_name..." echo "Resetting $target to $what_name..."
git remote rm upstream > /dev/null 2>&1 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 checkout master 2>/dev/null || git checkout -b master
git fetch upstream >/dev/null 2>&1 git fetch upstream >/dev/null 2>&1
git reset --hard upstream/upstream git reset --hard upstream/upstream
echo " Applying patches to $target..." echo " Applying patches to $target..."
git am --abort >/dev/null 2>&1 git am --abort >/dev/null 2>&1
git am --3way --ignore-whitespace "$basedir/patches/$patch_folder/"*.patch git am --3way --ignore-whitespace "$basedir/patches/$patch_folder/"*.patch
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
echo " Something did not apply cleanly to $target." echo " Something did not apply cleanly to $target."
echo " Please review above details and finish the apply then" echo " Please review above details and finish the apply then"
echo " save the changes with rebuildPatches.sh" echo " save the changes with rebuildPatches.sh"
exit 1 exit 1
else else
echo " Patches applied cleanly to $target" echo " Patches applied cleanly to $target"
fi fi
} }
function enableCommitSigningIfNeeded { function enableCommitSigningIfNeeded {
if [[ "$gpgsign" == "true" ]]; then if [[ "$gpgsign" == "true" ]]; then
git config commit.gpgsign true git config commit.gpgsign true
fi fi
} }
( (
(applyPatch Paper/Paper-API ${FORK_NAME}-API HEAD api $API_REPO && (applyPatch Paper/Paper-API Purpur-API HEAD api "$API_REPO" &&
applyPatch Paper/Paper-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO) || exit 1 applyPatch Paper/Paper-Server Purpur-Server HEAD server "$SERVER_REPO") || exit 1
enableCommitSigningIfNeeded enableCommitSigningIfNeeded
) || ( ) || (
echo "Failed to apply patches" echo "Failed to apply patches"
enableCommitSigningIfNeeded enableCommitSigningIfNeeded
exit 1 exit 1
) || exit 1 ) || exit 1

View File

@@ -2,39 +2,36 @@
SOURCE="${BASH_SOURCE[0]}" SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")" 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 [[ $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 done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
cd "$basedir" || exit
cd $basedir
paperVer=$(cat current-paper) paperVer=$(cat current-paper)
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4)
decompile="Paper/work/Minecraft/$minecraftversion/spigot" decompile="Paper/work/Minecraft/$minecraftversion/spigot"
mkdir -p mc-dev/src/net/minecraft/server mkdir -p mc-dev/src/net/minecraft/server
cd mc-dev cd mc-dev || exit
if [ ! -d ".git" ]; then if [ ! -d ".git" ]; then
git init git init
fi fi
rm src/net/minecraft/server/*.java rm src/net/minecraft/server/*.java
cp $basedir/$decompile/net/minecraft/server/*.java src/net/minecraft/server cp "$basedir"/"$decompile"/net/minecraft/server/*.java src/net/minecraft/server
base="$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server" base="$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server"
cd $basedir/mc-dev/src/net/minecraft/server/ cd "$basedir"/mc-dev/src/net/minecraft/server/ || exit
for file in $(/bin/ls $base) for file in $(/bin/ls "$base"); do
do if [ -f "$file" ]; then
if [ -f "$file" ]; then rm -f "$file"
rm -f "$file" fi
fi
done done
cd $basedir/mc-dev cd "$basedir"/mc-dev || exit
git add . -A git add . -A
git commit . -m "mc-dev" git commit . -m "mc-dev"
git tag -a "$paperVer" -m "$paperVer" 2>/dev/null git tag -a "$paperVer" -m "$paperVer" 2>/dev/null
pushRepo . $MCDEV_REPO $paperVer

View File

@@ -2,72 +2,71 @@
SOURCE="${BASH_SOURCE[0]}" SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")" 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 [[ $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 done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
workdir=$basedir/Paper/work workdir=$basedir/Paper/work
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4)
decompiledir=$workdir/Minecraft/$minecraftversion/spigot decompiledir=$workdir/Minecraft/$minecraftversion/spigot
nms="net/minecraft/server" nms="net/minecraft/server"
export MODLOG="" export MODLOG=""
cd $basedir cd "$basedir" || exit
function containsElement { function containsElement() {
local e local e
for e in "${@:2}"; do for e in "${@:2}"; do
[[ "$e" == "$1" ]] && return 0; [[ "$e" == "$1" ]] && return 0
done done
return 1 return 1
} }
export importedmcdev="" export importedmcdev=""
function import { function import() {
if [ -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$1.java" ]; then if [ -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$1.java" ]; then
echo "ALREADY IMPORTED $1" echo "ALREADY IMPORTED $1"
return 0 return 0
fi fi
export importedmcdev="$importedmcdev $1" export importedmcdev="$importedmcdev $1"
file="${1}.java" file="${1}.java"
target="$basedir/Paper/Paper-Server/src/main/java/$nms/$file" target="$basedir/Paper/Paper-Server/src/main/java/$nms/$file"
base="$decompiledir/$nms/$file" base="$decompiledir/$nms/$file"
if [[ ! -f "$target" ]]; then if [[ ! -f "$target" ]]; then
export MODLOG="$MODLOG Imported $file from mc-dev\n"; export MODLOG="$MODLOG Imported $file from mc-dev\n"
echo "$(bashColor 1 32) Copying $(bashColor 1 34)$base $(bashColor 1 32)to$(bashColor 1 34) $target $(bashColorReset)" echo "$(bashColor 1 32) Copying $(bashColor 1 34)$base $(bashColor 1 32)to$(bashColor 1 34) $target $(bashColorReset)"
cp "$base" "$target" cp "$base" "$target"
else else
echo "$(bashColor 1 33) UN-NEEDED IMPORT STATEMENT:$(bashColor 1 34) $file $(bashColorReset)" echo "$(bashColor 1 33) UN-NEEDED IMPORT STATEMENT:$(bashColor 1 34) $file $(bashColorReset)"
fi fi
} }
( (
cd Paper/Paper-Server/ cd Paper/Paper-Server/ || exit
lastlog=$(git log -1 --oneline) lastlog=$(git log -1 --oneline)
if [[ "$lastlog" = *"Purpur-Extra mc-dev Imports"* ]]; then if [[ "$lastlog" == *"Purpur-Extra mc-dev Imports"* ]]; then
git reset --hard HEAD^ git reset --hard HEAD^
fi fi
) )
files=$(cat patches/server/* | grep "+++ b/src/main/java/net/minecraft/server/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') files=$(cat patches/server/* | grep "+++ b/src/main/java/net/minecraft/server/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g')
nonnms=$(cat patches/server/* | grep "create mode " | grep -Po "src/main/java/net/minecraft/server/(.*?).java" | sort | uniq | sed 's/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g') nonnms=$(cat patches/server/* | grep "create mode " | grep -Po "src/main/java/net/minecraft/server/(.*?).java" | sort | uniq | sed 's/src\/main\/java\/net\/minecraft\/server\///g' | sed 's/.java//g')
for f in $files; do for f in $files; do
containsElement "$f" ${nonnms[@]} containsElement "$f" "${nonnms[@]}"
if [ "$?" == "1" ]; then if [ "$?" == "1" ]; then
if [ ! -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$f.java" ]; then if [ ! -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$f.java" ]; then
if [ ! -f "$decompiledir/$nms/$f.java" ]; then if [ ! -f "$decompiledir/$nms/$f.java" ]; then
echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"; echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"
else else
import $f import "$f"
fi fi
fi fi
fi fi
done done
############################################################################################### ###############################################################################################
@@ -80,10 +79,8 @@ done
################ ################
( (
cd Paper/Paper-Server/ cd Paper/Paper-Server/ || exit
rm -rf nms-patches rm -rf nms-patches
git add src -A git add src -A
echo -e "Purpur-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F - echo -e "Purpur-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F -
) )

View File

@@ -1,65 +1,45 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# BEGIN config
FORK_NAME="Purpur"
API_REPO=""
SERVER_REPO=""
PAPER_API_REPO=""
PAPER_SERVER_REPO=""
MCDEV_REPO=""
# END config
sourceBase=$(dirname $SOURCE)/../ sourceBase=$(dirname "$SOURCE")/../
cd ${basedir:-$sourceBase} cd "${basedir:-$sourceBase}" || exit
basedir=$(pwd -P) basedir=$(pwd -P)
cd - cd - || exit
function bashColor() {
function bashColor { if [ "$2" ]; then
if [ $2 ]; then echo -e "\e[$1;$2m"
echo -e "\e[$1;$2m" else
else echo -e "\e[$1m"
echo -e "\e[$1m" fi
fi
} }
function bashColorReset { function bashColorReset() {
echo -e "\e[m" echo -e "\e[m"
} }
function cleanupPatches { function cleanupPatches() {
cd "$1" cd "$1" || exit
for patch in *.patch; do for patch in *.patch; do
gitver=$(tail -n 2 $patch | grep -ve "^$" | tail -n 1) 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|Date\: )") diffs=$(git diff --staged "$patch" | grep -E "^(\+|\-)" | grep -Ev "(From [a-z0-9]{32,}|\-\-\- a|\+\+\+ b|.index|Date\: )")
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver") testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
if [ "x$testver" != "x" ]; then if [ "x$testver" != "x" ]; then
diffs=$(echo "$diffs" | tail -n +3) diffs=$(echo "$diffs" | tail -n +3)
fi fi
if [ "x$diffs" == "x" ] ; then if [ "x$diffs" == "x" ]; then
git reset HEAD $patch >/dev/null git reset HEAD "$patch" >/dev/null
git checkout -- $patch >/dev/null git checkout -- "$patch" >/dev/null
fi fi
done done
} }
function pushRepo { function basedir() {
if [ "$(git config minecraft.push-${FORK_NAME})" == "1" ]; then cd "$basedir" || exit
echo "Pushing - $1 ($3) to $2"
(
cd "$1"
git remote rm emc-push > /dev/null 2>&1
git remote add emc-push $2 >/dev/null 2>&1
git push emc-push $3 -f
)
fi
} }
function basedir { function gethead() {
cd "$basedir" (
} cd "$1" || exit
function gethead { git log -1 --oneline
( )
cd "$1"
git log -1 --oneline
)
} }

View File

@@ -1,22 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
( (
set -e set -e
basedir="$(cd "$1" && pwd -P)" basedir="$(cd "$1" && pwd -P)"
workdir="$basedir/Paper/work" workdir="$basedir/Paper/work"
mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) mcver=$(< "$workdir/BuildData/info.json" grep minecraftVersion | cut -d '"' -f 4)
purpurjar="$basedir/Purpur-Server/target/purpur-$mcver.jar" purpurjar="$basedir/Purpur-Server/target/purpur-$mcver.jar"
vanillajar="$workdir/Minecraft/$mcver/$mcver.jar" vanillajar="$workdir/Minecraft/$mcver/$mcver.jar"
( (
cd "$basedir/Paperclip" cd "$basedir/Paperclip"
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$purpurjar" "-Dvanillajar=$vanillajar" mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$purpurjar" "-Dvanillajar=$vanillajar"
) )
cp "$basedir/Paperclip/assembly/target/paperclip-${mcver}.jar" "$basedir/purpurclip.jar" cp "$basedir/Paperclip/assembly/target/paperclip-${mcver}.jar" "$basedir/purpurclip.jar"
echo "" echo ""
echo "" echo ""
echo "" echo ""
echo "Build success!" echo "Build success!"
echo "Copied final jar to $(cd "$basedir" && pwd -P)/purpurclip.jar" echo "Copied final jar to $(cd "$basedir" && pwd -P)/purpurclip.jar"
) || exit 1 ) || exit 1

View File

@@ -1,15 +0,0 @@
#!/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
. $(dirname $SOURCE)/init.sh
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
basedir
pushRepo ${FORK_NAME}-API $API_REPO master:$minecraftversion
pushRepo ${FORK_NAME}-Server $SERVER_REPO master:$minecraftversion

View File

@@ -2,43 +2,40 @@
# get base dir regardless of execution location # get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}" SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")" 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 [[ $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 done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
PS1="$" PS1="$"
echo "Rebuilding patch files from current fork state..." echo "Rebuilding patch files from current fork state..."
function savePatches { function savePatches() {
what=$1 what=$1
cd $basedir/$what/ cd "$basedir"/"$what"/ || exit
mkdir -p $basedir/patches/$2 mkdir -p "$basedir"/patches/"$2"
if [ -d ".git/rebase-apply" ]; then if [ -d ".git/rebase-apply" ]; then
# in middle of a rebase, be smarter # in middle of a rebase, be smarter
echo "REBASE DETECTED - PARTIAL SAVE" echo "REBASE DETECTED - PARTIAL SAVE"
last=$(cat ".git/rebase-apply/last") last=$(cat ".git/rebase-apply/last")
next=$(cat ".git/rebase-apply/next") next=$(cat ".git/rebase-apply/next")
declare -a files=("$basedir/patches/$2/"*.patch) declare -a files=("$basedir/patches/$2/"*.patch)
for i in $(seq -f "%04g" 1 1 $last) for i in $(seq -f "%04g" 1 1 "$last"); do
do if [ "$i" -lt "$next" ]; then
if [ $i -lt $next ]; then rm "${files[$(("$i" - 1))]}"
rm "${files[`expr $i - 1`]}" fi
fi done
done else
else rm "$basedir"/patches/"$2"/*.patch
rm $basedir/patches/$2/*.patch fi
fi
git format-patch --quiet -N -o $basedir/patches/$2 upstream/upstream git format-patch --quiet -N -o "$basedir"/patches/"$2" upstream/upstream
cd $basedir cd "$basedir" || exit
git add -A $basedir/patches/$2 git add -A "$basedir"/patches/"$2"
cleanupPatches $basedir/patches/$2/ cleanupPatches "$basedir"/patches/"$2"/
echo " Patches saved for $what to patches/$2" echo " Patches saved for $what to patches/$2"
} }
savePatches ${FORK_NAME}-API api savePatches Purpur-API api
savePatches ${FORK_NAME}-Server server savePatches Purpur-Server server
$basedir/scripts/push.sh

View File

@@ -2,61 +2,57 @@
# get base dir regardless of execution location # get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}" SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )" DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")" 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 [[ $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 done
. $(dirname $SOURCE)/init.sh . "$(dirname "$SOURCE")/init.sh"
if [[ "$1" == up* ]]; then if [[ "$1" == up* ]]; then
( (
cd "$basedir/Paper/" cd "$basedir/Paper/" || exit
git fetch && git reset --hard origin/master git fetch && git reset --hard origin/master
cd ../ cd ../
git add Paper git add Paper
) )
fi fi
paperVer=$(gethead Paper) paperVer=$(gethead Paper)
cd "$basedir/Paper/" cd "$basedir/Paper/" || exit
./paper patch ./paper patch
cd "Paper-Server" cd "Paper-Server" || exit
mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=minecraft_version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }') mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=minecraft_version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }')
basedir basedir
. $basedir/scripts/importmcdev.sh . "$basedir"/scripts/importmcdev.sh
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4)
version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev") version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev")
tag="${minecraftversion}-${mcVer}-$(echo -e $version | shasum | awk '{print $1}')" tag="${minecraftversion}-${mcVer}-$(echo -e "$version" | shasum | awk '{print $1}')"
echo "$tag" > $basedir/current-paper echo "$tag" >"$basedir"/current-paper
$basedir/scripts/generatesources.sh "$basedir"/scripts/generatesources.sh
cd Paper/ cd Paper/ || exit
function tag { function tag() {
( (
cd $1 cd "$1" || exit
if [ "$2" == "1" ]; then if [ "$2" == "1" ]; then
git tag -d "$tag" 2>/dev/null git tag -d "$tag" 2>/dev/null
fi fi
echo -e "$(date)\n\n$version" | git tag -a "$tag" -F - 2>/dev/null echo -e "$(date)\n\n$version" | git tag -a "$tag" -F - 2>/dev/null
) )
} }
echo "Tagging as $tag" echo "Tagging as $tag"
echo -e "$version" echo -e "$version"
forcetag=0 forcetag=0
if [ "$(cat $basedir/current-paper)" != "$tag" ]; then if [ "$(cat "$basedir"/current-paper)" != "$tag" ]; then
forcetag=1 forcetag=1
fi fi
tag Paper-API $forcetag tag Paper-API $forcetag
tag Paper-Server $forcetag tag Paper-Server $forcetag
pushRepo Paper-API $PAPER_API_REPO $tag
pushRepo Paper-Server $PAPER_SERVER_REPO $tag

View File

@@ -1,28 +1,28 @@
#!/usr/bin/env bash #!/usr/bin/env bash
( (
set -e set -e
PS1="$" PS1="$"
function changelog() { function changelog() {
base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1) base=$(git ls-tree HEAD "$1" | cut -d' ' -f3 | cut -f1)
cd $1 && git log --oneline ${base}...HEAD cd "$1" && git log --oneline "${base}"...HEAD
} }
paper=$(changelog Paper) paper=$(changelog Paper)
updated="" updated=""
logsuffix="" logsuffix=""
if [ ! -z "$paper" ]; then if [ -n "$paper" ]; then
logsuffix="$logsuffix\n\nPaper Changes:\n$paper" logsuffix="$logsuffix\n\nPaper Changes:\n$paper"
if [ -z "$updated" ]; then updated="Paper"; else updated="$updated/Paper"; fi if [ -z "$updated" ]; then updated="Paper"; else updated="$updated/Paper"; fi
fi fi
disclaimer="Upstream has released updates that appears to apply and compile correctly" disclaimer="Upstream has released updates that appears to apply and compile correctly"
if [ ! -z "$1" ]; then if [ -n "$1" ]; then
disclaimer="$@" disclaimer=( "$@" )
fi fi
log="${UP_LOG_PREFIX}Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}" log="${UP_LOG_PREFIX}Updated Upstream ($updated)\n\n${disclaimer[*]}${logsuffix}"
echo -e "$log" | git commit -F - echo -e "$log" | git commit -F -
) || exit 1 ) || exit 1