Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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