This repository has been archived by the owner on Nov 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
aurtoolsbuild
executable file
·101 lines (84 loc) · 3.21 KB
/
aurtoolsbuild
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
#!/bin/bash
base_packages='base base-devel sudo'
cmd="$(basename "$0" build)"
if [[ "${cmd%-*}" == multilib ]]; then
repo="${cmd}"
_arch='x86_64'
base_packages+=' gcc-multilib libtool-multilib'
else
repo=${cmd%-*}
_arch=${cmd##*-}
fi
chroots='/var/tmp/aurtoolsbuild'
clean_first=false
usage() {
echo "usage ${0##*/}"
echo ' -c Recreate the chroot before building'
echo ' -r <dir> Create chroots in this directory'
exit 1
}
while getopts 'cr:' arg; do
case "${arg}" in
c) clean_first=true ;;
r) chroots="$OPTARG" ;;
*) usage ;;
esac
done
. /etc/aurtools.conf || (echo 'failed to source /etc/aurtools.conf, now exiting' && exit 1)
# keep cache and repos seperate to avoid problems
AURREPODIR=${AURREPODIR}/${_arch}
AURCACHEDIR=${AURCACHEDIR}/${_arch}
mkdir -p ${AURREPODIR}
mkdir -p ${AURCACHEDIR}
###############################################################################
# Auto dependency resolution
###############################################################################
. PKGBUILD || { echo 'failed to source PKGBUILD'; exit 1; }
for package in ${depends[@]}; do
IFS=$'\t' read -r packagename packageversion < <(cower -i --format '%n\t%v' ${package} 2>/dev/null)
if [[ ${packagename} ]]; then
# not in main repos, check if in our local repo
if [[ ! -f ${AURREPODIR}/${packagename}-${packageversion}-${_arch}.pkg.tar.xz ]]; then
# not in our local repo, recurse
cower -d ${package}
pushd ${package}
if ! aur-${_arch}-build; then
echo "failed to build ${package} as a dependencity"
exit 1
fi
popd
fi
fi
done
###############################################################################
# end of Auto dependency resolution
###############################################################################
if ${clean_first} || [[ ! -d "${chroots}/${repo}-${_arch}" ]]; then
echo "Creating chroot for [${repo}] (${_arch})..."
sudo rm -rf ${chroots}/${repo}-${_arch}
sudo mkdir -p ${chroots}/${repo}-${_arch}
setarch ${_arch} sudo mkarchroot \
-C /usr/share/aurtools/pacman-${repo}.conf \
-M /usr/share/devtools/makepkg-${_arch}.conf \
${chroots}/${repo}-${_arch}/root \
${base_packages}
sudo mkdir -p ${chroots}/${repo}-${_arch}/root/var/tmp/aurtoolsrepo
sudo mount --bind ${AURREPODIR} ${chroots}/${repo}-${_arch}/root/var/tmp/aurtoolsrepo/
sudo mkdir -p ${chroots}/${repo}-${_arch}/root/var/cache/pacman/pkg/
sudo mount --bind ${AURCACHEDIR} ${chroots}/${repo}-${_arch}/root/var/cache/pacman/pkg/
else
sudo mkdir -p ${chroots}/${repo}-${_arch}/root/var/tmp/aurtoolsrepo
sudo mount --bind ${AURREPODIR} ${chroots}/${repo}-${_arch}/root/var/tmp/aurtoolsrepo/
sudo mkdir -p ${chroots}/${repo}-${_arch}/root/var/cache/pacman/pkg/
sudo mount --bind ${AURCACHEDIR} ${chroots}/${repo}-${_arch}/root/var/cache/pacman/pkg/
setarch ${_arch} sudo mkarchroot \
-u \
${chroots}/${repo}-${_arch}/root
fi
echo "Building in chroot for [${repo}] (${_arch})..."
setarch ${_arch} sudo makechrootpkg -c -r ${chroots}/${repo}-${_arch}
sudo umount ${chroots}/${repo}-${_arch}/root/var/tmp/aurtoolsrepo/
sudo umount ${chroots}/${repo}-${_arch}/root/var/cache/pacman/pkg/
repo-add ${AURREPODIR}/aurtools.db.tar.gz *.pkg.tar.xz
cp *.pkg.tar.xz ${AURREPODIR}
# vim: set noet ts=2 sw=2: