Magellan Linux

Contents of /trunk/mage-buildserver/buildserver-functions.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2775 - (show annotations) (download) (as text)
Thu Aug 28 09:10:04 2014 UTC (9 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 2887 byte(s)
-added enum-build-arch-types() and enum-all-arch-types() functions
1 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 local os_arch
13
14 # only allow the right arches
15 case ${arch} in
16 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 *) die "unknown architecture '${arch}'" ;;
19 esac
20
21 [ -f ${buildroot}/${script} ] || die "'${buildroot}/${script}' does not exist."
22
23 setarch "${os_arch}" systemd-nspawn \
24 --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 --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 bash --login "${script}" \
36 || die "runarch-script '${script}' for '${arch}' failed."
37
38 # wait for container to exit
39 sleep 1
40 }
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 }
65
66 runarch-pkg-install()
67 {
68 local arch="$1"
69 local pkg="$2"
70
71 if [ ! -f ${BUILDROOT}/.stamps/"${arch}"_"${pkg}"-ok ]
72 then
73 runarch "${arch}" mage install "${pkg}" || die "${arch} install 'python'"
74 touch ${BUILDROOT}/.stamps/"${arch}"_"${pkg}"-ok
75 else
76 echo "Warning: '${pkg}' already installed for arch '${arch}'"
77 fi
78
79 # never fail
80 return 0
81 }
82
83 enum-build-arch-types()
84 {
85 echo "${BUILD_ARCH[*]}"
86 }
87
88 enum-all-arch-types()
89 {
90 local arch
91 local build_arch_types
92
93 for arch in src ${BUILD_ARCH[*]}
94 do
95 if [ ! -e ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/${arch}/mage.rc ]
96 then
97 echo "Warning: mage.rc of '${arch}' not found. Arch '${arch}' ignored." >&2
98 else
99 build_arch_types+=( "${arch}" )
100 fi
101 done
102
103 if [[ ${BUILD_PLAYGROUND} -eq 1 ]]
104 then
105 for arch in ${BUILD_ARCH[*]}
106 do
107 if [ ! -e ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/playground-${arch}/mage.rc ]
108 then
109 echo "Warning: mage.rc of 'playground-${arch}' not found. Arch 'playground-${arch}' ignored." >&2
110 else
111 build_arch_types+=( "playground-${arch}" )
112 fi
113 done
114 fi
115
116 echo "${build_arch_types[*]}"
117 }