-
Notifications
You must be signed in to change notification settings - Fork 3
/
get-libs.sh
108 lines (98 loc) · 1.88 KB
/
get-libs.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
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
#!/bin/bash
#
# I think most devs just get curse updater or something to keep the libs
# globally. I don't know if that's a good idea or not. Honestly I feel
# pretty nervous about packaging "the newest version" all the time.
#
indent () {
sed -e 's/^/ /'
}
get_repotype () {
case "$1" in
*://repos.curseforge.com/wow/libactionbutton-1-0)
echo git
;;
*://repos.wowace.com/wow/libbuttonglow-1-0)
echo git
;;
*://repos.curseforge.com/*)
echo svn
;;
*://repos.wowace.com/*)
echo svn
;;
*://svn*)
echo svn
;;
svn:*)
echo svn
;;
*://git*)
echo git
;;
git:*)
echo git
;;
*) # I guess
echo git
;;
esac
}
get_libs () {
local INLIBS=0
local FILE
if [ -f pkgmeta.yaml ]; then
FILE=pkgmeta.yaml
else
FILE=.pkgmeta
fi
cat $FILE | while read k v; do
case $k in
externals:)
INLIBS=1
;;
"")
INLIBS=0
;;
*)
if [ $INLIBS -eq 1 ]; then
echo ${v} $( get_repotype $v ) ${k/:/}
fi
;;
esac
done
}
update_repo () {
local repotype=$1
local dir=$2
case $repotype in
git)
(cd $dir && git pull && git reset --hard)
;;
svn)
(cd $dir && svn up)
;;
esac
}
fetch_repo () {
local uri=$1
local repotype=$2
local dir=$3
case $repotype in
git)
git clone $uri $dir
;;
svn)
svn co $uri $dir
;;
esac
}
get_libs | while read uri repotype dir; do
if [ -d $dir ]; then
echo "Updating $dir"
update_repo $repotype $dir 2>&1 | indent
else
echo "Cloning $uri into $dir"
fetch_repo $uri $repotype $dir 2>&1 | indent
fi
done