Annotation of /trunk/mage-buildserver/buildserver-functions.sh
Parent Directory | Revision Log
Revision 2776 -
(hide annotations)
(download)
(as text)
Thu Aug 28 09:10:55 2014 UTC (10 years ago) by niro
File MIME type: application/x-sh
File size: 3141 byte(s)
Thu Aug 28 09:10:55 2014 UTC (10 years ago) by niro
File MIME type: application/x-sh
File size: 3141 byte(s)
-added os-arch() function
1 | niro | 2588 | die() |
2 | { | ||
3 | echo "ERROR: $@" | ||
4 | exit 1 | ||
5 | } | ||
6 | |||
7 | niro | 2776 | os-arch() |
8 | { | ||
9 | local arch="$1" | ||
10 | local os_arch | ||
11 | |||
12 | case ${arch} in | ||
13 | i*86|x86_64) os_arch="${arch}" ;; | ||
14 | src|playground*) os_arch="$(source ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/${arch}/mage.rc; echo ${ARCH})";; | ||
15 | esac | ||
16 | |||
17 | echo "${os_arch}" | ||
18 | } | ||
19 | |||
20 | niro | 2588 | runarch-script() |
21 | { | ||
22 | local arch="$1" | ||
23 | local script="$2" | ||
24 | local buildroot | ||
25 | niro | 2748 | local os_arch |
26 | niro | 2588 | |
27 | # only allow the right arches | ||
28 | case ${arch} in | ||
29 | niro | 2748 | i*86|x86_64) buildroot="${BUILDROOT}/${arch}"; os_arch="${arch}" ;; |
30 | src) os_arch="$(source ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/src/mage.rc; echo ${ARCH})"; buildroot="${BUILDROOT}/src" ;; | ||
31 | niro | 2588 | *) die "unknown architecture '${arch}'" ;; |
32 | esac | ||
33 | |||
34 | [ -f ${buildroot}/${script} ] || die "'${buildroot}/${script}' does not exist." | ||
35 | |||
36 | niro | 2748 | setarch "${os_arch}" systemd-nspawn \ |
37 | niro | 2588 | --directory="${buildroot}" \ |
38 | --bind=${BUILDROOT}/tmp/mage-tree:/usr/mage \ | ||
39 | --bind=${BUILDROOT}/svn/mage/include:/usr/mage/include \ | ||
40 | --bind=${BUILDROOT}/svn/mage/profiles:/usr/mage/profiles \ | ||
41 | --bind=${BUILDROOT}/svn/smage:/var/cache/mage/smage \ | ||
42 | --bind=${BUILDROOT}/packages/${arch}:/var/cache/mage/packages \ | ||
43 | --bind=${BUILDROOT}/packages/src:/var/cache/mage/src-packages \ | ||
44 | --bind=${BUILDROOT}/meta/${arch}:/var/cache/mage/meta \ | ||
45 | niro | 2748 | --bind=/usr/lib/mage-buildserver/helper:/usr/lib/mage-buildserver \ |
46 | --bind=${BUILDROOT}/build-info/${arch}:/var/cache/mage-buildserver \ | ||
47 | --bind=${BUILDROOT}/ssh:/root/.ssh \ | ||
48 | niro | 2588 | bash --login "${script}" \ |
49 | || die "runarch-script '${script}' for '${arch}' failed." | ||
50 | niro | 2748 | |
51 | # wait for container to exit | ||
52 | sleep 1 | ||
53 | niro | 2588 | } |
54 | |||
55 | runarch() | ||
56 | { | ||
57 | local arch="$1" | ||
58 | shift | ||
59 | local cmd="$@" | ||
60 | local buildroot | ||
61 | local runrc | ||
62 | |||
63 | # only allow the right arches | ||
64 | case ${arch} in | ||
65 | i*86|x86_64|src) buildroot="${BUILDROOT}/${arch}"; runrc="${buildroot}/.runrc" ;; | ||
66 | *) die "unknown architecture '${arch}'" ;; | ||
67 | esac | ||
68 | |||
69 | # create runrc | ||
70 | echo "${cmd}" > "${runrc}" | ||
71 | runarch-script "${arch}" .runrc || die "runarch script execition of '${runrc}' failed." | ||
72 | |||
73 | if [ -f "${runrc}" ] | ||
74 | then | ||
75 | rm "${runrc}" | ||
76 | fi | ||
77 | } | ||
78 | niro | 2774 | |
79 | runarch-pkg-install() | ||
80 | { | ||
81 | local arch="$1" | ||
82 | local pkg="$2" | ||
83 | |||
84 | if [ ! -f ${BUILDROOT}/.stamps/"${arch}"_"${pkg}"-ok ] | ||
85 | then | ||
86 | runarch "${arch}" mage install "${pkg}" || die "${arch} install 'python'" | ||
87 | touch ${BUILDROOT}/.stamps/"${arch}"_"${pkg}"-ok | ||
88 | else | ||
89 | echo "Warning: '${pkg}' already installed for arch '${arch}'" | ||
90 | fi | ||
91 | |||
92 | # never fail | ||
93 | return 0 | ||
94 | } | ||
95 | niro | 2775 | |
96 | enum-build-arch-types() | ||
97 | { | ||
98 | echo "${BUILD_ARCH[*]}" | ||
99 | } | ||
100 | |||
101 | enum-all-arch-types() | ||
102 | { | ||
103 | local arch | ||
104 | local build_arch_types | ||
105 | |||
106 | for arch in src ${BUILD_ARCH[*]} | ||
107 | do | ||
108 | if [ ! -e ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/${arch}/mage.rc ] | ||
109 | then | ||
110 | echo "Warning: mage.rc of '${arch}' not found. Arch '${arch}' ignored." >&2 | ||
111 | else | ||
112 | build_arch_types+=( "${arch}" ) | ||
113 | fi | ||
114 | done | ||
115 | |||
116 | if [[ ${BUILD_PLAYGROUND} -eq 1 ]] | ||
117 | then | ||
118 | for arch in ${BUILD_ARCH[*]} | ||
119 | do | ||
120 | if [ ! -e ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/playground-${arch}/mage.rc ] | ||
121 | then | ||
122 | echo "Warning: mage.rc of 'playground-${arch}' not found. Arch 'playground-${arch}' ignored." >&2 | ||
123 | else | ||
124 | build_arch_types+=( "playground-${arch}" ) | ||
125 | fi | ||
126 | done | ||
127 | fi | ||
128 | |||
129 | echo "${build_arch_types[*]}" | ||
130 | } |