blob: 35a073fb7eea4ecb2120393ee3eb2c8f796e24c5 (
plain)
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
|
#!/bin/sh
. /usr/lib/colors.sh
. /usr/lib/glyphs.sh
# increment a version string
#
# point - decimal point to update from
# version - string of the version (ie 1.4.7)
#
increment_ver () {
point=$1
version=$2
IFS='.'; set -- $version
i=$# out=""
[ "$point" -gt "$#" ] && {
IFS='.'; printf "%s\n" "$version"
return
}
while [ "$#" -gt "0" ]; do
p=$1
[ "$#" -eq "$point" ] && p=$((p+1))
[ "$#" -lt "$point" ] && p=0
out="$out$p."
shift
done
IFS='.'; set -- $out
printf "%s\n" "${*%${!#}}"
IFS=' '
}
get_source () {
local name ver
name=$1
ver=$2
sed "s/PKG_VER=.*/PKG_VER=$ver/" repo/$name/$name.xibuild > /tmp/xibuild
. /tmp/xibuild
echo "$SOURCE"
}
get_type () {
case "$(get_source $1)" in
git://*|*.git)
echo "git"
;;
"")
echo "none"
;;
*pythonhosted.org*)
echo "pypi"
;;
*)
echo "archive"
;;
esac
}
check_exists () {
local code
[ -n "$1" ] && {
code=$(curl -sSL -I -o /dev/null -w "%{http_code}" $1)
[ "$code" = "200" ]
}
}
cur_ver () {
local name
name=$1
. repo/$name/$name.xibuild
echo "$PKG_VER"
}
new_ver () {
local name exists point new_ver ver url
name=$1
ver=$(cur_ver $name)
point=1
while true; do
new_ver=$(increment_ver $point $ver)
url=$(get_source $name $new_ver)
check_exists $url && {
point=1
[ "$new_ver" = "$ver" ] && {
echo "$ver"
return
}
ver=$new_ver
} || {
point=$((point+1))
}
# check new_ver is real
# if is real ; repeat again with same point
# if not, increment point and then check
done
}
save_ver () {
local name ver
name=$1
ver=$2
sed -i "s/PKG_VER=.*/PKG_VER=$ver/" repo/$name/$name.xibuild
}
for pkg in $(ls repo); do
printf "${LIGHT_BLUE}%s " "$pkg"
case "$(get_type $pkg)" in
"git"|"none"|"pypi")
printf "${LIGHT_WHITE}skipped"
;;
*)
cur="$(cur_ver $pkg)"
new="$(new_ver $pkg)"
[ "$cur" = "$new" ] &&
printf "${LIGHT_WHITE}%s ${CHECKMARK}" "$cur" || {
printf "${GREEN}%s > %s" "$cur" "$new"
save_ver "$pkg" "$new"
}
esac
printf "\n"
done
|