Yatopia/scripts/applyPatches.sh
budgidiere ff560e687c
[WIP] Better Patch System (#18)
* Update build.yml

* Remove 3rd party patches

* Add Upsteam Submodules

* Fix patches

* ?

* Fix patches

* Add Fast Init script

* Lots of stuff

also it's broke

* more broken

* fixes

* mor stuff

* gfhfgh

hg

* fix patch

* fix up script

* update submodule

* add papercut

* update tuinity

* update gitmodules

* fix var name

* fix more var stuff

* some how it's not deleting shit anymore

* should now use the branch it just made

why are we doing this again?

* now it does thing thing

* return previous so YAPFA can use it

* ok now it really does the thing

* for REAL it does the thing

* don't do the thing because it causes too many problems

* fix api

* work

* use better patching for YAPFA patches

* fix better patching

* more fixes

* new patches stuff

* remove old 3rd parry patches add removed akarin patches

* make new branch for making patches

* hopefully build patches correctly

* fix gitignore and add config patches

* remove papercut files

* fix some weirdness

* fix bug

* time to do some fixin' 👀

* New Patch System Rebased Patches

* fix full build

* exit 1

* fix

* Remove patch

* Hopefully fix compile errors

* fixes

* this might work

* don't use rej for our patches

* tmp disable cache

* some times case sensitivity is dumb

* my sanity is at an all time low :)

* dfg

* readd cahce

* fix?

* Update Upstream

* fix perms

* fix

* fix api

* Redo API

* rm folders

* fix villager brain patch

* emc explosion pref

* fixed aikar's shit

* betterfix

* fix lagggg

* Origami

* Origami Fixes

* Update readme

* test async path finding

* WIP Async Path Finding

* WIP fix async path finding

* same as bellow

* same

* update to newer funcs

* fix newer funcs

* fix author

* Updates, Fixes, and new patches

* fixes

* possibly async flying path finding

* minor asnyc pathfinding fix

* test remove non asnyc path finder

* WIP make all path finding async

* Rename everything

* Exec flag

* Rebuild hashes

* remove dupe patch

* fix?

* Fix packages, redirect config

* old nav class is now async and back

* add getchatcolor.getbyid and handle patches with a . in them better

Co-authored-by: tr7zw <tr7zw@live.de>
Co-authored-by: Unknown <unknown@example.com>
Co-authored-by: Ovydux <68059159+Ovydux@users.noreply.github.com>
2020-08-03 11:48:42 -05:00

124 lines
4.2 KiB
Bash
Executable File

#!/usr/bin/env bash
# SCRIPT HEADER start
basedir=$1
source "$basedir/scripts/functions.sh"
gpgsign="$($gitcmd config commit.gpgsign || echo "false")"
echo " "
echo "----------------------------------------"
echo " $(bashcolor 1 32)Task$(bashcolorend) - Apply Patches"
echo " This will apply all of Yatopia 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 enableCommitSigningIfNeeded {
if [[ "$gpgsign" == "true" ]]; then
$gitcmd config commit.gpgsign true
fi
}
function applyPatch {
baseproject=$1
basename=$(basename $baseproject)
target=$2
branch=$3
patch_folder=$4
cd $basedir/$2
# 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
# 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
if [[ $needimport != "1" ]]; then
if [ $baseproject != "Tuinity/Tuinity-API" ]; then
echo " $(bashcolor 1 32)($5/$6)$(bashcolorend) - Import new introduced NMS files.."
#cd $basedir/Yatopia-Server/
#branch_name="$(git symbolic-ref HEAD 2>/dev/null)"
#branch_name=${branch_name:-9}
#cd $basedir
basedir && $scriptdir/importSources.sh $basedir "Yatopia" || exit 1
fi
fi
#$gitcmd branch $target
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
cd $basedir/$2
git branch -d $2
git branch $2
git checkout $2
# for filename in $basedir/patches/$patch_folder/*.patch; do
# # Abort previous applying operation
# git am --abort >/dev/null 2>&1
# # Apply our patches on top Paper in our dirs
# git am --reject --whitespace=fix --no-utf8 --3way --ignore-whitespace $filename || (
# files=`$gitcmd diff --name-only | grep -E '.rej$' `
# if [[ files != null ]]; then
# for filerej in files; do
# echo "Error found .rej file! Deleting. This might have unforseen consqunces!"
# rm -f filerej
# done
# fi
# filenamend="${filename##*/}"
# filenamens=${filenamend%/*}
# filenameedited=${filenamens%.*} # retain the part before the period
# filenameedited=${filenameedited:5} # retain the part after the frist slash
# git add .
# git commit -m $filenameedited
# )
# done
$gitcmd am --abort >/dev/null 2>&1
# Apply our patches on top Paper in our dirs
$gitcmd am --whitespace=fix --no-utf8 --3way --ignore-whitespace "$basedir/patches/$patch_folder/"*.patch
cd $basedir
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
}
rm -rf $basedir/Yatopia/Yatopia-Server
rm -rf $basedir/Yatopia/Yatopia-API
$1/scripts/resetToUpstream.sh $1
$1/scripts/getUpstream.sh $1
(applyPatch Yatopia/Yatopia-API ${FORK_NAME}-API HEAD api $API_REPO 0 2 &&
applyPatch Yatopia/Yatopia-Server ${FORK_NAME}-Server HEAD server $SERVER_REPO 1 2 && enableCommitSigningIfNeeded) || (
enableCommitSigningIfNeeded
exit 1 )