Annotation of /trunk/mage-buildserver/buildserver-functions.sh
Parent Directory | Revision Log
Revision 2748 -
(hide annotations)
(download)
(as text)
Wed Aug 13 14:04:10 2014 UTC (9 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 1766 byte(s)
Wed Aug 13 14:04:10 2014 UTC (9 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 1766 byte(s)
-fixed os issues and map ssh/build-info and buildserver helpers. also wait one second for the container to exit
1 | niro | 2588 | die() |
2 | { | ||
3 | echo "ERROR: $@" | ||
4 | exit 1 | ||
5 | } | ||
6 | |||
7 | runarch-script() | ||
8 | { | ||
9 | local arch="$1" | ||
10 | local script="$2" | ||
11 | local buildroot | ||
12 | niro | 2748 | local os_arch |
13 | niro | 2588 | |
14 | # only allow the right arches | ||
15 | case ${arch} in | ||
16 | niro | 2748 | i*86|x86_64) buildroot="${BUILDROOT}/${arch}"; os_arch="${arch}" ;; |
17 | src) os_arch="$(source ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/src/mage.rc; echo ${ARCH})"; buildroot="${BUILDROOT}/src" ;; | ||
18 | niro | 2588 | *) die "unknown architecture '${arch}'" ;; |
19 | esac | ||
20 | |||
21 | [ -f ${buildroot}/${script} ] || die "'${buildroot}/${script}' does not exist." | ||
22 | |||
23 | niro | 2748 | setarch "${os_arch}" systemd-nspawn \ |
24 | niro | 2588 | --directory="${buildroot}" \ |
25 | --bind=${BUILDROOT}/tmp/mage-tree:/usr/mage \ | ||
26 | --bind=${BUILDROOT}/svn/mage/include:/usr/mage/include \ | ||
27 | --bind=${BUILDROOT}/svn/mage/profiles:/usr/mage/profiles \ | ||
28 | --bind=${BUILDROOT}/svn/smage:/var/cache/mage/smage \ | ||
29 | --bind=${BUILDROOT}/packages/${arch}:/var/cache/mage/packages \ | ||
30 | --bind=${BUILDROOT}/packages/src:/var/cache/mage/src-packages \ | ||
31 | --bind=${BUILDROOT}/meta/${arch}:/var/cache/mage/meta \ | ||
32 | niro | 2748 | --bind=/usr/lib/mage-buildserver/helper:/usr/lib/mage-buildserver \ |
33 | --bind=${BUILDROOT}/build-info/${arch}:/var/cache/mage-buildserver \ | ||
34 | --bind=${BUILDROOT}/ssh:/root/.ssh \ | ||
35 | niro | 2588 | bash --login "${script}" \ |
36 | || die "runarch-script '${script}' for '${arch}' failed." | ||
37 | niro | 2748 | |
38 | # wait for container to exit | ||
39 | sleep 1 | ||
40 | niro | 2588 | } |
41 | |||
42 | runarch() | ||
43 | { | ||
44 | local arch="$1" | ||
45 | shift | ||
46 | local cmd="$@" | ||
47 | local buildroot | ||
48 | local runrc | ||
49 | |||
50 | # only allow the right arches | ||
51 | case ${arch} in | ||
52 | i*86|x86_64|src) buildroot="${BUILDROOT}/${arch}"; runrc="${buildroot}/.runrc" ;; | ||
53 | *) die "unknown architecture '${arch}'" ;; | ||
54 | esac | ||
55 | |||
56 | # create runrc | ||
57 | echo "${cmd}" > "${runrc}" | ||
58 | runarch-script "${arch}" .runrc || die "runarch script execition of '${runrc}' failed." | ||
59 | |||
60 | if [ -f "${runrc}" ] | ||
61 | then | ||
62 | rm "${runrc}" | ||
63 | fi | ||
64 | } |