-
Notifications
You must be signed in to change notification settings - Fork 0
/
archbuild
executable file
·73 lines (60 loc) · 1.58 KB
/
archbuild
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
#!/bin/bash
CONFDIR="/etc"
##
# Source configuration
##
if [ -f "$CONFDIR/devtools.conf" ]; then
source "$CONFDIR/devtools.conf"
else
error "Could not find configuration file $CONFDIR/devtools.conf"
exit 1
fi
##
# User based overrides
##
[ -f ~/.devtools.conf ] && source ~/.devtools.conf
##
base_packages='base base-devel sudo'
cmd="$(basename "${0%-build}")"
if [ "${cmd}" == 'multilib' ]; then
repo='multilib'
arch='x86_64'
base_packages+=' gcc-multilib'
elif [ "${cmd}" == 'multilib-testing' ]; then
repo='multilib-testing'
arch='x86_64'
base_packages+=' gcc-multilib'
else
repo=${cmd%-*}
arch=${cmd#*-}
fi
clean_first=false
usage() {
echo "usage $(basename "$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
if [ "$(uname -m)" == 'i686' -a "${arch}" != 'i686' ]; then
echo 'You can only build i686 packages on this system'
exit 1
fi
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/devtools/pacman-${repo}.conf \
-M /usr/share/devtools/makepkg-${arch}.conf \
${chroots}/${repo}-${arch}/root \
${base_packages}
fi
echo "Building in chroot for [${repo}] (${arch})..."
setarch ${arch} sudo makechrootpkg -c -u -r ${chroots}/${repo}-${arch}