-
Notifications
You must be signed in to change notification settings - Fork 8
/
builder.sh
executable file
·411 lines (371 loc) · 13.1 KB
/
builder.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
#!/usr/bin/env bash
TEST_DEVTOOLS=$(pacman -Qq devtools 2>/dev/null)
if [ $? -ne 0 ]; then
echo "ERROR! You must install 'devtools'."
exit 1
fi
TEST_DEVTOOLS=$(pacman -Qq darkhttpd 2>/dev/null)
if [ $? -ne 0 ]; then
echo "ERROR! You must install 'darkhttpd'."
exit 1
fi
if [ $(id -u) != "0" ]; then
echo "ERROR! You must be 'root'."
exit 1
fi
MACHINE=$(uname -m)
# http://wiki.mate-desktop.org/status:1.10
CORE=(
mate-common
mate-desktop
libmatekbd
libmatemixer
libmateweather
mate-icon-theme
caja
caja-gtk3
mate-polkit
marco
marco-gtk3
mate-settings-daemon
mate-settings-daemon-gtk3
mate-session-manager
mate-session-manager-gtk3
mate-menus
mate-panel
mate-panel-gtk3
mate-backgrounds
mate-themes
mate-notification-daemon
mate-control-center
mate-control-center-gtk3
mate-screensaver
mate-screensaver-gtk3
mate-media
mate-media-gtk3
mate-power-manager
mate-power-manager-gtk3
mate-system-monitor
)
CORE_REMAIN=(
mate-user-guide
)
EXTRA=(
atril
atril-gtk3
caja-extensions
caja-extensions-gtk3
engrampa
engrampa-gtk3
eom
eom-gtk3
mate-applets
mate-applets-gtk3
mate-netspeed
mate-netspeed-gtk3
mate-user-share
mate-user-share-gtk3
mate-utils
mate-utils-gtk3
pluma
pluma-gtk3
)
AUR_EXTRA=(
caja-dropbox
mate-indicator-applet
)
EXTRA_REMAIN=(
mate-icon-theme-faenza
mate-netbook
mate-netbook-gtk3
mate-sensors-applet
mate-sensors-applet-gtk3
mate-terminal
mate-terminal-gtk3
mozo
mozo-gtk3
python2-caja
python2-caja-gtk3
galculator
obex-data-server
blueman
)
DISABLED=(gnome-main-menu)
BUILD_ORDER=("${CORE[@]}" "${EXTRA[@]}")
MATE_VER=1.10
BASEDIR=$(dirname $(readlink -f ${0}))
REPONAME="mate-dual"
REPODIR="/var/local/${REPONAME}/${MATE_VER}"
# Show usage information.
function usage() {
echo "$(basename ${0}) - MATE build tool for Arch Linux"
echo
echo "Usage: $(basename ${0}) -t [task]"
echo
echo "Options:"
echo "-h Shows this help message."
echo "-t Provide a task to run which can be one of:"
echo " build Build MATE packages."
echo " check Check upstream for new source tarballs."
echo " clean Remove MATE packages from /var/cache/pacan/pkg."
echo " repo Create a package repository in '${HOME}/mate/'"
echo " sync 'rsync' a repo to ${RSYNC_UPSTREAM}."
echo
echo "Each of the tasks above run automatically and operate over the entire"
echo "package tree."
}
function create_readme() {
local REPO_URL="${1}"
local REPO_PATH="${2}"
local REPO_NAME="${3}"
echo "<pre>" > ${REPO_PATH}/README.html
echo "Add the following to '/etc/pacman.conf', it must be the first enabled repository" >> ${REPO_PATH}/README.html
echo "so put it above '[testing]'." >> ${REPO_PATH}/README.html
echo "" >> ${REPO_PATH}/README.html
echo "[${REPO_NAME}]" >> ${REPO_PATH}/README.html
echo "SigLevel = Optional TrustAll" >> ${REPO_PATH}/README.html
echo "Server = ${REPO_URL}/\$arch" >> ${REPO_PATH}/README.html
echo >> ${REPO_PATH}/README.html
echo "Update the package indexes with 'pacman -Syy' and then install the packages you" >> ${REPO_PATH}/README.html
echo "require." >> ${REPO_PATH}/README.html
echo "</pre>" >> ${REPO_PATH}/README.html
}
function touch_dir() {
local TOUCHDIR="${1}"
local FAKEDT="$(date +%Y%m%d)0000.00"
find "${TOUCHDIR}" -exec touch -t ${FAKEDT} {} \;
}
function config_builder() {
if [ "${MACHINE}" == "x86_64" ]; then
ln -s /usr/bin/archbuild /usr/local/bin/mate-unstable-i686-build 2>/dev/null
ln -s /usr/bin/archbuild /usr/local/bin/mate-unstable-x86_64-build 2>/dev/null
elif [ "${MACHINE}" == "i686" ]; then
ln -s /usr/bin/archbuild /usr/local/bin/mate-unstable-i686-build 2>/dev/null
fi
rm /usr/local/bin/mate-unstablepkg 2>/dev/null
# Augment /usr/share/devtools/pacman-extra.conf
cp pacman-mate-unstable.conf /usr/share/devtools/pacman-mate-unstable.conf
}
function repo_init() {
# Remove any existing repositories and create empty ones.
rm -rf /var/local/${REPONAME}/*
for INIT_ARCH in i686 x86_64
do
mkdir -p ${REPODIR}/${INIT_ARCH}
touch ${REPODIR}/${INIT_ARCH}/${REPONAME}.db
done
}
function repo_update() {
local CHROOT_PLAT="${1}"
if [ ! -d ${REPODIR}/${CHROOT_PLAT} ]; then
mkdir -p ${REPODIR}/${CHROOT_PLAT}
fi
repo-add -q --nocolor --new ${REPODIR}/${CHROOT_PLAT}/${REPONAME}.db.tar.gz ${REPODIR}/${CHROOT_PLAT}/*.pkg.tar.xz 2>/dev/null
}
function httpd_stop() {
if [ -f /tmp/${REPONAME}-darkhttpd.pid ]; then
local DARK_PID=`cat /tmp/${REPONAME}-darkhttpd.pid`
kill -9 ${DARK_PID}
rm /tmp/${REPONAME}-darkhttpd.pid
else
killall darkhttpd
fi
}
function httpd_start() {
if [ -f /tmp/${REPONAME}-darkhttpd.pid ]; then
httpd_stop
fi
rm /tmp/${REPONAME}-http.log 2>/dev/null
darkhttpd /var/local/${REPONAME}/ --port 8089 --daemon --log /tmp/${REPONAME}-darkhttpd.log --pidfile /tmp/${REPONAME}-darkhttpd.pid
}
# Build packages that are not at the current version.
function tree_build() {
local PKG=${1}
local PKGBASE=$(echo ${PKG} | sed 's/-gtk3//')
echo "Building ${PKG}"
cd ${PKG}
# If there is a git clone check the revision.
if [ -f ${PKGBASE}/FETCH_HEAD ]; then
echo " - Fetching revision from git"
# git version
local _ver=$(grep -E ^_ver PKGBUILD | cut -f2 -d'=')
cd ${PKGBASE}
git fetch
local PKGBUILD_VER=$(printf "%s.%s.%s" "${_ver}" "$(git log -1 --format=%cd --date=short | tr -d -)" "$(git rev-list --count HEAD)")
cd ..
else
# pacakge version
#local PKGBUILD_VER=$(grep -E ^pkgver PKGBUILD | cut -f2 -d'=' | head -n1)
local POINT_VER=$(grep -E ^pkgver PKGBUILD | cut -d'.' -f2)
local PKGBUILD_VER="${MATE_VER}.${POINT_VER}"
fi
local PKGBUILD_REL=$(grep -E ^pkgrel PKGBUILD | cut -f2 -d'=')
local PKGBUILD=${PKGBUILD_VER}-${PKGBUILD_REL}
local TEST_ANY=$(grep "^arch=" PKGBUILD | grep any)
if [ -n "${TEST_ANY}" ]; then
if [ "${MACHINE}" == "i686" ] || [ "${MACHINE}" == "x86_64" ]; then
local CHROOT_ARCHS=(i686)
fi
else
if [ "${MACHINE}" == "i686" ] || [ "${MACHINE}" == "x86_64" ]; then
local CHROOT_ARCHS=(i686 x86_64)
fi
fi
for CHROOT_ARCH in ${CHROOT_ARCHS[@]};
do
if [ "${PKG}" == "caja-extensions" ]; then
PKG_CHECK="caja-share"
elif [ "${PKG}" == "caja-extensions-gtk3" ]; then
PKG_CHECK="caja-share-gtk3"
else
PKG_CHECK="${PKG}"
fi
if [ -n "${TEST_ANY}" ]; then
echo " - Looking for ${PKG_CHECK}-${PKGBUILD}-any.pkg.tar.xz"
EXIST=$(ls -1 ${PKG_CHECK}-${PKGBUILD}-any.pkg.tar.xz 2>/dev/null)
local RET=$?
else
echo " - Looking for ${PKG_CHECK}-${PKGBUILD}-${CHROOT_ARCH}.pkg.tar.xz"
EXIST=$(ls -1 ${PKG_CHECK}-${PKGBUILD}-${CHROOT_ARCH}.pkg.tar.xz 2>/dev/null)
local RET=$?
fi
if [ ${RET} -ne 0 ]; then
echo " - Did not find built packages for ${PKG}."
echo " - Building ${PKG}"
mate-unstable-${CHROOT_ARCH}-build
if [ $? -ne 0 ]; then
echo " - Failed to build ${PKG} for ${CHROOT_ARCH}. Stopping here."
httpd_stop
exit 1
fi
else
echo " - Found matching build for ${PKG}."
if [ -n "${TEST_ANY}" ]; then
echo " - ${PKG}-${PKGBUILD}-any is current"
else
echo " - ${PKG}-${PKGBUILD}-${CHROOT_ARCH} is current"
fi
fi
echo " - Adding '${PKG}' to [${REPONAME}]"
if [ -n "${TEST_ANY}" ]; then
if [ "${MACHINE}" == "i686" ] || [ "${MACHINE}" == "x86_64" ]; then
if [ "${PKG}" == "caja-extensions" ] || [ "${PKG}" == "caja-extensions-gtk3" ]; then
cp -a caja*-any.pkg.tar.xz ${REPODIR}/i686/ 2>/dev/null
cp -a caja*-any.pkg.tar.xz ${REPODIR}/x86_64/ 2>/dev/null
else
cp -a ${PKG}*-any.pkg.tar.xz ${REPODIR}/i686/ 2>/dev/null
cp -a ${PKG}*-any.pkg.tar.xz ${REPODIR}/x86_64/ 2>/dev/null
fi
repo_update i686
repo_update x86_64
fi
else
if [ "${PKG}" == "caja-extensions" ] || [ "${PKG}" == "caja-extensions-gtk3" ]; then
cp -a caja*-${CHROOT_ARCH}.pkg.tar.xz ${REPODIR}/${CHROOT_ARCH}/ 2>/dev/null
else
cp -a ${PKG}*-${CHROOT_ARCH}.pkg.tar.xz ${REPODIR}/${CHROOT_ARCH}/ 2>/dev/null
fi
repo_update ${CHROOT_ARCH}
fi
# Copy the build logs and PKGBUILD (with assets) for posterity.
# Yes 'any' and architecture specific packages are required all the time.
mkdir -p ${REPODIR}/${CHROOT_ARCH}/PKGBUILD/${PKG} 2>/dev/null
cp -a *-any*.log ${REPODIR}/${CHROOT_ARCH}/PKGBUILD/${PKG}/ 2>/dev/null
cp -a *-${CHROOT_ARCH}*.log ${REPODIR}/${CHROOT_ARCH}/PKGBUILD/${PKG}/ 2>/dev/null
cp -a {PKGBUILD,*.install,*.desktop,*.diff,*.patch} ${REPODIR}/${CHROOT_ARCH}/PKGBUILD/${PKG}/ 2>/dev/null
done
echo
}
# Check for new upstream releases.
function tree_check() {
local PKG=${1}
if [ "${PKG}" == "python2-caja" ]; then
UPSTREAM_PKG="python-caja"
else
UPSTREAM_PKG="${PKG}"
fi
if [ ! -f /tmp/${MATE_VER}_SUMS ]; then
echo " - Downloading MATE ${MATE_VER} SHA1SUMS"
wget -c -q http://pub.mate-desktop.org/releases/${MATE_VER}/SHA1SUMS -O /tmp/${MATE_VER}_SUMS
fi
echo " - Checking ${UPSTREAM_PKG}"
IS_UPSTREAM=$(grep -E ${UPSTREAM_PKG}-[0-9]. /tmp/${MATE_VER}_SUMS)
if [ -n "${IS_UPSTREAM}" ]; then
local UPSTREAM_TARBALL=$(grep [0-9a-f]\ .${UPSTREAM_PKG}\-[0-9] /tmp/${MATE_VER}_SUMS | cut -c43- | tail -n1)
local UPSTREAM_SHA1=$(grep [0-9a-f]\ .${UPSTREAM_PKG}\-[0-9] /tmp/${MATE_VER}_SUMS | cut -c1-40 | tail -n1)
local DOWNSTREAM_VER=$(grep -E ^pkgver ${PKG}/PKGBUILD | cut -f2 -d'=')
local DOWNSTREAM_TARBALL="${UPSTREAM_PKG}-${DOWNSTREAM_VER}.tar.xz"
local DOWNSTREAM_SHA1=$(grep -E ^sha1 ${PKG}/PKGBUILD | cut -f2 -d"'")
if [ "${UPSTREAM_TARBALL}" != "${DOWNSTREAM_TARBALL}" ]; then
echo " +---> Upstream tarball differs : ${UPSTREAM_TARBALL}"
fi
if [ "${UPSTREAM_SHA1}" != "${DOWNSTREAM_SHA1}" ]; then
echo " +---> Upstream SHA1SUM differs : ${UPSTREAM_SHA1}"
fi
else
echo " +---> No upstream version of ${PKG} detected. Skipping."
fi
}
# `rsync` repo upstream.
function tree_sync() {
echo "Action : sync"
# Modify this accordingly.
local RSYNC_UPSTREAM="[email protected]::mate-${MATE_VER}"
chown -R 1000:100 ${REPODIR}
rsync -av --delete --progress ${REPODIR}/ "${RSYNC_UPSTREAM}/"
}
# `rsync` repo upstream.
function tree_clean() {
echo "Action : clean"
rm -fv /var/cache/pacman/pkg/atril*
rm -fv /var/cache/pacman/pkg/*caja*
rm -fv /var/cache/pacman/pkg/engrampa*
rm -fv /var/cache/pacman/pkg/eom*
rm -fv /var/cache/pacman/pkg/marco*
rm -fv /var/cache/pacman/pkg/*mate*
rm -fv /var/cache/pacman/pkg/mozo*
rm -fv /var/cache/pacman/pkg/pluma*
rm -fv */*.pkg.tar.xz
rm -fv */*.log
rm -rfv ${REPODIR}/*
}
function tree_run() {
local ACTION=${1}
echo "Action : ${ACTION}"
config_builder
repo_init
httpd_start
for PKG in ${BUILD_ORDER[@]};
do
cd ${BASEDIR}
tree_${ACTION} ${PKG}
done
httpd_stop
# We only arrive here if every package action completed successfully.
if [ "${ACTION}" == "build" ]; then
create_readme "http://pkgbuild.com/~flexiondotorg/${REPONAME}/${MATE_VER}" "${REPODIR}" "${REPONAME}"
touch_dir "${REPODIR}"
fi
}
TASK=""
OPTSTRING=ht:
while getopts ${OPTSTRING} OPT; do
case ${OPT} in
h) usage; exit 0;;
t) TASK=${OPTARG};;
*) usage; exit 1;;
esac
done
shift "$(( $OPTIND - 1 ))"
if [ "${TASK}" == "build" ] ||
[ "${TASK}" == "check" ]; then
tree_run ${TASK}
elif [ "${TASK}" == "clean" ] ||
[ "${TASK}" == "sync" ]; then
tree_${TASK}
else
usage
exit 1
fi
# Clean up.
rm -f /tmp/*_SUMS 2>/dev/null