Rewrite scripts and fix more build issues

This commit is contained in:
Sotr
2020-04-13 01:20:55 +07:00
parent 6f32d02a63
commit 7aa8eb6363
29 changed files with 930 additions and 390 deletions

View File

@@ -1,72 +0,0 @@
#!/usr/bin/env bash
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
paperVer=$(cat current-paper)
gpgsign="$(git config commit.gpgsign || echo "false")"
echo "Rebuilding Forked projects.... "
function applyPatch {
what=$1
what_name=$(basename $what)
target=$2
branch=$3
patch_folder=$4
cd "$basedir/$what"
git fetch --all
git branch -f upstream "$branch" >/dev/null
cd "$basedir"
if [ ! -d "$basedir/$target" ]; then
mkdir "$basedir/$target"
cd "$basedir/$target"
git init
git remote add origin "$5"
cd "$basedir"
fi
cd "$basedir/$target"
# 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.
# Calm down kids, it's re-enabled (if needed) immediately after, pass or fail.
git config commit.gpgsign false
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 checkout master 2>/dev/null || git checkout -b master
git fetch upstream >/dev/null 2>&1
git reset --hard upstream/upstream
echo " Applying patches to $target..."
git am --abort >/dev/null 2>&1
git am --3way --ignore-whitespace "$basedir/patches/$patch_folder/"*.patch
if [ "$?" != "0" ]; then
echo " Something did not apply cleanly to $target."
echo " Please review above details and finish the apply then"
echo " save the changes with rebuildPatches.sh"
exit 1
else
echo " Patches applied cleanly to $target"
fi
}
function enableCommitSigningIfNeeded {
if [[ "$gpgsign" == "true" ]]; then
git config commit.gpgsign true
fi
}
echo "Importing MC-DEV"
./scripts/importmcdev.sh "$basedir" || exit 1
(
(applyPatch Paper/Paper-API ${FORK_NAME}-API HEAD api $API_REPO &&
applyPatch Paper/Paper-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO) || exit 1
enableCommitSigningIfNeeded
) || (
echo "Failed to apply patches"
enableCommitSigningIfNeeded
exit 1
) || exit 1

112
scripts/applyPatches.sh Normal file
View File

@@ -0,0 +1,112 @@
#!/usr/bin/env bash
# SCRIPT HEADER start
echo "----------------------------------------"
echo " $(bashcolor 1 32)Task$(bashcolorend) - Apply Patches"
echo " This will apply all of Akarin patches on top of the Paper."
echo " "
echo " $(bashcolor 1 32)Subtask:$(bashcolorend)"
echo " - Import Sources"
echo " "
echo " $(bashcolor 1 32)Modules:$(bashcolorend)"
echo " - $(bashcolor 1 32)1$(bashcolorend) : API"
echo " - $(bashcolor 1 32)2$(bashcolorend) : Server"
echo "----------------------------------------"
# SCRIPT HEADER end
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
gpgsign="$(git config commit.gpgsign || echo "false")"
function applyPatch {
baseproject=$1
basename=$(basename $baseproject)
target=$2
branch=$3
patch_folder=$4
# Skip if that software have no patch
haspatch=-f "$basedir/patches/$patch_folder/"*.patch >/dev/null 2>&1 # too many files
if [ ! haspatch ]; then
echo " $(bashcolor 1 33)($5/$6) Skipped$(bashcolorend) - No patch found for $target under patches/$patch_folder"
return
fi
echo " $(bashcolor 1 32)($5/$6)$(bashcolorend) - Setup upstream project.."
cd "$basedir/$baseproject"
$gitcmd fetch --all &> /dev/null
# Create the upstream branch in Paper project with current state
$gitcmd checkout master >/dev/null # possibly already in
$gitcmd branch -D upstream >/dev/null &> /dev/null
$gitcmd branch -f upstream "$branch" &> /dev/null && $gitcmd checkout upstream &> /dev/null
if [ $baseproject != "Paper/Paper-API" ]; then
echo " $(bashcolor 1 32)($5/$6)$(bashcolorend) - Import new introduced NMS files.."
basedir && $scriptdir/importSources.sh $basedir 1
fi
basedir
# Create source project dirs
if [ ! -d "$basedir/$target" ]; then
mkdir "$basedir/$target"
cd "$basedir/$target"
# $gitcmd remote add origin "$5"
fi
cd "$basedir/$target"
$gitcmd init > /dev/null 2>&1
# 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.
# Calm down kids, it's re-enabled (if needed) immediately after, pass or fail.
$gitcmd config commit.gpgsign false
echo " $(bashcolor 1 32)($5/$6)$(bashcolorend) - Reset $target to $basename.."
# Add the generated Paper project as the upstream remote of subproject
$gitcmd remote rm upstream >/dev/null 2>&1
$gitcmd remote add upstream "$basedir/$baseproject" >/dev/null 2>&1
# Ensure that we are in the branch we want so not overriding things
$gitcmd checkout master 2>/dev/null || $gitcmd checkout -b master
$gitcmd fetch upstream >/dev/null 2>&1
# Reset our source project to Paper
cd "$basedir/$target" && $gitcmd reset --hard upstream/upstream
echo " $(bashcolor 1 32)($5/$6)$(bashcolorend) - Apply patches to $target.."
# Abort previous applying operation
$gitcmd am --abort >/dev/null 2>&1
# Apply our patches on top Paper in our dirs
$gitcmd am --no-utf8 --3way --ignore-whitespace "$basedir/patches/$patch_folder/"*.patch
if [ "$?" != "0" ]; then
echo " Something did not apply cleanly to $target."
echo " Please review above details and finish the apply then"
echo " save the changes with rebuildPatches.sh"
echo " or use 'git am --abort' to cancel this applying."
echo " $(bashcolor 1 33)($5/$6) Suspended$(bashcolorend) - Resolve the conflict or abort the apply"
echo " "
cd "$basedir/$target"
exit 1
else
echo " $(bashcolor 1 32)($6/$6) Succeed$(bashcolorend) - Patches applied cleanly to $target"
echo " "
fi
}
function enableCommitSigningIfNeeded {
if [[ "$gpgsign" == "true" ]]; then
git config commit.gpgsign true
fi
}
# echo "Importing MC-DEV"
# ./scripts/importSources.sh "$basedir" || exit 1
(
(applyPatch Paper/Paper-API ${FORK_NAME}-API HEAD api $API_REPO 0 2 &&
applyPatch Paper/Paper-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO 1 2) || exit 1
enableCommitSigningIfNeeded
) || (
enableCommitSigningIfNeeded
exit 1
) || exit 1

10
scripts/upstreamCommit.sh → scripts/commitUpstream.sh Executable file → Normal file
View File

@@ -1,13 +1,15 @@
#!/usr/bin/env bash
echo "[Akarin] State: Commit Upstream"
(
set -e
PS1="$"
function changelog() {
function changeLog() {
base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1)
cd $1 && git log --oneline ${base}...HEAD
}
paper=$(changelog Paper)
paper=$(changeLog Paper)
updated=""
logsuffix=""
@@ -21,7 +23,7 @@ if [ ! -z "$1" ]; then
disclaimer="$@"
fi
log="${UP_LOG_PREFIX}Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}"
log="Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}"
echo -e "$log" | git commit -F -

View File

@@ -14,15 +14,26 @@ gitcmd="git -c commit.gpgsign=false"
case "$(echo "$SHELL" | sed -E 's|/usr(/local)?||g')" in
"/bin/zsh")
RCPATH="$HOME/.zshrc"
SOURCE="${BASH_SOURCE[0]:-${(%):-%N}}"
;;
*)
RCPATH="$HOME/.bashrc"
if [[ -f "$HOME/.bash_aliases" ]]; then
RCPATH="$HOME/.bash_aliases"
fi
SOURCE="${BASH_SOURCE[0]}"
;;
esac
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#./}")
scriptdir=$(dirname "$SOURCE")
basedir=$(dirname "$scriptdir")
function basedir {
cd "$basedir"
}
@@ -48,6 +59,18 @@ colorend() {
echo -e "\e[m"
}
function bashcolor {
if [ $2 ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
}
function bashcolorend {
echo -e "\e[m"
}
# GIT functions
gitstash() {
STASHED=$($gitcmd stash 2>/dev/null|| return 0) # errors are ok
@@ -60,7 +83,7 @@ gitunstash() {
}
function gethead {
cd "$1"
basedir
git log -1 --oneline
}
@@ -68,7 +91,7 @@ function gitpush {
if [ "$(git config minecraft.push-${FORK_NAME})" == "1" ]; then
echo "Push - $1 ($3) to $2"
(
cd "$1"
basedir
git remote rm script-push > /dev/null 2>&1
git remote add script-push $2 >/dev/null 2>&1
git push script-push $3 -f
@@ -101,16 +124,4 @@ function containsElement {
[[ "$e" == "$1" ]] && return 0;
done
return 1
}
function bashColor {
if [ $2 ]; then
echo -e "\e[$1;$2m"
else
echo -e "\e[$1m"
fi
}
function bashColorReset {
echo -e "\e[m"
}
}

View File

@@ -1,5 +1,9 @@
#!/usr/bin/env bash
echo "[Akarin] State: Generate Imports"
# For a description of this script, see updateUpstream.sh.
# get base dir regardless of execution location
basedir=$1
@@ -21,7 +25,7 @@ if [ ! -d ".git" ]; then
$gitcmd init
fi
# reset dev files to spigot
# reset dev files to raw nms in spigot naming
rm src/net/minecraft/server/*.java
cp $decompile/net/minecraft/server/*.java src/net/minecraft/server
@@ -38,7 +42,7 @@ done
# push the dev project
cd $basedir/mc-dev
gitcmd add . -A
gitcmd commit --allow-empty . -m "$paperVer"
gitcmd tag -a "$paperVer" -m "$paperVer" 2>/dev/null
gitpush . $MCDEV_REPO $paperVer
$gitcmd add . -A
$gitcmd commit . -m "$paperVer"
$gitcmd tag -a "$paperVer" -m "$paperVer" 2>/dev/null
# gitpush . $MCDEV_REPO $paperVer

123
scripts/importSources.sh Normal file
View File

@@ -0,0 +1,123 @@
#!/usr/bin/env bash
maintask=$2
tasktitle=maintask && "Import Sources" || "Import Sources (Subtask)"
# SCRIPT HEADER start
echo "----------------------------------------"
echo " $(bashcolor 1 32)Task$(bashcolorend) - "
echo " This will import unimported sources newly added/mod by Akarin to Paper workspace"
echo " "
echo "----------------------------------------"
# SCRIPT HEADER end
# For a description of this script, see updateUpstream.sh.
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
paperworkdir="$basedir/Paper/work"
paperserverdir="$basedir/Paper/Paper-Server"
papersrcdir="$paperserverdir/src/main/java"
papernmsdir="$papersrcdir/net/minecraft/server"
(
# fast-fail if Paper not set
if [ ! -f "$papernmsdir" ]; then
echo "$(bashcolor 1 31) Exception $(bashcolorend) - Paper sources not generated, run updateUpstream.sh to setup."
exit 1
fi
}
minecraftversion=$(cat "$basedir"/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
decompiledir=$paperworkdir/Minecraft/$minecraftversion/spigot
nms="net/minecraft/server"
export IMPORT_LOG="" # for commit message, list all files and source for libs
basedir
function importToPaperWorkspace {
if [ -f "$papernmsdir/$1.java" ]; then
echo "$(bashcolor 1 33) Skipped $(bashcolorend) - Already imported $1.java"
return 0
fi
file="$1.java"
target="$papernmsdir/$file"
base="$decompiledir/$nms/$file"
if [[ ! -f "$target" ]]; then
export IMPORT_LOG="$IMPORT_LOG Import: $file\n";
echo "Import: $file"
cp "$base" "$target"
fi
}
function importLibraryToPaperWorkspace {
group=$1
lib=$2
prefix=$3
shift 3
for file in "$@"; do
file="$prefix/$file"
target="$papersrcdir/$file"
targetdir=$(dirname "$target")
mkdir -p "${targetdir}"
base="$paperworkdir/Minecraft/$minecraftversion/libraries/${group}/${lib}/$file"
if [ ! -f "$base" ]; then
echo "$(bashcolor 1 31) Exception $(bashcolorend) - Cannot find file $file.java of lib $lib in group $group to import, re-decomplie or remove the import."
exit 1
fi
export IMPORT_LOG="$IMPORT_LOG Import: $file from lib $lib\n";
echo "Import: $file ($lib)"
sed 's/\r$//' "$base" > "$target" || exit 1
done
}
(
cd "$paperserverdir"
lastcommit=$(git log -1 --pretty=oneline --abbrev-commit)
if [[ "$lastcommit" = *"Extra dev imports of Akarin"* ]]; then
git reset --hard HEAD^
fi
)
# Filter and import every files which have patch to modify
patchedFiles=$(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')
patchedFilesNonNMS=$(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 $patchedFiles; do
containsElement "$f" ${patchedFilesNonNMS[@]}
if [ "$?" == "1" ]; then
if [ ! -f "$papersrcdir/$nms/$f.java" ]; then
if [ ! -f "$decompiledir/$nms/$f.java" ]; then
echo "$(bashcolor 1 31) ERROR!!! Missing NMS$(bashcolor 1 34) $f $(bashcolorend)";
echo "$(bashcolor 1 31) Exception $(bashcolorend) - Cannot find NMS file $f.java to import, re-decomplie or remove the import."
exit 1
else
importToPaperWorkspace $f
fi
fi
fi
done
# NMS import format:
# importToPaperWorkspace MinecraftServer.java
# Library import format (multiple files are supported):
# importLibraryToPaperWorkspace com.mojang datafixerupper com/mojang/datafixers/util Either.java
# Submit imports by commit with file descriptions
(
cd "$paperserverdir"
# rm -rf nms-patches
git add . &> /dev/null
echo -e "Extra dev imports of Akarin:\n\n$IMPORT_LOG" | git commit src -F - &> /dev/null
echo " $(bashcolor 1 32) Succeed$(bashcolorend) - Sources have been imported to the current branch/state of Paper/Paper-Server"
)

View File

@@ -1,107 +0,0 @@
#!/usr/bin/env bash
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
paperworkdir="$basedir/Paper/work"
minecraftversion=$(cat "$basedir"/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
decompiledir=$paperworkdir/Minecraft/$minecraftversion/spigot
nms="net/minecraft/server"
export MODLOG=""
basedir
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 "$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="$paperworkdir/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/
lastlog=$(git log -1 --oneline)
if [[ "$lastlog" = *"Akarin 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')
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
fi
done
###############################################################################################
###############################################################################################
#################### ADD TEMPORARY ADDITIONS HERE #############################################
###############################################################################################
###############################################################################################
# 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/
rm -rf nms-patches
git add src -A
echo -e "Akarin extra mc-dev Imports\n\n$MODLOG" | git commit --allow-empty src -F -
exit 0
)

25
scripts/makeAkarinclip.sh Normal file
View File

@@ -0,0 +1,25 @@
#!/usr/bin/env bash
echo "[Akarin] State: Make Akarinclip"
# 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)"
paperworkdir="$basedir/Paper/work"
mcver=$(cat "$paperworkdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
serverjar="$basedir/Akarin-Server/target/akarin-$mcver.jar"
vanillajar="$paperworkdir/Minecraft/$mcver/$mcver.jar"
(
cd "$paperworkdir/Paperclip"
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$serverjar" "-Dvanillajar=$vanillajar"
)
cp "$paperworkdir/Paperclip/assembly/target/paperclip-${mcver}.jar" "$basedir/akarinclip-${mcver}.jar"
echo ""
echo ""
echo ""
echo "Build success!"
echo "Copied final jar to $(cd "$basedir" && pwd -P)/akarinclip-${mcver}.jar"

View File

@@ -1,23 +0,0 @@
#!/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=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
paperjar="$basedir/Akarin-Server/target/akarin-$mcver.jar"
vanillajar="$workdir/Minecraft/$mcver/$mcver.jar"
(
cd "$workdir/Paperclip"
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$paperjar" "-Dvanillajar=$vanillajar"
)
cp "$workdir/Paperclip/assembly/target/paperclip-${mcver}.jar" "$basedir/akarin-paperclip.jar"
echo ""
echo ""
echo ""
echo "Build success!"
echo "Copied final jar to $(cd "$basedir" && pwd -P)/akarin-paperclip.jar"

View File

@@ -1,12 +0,0 @@
#!/usr/bin/env bash
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
minecraftversion=$(cat $basedir/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
basedir
gitpush ${FORK_NAME}-API $API_REPO master:$minecraftversion
gitpush ${FORK_NAME}-Server $SERVER_REPO master:$minecraftversion

View File

@@ -1,15 +1,16 @@
#!/usr/bin/env bash
echo "[Akarin] State: Rebuild Patches"
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
gitcmd="git -c commit.gpgsign=false -c core.safecrlf=false"
echo "Rebuilding patch files from current fork state..."
echo "Rebuild patch files from local sources.."
function savePatches {
what=$1
cd $basedir/$what/
basedir
mkdir -p $basedir/patches/$2
if [ -d ".git/rebase-apply" ]; then
# in middle of a rebase, be smarter
@@ -24,16 +25,16 @@ function savePatches {
fi
done
else
rm $basedir/patches/$2/*.patch
rm -rf $basedir/patches/$2/*.patch
fi
git format-patch --no-signature --zero-commit --full-index --no-stat -N -o $basedir/patches/$2 upstream/upstream
cd $basedir
git add -A $basedir/patches/$2
echo " Patches saved for $what to patches/$2"
cd "$basedir/$1"
$gitcmd format-patch --no-stat -N -o "$basedir/patches/$2" upstream/upstream >/dev/null
basedir
$gitcmd add -A "$basedir/patches/$2"
echo " Patches saved for $basedir to patches/$2"
}
savePatches ${FORK_NAME}-API api
savePatches ${FORK_NAME}-Server server
$basedir/scripts/push.sh "$basedir"
# gitpushproject

86
scripts/updateUpstream.sh Normal file
View File

@@ -0,0 +1,86 @@
#!/usr/bin/env bash
# SCRIPT HEADER start
echo "----------------------------------------"
echo " $(bashcolor 1 32)Task$(bashcolorend) - Update Upstream"
echo " This will update and patch Paper, then importing necessary sources for patching."
echo " "
echo " $(bashcolor 1 32)Subtask:$(bashcolorend)"
echo " - Import Sources"
echo " "
echo " $(bashcolor 1 32)Projects:$(bashcolorend)"
echo " - $(bashcolor 1 32)1$(bashcolorend) : Paper"
echo " - $(bashcolor 1 32)2$(bashcolorend) : Akarin"
echo "----------------------------------------"
# SCRIPT HEADER end
# This script are capable of patching paper which have the same effect with renewing the source codes of paper to its corresponding remote/official state, and also are able to reset the patches of paper to its head commit to override dirty changes which needs a argument with --resetPaper.
# After the patching, it will copying sources that do no exist in the akarin workspace but referenced in akarin patches into our workspace, depending on the content of our patches, this will be addressed by calling importSources.sh.
# Following by invoking generateImports.sh, it will generate new added/imported files of paper compared to the original decompiled sources into mc-dev folder under the root dir of the project, whose intention is unclear yet.
# exit immediately if a command exits with a non-zero status
set -e
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
subtasks=2
echo " $(bashcolor 1 32)(0/$subtasks)$(bashcolorend) - Update Git submodules.."
git submodule update --init --recursive
if [[ "$2" == "--resetPaper" ]]; then
echo " $(bashcolor 1 32)(0/$subtasks)$(bashcolorend) - Reset Paper submodule.."
paperdir
$gitcmd fetch && $gitcmd reset --hard origin/master
basedir
$gitcmd add Paper
fi
# patch paper
echo " $(bashcolor 1 32)(0/$subtasks)$(bashcolorend) - Apply patches of Paper.."
paperVer=$(gethead Paper)
paperdir
./paper patch
cd "Paper-Server"
mcVer=$(mvn -o org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=minecraft_version | sed -n -e '/^\[.*\]/ !{ /^[0-9]/ { p; q } }')
echo " $(bashcolor 1 32)(1/$subtasks)$(bashcolorend) - Update Git submodule.."
basedir
"$basedir"/scripts/importSources.sh $1
#minecraftversion=$(cat "$basedir"/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
#version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev")
#tag="${minecraftversion}-${mcVer}-$(echo -e $version | shasum | awk '{print $2}')"
#echo "$tag" > "$basedir"/current-paper
# "$basedir"/scripts/generateImports.sh $1 # unused
#echo " $(bashcolor 1 32)(1/$subtasks)$(bashcolorend) - Tagging Paper submodules.."
#function tag {
# paperdir && cd $1
# if [ "$3" == "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 -e "$version"
#forcetag=0
#if [ "$(cat "$basedir"/current-paper)" != "$tag" ]; then
# forcetag=1
#fi
#tag Paper-API $forcetag
#tag Paper-Server $forcetag
echo " $(bashcolor 1 32)($subtasks/$subtasks) Succeed$(bashcolorend) - Submodules have been updated, regenerated and imported, run 'akarin patch' to test/fix patches, and by 'akarin rbp' to rebuild patches that fixed with the updated upstream."
echo " "
# gitpush Paper-API $PAPER_API_REPO $tag
# gitpush Paper-Server $PAPER_SERVER_REPO $tag

View File

@@ -1,50 +0,0 @@
#!/usr/bin/env bash
# exit immediately if a command exits with a non-zero status
set -e
# get base dir regardless of execution location
basedir=$1
source "$basedir/scripts/functions.sh"
git submodule update --init --recursive
if [[ "$2" == reset* ]]; then
paperdir
gitcmd fetch && gitcmd reset --hard origin/master
basedir
gitcmd add Paper
fi
# patch paper
paperVer=$(gethead Paper)
paperdir
./paper patch
cd "Paper-Server"
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"/scripts/importmcdev.sh $1
minecraftversion=$(cat "$basedir"/Paper/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
version=$(echo -e "Paper: $paperVer\nmc-dev:$importedmcdev")
tag="${minecraftversion}-${mcVer}-$(echo -e $version | shasum | awk '{print $2}')"
echo "$tag" > "$basedir"/current-paper
"$basedir"/scripts/generateImports.sh $1
function tag {
cd $1
echo -e "$(date)\n\n$version" | git tag -f -a "$tag" -F - 2>/dev/null
}
echo "Tagging as $tag"
echo -e "$version"
tag "$basedir"/Paper/Paper-API
tag "$basedir"/Paper/Paper-Server
gitpush "$basedir"/Paper/Paper-API $PAPER_API_REPO $tag
gitpush "$basedir"/Paper/Paper-Server $PAPER_SERVER_REPO $tag