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 # 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
"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") "p" | "patch" | "apply")
( (
set -e 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")
cd "$basedir" cd "$basedir"
;; if [ "$2" != "fast" ]; then
"a" | "api") scripts/upstream.sh
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."
fi 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 "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 " * am, amend | Amend current edits to last patches" echo " * p, patch | Apply all patches to top of Paper without building it"
echo " * rb, rebuild | Rebuild patches, can be called from anywhere." echo " * b, build | Build Purpur API and Server"
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere." echo " * rb, rebuild | Rebuild patches"
echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere." echo " * am, amend | Amend current edits to last patches"
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"
echo " * d, deploy | Build and Deploy API jar and build Server. Can be ran anywhere." echo " * jar, purpurclip | Apply all patches and build the project, purpurclip.jar will be output"
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."
;;
esac esac
unset -f purpurstash unset -f purpurstash

View File

@@ -79,6 +79,8 @@ function enableCommitSigningIfNeeded {
fi fi
} }
echo "Importing MC-DEV"
./scripts/importmcdev.sh "$basedir" || exit 1
( (
(applyPatch Paper/Paper-API Purpur-API HEAD api "$API_REPO" && (applyPatch Paper/Paper-API Purpur-API HEAD api "$API_REPO" &&
applyPatch Paper/Paper-Server Purpur-Server HEAD server "$SERVER_REPO") || exit 1 applyPatch Paper/Paper-Server Purpur-Server HEAD server "$SERVER_REPO") || exit 1

View File

@@ -2,23 +2,23 @@
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" || exit
paperVer=$(cat current-paper) paperVer=$(cat current-paper)
minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(grep <"$basedir"/Paper/work/BuildData/info.json 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 || exit 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
@@ -27,9 +27,9 @@ 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/ || exit cd "$basedir"/mc-dev/src/net/minecraft/server/ || exit
for file in $(/bin/ls "$base"); do for file in $(/bin/ls "$base"); do
if [ -f "$file" ]; then if [ -f "$file" ]; then
rm -f "$file" rm -f "$file"
fi fi
done done
cd "$basedir"/mc-dev || exit cd "$basedir"/mc-dev || exit
git add . -A git add . -A

View File

@@ -2,14 +2,14 @@
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=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(grep <"$basedir"/Paper/work/BuildData/info.json minecraftVersion | cut -d '"' -f 4)
decompiledir=$workdir/Minecraft/$minecraftversion/spigot decompiledir=$workdir/Minecraft/$minecraftversion/spigot
nms="net/minecraft/server" nms="net/minecraft/server"
@@ -17,39 +17,59 @@ export MODLOG=""
cd "$basedir" || exit 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
}
function importLibrary() {
group=$1
lib=$2
prefix=$3
shift 3
for file in "$@"; do
file="$prefix/$file"
target="$basedir/Paper/Paper-Server/src/main/java/$file"
targetdir=$(dirname "$target")
mkdir -p "${targetdir}"
base="$workdir/Minecraft/$minecraftversion/libraries/${group}/${lib}/$file"
if [ ! -f "$base" ]; then
echo "Missing $base"
exit 1
fi fi
export MODLOG="$MODLOG Imported $file from $lib\n"
sed 's/\r$//' "$base" >"$target" || exit 1
done
} }
( (
cd Paper/Paper-Server/ || exit 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')
@@ -57,16 +77,16 @@ files=$(cat patches/server/* | grep "+++ b/src/main/java/net/minecraft/server/"
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" ] && [ true ]; 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
############################################################################################### ###############################################################################################
@@ -77,10 +97,20 @@ done
# import Foo # import Foo
########################################################
########################################################
########################################################
# LIBRARY IMPORTS
# These must always be mapped manually, no automatic stuff
#
# # group # lib # prefix # many files
#importLibrary com.mojang datafixerupper com/mojang/datafixers/util Either.java
################ ################
( (
cd Paper/Paper-Server/ || exit 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

@@ -7,39 +7,39 @@ basedir=$(pwd -P)
cd - || exit 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" || exit 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 basedir() { function basedir() {
cd "$basedir" || exit cd "$basedir" || exit
} }
function gethead() { function gethead() {
( (
cd "$1" || exit cd "$1" || exit
git log -1 --oneline git log -1 --oneline
) )
} }

View File

@@ -1,21 +1,25 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Copied from https://github.com/PaperMC/Paper/blob/d54ce6c17fb7a35238d6b9f734d30a4289886773/scripts/paperclip.sh
# License from Paper applies to this file
( (
set -e set -e
basedir="$(cd "$1" && pwd -P)" basedir="$(cd "$1" && pwd -P)"
workdir="$basedir/Paper/work" workdir="$basedir/Paper/work"
mcver=$(< "$workdir/BuildData/info.json" grep minecraftVersion | cut -d '"' -f 4) mcver=$(grep <"$workdir/BuildData/info.json" 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 "$workdir/Paperclip" cd "$workdir/Paperclip"
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$purpurjar" "-Dvanillajar=$vanillajar" mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$purpurjar" "-Dvanillajar=$vanillajar"
) )
cp "$workdir/Paperclip/assembly/target/paperclip-${mcver}.jar" "$basedir/purpurclip.jar" cp "$workdir/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

@@ -2,39 +2,39 @@
# 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"/ || exit 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"); do for i in $(seq -f "%04g" 1 1 "$last"); do
if [ "$i" -lt "$next" ]; then if [ "$i" -lt "$next" ]; then
rm "${files[$(("$i" - 1))]}" rm "${files[$(("$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 --no-signature --zero-commit --no-stat -N -o "$basedir"/patches/"$2" upstream/upstream
cd "$basedir" || exit 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 Purpur-API api savePatches Purpur-API api

View File

@@ -2,19 +2,19 @@
# 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/" || exit cd "$basedir/Paper/" || exit
git fetch && git reset --hard origin/ver/1.16 git fetch && git reset --hard origin/ver/1.16
cd ../ cd ../
git add Paper git add Paper
) )
fi fi
paperVer=$(gethead Paper) paperVer=$(gethead Paper)
@@ -28,7 +28,7 @@ mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpre
basedir basedir
. "$basedir"/scripts/importmcdev.sh . "$basedir"/scripts/importmcdev.sh
minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4) minecraftversion=$(grep <"$basedir"/Paper/work/BuildData/info.json 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
@@ -38,20 +38,20 @@ echo "$tag" >"$basedir"/current-paper
cd Paper/ || exit cd Paper/ || exit
function tag() { function tag() {
( (
cd "$1" || exit 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

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 [ -n "$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 [ -n "$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