Skip to content

Commit 140a58f

Browse files
Update byof scripts
1 parent 7a778f7 commit 140a58f

9 files changed

Lines changed: 270 additions & 265 deletions

File tree

purpur

Lines changed: 82 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -3,137 +3,106 @@
33
# get base dir regardless of execution location
44
SOURCE="${BASH_SOURCE[0]}"
55
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
6-
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
7-
SOURCE="$(readlink "$SOURCE")"
8-
[[ "$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
6+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
7+
SOURCE="$(readlink "$SOURCE")"
8+
[[ "$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
99
done
1010
SOURCE=$([[ "$SOURCE" == /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
1111
basedir=$(dirname "$SOURCE")
1212
. "$basedir"/scripts/init.sh
1313

1414
purpurstash() {
15-
STASHED=$(git stash)
15+
STASHED=$(git stash)
1616
}
1717

1818
purpurunstash() {
19-
if [[ "$STASHED" != "No local changes to save" ]]; then
20-
git stash pop
21-
fi
19+
if [[ "$STASHED" != "No local changes to save" ]]; then
20+
git stash pop
21+
fi
2222
}
2323

2424
case "$1" in
25-
"am" | "amend")
26-
(
27-
cd "$basedir"/Purpur-API/
28-
git add .
29-
git commit --amend --no-edit
30-
cd "$basedir"/Purpur-Server/
31-
git add .
32-
git commit --amend --no-edit
33-
cd "$basedir"
34-
scripts/rebuildpatches.sh "$basedir"
35-
)
36-
;;
37-
"rb" | "rbp" | "rebuild")
38-
(
39-
set -e
40-
cd "$basedir"
41-
scripts/rebuildpatches.sh "$basedir"
42-
)
43-
;;
4425
"p" | "patch" | "apply")
45-
(
46-
set -e
47-
cd "$basedir"
48-
scripts/apply.sh "$basedir"
49-
)
50-
;;
26+
(
27+
set -e
28+
cd "$basedir"
29+
if [ "$2" != "fast" ]; then
30+
scripts/upstream.sh
31+
fi
32+
scripts/apply.sh "$basedir"
33+
)
34+
;;
5135
"b" | "bu" | "build")
52-
(
53-
basedir
54-
mvn -N install
55-
cd Purpur-API
56-
mvn -e clean install
57-
cd ../Purpur-Server
58-
mvn -e clean install
59-
)
60-
;;
61-
"jar" | "purpurclip")
62-
(
63-
basedir
64-
cd "$basedir"
65-
if [ "$2" != "fast" ]; then
66-
scripts/upstream.sh
67-
fi
68-
./scripts/apply.sh "$basedir"
69-
./scripts/purpurclip.sh
70-
)
71-
;;
72-
"d" | "de" | "deploy")
73-
(
74-
basedir
75-
mvn -N install
76-
cd Purpur-API
77-
mvn clean deploy
78-
cd ../Purpur-Server
79-
mvn clean install
80-
)
81-
;;
36+
(
37+
basedir
38+
mvn -N install
39+
cd Purpur-API
40+
mvn -e clean install
41+
cd ../Paper/Paper-MojangAPI
42+
mvn -e clean install
43+
cd ../../Purpur-Server
44+
mvn -e clean install
45+
)
46+
;;
47+
48+
"rb" | "rbp" | "rebuild")
49+
(
50+
set -e
51+
cd "$basedir"
52+
scripts/rebuildpatches.sh "$basedir"
53+
)
54+
;;
55+
"am" | "amend")
56+
(
57+
cd "$basedir"/Purpur-API/
58+
git add .
59+
git commit --amend --no-edit
60+
cd "$basedir"/Purpur-Server/
61+
git add .
62+
git commit --amend --no-edit
63+
cd "$basedir"
64+
scripts/rebuildpatches.sh "$basedir"
65+
)
66+
;;
8267
"up" | "upstream")
83-
(
84-
cd "$basedir"
85-
scripts/upstream.sh "$2"
86-
)
87-
;;
88-
"r" | "root")
68+
(
8969
cd "$basedir"
90-
;;
91-
"a" | "api")
92-
cd "$basedir/Purpur-API"
93-
;;
94-
"s" | "server")
95-
cd "$basedir/Purpur-Server"
96-
;;
97-
"setup")
98-
if [[ -f ~/.bashrc ]]; then
99-
NAME="purpur"
100-
if [[ -n "${2+x}" ]]; then
101-
NAME="$2"
102-
fi
103-
(grep "alias $NAME=" ~/.bashrc >/dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >>~/.bashrc)
104-
alias "$NAME=. $SOURCE"
105-
echo "You can now just type '$NAME' at any time to access the purpur tool."
70+
scripts/upstream.sh "$2"
71+
)
72+
;;
73+
"jar" | "purpurclip")
74+
(
75+
basedir
76+
cd "$basedir"
77+
if [ "$2" != "fast" ]; then
78+
scripts/upstream.sh
10679
fi
107-
;;
80+
./scripts/apply.sh "$basedir"
81+
cd "$basedir"
82+
mvn -N install
83+
cd Purpur-API
84+
mvn -e clean install
85+
cd ../Paper/Paper-MojangAPI
86+
mvn -e clean install
87+
cd ../../Purpur-Server
88+
mvn -e clean install
89+
cd "$basedir"
90+
./scripts/purpurclip.sh
91+
)
92+
;;
10893
*)
109-
echo "Purpur build tool command. This provides a variety of commands to build and manage the Purpur build"
110-
echo "environment. For all of the functionality of this command to be available, you must first run the"
111-
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
112-
echo ""
113-
echo " Normal commands:"
114-
echo " * am, amend | Amend current edits to last patches"
115-
echo " * rb, rebuild | Rebuild patches, can be called from anywhere."
116-
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere."
117-
echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere."
118-
echo " * b, build | Build API and Server but no deploy. Can be ran anywhere."
119-
echo " * d, deploy | Build and Deploy API jar and build Server. Can be ran anywhere."
120-
echo ""
121-
echo " These commands require the setup command before use:"
122-
echo " * r, root | Change directory to the root of the project."
123-
echo " * a. api | Move to the Purpur-API directory."
124-
echo " * s, server | Move to the Purpur-Server directory."
125-
echo " * e, edit | Use to edit a specific patch, give it the argument \"server\" or \"api\""
126-
echo " | respectively to edit the correct project. Use the argument \"continue\" after"
127-
echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere."
128-
echo ""
129-
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
130-
echo " | . ./purpur setup"
131-
echo " | After you run this command you'll be able to just run 'purpur' from anywhere."
132-
echo " | The default name for the resulting alias is 'purpur', you can give an argument to override"
133-
echo " | this default, such as:"
134-
echo " | . ./purpur setup example"
135-
echo " | Which will allow you to run 'example' instead."
136-
;;
94+
echo "Purpur build tool command. This provides a variety of commands to build and manage the Purpur build"
95+
echo "environment. For all of the functionality of this command to be available, you must first run the"
96+
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
97+
echo ""
98+
echo " Normal commands:"
99+
echo " * p, patch | Apply all patches to top of Paper without building it"
100+
echo " * b, build | Build Purpur API and Server"
101+
echo " * rb, rebuild | Rebuild patches"
102+
echo " * am, amend | Amend current edits to last patches"
103+
echo " * up, upstream | Build Paper upstream, pass arg up to update paper"
104+
echo " * jar, purpurclip | Apply all patches and build the project, purpurclip.jar will be output"
105+
;;
137106
esac
138107

139108
unset -f purpurstash

scripts/apply.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ function enableCommitSigningIfNeeded {
7979
fi
8080
}
8181

82+
echo "Importing MC-DEV"
83+
./scripts/importmcdev.sh "$basedir" || exit 1
8284
(
8385
(applyPatch Paper/Paper-API Purpur-API HEAD api "$API_REPO" &&
8486
applyPatch Paper/Paper-Server Purpur-Server HEAD server "$SERVER_REPO") || exit 1

scripts/generatesources.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@
22

33
SOURCE="${BASH_SOURCE[0]}"
44
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
5-
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
6-
SOURCE="$(readlink "$SOURCE")"
7-
[[ $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
5+
DIR="$(cd -P "$(dirname "$SOURCE")" && pwd)"
6+
SOURCE="$(readlink "$SOURCE")"
7+
[[ $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
88
done
99
. "$(dirname "$SOURCE")/init.sh"
1010

1111
cd "$basedir" || exit
1212
paperVer=$(cat current-paper)
1313

14-
minecraftversion=$(< "$basedir"/Paper/work/BuildData/info.json grep minecraftVersion | cut -d '"' -f 4)
14+
minecraftversion=$(grep <"$basedir"/Paper/work/BuildData/info.json minecraftVersion | cut -d '"' -f 4)
1515
decompile="Paper/work/Minecraft/$minecraftversion/spigot"
1616

1717
mkdir -p mc-dev/src/net/minecraft/server
1818

1919
cd mc-dev || exit
2020
if [ ! -d ".git" ]; then
21-
git init
21+
git init
2222
fi
2323

2424
rm src/net/minecraft/server/*.java
@@ -27,9 +27,9 @@ cp "$basedir"/"$decompile"/net/minecraft/server/*.java src/net/minecraft/server
2727
base="$basedir/Paper/Paper-Server/src/main/java/net/minecraft/server"
2828
cd "$basedir"/mc-dev/src/net/minecraft/server/ || exit
2929
for file in $(/bin/ls "$base"); do
30-
if [ -f "$file" ]; then
31-
rm -f "$file"
32-
fi
30+
if [ -f "$file" ]; then
31+
rm -f "$file"
32+
fi
3333
done
3434
cd "$basedir"/mc-dev || exit
3535
git add . -A

0 commit comments

Comments
 (0)