-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·288 lines (252 loc) · 7.54 KB
/
build.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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#!/bin/sh -ex
_outH1() {
echo
echo "# $1"
echo
}
_execFunction() {
_functionName=${1}
if [ "$(LC_ALL=C type -t ${_functionName})" == "function" ];
then
_outH1 "Execute ${_functionName}"
${_functionName}
fi
}
_pkgBuild() {
_pwd=$(pwd)
cd $1
# Install compiled make dependencies
if [ -e "makedepends" ];
then
sudo pacman --noconfirm -U makedepends/*.pkg.*
fi
makepkg --ignorearch --syncdeps --clean --cleanbuild --force --noconfirm --skipinteg
# in case there's nothing to copy, don't fail
cp -n *.pkg.* /build-target || true
# Install packages separately.
# When building multiple packages with different version numbers and in one PKGBUILD,
# on the end makepkg tries to install all packages with the last version number
sudo pacman --noconfirm -U *.pkg.*
cd ${_pwd}
}
# TODO Increment pkgrel if changes found
_pkgSync() {
_pwd=$(pwd)
_makepkg=$(realpath ${1})
cd ${_makepkg}
eval local $(grep -o -m 1 '^\s*pkgname\s*=\s*.*' PKGBUILD)
(echo "# Find this package on $(git remote get-url origin)" | cat - PKGBUILD) > PKGBUILD.new && mv PKGBUILD.new PKGBUILD
# Create .SRCINFO and other resources
makepkg --printsrcinfo > .SRCINFO
_syncPath="${_pwd}/makepkgs-sync/${pkgname}"
if ! git clone http://aur.archlinux.org/${pkgname}.git ${_syncPath} ;
then
echo "Clone failed ${pkgname}"
return $?
fi
cd ${_syncPath}
find ./ -maxdepth 1 -mindepth 1 -not -name ".git*" -exec rm -rf {} \;
cp -RT ${_makepkg} .
# Create checksums at last. This will download sourcefiles and changes the source directory.
# Will break dynamic array extension.
#cd ${_makepkg}
#updpkgsums
#makepkg --printsrcinfo > .SRCINFO
#cp -rf PKGBUILD ${_syncPath}
#cp -rf .SRCINFO ${_syncPath}
cd ${_syncPath}
git add -A || true
git commit -a -m "next iteration" || true
cd ${_pwd}
}
_pkgPush() {
_pwd=$(pwd)
_makepkg_sync=$(realpath ${1})
cd ${_makepkg_sync}
git remote set-url origin ssh://[email protected]/$(basename ${_makepkg_sync}).git
git push
cd ${_pwd}
}
_pkgConvertToGitPackage() {
_pkgnameDeclaration="$(grep -o -m 1 '^\s*pkgname\s*=\s*.*$' ${1}/PKGBUILD)"
eval local ${_pkgnameDeclaration}
if [[ "${pkgname}" == *-git ]];
then
echo "Is already Git-Package ${1} (${pkgname})"
return 0
fi
# Only first occurence
sed -i "0,/${_pkgnameDeclaration}/s//pkgname='${pkgname}-git'/" ${1}/PKGBUILD
}
_pkgUpdateToLatestVersion() {
if ! _sourceDeclaration="$(grep -o -m 1 '^\s*_source\s*=\s*.*$' ${1}/PKGBUILD)" ;
then
echo "No _source deaclared ${1}"
return 0
fi
eval local ${_sourceDeclaration}
if [[ "${_source}" != git+* ]];
then
echo "No supported location declared in _source ${1} (${_source})"
return 0
fi
if _tagPrefixDeclaration="$(grep -o -m 1 '^\s*_tagPrefix\s*=\s*.*$' ${1}/PKGBUILD)" ;
then
eval local ${_tagPrefixDeclaration}
fi
if _tagSuffixDeclaration="$(grep -o -m 1 '^\s*_tagSuffix\s*=\s*.*$' ${1}/PKGBUILD)" ;
then
eval local ${_tagSuffixDeclaration}
fi
_pkgverDeclaration="$(grep -o -m 1 '^\s*pkgver\s*=\s*.*$' ${1}/PKGBUILD)"
eval local ${_pkgverDeclaration}
_latestPkgver=$(git ls-remote --refs --tags "$(echo "${_source}" | sed 's|^git+||')" | sed 's|.*tags/\(.*\)$|\1|' | grep "^${_tagPrefix}.*" | grep ".*${_tagSuffix}$" | sed "s|${_tagPrefix}\(.*\)${_tagSuffix}|\1|" | sort -u -V | grep -vE "(beta|alpha|test)" | tail -n 1)
if [[ "${pkgver}" == "${_latestPkgver}" ]];
then
echo "Is already latest version ${1}"
return 0
fi
# Only first occurence
sed -i "0,/${_pkgverDeclaration}/s//pkgver='${_latestPkgver}'/" ${1}/PKGBUILD
}
### START
makepkgsClone=(
'https://aur.archlinux.org/libiconv.git'
'https://aur.archlinux.org/php74.git'
)
makepkgs=(
# TESTING BUILD
# 'test#nosync#nogit'
# CORE
'libiconv#nosync#nogit'
'swig#nosync#nogit'
'libvmime#nosync'
# 'kopano-libvmime'
'php74#nosync#nogit'
'php-binding#nosync#nogit'
'kopano-core'
# z-push
'z-push'
# WEBAPP
# OPTIONAL 'jdk#nosync#nogit'
'kopano-webapp'
# 'kopano-webapp-gmaps'
# 'kopano-webapp-contactfax'
# 'kopano-webapp-pimfolder'
'kopano-webapp-nginx'
'kopano-webapp-files'
'kopano-webapp-files-owncloud-backend'
'kopano-webapp-files-smb-backend'
'kopano-webapp-filepreview'
'kopano-webapp-desktopnotifications'
# 'kopano-webapp-htmleditor-jodit'
'kopano-webapp-htmleditor-minimaltiny'
'kopano-webapp-intranet'
'kopano-webapp-smime'
'kopano-webapp-spellchecker'
'kopano-webapp-spellchecker-languagepack-de-at'
'kopano-webapp-spellchecker-languagepack-de-ch'
'kopano-webapp-spellchecker-languagepack-de-de'
'kopano-webapp-spellchecker-languagepack-en-gb'
'kopano-webapp-spellchecker-languagepack-en-us'
'kopano-webapp-spellchecker-languagepack-es-es'
'kopano-webapp-spellchecker-languagepack-fr-fr'
'kopano-webapp-spellchecker-languagepack-italian-it'
'kopano-webapp-spellchecker-languagepack-nl'
'kopano-webapp-spellchecker-languagepack-pl-pl'
'kopano-webapp-mdm'
'kopano-webapp-mattermost'
'kopano-webapp-meet'
'kopano-webapp-webmeetings'
'kopano-webapp-passwd'
'kopano-webapp-fetchmail'
# 'kopano-webapp-google2fa'
)
_outH1 "CHECKOUT"
for makepkgClone in "${makepkgsClone[@]}"
do
makepkgCloneName=${makepkgClone}
makepkgCloneName="${makepkgCloneName//*\//}"
makepkgCloneName="${makepkgCloneName//.git/}"
git clone ${makepkgClone} makepkgs/${makepkgCloneName}
done
_outH1 "PREPARE"
_templateDir=$(realpath ./makepkgs-templates)
${_templateDir}/recreate-symlinks.sh
grep -R -l "# template " makepkgs | while read _file
do
echo "Replacing Template Markers: ${_file}"
makepkg-template --template-dir ${_templateDir} --input ${_file}
done
for _task in "$@"
do
case "${_task}" in
"convertToGitPackage")
_outH1 "CONVERT TO GIT PACKAGE"
for makepkg in "${makepkgs[@]}"
do
makepkgname="${makepkg//#*/}"
if [[ "${makepkg}" == *#nogit* ]];
then
echo "NO GIT : ${makepkgname}"
continue
fi
_pkgConvertToGitPackage makepkgs/${makepkgname}
done
;;
"updateToLatestVersion")
_outH1 "UPDATE PACKAGE TO LATEST VERSION"
for makepkg in "${makepkgs[@]}"
do
makepkgname="${makepkg//#*/}"
if [[ "${makepkg}" == *#nogit* ]];
then
echo "NO GIT : ${makepkgname}"
continue
fi
_pkgUpdateToLatestVersion makepkgs/${makepkgname}
done
;;
"sync")
_outH1 "SYNC"
if [ -z "$(git config --global user.email)" ] \
|| [ -z "$(git config --global user.name)" ];
then
git config --global user.email "[email protected]"
git config --global user.name "Your Name"
fi
for makepkg in "${makepkgs[@]}"
do
makepkgname="${makepkg//#*/}"
if [[ "${makepkg}" == *#nosync* ]];
then
echo "NO SYNC : ${makepkgname}"
continue
fi
_execFunction "presync_${makepkgname//-/_}"
_pkgSync makepkgs/${makepkgname}
done
cp -R makepkgs-sync /build-target/
;;
"push")
for pkg in $(ls makepkgs-sync/);
do
_outH1 "PUSHING ${pkg}"
_pkgPush makepkgs-sync/${pkg}
done;
;;
"build")
_outH1 "BUILD"
for makepkg in "${makepkgs[@]}"
do
makepkgname="${makepkg//#*/}"
_execFunction "prebuild_${makepkgname//-/_}"
_execFunction "build_${makepkgname//-/_}"
_pkgBuild makepkgs/${makepkgname}
_execFunction "postbuild_${makepkgname//-/_}"
done
;;
*)
;;
esac
done