mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-06 02:42:34 +01:00
Fix
This commit is contained in:
parent
5566583015
commit
b8c158bd41
@ -1,79 +0,0 @@
|
||||
#!/bin/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
|
||||
PS1="$"
|
||||
|
||||
tuinityVer=$(cat current-tuinity)
|
||||
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 am --abort ; git rebase --abort) 1>&2 2>/dev/null || true
|
||||
git checkout master 2>/dev/null
|
||||
git fetch upstream >/dev/null 2>&1
|
||||
git reset --hard upstream/upstream
|
||||
echo " Applying patches to $target..."
|
||||
statusfile=".git/patch-apply-failed"
|
||||
rm -f "$statusfile"
|
||||
git am --abort >/dev/null 2>&1
|
||||
git am --3way --ignore-whitespace "$basedir/patches/$patch_folder/"*.patch
|
||||
if [ "$?" != "0" ]; then
|
||||
echo 1 > "$statusfile"
|
||||
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
|
||||
rm -f "$statusfile"
|
||||
echo " Patches applied cleanly to $target"
|
||||
fi
|
||||
}
|
||||
function enableCommitSigningIfNeeded {
|
||||
if [[ "$gpgsign" == "true" ]]; then
|
||||
git config commit.gpgsign true
|
||||
fi
|
||||
}
|
||||
|
||||
(
|
||||
(applyPatch Tuinity/Tuinity-API ${FORK_NAME}-API HEAD api $API_REPO &&
|
||||
applyPatch Tuinity/Tuinity-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO) || exit 1
|
||||
enableCommitSigningIfNeeded
|
||||
) || (
|
||||
echo "Failed to apply patches"
|
||||
enableCommitSigningIfNeeded
|
||||
exit 1
|
||||
) || exit 1
|
95
scripts/applyPatches.sh
Normal file
95
scripts/applyPatches.sh
Normal file
@ -0,0 +1,95 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# SCRIPT HEADER start
|
||||
basedir=$1
|
||||
source "$basedir/scripts/functions.sh"
|
||||
echo " "
|
||||
echo "----------------------------------------"
|
||||
echo " $(bashcolor 1 32)Task$(bashcolorend) - Apply Patches"
|
||||
echo " This will apply all of YAPFA 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
|
||||
|
||||
needimport=$2
|
||||
|
||||
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 2>&1 # possibly already in
|
||||
$gitcmd branch -D upstream &> /dev/null
|
||||
$gitcmd branch -f upstream "$branch" &> /dev/null && $gitcmd checkout upstream &> /dev/null
|
||||
|
||||
if [[ $needimport != "1" ]]; then
|
||||
if [ $baseproject != "Paper/Paper-API" ]; then
|
||||
echo " $(bashcolor 1 32)($5/$6)$(bashcolorend) - Import new introduced NMS files.."
|
||||
basedir && $scriptdir/importSources.sh $basedir 1 || exit 1
|
||||
fi
|
||||
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
|
||||
|
||||
echo " "
|
||||
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
|
||||
$gitcmd remote add upstream "$basedir/$baseproject" &> /dev/null
|
||||
# Ensure that we are in the branch we want so not overriding things
|
||||
$gitcmd checkout master &> /dev/null || $gitcmd checkout -b master &> /dev/null
|
||||
$gitcmd fetch upstream &> /dev/null
|
||||
# Reset our source project to Paper
|
||||
cd "$basedir/$target" && $gitcmd reset --hard upstream/upstream &> /dev/null
|
||||
echo " "
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
(applyPatch Tuinity/Tuinity-API ${FORK_NAME}-API HEAD api $API_REPO 0 2 &&
|
||||
applyPatch Tuinity/Tuinity-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO 1 2) || exit 1
|
30
scripts/commitUpstream.sh
Normal file
30
scripts/commitUpstream.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "[YAPFA] State: Commit Upstream"
|
||||
|
||||
(
|
||||
set -e
|
||||
|
||||
function changeLog() {
|
||||
base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1)
|
||||
cd $1 && git log --oneline ${base}...HEAD
|
||||
}
|
||||
paper=$(changeLog Tuinity)
|
||||
|
||||
updated=""
|
||||
logsuffix=""
|
||||
if [ ! -z "$paper" ]; then
|
||||
logsuffix="$logsuffix\nTuinity Changes:\n$paper"
|
||||
if [ -z "$updated" ]; then updated="Tuinity"; else updated="$updated/Tuinity"; fi
|
||||
fi
|
||||
disclaimer="Upstream has released updates that appears to apply and compile correctly"
|
||||
|
||||
if [ ! -z "$1" ]; then
|
||||
disclaimer="$@"
|
||||
fi
|
||||
|
||||
log="Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}"
|
||||
|
||||
echo -e "$log" | git commit -F -
|
||||
|
||||
) || exit 1
|
@ -1,16 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
(
|
||||
set -e
|
||||
PS1="$"
|
||||
|
||||
function changelog() {
|
||||
base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1)
|
||||
cd $1 && git log --oneline ${base}...HEAD
|
||||
}
|
||||
tuinity=$(changelog Tuinity)
|
||||
|
||||
log="Updated Tuinity \n\nUpdating our baseline Tuinity reference\n\nTuinity changes since last:\n$tuinity"
|
||||
|
||||
echo -e "$log" | git commit -F -
|
||||
|
||||
) || exit 1
|
131
scripts/functions.sh
Normal file
131
scripts/functions.sh
Normal file
@ -0,0 +1,131 @@
|
||||
#!/usr/bin/env bash
|
||||
# CONFIG set
|
||||
FORK_NAME="YAPFA"
|
||||
API_REPO=""
|
||||
SERVER_REPO=""
|
||||
PAPER_API_REPO=""
|
||||
PAPER_SERVER_REPO=""
|
||||
MCDEV_REPO=""
|
||||
|
||||
# Added Multithreading to builds
|
||||
# By JosephWorks
|
||||
mvncmd="mvn -T 1.5C"
|
||||
|
||||
gitcmd="git -c commit.gpgsign=false -c core.quotepath=false -c core.safecrlf=false -c i18n.commit.encoding=UTF-8 -c i18n.logoutputencoding=UTF-8"
|
||||
|
||||
# DIR configure
|
||||
# resolve shell-specifics
|
||||
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"
|
||||
}
|
||||
|
||||
function paperdir {
|
||||
cd "$basedir/Tuinity"
|
||||
}
|
||||
|
||||
gitcmd() {
|
||||
$gitcmd "$@"
|
||||
}
|
||||
|
||||
# COLOUR functions
|
||||
color() {
|
||||
if [ $2 ]; then
|
||||
echo -e "\e[$1;$2m"
|
||||
else
|
||||
echo -e "\e[$1m"
|
||||
fi
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
gitunstash() {
|
||||
if [[ "$STASHED" != "No local changes to save" ]] ; then
|
||||
$gitcmd stash pop 2>/dev/null|| return 0 # errors are ok
|
||||
fi
|
||||
}
|
||||
|
||||
function gethead {
|
||||
basedir
|
||||
git log -1 --oneline
|
||||
}
|
||||
|
||||
function gitpush {
|
||||
if [ "$(git config minecraft.push-${FORK_NAME})" == "1" ]; then
|
||||
echo "Push - $1 ($3) to $2"
|
||||
(
|
||||
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
|
||||
)
|
||||
fi
|
||||
}
|
||||
|
||||
# PATCH functions
|
||||
function cleanupPatches {
|
||||
cd "$1"
|
||||
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
|
||||
|
||||
if [ "x$diffs" == "x" ] ; then
|
||||
git reset HEAD $patch >/dev/null
|
||||
git checkout -- $patch >/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function containsElement {
|
||||
local e
|
||||
for e in "${@:2}"; do
|
||||
[[ "$e" == "$1" ]] && return 0;
|
||||
done
|
||||
return 1
|
||||
}
|
46
scripts/generateImports.sh
Normal file
46
scripts/generateImports.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
echo "[YAPFA] State: Generate Imports"
|
||||
|
||||
# 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/Tuinity/Paper/work"
|
||||
minecraftversion=$(cat $paperworkdir/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
|
||||
decompile="$paperworkdir/Minecraft/$minecraftversion/spigot"
|
||||
|
||||
# create dev dir
|
||||
basedir
|
||||
mkdir -p mc-dev/src/net/minecraft/server
|
||||
cd mc-dev
|
||||
|
||||
# prepare to push
|
||||
if [ ! -d ".git" ]; then
|
||||
$gitcmd init
|
||||
fi
|
||||
|
||||
# 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
|
||||
|
||||
# diff and only preserve new added files
|
||||
paperserver="$basedir/Tuinity/Tuinity-Server/src/main/java/net/minecraft/server"
|
||||
cd $basedir/mc-dev/src/net/minecraft/server/
|
||||
|
||||
for file in $(/bin/ls $paperserver)
|
||||
do
|
||||
if [ -f "$file" ]; then
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
||||
|
||||
# push the dev project
|
||||
cd $basedir/mc-dev
|
||||
$gitcmd add . -A
|
||||
$gitcmd commit . -m "YAPFA-base"
|
||||
$gitcmd tag -a "YAPFA-base" -m "YAPFA-base" 2>/dev/null
|
||||
# gitpush . $MCDEV_REPO $paperVer
|
@ -1,43 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
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
|
||||
|
||||
|
||||
cd $basedir
|
||||
tuinityVer=$(cat current-tuinity)
|
||||
|
||||
minecraftversion=$(cat $basedir/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
|
||||
decompile="Tuinity/work/Minecraft/$minecraftversion/spigot"
|
||||
|
||||
mkdir -p mc-dev/src/net/minecraft/server
|
||||
|
||||
cd mc-dev
|
||||
if [ ! -d ".git" ]; then
|
||||
git init
|
||||
fi
|
||||
|
||||
rm src/net/minecraft/server/*.java
|
||||
for i in $basedir/$decompile/net/minecraft/server/*.java;
|
||||
do
|
||||
cp "$i" src/net/minecraft/server
|
||||
done
|
||||
|
||||
|
||||
base="$basedir/Tuinity/Tuinity-Server/src/main/java/net/minecraft/server"
|
||||
cd $basedir/mc-dev/src/net/minecraft/server/
|
||||
for file in $(/bin/ls $base)
|
||||
do
|
||||
if [ -f "$file" ]; then
|
||||
rm -f "$file"
|
||||
fi
|
||||
done
|
||||
cd $basedir/mc-dev
|
||||
git add . -A
|
||||
git commit . -m "mc-dev"
|
||||
git tag -a "$tuinityVer" -m "$tuinityVer" 2>/dev/null
|
138
scripts/importSources.sh
Normal file
138
scripts/importSources.sh
Normal file
@ -0,0 +1,138 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
maintask=$2
|
||||
if [[ $maintask == "0" ]]; then
|
||||
TASKTITLE="Import Sources"
|
||||
else
|
||||
TASKTITLE="Import Sources (Subtask)"
|
||||
fi
|
||||
|
||||
# SCRIPT HEADER start
|
||||
basedir=$1
|
||||
source "$basedir/scripts/functions.sh"
|
||||
echo " "
|
||||
echo "----------------------------------------"
|
||||
echo " $(bashcolor 1 32)Task$(bashcolorend) - $TASKTITLE"
|
||||
echo " This will import unimported newly added/mod sources to Paper workspace"
|
||||
echo "----------------------------------------"
|
||||
# SCRIPT HEADER end
|
||||
|
||||
# For a description of this script, see updateUpstream.sh.
|
||||
paperworkdir="$basedir/Tuinity/Paper/work"
|
||||
paperserverdir="$basedir/Tuinity/Tuinity-Server"
|
||||
papersrcdir="$paperserverdir/src/main/java"
|
||||
papernmsdir="$papersrcdir/net/minecraft/server"
|
||||
|
||||
(
|
||||
# fast-fail if Paper not set
|
||||
if [ ! -d "$papernmsdir" ]; then
|
||||
echo " $(bashcolor 1 31)Exception$(bashcolorend) - Paper sources not generated, run updateUpstream.sh to setup."
|
||||
exit 1
|
||||
fi
|
||||
)
|
||||
|
||||
minecraftversion=$(cat "$basedir"/Tuinity/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
|
||||
}
|
||||
|
||||
(
|
||||
# Reset to last NORMAL commit if already have imported before
|
||||
cd "$paperserverdir"
|
||||
lastcommit=$(git log -1 --pretty=oneline --abbrev-commit)
|
||||
if [[ "$lastcommit" = *"Extra dev imports of YAPFA"* ]]; 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')
|
||||
|
||||
(
|
||||
cd "$paperserverdir"
|
||||
$gitcmd fetch --all &> /dev/null
|
||||
# Create the upstream branch in Paper project with current state
|
||||
$gitcmd checkout master >/dev/null 2>&1 # possibly already in
|
||||
$gitcmd branch -D upstream &>/dev/null
|
||||
$gitcmd branch -f upstream HEAD && $gitcmd checkout upstream
|
||||
)
|
||||
|
||||
basedir
|
||||
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)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
|
||||
|
||||
# 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 YAPFA\n\n$IMPORT_LOG" | git commit src -F - &> /dev/null
|
||||
echo " $(bashcolor 1 32)Succeed$(bashcolorend) - Sources have been imported to Paper/Paper-Server (branch upstream)"
|
||||
|
||||
if [[ $maintask != "0" ]]; then # this is magical
|
||||
echo "----------------------------------------"
|
||||
echo " Subtask finished"
|
||||
echo "----------------------------------------"
|
||||
fi
|
||||
)
|
@ -1,46 +0,0 @@
|
||||
#!/bin/bash
|
||||
sourceBase=$(dirname $SOURCE)/../
|
||||
cd "${basedir:-$sourceBase}"
|
||||
|
||||
basedir=$(pwd -P)
|
||||
cd -
|
||||
|
||||
FORK_NAME="YAPFA"
|
||||
|
||||
function bashColor {
|
||||
if [ $2 ]; then
|
||||
echo -e "\e[$1;$2m"
|
||||
else
|
||||
echo -e "\e[$1m"
|
||||
fi
|
||||
}
|
||||
function bashColorReset {
|
||||
echo -e "\e[m"
|
||||
}
|
||||
|
||||
function cleanupPatches {
|
||||
cd "$1"
|
||||
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
|
||||
|
||||
if [ "x$diffs" == "x" ] ; then
|
||||
git reset HEAD $patch >/dev/null
|
||||
git checkout -- $patch >/dev/null
|
||||
fi
|
||||
done
|
||||
}
|
||||
function basedir {
|
||||
cd "$basedir"
|
||||
}
|
||||
function gethead {
|
||||
(
|
||||
cd "$1"
|
||||
git log -1 --oneline
|
||||
)
|
||||
}
|
31
scripts/installLauncher.sh
Normal file
31
scripts/installLauncher.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# SCRIPT HEADER start
|
||||
basedir=$1
|
||||
source "$basedir/scripts/functions.sh"
|
||||
echo " "
|
||||
echo "----------------------------------------"
|
||||
echo " $(bashcolor 1 32)Task$(bashcolorend) - Install Launcher"
|
||||
echo " This will build a launcher that similar to Paperclip by the server jar."
|
||||
echo " "
|
||||
echo "----------------------------------------"
|
||||
# SCRIPT HEADER end
|
||||
|
||||
# Copied from https://github.com/PaperMC/Paper/blob/d54ce6c17fb7a35238d6b9f734d30a4289886773/scripts/paperclip.sh
|
||||
# License from Paper applies to this file
|
||||
|
||||
set -e
|
||||
paperworkdir="$basedir/Tuinity/Paper/work"
|
||||
mcver=$(cat "$paperworkdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
serverjar="$basedir/YAPFA-Server/target/YAPFA-$mcver.jar"
|
||||
vanillajar="$paperworkdir/Minecraft/$mcver/$mcver.jar"
|
||||
|
||||
(
|
||||
cd "$paperworkdir/Paperclip"
|
||||
mvn clean package "-Dmcver=$mcver" "-Dpaperjar=$serverjar" "-Dvanillajar=$vanillajar"
|
||||
)
|
||||
mkdir -p "$basedir/target"
|
||||
cp "$paperworkdir/Paperclip/assembly/target/paperclip-${mcver}.jar" "$basedir/target/YAPFA-${mcver}-launcher.jar"
|
||||
|
||||
echo ""
|
||||
echo " $(bashcolor 1 32)Success$(bashcolorend) - Saved launcher jar to target/YAPFA-${mcver}-launcher.jar"
|
@ -1,25 +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/Tuinity/Paper/work"
|
||||
mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)
|
||||
paperjar="$basedir/YAPFA-Server/target/yapfa-$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/yapfa-paperclip.jar"
|
||||
|
||||
echo ""
|
||||
echo ""
|
||||
echo ""
|
||||
echo "Build success!"
|
||||
echo "Copied final jar to $(cd "$basedir" && pwd -P)/yapfa-paperclip.jar"
|
||||
) || exit 1
|
@ -1,13 +0,0 @@
|
||||
#!/bin/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/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
|
||||
|
||||
basedir
|
@ -1,51 +1,46 @@
|
||||
#!/bin/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
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# SCRIPT HEADER start
|
||||
basedir=$1
|
||||
source "$basedir/scripts/functions.sh"
|
||||
echo " "
|
||||
echo "----------------------------------------"
|
||||
echo " $(bashcolor 1 32)Task$(bashcolorend) - Rebuild Patches"
|
||||
echo " This will diff the sources of YAPFA and Paper to build patches."
|
||||
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
|
||||
|
||||
PS1="$"
|
||||
echo "Rebuilding patch files from current fork state..."
|
||||
function savePatches {
|
||||
what=$1
|
||||
cd ${basedir}/${what}/
|
||||
targetname=$1
|
||||
basedir
|
||||
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[`expr $i - 1`]}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
rm -rf $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[`expr ${i} - 1`]}"
|
||||
fi
|
||||
done
|
||||
else
|
||||
rm ${basedir}/patches/$2/*.patch
|
||||
fi
|
||||
|
||||
git format-patch --quiet -N -o ${basedir}/patches/$2 upstream/upstream
|
||||
cd ${basedir}
|
||||
git add -A ${basedir}/patches/$2
|
||||
cleanupPatches ${basedir}/patches/$2/
|
||||
echo " Patches saved for $what to patches/$2"
|
||||
cd "$basedir/$targetname"
|
||||
$gitcmd format-patch --no-signature --zero-commit --full-index --no-stat -N -o "$basedir/patches/$2" upstream/upstream >/dev/null
|
||||
basedir
|
||||
$gitcmd add -A "$basedir/patches/$2"
|
||||
echo " $(bashcolor 1 32)($3/$4)$(bashcolorend) - Patches saved for $targetname to patches/$2"
|
||||
}
|
||||
|
||||
savePatches ${FORK_NAME}-API api
|
||||
if [ -f "$basedir/${FORK_NAME}-API/.git/patch-apply-failed" ]; then
|
||||
echo "$(bashColor 1 31)[[[ WARNING ]]] $(bashColor 1 33)- Not saving Tuinity-Server as it appears ${FORK_NAME}-API did not apply clean.$(bashColorReset)"
|
||||
echo "$(bashColor 1 33)If this is a mistake, delete $(bashColor 1 34)${FORK_NAME}-API/.git/patch-apply-failed$(bashColor 1 33) and run rebuild again.$(bashColorReset)"
|
||||
echo "$(bashColor 1 33)Otherwise, rerun ./tuinity patch to have a clean Tuinity-API apply so the latest Tuinity-Server can build.$(bashColorReset)"
|
||||
else
|
||||
savePatches ${FORK_NAME}-Server server
|
||||
${basedir}/scripts/push.sh
|
||||
fi
|
||||
|
||||
|
||||
savePatches ${FORK_NAME}-API api 1 2
|
||||
savePatches ${FORK_NAME}-Server server 2 2
|
||||
# gitpushproject
|
||||
|
87
scripts/updateUpstream.sh
Normal file
87
scripts/updateUpstream.sh
Normal file
@ -0,0 +1,87 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# SCRIPT HEADER start
|
||||
basedir=$1
|
||||
source "$basedir/scripts/functions.sh"
|
||||
echo "----------------------------------------"
|
||||
echo " $(bashcolor 1 32)Task$(bashcolorend) - Update Upstream"
|
||||
echo " This will update and patch Paper, 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) : YAPFA"
|
||||
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 YAPFA workspace but referenced in YAPFA 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
|
||||
|
||||
subtasks=1
|
||||
updatepaper=$2
|
||||
if [ "$updatepaper" == "1" ]; then
|
||||
echo " $(bashcolor 1 32)(0/$subtasks)$(bashcolorend) - Update Git submodules.."
|
||||
$gitcmd submodule update --init --remote
|
||||
fi
|
||||
|
||||
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 Tuinity.."
|
||||
echo " "
|
||||
paperVer=$(gethead Tuinity)
|
||||
paperdir
|
||||
./tuinity patch
|
||||
|
||||
#cd "Paper-Server"
|
||||
#mcVer=$($mvncmd -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) - Import necessary sources.."
|
||||
#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 'YAPFA patch' to test/fix patches, and by 'YAPFA 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
|
@ -1,60 +0,0 @@
|
||||
#!/bin/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
|
||||
|
||||
if [[ "$1" == up* ]]; then
|
||||
(
|
||||
cd "$basedir/Tuinity/"
|
||||
git fetch && git reset --hard origin/ver/1.14
|
||||
cd ../
|
||||
git add Tuinity
|
||||
)
|
||||
fi
|
||||
|
||||
tuinityVer=$(gethead Tuinity)
|
||||
cd "$basedir/Tuinity/"
|
||||
|
||||
./tuinity patch
|
||||
|
||||
cd "Tuinity-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
|
||||
|
||||
minecraftversion=$(cat $basedir/Tuinity/work/BuildData/info.json | grep minecraftVersion | cut -d '"' -f 4)
|
||||
version=$(echo -e "Tuinity: $tuinityVer\nmc-dev:$importedmcdev")
|
||||
tag="${minecraftversion}-${mcVer}-$(echo -e $version | shasum | awk '{print $1}')"
|
||||
echo "$tag" > $basedir/current-tuinity
|
||||
git add "$basedir/current-tuinity"
|
||||
|
||||
$basedir/scripts/generatesources.sh
|
||||
|
||||
cd Tuinity/
|
||||
|
||||
function tag {
|
||||
(
|
||||
cd $1
|
||||
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-tuinity)" != "$tag" ]; then
|
||||
forcetag=1
|
||||
fi
|
||||
|
||||
tag Tuinity-API $forcetag
|
||||
tag Tuinity-Server $forcetag
|
||||
|
@ -1,33 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
(
|
||||
set -e
|
||||
PS1="$"
|
||||
|
||||
function changelog() {
|
||||
base=$(git ls-tree HEAD $1 | cut -d' ' -f3 | cut -f1)
|
||||
cd $1 && git log --oneline ${base}...ORIGIN/ver/1.16
|
||||
}
|
||||
tuinity=$(changelog Tuinity)
|
||||
#paper=$(changelog Tuinity/Paper)
|
||||
|
||||
updated=""
|
||||
logsuffix=""
|
||||
if [ ! -z "$tuinity" ]; then
|
||||
logsuffix="$logsuffix\n\nTuinity Changes:\n$tuinity"
|
||||
if [ -z "$updated" ]; then updated="Tuinity"; else updated="$updated/Tuinity"; fi
|
||||
fi
|
||||
#if [ ! -z "$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 [ ! -z "$1" ]; then
|
||||
disclaimer="$@"
|
||||
fi
|
||||
|
||||
log="${UP_LOG_PREFIX}Updated Upstream ($updated)\n\n${disclaimer}${logsuffix}"
|
||||
|
||||
echo -e "$log"
|
||||
|
||||
) || exit 1
|
Loading…
Reference in New Issue
Block a user