-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathcheck_versions.sh
executable file
·80 lines (67 loc) · 2.07 KB
/
check_versions.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
#!/bin/bash
. ./osc_project_sep.sh
UPDATE=
NODE_VERSIONS=
while getopts uh name
do
case $name in
u)
UPDATE="yes"
;;
*)
printf "Usage: %s [-u] [[NODE_VERSION] ...]\n" $0
echo ""
printf " $s -u nodejs10 nodejs12\n" $0
exit 2
;;
esac
done
for i in ${@:$OPTIND}; do
if ! [ ${i:0:6} = "nodejs" ] || ! [ ${i:6} -ge 4 ]; then
echo "Invalid NodeJS version: $i";
exit 3;
fi
NODE_VERSIONS="$NODE_VERSIONS $i"
done
if [ "x$NODE_VERSIONS" = "x" ]; then
NODE_VERSIONS=$(ls -d nodejs? nodejs??)
fi
for i in $NODE_VERSIONS; do
ver=${i:6}
if [ $ver -lt 18 ]; then
echo "Skipping old versions $ver.x"
continue
fi
echo "Checking version for Node $ver.x"
URL="https://nodejs.org/dist/latest-v$ver.x"
upstream_ver=
while [ "x$upstream_ver" = "x" ]; do
upstream_ver=$(curl -LSs $URL | grep 'node-v[.0-9]\+'tar.xz | sed -e 's/^.*node-v\([0-9]\+\.[0-9]\+\.[0-9]\+\).tar.xz.*$/\1/') || exit 1
done
local_ver=$(grep {{node_version}} nodejs$ver.sed | sed -e 's,s/{{node_version}}/,,' | sed -e 's,/g,,')
if [ "x$local_ver" != "x$upstream_ver" ]; then
echo -e "New version $upstream_ver\t\t(local: $local_ver)"
if [ ! -z "$UPDATE" ]; then
echo " updating hash values";
curl -Ls -o nodejs$ver/SHASUMS256.txt $URL/SHASUMS256.txt || exit
curl -Ls -o nodejs$ver/SHASUMS256.txt.sig $URL/SHASUMS256.txt.sig || exit
sed -i -e "s,^s/{{node_version}}.*/g$,s/{{node_version}}/$upstream_ver/g," nodejs$ver.sed
# DL upstream package too, if directory exists
if [ -d devel${PS}languages${PS}nodejs/nodejs$ver ]; then
pushd devel${PS}languages${PS}nodejs/nodejs$ver > /dev/null
curl -Ls -o node-v$upstream_ver.tar.xz $URL/node-v$upstream_ver.tar.xz
if test -d .git; then
git rm node-v$local_ver.tar.xz
git add node-v$upstream_ver.tar.xz
else
osc rm node-v$local_ver.tar.xz
osc add node-v$upstream_ver.tar.xz
fi
[ -d node-v$local_ver ] && rm -r node-v$local_ver
popd > /dev/null
fi
# Update bundled versions
./bundling.sh $ver
fi
fi
done