-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
origami
executable file
·175 lines (169 loc) · 6.25 KB
/
origami
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#!/usr/bin/env bash
shopt -s nocasematch
# 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
SOURCE=$([[ "$SOURCE" = /* ]] && echo "$SOURCE" || echo "$PWD/${SOURCE#./}")
basedir=$(dirname "$SOURCE")
gitcmd="git -c commit.gpgsign=false"
. $basedir/scripts/init.sh
origamistash() {
STASHED=$(git stash)
}
origamiunstash() {
if [[ "$STASHED" != "No local changes to save" ]] ; then
git stash pop
fi
}
case "$1" in
"rb" | "rbp" | "rebuild")
(
set -e
cd "$basedir"
scripts/rebuildpatches.sh "$basedir"
)
;;
"p" | "patch" | "apply")
(
set -e
cd "$basedir"
scripts/apply.sh "$basedir"
)
;;
"e" | "edit" )
case "$2" in
"s" | "server")
type="Server"
;;
"m" | "mojang" | "mojangapi")
type="MojangAPI"
;;
"a" | "api")
type="API"
;;
*)
echo "You must edit either the api or server."
;;
esac
if [ $type ]; then
cd "$basedir/${FORK_NAME}-$type"
set -e
case "$3" in
"c" | "continue")
(
$gitcmd add .
$gitcmd commit --amend
$gitcmd rebase --continue
cd "$basedir"
scripts/rebuildPatches.sh $2
)
;;
*)
origamistash
$gitcmd rebase -i upstream/upstream
origamiunstash
;;
esac
fi
;;
"b" | "bu" | "build")
(
cd "$basedir"
mvn -N install
cd ${FORK_NAME}-API && mvn -e clean install && cd ../${FORK_NAME}-MojangAPI && mvn -e clean install && cd ../${FORK_NAME}-Server && mvn -e clean install
)
;;
"devbuild")
(
cd "$basedir"
mvn -N install
cd ${FORK_NAME}-API && mvn -e clean install && cd ../${FORK_NAME}-MojangAPI && mvn -e clean install && cd ../${FORK_NAME}-Server && mvn -P dont-relocate -e clean install
)
;;
"crane" | "patcher")
(
cd "$basedir"
scripts/origamicrane.sh "$basedir"
)
;;
"d" | "de" | "deploy")
(
basedir
mvn -N install
cd ${FORK_NAME}-API && mvn clean deploy && cd ../${FORK_NAME}-MojangAPI && mvn clean deploy && cd ../${FORK_NAME}-Server && mvn clean install
)
;;
"up" | "upstream")
(
cd "$basedir"
scripts/upstream.sh "$2"
)
;;
"update")
(
cd "$basedir" && scripts/upstream.sh "up" && \
set -e && cd "$basedir" && scripts/apply.sh "$basedir" && \
cd "$basedir" && scripts/rebuildpatches.sh "$basedir" && \
cd "$basedir" && scripts/upstreamCommit.sh
)
;;
"r" | "root")
cd "$basedir"
;;
"a" | "api")
cd "$basedir/${FORK_NAME}-API"
;;
"m" | "mojang" | "mojangapi")
cd "$basedir/${FORK_NAME}-MojangAPI"
;;
"s" | "server")
cd "$basedir/${FORK_NAME}-Server"
;;
"setup")
if [[ -f ~/.bashrc ]] ; then
NAME="ec"
if [[ ! -z "${2+x}" ]] ; then
NAME="$2"
fi
(grep "alias $NAME=" ~/.bashrc > /dev/null) && (sed -i "s|alias $NAME=.*|alias $NAME='. $SOURCE'|g" ~/.bashrc) || (echo "alias $NAME='. $SOURCE'" >> ~/.bashrc)
alias "$NAME=. $SOURCE"
echo "You can now just type '$NAME' at any time to access the origami tool."
fi
;;
*)
echo "${FORK_NAME} build tool command. This provides a variety of commands to build and manage the PaperMC build"
echo "environment. For all of the functionality of this command to be available, you must first run the"
echo "'setup' command. View below for details. For essential building and patching, you do not need to do the setup."
echo ""
echo " Normal commands:"
echo " * rb, rebuild | Rebuild patches, can be called from anywhere."
echo " * p, patch | Apply all patches to top of Paper without building it. Can be run from anywhere."
echo " * e, edit | Edit specific patches either in the [api] or [server]."
echo " * up, upstream | Build Paper upstream, pass arg up to update paper. Can be run from anywhere."
echo " * b, build | Build API and Server but no deploy. Can be ran anywhere."
echo " * d, deploy | Build and Deploy API jar and build Server. Can be ran anywhere."
echo ""
echo " These commands require the setup command before use:"
echo " * r, root | Change directory to the root of the project."
echo " * a. api | Move to the ${FORK_NAME}-API directory."
echo " * m. mojangapi | Move to the ${FORK_NAME}-MojangAPI directory."
echo " * s, server | Move to the ${FORK_NAME}-Server directory."
echo " * e, edit | Use to edit a specific patch, give it the argument \"server\" or \"api\""
echo " | respectively to edit the correct project. Use the argument \"continue\" after"
echo " | the changes have been made to finish and rebuild patches. Can be called from anywhere."
echo ""
echo " * setup | Add an alias to .bashrc to allow full functionality of this script. Run as:"
echo " | . ./origami setup"
echo " | After you run this command you'll be able to just run 'origami' from anywhere."
echo " | The default name for the resulting alias is 'origami', you can give an argument to override"
echo " | this default, such as:"
echo " | . ./origami setup example"
echo " | Which will allow you to run 'example' instead."
;;
esac
unset -f origamistash
unset -f origamiunstash