From c8ecb664c640639bf6b57a4e82bb5ba43518b02c Mon Sep 17 00:00:00 2001 From: Kyle Wood Date: Tue, 15 Jun 2021 01:42:57 -0500 Subject: [PATCH] Remove now unnecessary scripts and update upstreamMerge.sh --- scripts/applyPatches.sh | 109 -------------------- scripts/build.sh | 15 --- scripts/decompile.sh | 146 -------------------------- scripts/functions.sh | 24 ----- scripts/importmcdev.sh | 126 ----------------------- scripts/init.sh | 77 -------------- scripts/makemcdevsrc.sh | 29 ------ scripts/paperclip.sh | 22 ---- scripts/pre-source-patches/README.md | 16 --- scripts/rebuildPatches.sh | 70 ------------- scripts/remap.sh | 81 --------------- scripts/requireDeps.sh | 26 ----- scripts/testServer.sh | 148 --------------------------- scripts/upstreamMerge.sh | 4 +- 14 files changed, 2 insertions(+), 891 deletions(-) delete mode 100755 scripts/applyPatches.sh delete mode 100755 scripts/build.sh delete mode 100755 scripts/decompile.sh delete mode 100755 scripts/functions.sh delete mode 100755 scripts/importmcdev.sh delete mode 100755 scripts/init.sh delete mode 100755 scripts/makemcdevsrc.sh delete mode 100755 scripts/paperclip.sh delete mode 100644 scripts/pre-source-patches/README.md delete mode 100755 scripts/rebuildPatches.sh delete mode 100755 scripts/remap.sh delete mode 100755 scripts/requireDeps.sh delete mode 100755 scripts/testServer.sh diff --git a/scripts/applyPatches.sh b/scripts/applyPatches.sh deleted file mode 100755 index e700fde80..000000000 --- a/scripts/applyPatches.sh +++ /dev/null @@ -1,109 +0,0 @@ -#!/usr/bin/env bash - -( -PS1="$" -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) -gitcmd="git -c commit.gpgsign=false" -applycmd="$gitcmd am --3way --ignore-whitespace" -# Windows detection to workaround ARG_MAX limitation -windows="$([[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]] && echo "true" || echo "false")" - -echo "Rebuilding Forked projects.... " - -function applyPatch { - what=$1 - what_name=$(basename "$what") - target=$2 - branch=$3 - - cd "$basedir/$what" - $gitcmd fetch - $gitcmd branch -f upstream "$branch" >/dev/null - - cd "$basedir" - if [ ! -d "$basedir/$target" ]; then - $gitcmd clone "$what" "$target" - fi - cd "$basedir/$target" - - echo "Resetting $target to $what_name..." - $gitcmd remote rm upstream > /dev/null 2>&1 - $gitcmd remote add upstream "$basedir/$what" >/dev/null 2>&1 - $gitcmd checkout master 2>/dev/null || $gitcmd checkout -b master - $gitcmd fetch upstream >/dev/null 2>&1 - $gitcmd reset --hard upstream/upstream - - echo " Applying patches to $target..." - - statusfile=".git/patch-apply-failed" - rm -f "$statusfile" - git config commit.gpgsign false - $gitcmd am --abort >/dev/null 2>&1 - - # Special case Windows handling because of ARG_MAX constraint - if [[ $windows == "true" ]]; then - echo " Using workaround for Windows ARG_MAX constraint" - find "$basedir/${what_name}-Patches/"*.patch -print0 | xargs -0 $applycmd - else - $applycmd "$basedir/${what_name}-Patches/"*.patch - fi - - 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" - - # On Windows, finishing the patch apply will only fix the latest patch - # users will need to rebuild from that point and then re-run the patch - # process to continue - if [[ $windows == "true" ]]; then - echo "" - echo " Because you're on Windows you'll need to finish the AM," - echo " rebuild all patches, and then re-run the patch apply again." - echo " Consider using the scripts with Windows Subsystem for Linux." - fi - - exit 1 - else - rm -f "$statusfile" - echo " Patches applied cleanly to $target" - fi -} - -# Move into spigot dir -cd "$workdir/Spigot" -basedir=$(pwd) -# Apply Spigot -( - applyPatch ../Bukkit Spigot-API HEAD && - applyPatch ../CraftBukkit Spigot-Server patched -) || ( - echo "Failed to apply Spigot Patches" - exit 1 -) || exit 1 -# Move out of Spigot -basedir="$1" -cd "$basedir" - -echo "Importing MC Dev" - -./scripts/importmcdev.sh "$basedir" || exit 1 - -# Apply paper -( - applyPatch "work/Spigot/Spigot-API" Paper-API HEAD && - applyPatch "work/Spigot/Spigot-Server" Paper-Server HEAD - cd "$basedir" - - # if we have previously ran ./paper mcdev, update it - if [ -d "$workdir/Minecraft/$minecraftversion/src" ]; then - ./scripts/makemcdevsrc.sh "$basedir" - fi -) || ( - echo "Failed to apply Paper Patches" - exit 1 -) || exit 1 -) || exit 1 diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index 9b8fa286a..000000000 --- a/scripts/build.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env bash - -( -set -e -basedir="$(cd "$1" && pwd -P)" -gitcmd="git -c commit.gpgsign=false" - -($gitcmd submodule update --init && ./scripts/remap.sh "$basedir" && ./scripts/decompile.sh "$basedir" && ./scripts/init.sh "$basedir" && ./scripts/applyPatches.sh "$basedir") || ( - echo "Failed to build Paper" - exit 1 -) || exit 1 -if [ "$2" == "--jar" ]; then - mvn clean install && ./scripts/paperclip.sh "$basedir" -fi -) || exit 1 diff --git a/scripts/decompile.sh b/scripts/decompile.sh deleted file mode 100755 index 0d0467d99..000000000 --- a/scripts/decompile.sh +++ /dev/null @@ -1,146 +0,0 @@ -#!/usr/bin/env bash - -( -set -e -PS1="$" -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) -windows="$([[ "$OSTYPE" == "cygwin" || "$OSTYPE" == "msys" ]] && echo "true" || echo "false")" -decompiledir="$workdir/Minecraft/$minecraftversion" -spigotdecompiledir="$decompiledir/spigot" -forgedecompiledir="$decompiledir/forge" -forgeflowerversion="1.5.380.19" -forgeflowerurl="http://files.minecraftforge.net/maven/net/minecraftforge/forgeflower/$forgeflowerversion/forgeflower-$forgeflowerversion.jar" -# temp use patched version -forgeflowerurl="https://zachbr.keybase.pub/paper/forgeflower-patched/forgeflower-1.5.380.19.jar?dl=1" -forgeflowerbin="$workdir/ForgeFlower/$forgeflowerversion.jar" -# TODO: Make this better? We don't need spigot compat for this stage -forgefloweroptions="-dgs=1 -hdc=0 -asc=1 -udv=1 -jvn=1" -forgeflowercachefile="$decompiledir/forgeflowercache" -forgeflowercachevalue="$forgeflowerurl - $forgeflowerversion - $forgefloweroptions"; -classdir="$decompiledir/classes" -versionjson="$workdir/Minecraft/$minecraftversion/$minecraftversion.json" - -if [[ ! -f "$versionjson" ]]; then - echo "Downloading $minecraftversion JSON Data" - verescaped=$(echo ${minecraftversion} | sed 's/\-pre/ Pre-Release /g' | sed 's/\./\\./g') - urlescaped=$(echo ${verescaped} | sed 's/ /_/g') - verentry=$(curl -s "https://launchermeta.mojang.com/mc/game/version_manifest.json" | grep -oE "\{\"id\": \"${verescaped}\".*${urlescaped}\.json") - jsonurl=$(echo $verentry | grep -oE https:\/\/.*\.json) - curl -o "$versionjson" "$jsonurl" - echo "$versionjson - $jsonurl" -fi - -function downloadLibraries { - group=$1 - groupesc=$(echo ${group} | sed 's/\./\\./g') - grouppath=$(echo ${group} | sed 's/\./\//g') - libdir="$decompiledir/libraries/${group}/" - mkdir -p "$libdir" - shift - for lib in "$@" - do - jar="$libdir/${lib}-sources.jar" - destlib="$libdir/${lib}" - if [ ! -f "$jar" ]; then - libesc=$(echo ${lib} | sed 's/\./\\]./g') - ver=$(grep -oE "${groupesc}:${libesc}:[0-9\.]+" "$versionjson" | sed "s/${groupesc}:${libesc}://g") - echo "Downloading ${group}:${lib}:${ver} Sources" - curl -s -o "$jar" "https://libraries.minecraft.net/${grouppath}/${lib}/${ver}/${lib}-${ver}-sources.jar" - set +e - grep "" "$jar" && grep -oE ".*?" "$jar" && rm "$jar" && echo "Failed to download $jar" && exit 1 - set -e - fi - - if [ ! -d "$destlib/$grouppath" ]; then - echo "Extracting $group:$lib Sources" - mkdir -p "$destlib" - (cd "$destlib" && jar xf "$jar") - fi - done -} - -downloadLibraries "com.mojang" datafixerupper authlib brigadier - -# prep folders -mkdir -p "$workdir/ForgeFlower" -mkdir -p "$spigotdecompiledir" -mkdir -p "$forgedecompiledir" - -echo "Extracting NMS classes..." -if [ ! -d "$classdir" ]; then - mkdir -p "$classdir" - cd "$classdir" - set +e - jar xf "$decompiledir/$minecraftversion-mapped.jar" net/minecraft com/mojang/math - if [ "$?" != "0" ]; then - cd "$basedir" - echo "Failed to extract NMS classes." - exit 1 - fi - set -e -fi - -#needsDecomp=0 -#if [ ! -f "$forgeflowercachefile" ]; then -# needsDecomp=1 -#elif [ "$(cat ${forgeflowercachefile})" != "$forgeflowercachevalue" ]; then -# needsDecomp=1 -#fi -#if [ "$needsDecomp" == "1" ]; then -# # our local cache is now invalidated, we can update forgeflower to get better deobfuscation -# rm -rf "$forgedecompiledir/net" -#fi - -## Forge (for Paper mc-dev imports, and dev src folders for unimported files) -#if [ ! -d "$forgedecompiledir/net" ] ; then -# echo "Decompiling classes (stage 1)..." -# cd "$basedir" -# -# if [ ! -f "$forgeflowerbin" ]; then -# echo "Downloading ForgeFlower ($forgeflowerversion)..." -# curl -s -o "$forgeflowerbin" "$forgeflowerurl" -# fi -# -# set +e -# java -Ddecomp.renameparams=true -jar "$forgeflowerbin" ${forgefloweroptions} -ind=' ' "$classdir" "$forgedecompiledir" -# if [ "$?" != "0" ]; then -# rm -rf "$forgedecompiledir/net" -# echo "Failed to decompile classes." -# exit 1 -# fi -# echo "$forgeflowercachevalue" > "$forgeflowercachefile" -# set -e -#fi - -# Spigot (for CraftBukkit patches) - -# if we see the old net folder, copy it to spigot to avoid redecompiling -if [ -d "$decompiledir/net" ]; then - cp -r "$decompiledir/net" "$spigotdecompiledir/" -fi - -if [ ! -d "$spigotdecompiledir/net" ]; then - echo "Decompiling classes (stage 2)..." - cd "$basedir" - set +e - java -jar "$workdir/BuildData/bin/fernflower.jar" -dgs=1 -hdc=0 -asc=1 -udv=0 -rsy=1 -aoa=1 "$classdir" "$spigotdecompiledir" - if [ "$?" != "0" ]; then - rm -rf "$spigotdecompiledir/net" - echo "Failed to decompile classes." - exit 1 - fi - set -e -fi - -# set a symlink to current -currentlink="$workdir/Minecraft/current" -if ([ ! -e "$currentlink" ] || [ -L "$currentlink" ]) && [ "$windows" == "false" ]; then - set +e - echo "Pointing $currentlink to $minecraftversion" - rm -rf "$currentlink" || true - ln -sfn "$minecraftversion" "$currentlink" || echo "Failed to set current symlink" -fi - -) diff --git a/scripts/functions.sh b/scripts/functions.sh deleted file mode 100755 index fecad9922..000000000 --- a/scripts/functions.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env bash - -gitcmd="git -c commit.gpgsign=false" - -color() { - if [ $2 ]; then - printf "\e[$1;$2m" - else - printf "\e[$1m" - fi -} -colorend() { - printf "\e[m" -} - -paperstash() { - STASHED=$($gitcmd stash 2>/dev/null|| return 0) # errors are ok -} - -paperunstash() { - if [[ "$STASHED" != "No local changes to save" ]] ; then - $gitcmd stash pop 2>/dev/null|| return 0 # errors are ok - fi -} diff --git a/scripts/importmcdev.sh b/scripts/importmcdev.sh deleted file mode 100755 index 3e8c8e216..000000000 --- a/scripts/importmcdev.sh +++ /dev/null @@ -1,126 +0,0 @@ -#!/usr/bin/env bash - -( -set -e -nms="net/minecraft" -export MODLOG="" -PS1="$" -basedir="$(cd "$1" && pwd -P)" -source "$basedir/scripts/functions.sh" -gitcmd="git -c commit.gpgsign=false" - -workdir="$basedir/work" -minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) -decompiledir="$workdir/Minecraft/$minecraftversion/forge" -# replace for now -decompiledir="$workdir/Minecraft/$minecraftversion/spigot" -export importedmcdev="" -function import { - export importedmcdev="$importedmcdev $1" - file="${1}.java" - target="$workdir/Spigot/Spigot-Server/src/main/java/$nms/$file" - base="$decompiledir/$nms/$file" - - if [[ ! -f "$target" ]]; then - export MODLOG="$MODLOG Imported $file from mc-dev\n"; - #echo "Copying $base to $target" - mkdir -p "$(dirname "$target")" - cp "$base" "$target" || exit 1 - else - echo "UN-NEEDED IMPORT: $file" - fi -} - -function importLibrary { - group=$1 - lib=$2 - prefix=$3 - shift 3 - for file in "$@"; do - file="$prefix/$file" - target="$workdir/Spigot/Spigot-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 "$workdir/Spigot/Spigot-Server/" - lastlog=$($gitcmd log -1 --oneline) - if [[ "$lastlog" = *"mc-dev Imports"* ]]; then - $gitcmd reset --hard HEAD^ - fi -) - - -files=$(cat "$basedir/Spigot-Server-Patches/"* | grep "+++ b/src/main/java/net/minecraft/" | sort | uniq | sed 's/\+\+\+ b\/src\/main\/java\/net\/minecraft\///g') - -nonnms=$(grep -R "new file mode" -B 1 "$basedir/Spigot-Server-Patches/" | grep -v "new file mode" | grep -oE --color=none "net\/minecraft\/.*.java" | sed 's/.*\/net\/minecraft\///g') -function containsElement { - local e - for e in "${@:2}"; do - [[ "$e" == "$1" ]] && return 0; - done - return 1 -} -set +e -for f in $files; do - containsElement "$f" ${nonnms[@]} - if [ "$?" == "1" ]; then - if [ ! -f "$workdir/Spigot/Spigot-Server/src/main/java/net/minecraft/$f" ]; then - f="$(echo "$f" | sed 's/.java//g')" - if [ ! -f "$decompiledir/$nms/$f.java" ]; then - echo "$(color 1 31) ERROR!!! Missing NMS$(color 1 34) $f $(colorend)"; - error=true - else - import $f - fi - fi - fi -done -if [ -n "$error" ]; then - exit 1 -fi - -######################################################## -######################################################## -######################################################## -# NMS IMPORTS -# Temporarily add new NMS dev imports here before you run paper patch -# but after you have paper rb'd your changes, remove the line from this file before committing. -# we do not need any lines added to this file for NMS - -# import FileName - - -######################################################## -######################################################## -######################################################## -# LIBRARY IMPORTS -# These must always be mapped manually, no automatic stuff -# -# # group # lib # prefix # many files - -# dont forget \ at end of each line but last -importLibrary com.mojang authlib com/mojang/authlib yggdrasil/YggdrasilGameProfileRepository.java -importLibrary com.mojang datafixerupper com/mojang/datafixers DataFixerBuilder.java -importLibrary com.mojang datafixerupper com/mojang/datafixers/util Either.java -importLibrary com.mojang datafixerupper com/mojang/serialization/codecs KeyDispatchCodec.java -importLibrary com.mojang datafixerupper com/mojang/serialization Dynamic.java - -######################################################## -######################################################## -######################################################## -set -e -cd "$workdir/Spigot/Spigot-Server/" -rm -rf nms-patches applyPatches.sh makePatches.sh >/dev/null 2>&1 -$gitcmd add --force . -A >/dev/null 2>&1 -echo -e "mc-dev Imports\n\n$MODLOG" | $gitcmd commit . -F - -) diff --git a/scripts/init.sh b/scripts/init.sh deleted file mode 100755 index 8b1929c83..000000000 --- a/scripts/init.sh +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env bash - -( -set -e -PS1="$" -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) -spigotdecompiledir="$workdir/Minecraft/$minecraftversion/spigot" -nms="$spigotdecompiledir" -cb="src/main/java" -gitcmd="git -c commit.gpgsign=false" - -# https://stackoverflow.com/a/38595160 -# https://stackoverflow.com/a/800644 -if sed --version >/dev/null 2>&1; then - strip_cr() { - sed -i -- "s/\r//" "$@" - } -else - strip_cr () { - sed -i "" "s/$(printf '\r')//" "$@" - } -fi - -patch=$(which patch 2>/dev/null) -if [ "x$patch" == "x" ]; then - patch="$basedir/hctap.exe" -fi - -# apply patches directly to the file tree -# used to fix issues from upstream source repos -cd "$basedir" -prepatchesdir="$basedir/scripts/pre-source-patches" -for file in $(ls "$prepatchesdir") -do - if [ $file == "README.md" ]; then - continue - fi - - echo "--==-- Applying PRE-SOURCE patch: $file --==--" - $patch -p0 < "$prepatchesdir/$file" -done - -echo "Applying CraftBukkit patches to NMS..." -cd "$workdir/CraftBukkit" -$gitcmd checkout -B patched HEAD >/dev/null 2>&1 -rm -rf "$cb/net" -# create baseline NMS import so we can see diff of what CB changed -while IFS= read -r -d '' file -do - patchFile="$file" - file="$(echo "$file" | cut -d "/" -f2- | cut -d. -f1).java" - mkdir -p "$(dirname $cb/"$file")" - cp "$nms/$file" "$cb/$file" -done < <(find nms-patches -type f -print0) -$gitcmd add --force src -$gitcmd commit -m "Minecraft $ $(date)" --author="Vanilla " - -# apply patches -while IFS= read -r -d '' file -do - patchFile="$file" - file="$(echo "$file" | cut -d "/" -f2- | cut -d. -f1).java" - - echo "Patching $file < $patchFile" - set +e - strip_cr "$nms/$file" > /dev/null - set -e - - "$patch" -d src/main/java -p 1 < "$patchFile" -done < <(find nms-patches -type f -print0) - -$gitcmd add --force src -$gitcmd commit -m "CraftBukkit $ $(date)" --author="CraftBukkit " -$gitcmd checkout -f HEAD~2 -) diff --git a/scripts/makemcdevsrc.sh b/scripts/makemcdevsrc.sh deleted file mode 100755 index bd86947f8..000000000 --- a/scripts/makemcdevsrc.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -( -set -e -PS1="$" - -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) -decompiledir="$workdir/Minecraft/$minecraftversion" -nms="$decompiledir/spigot/net/minecraft" -papernms="$basedir/Paper-Server/src/main/java/net/minecraft" -mcdevsrc="${decompiledir}/src/net/minecraft" -rm -rf "${mcdevsrc}" -mkdir -p "${mcdevsrc}" -cd "${nms}" - -for file in $(find . -name '*.java') -do - if [ ! -f "${papernms}/${file}" ]; then - destdir="${mcdevsrc}"/$(dirname "${file}") - mkdir -p "${destdir}" - cp "${file}" "${destdir}" - fi -done - -cd "$basedir" -echo "Built $decompiledir/src to be included in your project for src access"; -) diff --git a/scripts/paperclip.sh b/scripts/paperclip.sh deleted file mode 100755 index 2722ca3dd..000000000 --- a/scripts/paperclip.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -( -set -e -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -mcver=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) -paperjar="$basedir/Paper-Server/target/paper-$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/paperclip.jar" - -echo "" -echo "" -echo "" -echo "Build success!" -echo "Copied final jar to $(cd "$basedir" && pwd -P)/paperclip.jar" -) || exit 1 diff --git a/scripts/pre-source-patches/README.md b/scripts/pre-source-patches/README.md deleted file mode 100644 index f91d42efd..000000000 --- a/scripts/pre-source-patches/README.md +++ /dev/null @@ -1,16 +0,0 @@ -Files in this directory are applied directly to the tree before any other -patches. - -These patches are always applied directly from the root of the repository. -"$basedir" - -This allows us to fix malformed patch files and other changes from upstream. -This is not intended to replace any other system and should not be used in -place of the existing specific patch directories. - -Documentation is intentionally sparse to avoid being misused. - -`diff -ruN originalfile changedfile` - -See the man pages on diff and patch. - diff --git a/scripts/rebuildPatches.sh b/scripts/rebuildPatches.sh deleted file mode 100755 index a910d6f23..000000000 --- a/scripts/rebuildPatches.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/usr/bin/env bash - -( -PS1="$" -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -source "$basedir/scripts/functions.sh" -gitcmd="git -c commit.gpgsign=false -c core.safecrlf=false" - -echo "Rebuilding patch files from current fork state..." -nofilter="0" -if [ "$2" == "nofilter" ] || [ "$2" == "noclean" ]; then - nofilter="1" -fi -function cleanupPatches { - cd "$1" - for patch in *.patch; do - echo "$patch" - diffs=$($gitcmd diff --staged "$patch" | grep --color=none -E "^(\+|\-)" | grep --color=none -Ev "(\-\-\- a|\+\+\+ b|^.index)") - - if [ "x$diffs" == "x" ] ; then - $gitcmd reset HEAD "$patch" >/dev/null - $gitcmd checkout -- "$patch" >/dev/null - fi - done -} - -function savePatches { - what=$1 - what_name=$(basename "$what") - target=$2 - echo "Formatting patches for $what..." - - cd "$basedir/${what_name}-Patches/" - if [ -d "$basedir/$target/.git/rebase-apply" ]; then - # in middle of a rebase, be smarter - echo "REBASE DETECTED - PARTIAL SAVE" - last=$(cat "$basedir/$target/.git/rebase-apply/last") - next=$(cat "$basedir/$target/.git/rebase-apply/next") - orderedfiles=$(find . -name "*.patch" | sort) - for i in $(seq -f "%04g" 1 1 $last) - do - if [ $i -lt $next ]; then - rm $(echo "$orderedfiles{@}" | sed -n "${i}p") - fi - done - else - rm -rf *.patch - fi - - cd "$basedir/$target" - - $gitcmd format-patch --zero-commit --full-index --no-signature --no-stat -N -o "$basedir/${what_name}-Patches/" upstream/upstream >/dev/null - cd "$basedir" - $gitcmd add --force -A "$basedir/${what_name}-Patches" - if [ "$nofilter" == "0" ]; then - cleanupPatches "$basedir/${what_name}-Patches" - fi - echo " Patches saved for $what to $what_name-Patches/" -} - -savePatches "$workdir/Spigot/Spigot-API" "Paper-API" -if [ -f "$basedir/Paper-API/.git/patch-apply-failed" ]; then - echo "$(color 1 31)[[[ WARNING ]]] $(color 1 33)- Not saving Paper-Server as it appears Paper-API did not apply clean.$(colorend)" - echo "$(color 1 33)If this is a mistake, delete $(color 1 34)Paper-API/.git/patch-apply-failed$(color 1 33) and run rebuild again.$(colorend)" - echo "$(color 1 33)Otherwise, rerun ./paper patch to have a clean Paper-API apply so the latest Paper-Server can build.$(colorend)" -else - savePatches "$workdir/Spigot/Spigot-Server" "Paper-Server" -fi -) || exit 1 diff --git a/scripts/remap.sh b/scripts/remap.sh deleted file mode 100755 index e47992e17..000000000 --- a/scripts/remap.sh +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env bash - -( -set -e -PS1="$" -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -minecraftversion="$(cat "${workdir}/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4)" -minecraftserverurl=$(cat "${workdir}/BuildData/info.json" | grep serverUrl | cut -d '"' -f 4) -minecrafthash=$(cat "${workdir}/BuildData/info.json" | grep minecraftHash | cut -d '"' -f 4) -accesstransforms="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep accessTransforms | cut -d '"' -f 4) -classmappings="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep classMappings | cut -d '"' -f 4) -membermappings="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep memberMappings | cut -d '"' -f 4) -#packagemappings="$workdir/BuildData/mappings/"$(cat "${workdir}/BuildData/info.json" | grep packageMappings | cut -d '"' -f 4) -decompiledir="$workdir/Minecraft/$minecraftversion" -jarpath="$decompiledir/$minecraftversion" -mkdir -p "$decompiledir" - -echo "Downloading unmapped vanilla jar..." -if [ ! -f "$jarpath.jar" ]; then - curl -s -o "$jarpath.jar" "$minecraftserverurl" - if [ "$?" != "0" ]; then - echo "Failed to download the vanilla server jar. Check connectivity or try again later." - exit 1 - fi -fi - -# OS X & FreeBSD don't have md5sum, just md5 -r -#command -v md5sum >/dev/null 2>&1 || { -# command -v md5 >/dev/null 2>&1 && { -# shopt -s expand_aliases -# alias md5sum='md5 -r' -# echo "md5sum command not found, using an alias instead" -# } || { -# echo >&2 "No md5sum or md5 command found" -# exit 1 -# } -#} -# -#checksum=$(md5sum "$jarpath.jar" | cut -d ' ' -f 1) -#if [ "$checksum" != "$minecrafthash" ]; then -# echo "The MD5 checksum of the downloaded server jar does not match the BuildData hash." -# exit 1 -#fi - -# These specialsource commands are from https://hub.spigotmc.org/stash/projects/SPIGOT/repos/builddata/browse/info.json -echo "Applying class mappings..." -if [ ! -f "$jarpath-cl.jar" ]; then - java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map --only . --only net/minecraft --only com/mojang/math --auto-lvt BASIC --auto-member SYNTHETIC -i "$jarpath.jar" -m "$classmappings" -o "$jarpath-cl.jar" 1>/dev/null - if [ "$?" != "0" ]; then - echo "Failed to apply class mappings." - exit 1 - fi -fi - -echo "Applying member mappings..." -if [ ! -f "$jarpath-m.jar" ]; then - java -jar "$workdir/BuildData/bin/SpecialSource-2.jar" map --only . --only com/mojang/math --only net/minecraft --auto-member TOKENS -i "$jarpath-cl.jar" -m "$membermappings" -o "$jarpath-m.jar" 1>/dev/null - if [ "$?" != "0" ]; then - echo "Failed to apply member mappings." - exit 1 - fi -fi - -echo "Creating remapped jar..." -if [ ! -f "$jarpath-mapped.jar" ]; then - java -jar "$workdir/BuildData/bin/SpecialSource.jar" --only . --only com/mojang/math --only net/minecraft -i "$jarpath-m.jar" --access-transformer "$accesstransforms" -m "/home/martin/Projects/Paper/bukkit-e3c5450d-fields.csrg" -o "$jarpath-mapped.jar" 1>/dev/null - if [ "$?" != "0" ]; then - echo "Failed to create remapped jar." - exit 1 - fi -fi - -echo "Installing remapped jar..." -cd "$workdir/CraftBukkit" # Need to be in a directory with a valid POM at the time of install. -mvn install:install-file -q -Dfile="$jarpath-mapped.jar" -Dpackaging=jar -DgroupId=io.papermc -DartifactId=minecraft-server -Dversion="$minecraftversion-SNAPSHOT" -if [ "$?" != "0" ]; then - echo "Failed to install remapped jar." - exit 1 -fi -) diff --git a/scripts/requireDeps.sh b/scripts/requireDeps.sh deleted file mode 100755 index 8437accfa..000000000 --- a/scripts/requireDeps.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/sh -set -ue - -# Check if an application is on the PATH. -# If it is not, return with non-zero. -_is_dep_available() { - command -v "$1" >/dev/null || (echo "\`$1\` ${2:-command was not found in the path and is a required dependency}"; return 1) -} - -if [ -z "${1:-}" ]; then - # No specific dependency was found; let's just check for all required ones. - _is_dep_available git - _is_dep_available patch - _is_dep_available mvn - _is_dep_available curl - - _is_dep_available javac "was not found; you can download the JDK from https://adoptopenjdk.net/ or via your package manager" - _is_dep_available jar "was not found; you can download the JDK from https://adoptopenjdk.net/ or via your package manager" -else - # Require all dependencies provided. - for dep in $@; do - _is_dep_available "$dep" - done -fi - -# vim: set ff=unix autoindent ts=4 sw=4 tw=0 et : diff --git a/scripts/testServer.sh b/scripts/testServer.sh deleted file mode 100755 index 3fabfcd0b..000000000 --- a/scripts/testServer.sh +++ /dev/null @@ -1,148 +0,0 @@ -#!/usr/bin/env bash - -set -e -PS1="$" -basedir="$(cd "$1" && pwd -P)" -workdir="$basedir/work" -minecraftversion=$(cat "$workdir/BuildData/info.json" | grep minecraftVersion | cut -d '"' -f 4) -gitcmd="git -c commit.gpgsign=false" - -# -# FUNCTIONS -# -source "$basedir"/scripts/functions.sh - -updateTest() { - paperstash - $gitcmd reset --hard origin/master - paperunstash -} - -papertestdir="${PAPER_TEST_DIR:-$workdir/test-server}" - -mkdir -p "$papertestdir" -cd "$papertestdir" - -# -# SKELETON CHECK -# - -if [ ! -d .git ]; then - $gitcmd init - $gitcmd remote add origin ${PAPER_TEST_SKELETON:-https://github.com/PaperMC/PaperTestServer} - $gitcmd fetch origin - updateTest -elif [ "$2" == "update" ] || [ "$3" == "update" ]; then - updateTest -fi - -if [ ! -f server.properties ] || [ ! -d plugins ]; then - echo " " - echo " Checking out Test Server Skeleton" - updateTest -fi - - -# -# EULA CHECK -# - -if [ -z "$(grep true eula.txt 2>/dev/null)" ]; then - echo - echo "$(color 32) It appears you have not agreed to Mojangs EULA yet! Press $(color 1 33)y$(colorend) $(color 32)to confirm agreement to" - read -p " Mojangs EULA found at:$(color 1 32) https://account.mojang.com/documents/minecraft_eula $(colorend) " -n 1 -r - echo "" - if [[ ! $REPLY =~ ^[Yy]$ ]]; then - echo "$(color 1 31)Aborted$(colorend)" - exit; - fi - echo "eula=true" > eula.txt -fi - -# -# JAR CHECK -# - -folder="$basedir/Paper-Server" -jar="$folder/target/paper-${minecraftversion}.jar" -if [ ! -z "$PAPER_JAR" ]; then - jar="$PAPER_JAR" -fi -if [ ! -d "$folder" ]; then -( - echo "Building Patched Repo" - cd "$basedir" - ./paper patch -) -fi - -if [ "$2" == "build" ] || [ "$3" == "build" ]; then -( - echo "Building Paper" - cd "$basedir" - mvn package -) -fi -# -# JVM FLAGS -# - -if [ -f "$jar" ]; then - cp "$jar" paper.jar -fi -baseargs="-server -Xms${PAPER_MIN_TEST_MEMORY:-512M} -Xmx${PAPER_TEST_MEMORY:-2G} -Dfile.encoding=UTF-8 -XX:MaxGCPauseMillis=150 -XX:+UseG1GC " -baseargs="$baseargs -DIReallyKnowWhatIAmDoingISwear=1 " -baseargs="$baseargs -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=40 -XX:G1MaxNewSizePercent=60 " -baseargs="$baseargs -XX:InitiatingHeapOccupancyPercent=10 -XX:G1MixedGCLiveThresholdPercent=80 " -baseargs="$baseargs -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5100" - - -cmd="java ${PAPER_TEST_BASE_JVM_ARGS:-$baseargs} ${PAPER_TEST_EXTRA_JVM_ARGS} -jar paper.jar ${PAPER_TEST_APP_ARGS:-} nogui" -screen_command="screen -DURS papertest $cmd" -tmux_command="tmux new-session -A -s Paper -n 'Paper Test' -c '$(pwd)' '$cmd'" - -# -# MULTIPLEXER CHOICE -# - -multiplex=${PAPER_TEST_MULTIPLEXER} - -if [ ! -z "$PAPER_NO_MULTIPLEX" ]; then - cmd="$cmd" -elif [ "$multiplex" == "screen" ]; then - if command -v "screen" >/dev/null 2>&1 ; then - cmd="$screen_command" - else - echo "screen not found" - exit 1 - fi -elif [ "$multiplex" == "tmux" ] ; then - if command -v "tmux" >/dev/null 2>&1 ; then - cmd="$tmux_command" - else - echo "tmux not found" - exit 1 - fi -else - if command -v "screen" >/dev/null 2>&1 ; then - cmd="$screen_command" - elif command -v "tmux" >/dev/null 2>&1 ; then - cmd="$tmux_command" - else - echo "screen or tmux not found - it is strongly recommended to install either" - echo "No terminal multiplexer will be used" - fi -fi - -# -# START / LOG -# - -if [ ! -z "$PAPER_TEST_COMMAND_WRAPPER" ]; then - $PAPER_TEST_COMMAND_WRAPPER $cmd -else - echo "Running command: $cmd" - echo "In directory: $(pwd)" - #sleep 1 - /usr/bin/env bash -c "$cmd" -fi diff --git a/scripts/upstreamMerge.sh b/scripts/upstreamMerge.sh index f011f708f..02376dc7a 100755 --- a/scripts/upstreamMerge.sh +++ b/scripts/upstreamMerge.sh @@ -30,11 +30,11 @@ update Spigot if [[ "$2" = "all" || "$2" = "a" ]] ; then update BuildData - update Paperclip fi if [ "$updated" == "1" ]; then echo "Rebuilding patches without filtering to improve apply ability" cd "$basedir" - scripts/rebuildPatches.sh "$basedir" nofilter 1>/dev/null|| exit 1 + ./gradlew applyPatches -Dpaperweight.debug=true || exit 1 + ./gradlew rebuildPatches || exit 1 fi )