-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.sh
62 lines (56 loc) · 1.59 KB
/
init.sh
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
#!/bin/bash
# usage: addenv env_name path
function addenv() {
sed -i -e "/^export $1=.*/d" ~/.bashrc
echo "export $1=`readlink -e $2`" >> ~/.bashrc
echo "By default this script will add environment variables into ~/.bashrc."
echo "After that, please run 'source ~/.bashrc' to let these variables take effect."
echo "If you use shell other than bash, please add these environment variables manually."
}
# usage: init repo branch directory trace [env]
# trace = true|false
function init() {
if [ -d $3 ]; then
echo "$3 is already initialized, skipping..."
return
fi
while [ ! -d $3 ]; do
git clone -b $2 git@github.com:$1.git $3
done
log="$1 `cd $3 && git log --oneline --no-abbrev-commit -n1`"$'\n'
if [ $4 == "true" ] ; then
rm -rf $3/.git
git add -A $3
git commit -am "$1 $2 initialized"$'\n\n'"$log"
else
sed -i -e "/^\/$3/d" .gitignore
echo "/$3" >> .gitignore
git add -A .gitignore
git commit --no-verify --allow-empty -am "$1 $2 initialized without tracing"$'\n\n'"$log"
fi
if [ $5 ] ; then
addenv $5 $3
fi
}
case $1 in
nemu)
init NJU-ProjectN/nemu ics2023 nemu true NEMU_HOME
;;
abstract-machine)
init NJU-ProjectN/abstract-machine ics2023 abstract-machine true AM_HOME
init NJU-ProjectN/fceux-am ics2021 fceux-am false
;;
am-kernels)
init NJU-ProjectN/am-kernels ics2021 am-kernels false
;;
nanos-lite)
init NJU-ProjectN/nanos-lite ics2021 nanos-lite true
;;
navy-apps)
init NJU-ProjectN/navy-apps ics2023 navy-apps true NAVY_HOME
;;
*)
echo "Invalid input..."
exit
;;
esac