blob: 33c63e171e6e20a293050a6e8cdd22b6d04818cb (
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
|
#!/bin/bash
# build package automation
readonly base=$(cd "${BASH_SOURCE%/*}" && pwd)
source $base/PKGBUILD
is_root() {
[[ $(id -u) == 0 ]]
}
has_makepkg() {
&>/dev/null which makepkg
}
do_provision() {
if has_makepkg ; then
do_provision_proper
else
do_provision_simple
fi
}
do_provision_proper() {
echo "// do_provision_proper"
local suno=""
if is_root ; then
#chown -R nobody $base
suno="sudo -u nobody"
fi
$suno makepkg --force
}
do_provision_simple() {
echo "// do_provision_simple"
local source="$url.git"
if [[ -e $pkgname ]] ; then
git -C $pkgname pull
else
git clone $source
fi
}
do_version() {
#echo "version $pkgver -> $(pkgver)"
if has_makepkg; then
do_version_proper
else
do_version_simple
fi
}
do_version_simple() {
echo "// do_version_simple"
local pkgver=$(pkgver)
local file_list="PKGBUILD .SRCINFO"
local file
for file in $file_list ; do
sed -r -i "s%^([ ]*pkgver[ ]*=[ ]*).*%\1$pkgver%" "$file"
sed -r -i "s%#tag=v[0-9]+%#tag=v$pkgver%" "$file"
done
}
do_version_proper() {
echo "// do_version_proper"
local suno=""
local user="nobody"
if is_root ; then
chown -R $user $base
suno="sudo -u $user"
fi
$suno makepkg --printsrcinfo > .SRCINFO
}
do_commit() {
echo "// do_commit"
git add --all :/
git status
local message=$(git status --short)
git commit --message "$message"
git push
}
do_clean() {
echo "// clean"
rm -rf "$base/$pkgname"
rm -rf "$base/src"
rm -rf "$base/pkg"
}
###
set -e -u
do_provision
do_version
do_commit
do_clean
|