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

View File

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

View File

@@ -2,23 +2,23 @@
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. "$(dirname "$SOURCE")/init.sh"
cd "$basedir" || exit
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"
mkdir -p mc-dev/src/net/minecraft/server
cd mc-dev || exit
if [ ! -d ".git" ]; then
git init
git init
fi
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"
cd "$basedir"/mc-dev/src/net/minecraft/server/ || exit
for file in $(/bin/ls "$base"); do
if [ -f "$file" ]; then
rm -f "$file"
fi
if [ -f "$file" ]; then
rm -f "$file"
fi
done
cd "$basedir"/mc-dev || exit
git add . -A

View File

@@ -2,14 +2,14 @@
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. "$(dirname "$SOURCE")/init.sh"
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
nms="net/minecraft/server"
@@ -17,39 +17,59 @@ export MODLOG=""
cd "$basedir" || exit
function containsElement() {
local e
for e in "${@:2}"; do
[[ "$e" == "$1" ]] && return 0
done
return 1
local e
for e in "${@:2}"; do
[[ "$e" == "$1" ]] && return 0
done
return 1
}
export importedmcdev=""
function import() {
if [ -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$1.java" ]; then
echo "ALREADY IMPORTED $1"
return 0
fi
export importedmcdev="$importedmcdev $1"
file="${1}.java"
target="$basedir/Paper/Paper-Server/src/main/java/$nms/$file"
base="$decompiledir/$nms/$file"
if [ -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$1.java" ]; then
echo "ALREADY IMPORTED $1"
return 0
fi
export importedmcdev="$importedmcdev $1"
file="${1}.java"
target="$basedir/Paper/Paper-Server/src/main/java/$nms/$file"
base="$decompiledir/$nms/$file"
if [[ ! -f "$target" ]]; then
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)"
cp "$base" "$target"
else
echo "$(bashColor 1 33) UN-NEEDED IMPORT STATEMENT:$(bashColor 1 34) $file $(bashColorReset)"
if [[ ! -f "$target" ]]; then
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)"
cp "$base" "$target"
else
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
export MODLOG="$MODLOG Imported $file from $lib\n"
sed 's/\r$//' "$base" >"$target" || exit 1
done
}
(
cd Paper/Paper-Server/ || exit
lastlog=$(git log -1 --oneline)
if [[ "$lastlog" == *"Purpur-Extra mc-dev Imports"* ]]; then
git reset --hard HEAD^
fi
cd Paper/Paper-Server/ || exit
lastlog=$(git log -1 --oneline)
if [[ "$lastlog" == *"Purpur-Extra mc-dev Imports"* ]]; then
git reset --hard HEAD^
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')
@@ -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')
for f in $files; do
containsElement "$f" "${nonnms[@]}"
if [ "$?" == "1" ]; then
if [ ! -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$f.java" ]; then
if [ ! -f "$decompiledir/$nms/$f.java" ]; then
echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"
else
import "$f"
fi
fi
containsElement "$f" "${nonnms[@]}"
if [ "$?" == "1" ]; then
if [ ! -f "$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server/$f.java" ]; then
if [ ! -f "$decompiledir/$nms/$f.java" ] && [ true ]; then
echo "$(bashColor 1 31) ERROR!!! Missing NMS$(bashColor 1 34) $f $(bashColorReset)"
else
import "$f"
fi
fi
fi
done
###############################################################################################
@@ -77,10 +97,20 @@ done
# 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
rm -rf nms-patches
git add src -A
echo -e "Purpur-Extra mc-dev Imports\n\n$MODLOG" | git commit src -F -
cd Paper/Paper-Server/ || exit
rm -rf nms-patches
git add src -A
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
function bashColor() {
if [ "$2" ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
if [ "$2" ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
}
function bashColorReset() {
echo -e "\e[m"
echo -e "\e[m"
}
function cleanupPatches() {
cd "$1" || exit
for patch in *.patch; do
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\: )")
cd "$1" || exit
for patch in *.patch; do
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\: )")
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
if [ "x$testver" != "x" ]; then
diffs=$(echo "$diffs" | tail -n +3)
fi
testver=$(echo "$diffs" | tail -n 2 | grep -ve "^$" | tail -n 1 | grep "$gitver")
if [ "x$testver" != "x" ]; then
diffs=$(echo "$diffs" | tail -n +3)
fi
if [ "x$diffs" == "x" ]; then
git reset HEAD "$patch" >/dev/null
git checkout -- "$patch" >/dev/null
fi
done
if [ "x$diffs" == "x" ]; then
git reset HEAD "$patch" >/dev/null
git checkout -- "$patch" >/dev/null
fi
done
}
function basedir() {
cd "$basedir" || exit
cd "$basedir" || exit
}
function gethead() {
(
cd "$1" || exit
git log -1 --oneline
)
(
cd "$1" || exit
git log -1 --oneline
)
}

View File

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

View File

@@ -2,39 +2,39 @@
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. "$(dirname "$SOURCE")/init.sh"
PS1="$"
echo "Rebuilding patch files from current fork state..."
function savePatches() {
what=$1
cd "$basedir"/"$what"/ || exit
what=$1
cd "$basedir"/"$what"/ || exit
mkdir -p "$basedir"/patches/"$2"
if [ -d ".git/rebase-apply" ]; then
# in middle of a rebase, be smarter
echo "REBASE DETECTED - PARTIAL SAVE"
last=$(cat ".git/rebase-apply/last")
next=$(cat ".git/rebase-apply/next")
declare -a files=("$basedir/patches/$2/"*.patch)
for i in $(seq -f "%04g" 1 1 "$last"); do
if [ "$i" -lt "$next" ]; then
rm "${files[$(("$i" - 1))]}"
fi
done
else
rm "$basedir"/patches/"$2"/*.patch
fi
mkdir -p "$basedir"/patches/"$2"
if [ -d ".git/rebase-apply" ]; then
# in middle of a rebase, be smarter
echo "REBASE DETECTED - PARTIAL SAVE"
last=$(cat ".git/rebase-apply/last")
next=$(cat ".git/rebase-apply/next")
declare -a files=("$basedir/patches/$2/"*.patch)
for i in $(seq -f "%04g" 1 1 "$last"); do
if [ "$i" -lt "$next" ]; then
rm "${files[$(("$i" - 1))]}"
fi
done
else
rm "$basedir"/patches/"$2"/*.patch
fi
git format-patch --quiet -N -o "$basedir"/patches/"$2" upstream/upstream
cd "$basedir" || exit
git add -A "$basedir"/patches/"$2"
cleanupPatches "$basedir"/patches/"$2"/
echo " Patches saved for $what to patches/$2"
git format-patch --no-signature --zero-commit --no-stat -N -o "$basedir"/patches/"$2" upstream/upstream
cd "$basedir" || exit
git add -A "$basedir"/patches/"$2"
cleanupPatches "$basedir"/patches/"$2"/
echo " Patches saved for $what to patches/$2"
}
savePatches Purpur-API api

View File

@@ -2,19 +2,19 @@
# get base dir regardless of execution location
SOURCE="${BASH_SOURCE[0]}"
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
SOURCE="$(readlink "$SOURCE")"
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
done
. "$(dirname "$SOURCE")/init.sh"
if [[ "$1" == up* ]]; then
(
cd "$basedir/Paper/" || exit
git fetch && git reset --hard origin/ver/1.16
cd ../
git add Paper
)
(
cd "$basedir/Paper/" || exit
git fetch && git reset --hard origin/ver/1.16
cd ../
git add Paper
)
fi
paperVer=$(gethead Paper)
@@ -28,7 +28,7 @@ mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpre
basedir
. "$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")
tag="${minecraftversion}-${mcVer}-$(echo -e "$version" | shasum | awk '{print $1}')"
echo "$tag" >"$basedir"/current-paper
@@ -38,20 +38,20 @@ echo "$tag" >"$basedir"/current-paper
cd Paper/ || exit
function tag() {
(
cd "$1" || exit
if [ "$2" == "1" ]; then
git tag -d "$tag" 2>/dev/null
fi
echo -e "$(date)\n\n$version" | git tag -a "$tag" -F - 2>/dev/null
)
(
cd "$1" || exit
if [ "$2" == "1" ]; then
git tag -d "$tag" 2>/dev/null
fi
echo -e "$(date)\n\n$version" | git tag -a "$tag" -F - 2>/dev/null
)
}
echo "Tagging as $tag"
echo -e "$version"
forcetag=0
if [ "$(cat "$basedir"/current-paper)" != "$tag" ]; then
forcetag=1
forcetag=1
fi
tag Paper-API $forcetag

View File

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