-
Notifications
You must be signed in to change notification settings - Fork 9
/
update
executable file
·106 lines (83 loc) · 2.31 KB
/
update
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
#!/bin/bash
statusfile=`mktemp status.XXX`
vercmp() {
[ "$2" = `echo -e "$1\n$2" | sort -Vr | head -n1` ]
}
updatepkgbuild() {
pkg=$1
pkgbuild=$pkg/PKGBUILD
curl -s https://aur.archlinux.org/cgit/aur.git/snapshot/$pkg.tar.gz | /bin/tar -xz 2>/dev/null
if [ -x "$pkg/PKGBUILD-update.sh" ]; then
pushd $pkg > /dev/null
./PKGBUILD-update.sh
popd > /dev/null
fi
if $(git status -s | grep -q " $pkgbuild"); then
# modified pkgbuild
if $(git diff $pkgbuild | grep -q "^+epoch="); then
# newer epoch, flip tables
echo "$pkg : new epoch, /fliptables" >> $statusfile
elif $(git diff $pkgbuild | grep -q "^-pkgver="); then
# modified pkgver
oldver=$(git diff $pkgbuild | grep "^-pkgver=" | cut -d= -f2)
newver=$(git diff $pkgbuild | grep "^+pkgver=" | cut -d= -f2)
if vercmp $oldver $newver; then
# newer pkgver, announce it
echo "$pkg : $oldver => $newver" >> $statusfile
else
# older pkgver, revert it
echo "$pkg : $oldver => $newver (ignoring)" >> $statusfile
#git checkout -f $pkgbuild >/dev/null 2>&1
fi
elif $(git diff $pkgbuild | grep -q "^-pkgrel="); then
# modified pkgrel
pkgver=$(git diff $pkgbuild | grep "^ pkgver=" | cut -d= -f2)
oldrel=$(git diff $pkgbuild | grep "^-pkgrel=" | cut -d= -f2)
newrel=$(git diff $pkgbuild | grep "^+pkgrel=" | cut -d= -f2)
if vercmp $oldrel $newrel; then
# newer pkgrel, announce it
echo "$pkg : $pkgver-$oldrel => $pkgver-$newrel" >> $statusfile
else
# older pkgrel, revert it
echo "$pkg : $pkgver-$oldrel => $pkgver-$newrel (ignoring)" >> $statusfile
#git checkout -f $pkgbuild >/dev/null 2>&1
fi
fi
fi
}
ignore_forked="yes"
if [ "$1" = "-f" ]; then
echo "Including packages with .forked"
ignore_forked="no"
shift
fi
if [[ $# > 0 ]]; then
echo "Importing PKGBUILDs from AUR..."
until [ -z "$1" ]
do
updatepkgbuild $1
shift
done
else
echo -n "Updating PKGBUILDs from AUR..."
counter=0
for pkg in $(ls */PKGBUILD | grep -v jreese | sed 's@/.*$@@'); do
if [ -f "$pkg/.forked" ] && [ "$ignore_forked" = "yes" ]; then
continue
fi
echo -n "."
updatepkgbuild $pkg &
counter=$((counter + 1))
if [[ $counter == 5 ]]
then
counter=0
wait
fi
done
echo
fi
wait
cat $statusfile
rm $statusfile
echo
echo "Done"