-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.sh
41 lines (29 loc) · 914 Bytes
/
update.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
#!/bin/sh
op="$PWD"
git pull
if [ -z "$ZN_LOC" ]; then
ZN_LOC="$HOME/ZeroNet"
fi
cd "$ZN_LOC"
git pull
#lver=$(git tag | sort | tail -n 1)
lver=$(cat src/Config.py | grep "^[ ]*self.version" | grep "[0-9]*\.[0-9]*\.[0-9]*" -o)
lat=$(git log --grep="Rev[0-9]*" --format="[%H] = %s" | head -n 1)
lc=$(echo "$lat" | grep "\[[a-z0-9A-Z]*\]" -o | grep "[a-z0-9A-Z]*" -o)
lrev=$(echo "$lat" | grep "Rev[0-9]*" -o)
echo "commit = $lc / rev = $lrev / ver = $lver"
v1=$(echo "$lver")
v2=$(echo "$lrev" | sed "s/Rev/r/g")
v="$v1-$v2"
cd "$op/snap"
pre=$(echo $(cat snapcraft.yaml | grep "^version: " | grep " [0-9a-z.-]*" -o))
if [ "$pre" != "$v" ]; then
echo "Update... ($pre => $v)"
set -x
sed "s/^version: .*$/version: $v/" -i snapcraft.yaml
sed "s/source-commit: .*/source-commit: $lc/" -i snapcraft.yaml
git commit -m "$lrev" snapcraft.yaml
else
echo "Up-to-date! ($v)"
fi
git gc --aggressive