Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2793 - (show annotations) (download) (as text)
Thu Aug 28 09:42:57 2014 UTC (9 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 4335 byte(s)
-introduce ALL_ARCH_PACKAGES and NON_SRC_ARCH_PACKAGES arrays to install required packages and use runarch-pkg-install() function for it
1 #!/bin/bash
2
3 # get configuration
4 BUILDSERVER_CONFIG_DIR="/etc/mage-buildserver"
5 BUILDSERVER_CACHE_DIR="/var/cache/mage-buildserver"
6 source ${BUILDSERVER_CONFIG_DIR}/buildserver.conf
7
8 source ${BUILDSERVER_LIB_DIR}/buildserver-functions.sh
9
10 ALL_ARCH_PACKAGES=( subversion openssh )
11 NON_SRC_ARCH_PACKAGES=( "${BOOTSTRAP_DEVUTILS}" ccache python scanelf )
12
13 # fallback
14 if [[ -z ${MAGE_PROFILE} ]]
15 then
16 echo "Warning: using '${BUILDROOT_PROFILE}' as MAGE_PROFILE. You should define MAGE_PROFILE in the profile.conf."
17 MAGE_PROFILE="${BUILDROOT_PROFILE}"
18 fi
19
20 if [ ! -f ${BUILDROOT}/.stamps/mage_svn-checkout-ok ]
21 then
22 die "svn checkout of mage required. run buildserver-svn first."
23 fi
24
25 # create buildroot layout
26 install -d ${BUILDROOT}/.stamps
27 install -d ${BUILDROOT}/ssh
28 for arch in ${BUILD_ARCH[*]} src
29 do
30 install -d ${BUILDROOT}/${arch}
31 install -d ${BUILDROOT}/mage-tree/${arch}
32 install -d ${BUILDROOT}/packages/${arch}
33 install -d ${BUILDROOT}/meta/${arch}
34 install -d ${BUILDROOT}/build-info/${arch}
35 done
36
37 #
38 # arch specific
39 #
40 for arch in src ${BUILD_ARCH[*]}
41 do
42 if [ ! -f ${BUILDROOT}/.stamps/${arch}_bootstrap-ok ]
43 then
44 mage-bootstrap \
45 --root ${BUILDROOT}/${arch} \
46 --magerc ${BUILDSERVER_CONFIG_DIR}/profiles/${BUILDROOT_PROFILE}/${arch}/mage.rc \
47 --profile "${MAGE_PROFILE}" \
48 --basesystem "${BOOTSTRAP_BASESYSTEM}" \
49 || die "'${arch}' bootstrap"
50 touch ${BUILDROOT}/.stamps/${arch}_bootstrap-ok
51 else
52 echo "Warning: bootstrap already done for arch '${arch}'"
53 fi
54 done
55
56 # create initial mage-tree for all arches
57 ${BUILDSERVER_LIB_DIR}/buildserver-setup-mage-tree.sh
58
59 for arch in src ${BUILD_ARCH[*]}
60 do
61
62 echo "DEBUG: arch='${arch}' BUILD_ARCH[*]='${BUILD_ARCH[*]}'"
63
64 # honor any proxy settings
65 :> ${BUILDROOT}/${arch}/etc/env.d/01proxy
66 [[ -n ${http_proxy} ]] && echo "http_proxy=\"${http_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy
67 [[ -n ${https_proxy} ]] && echo "https_proxy=\"${https_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy
68 [[ -n ${ftp_proxy} ]] && echo "ftp_proxy=\"${ftp_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy
69 [[ -n ${ftps_proxy} ]] && echo "ftps_proxy=\"${ftps_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy
70 [[ -n ${no_proxy} ]] && echo "no_proxy=\"${no_proxy}\"" >> ${BUILDROOT}/${arch}/etc/env.d/01proxy
71 runarch ${arch} env-rebuild || die "${arch} environment rebuild for proxy setup"
72
73 # always enable bootstrap mode to supress the startups of any services
74 :> ${BUILDROOT}/${arch}/etc/env.d/00mage-buildserver
75 echo "MAGE_BOOTSTRAP=\"true\"" >> ${BUILDROOT}/${arch}/etc/env.d/00mage-buildserver
76
77 for pkg in ${ALL_ARCH_PACKAGES[*]}
78 do
79 runarch-pkg-install "${arch}" "${pkg}"
80 done
81
82 # exclude these pkg from src chroot
83 if [[ ${arch} != src ]]
84 then
85 for pkg in ${NON_SRC_ARCH_PACKAGES[*]}
86 do
87 runarch-pkg-install "${arch}" "${pkg}"
88 done
89
90 # setup ccache
91 if [ ! -f ${BUILDROOT}/.stamps/${arch}_setup-ccache-ok ]
92 then
93 runarch "${arch}" ccache -M 4G || die "${arch} setup ccache"
94 touch ${BUILDROOT}/.stamps/${arch}_setup-ccache-ok
95 else
96 echo "Warning: ccache already configured for arch '${arch}'"
97 fi
98 fi
99
100 # update-ca-certificates
101 runarch "${arch}" update-ca-certificates # no die here, cmd may missing
102
103 # create list of protected packages
104 echo "BUILDSERVER_CACHE_DIR=\"${BUILDSERVER_CACHE_DIR}\"" > ${BUILDROOT}/${arch}/.runrc
105 cat >> ${BUILDROOT}/${arch}/.runrc << "EOF"
106 if [ -f /etc/rc.d/init.d/functions ]
107 then
108 source /etc/rc.d/init.d/functions
109 else
110 die "/etc/rc.d/init.d/functions not found"
111 fi
112 if [ -f /etc/mage.rc.global ]
113 then
114 source /etc/mage.rc.global
115 else
116 die "/etc/mage.rc.global not found"
117 fi
118 if [ -f /etc/mage.rc ]
119 then
120 source /etc/mage.rc
121 else
122 die "/etc/mage.rc not found"
123 fi
124
125 env-rebuild
126 source /etc/profile
127
128 echo "generate protected packages info data"
129 install -d ${BUILDSERVER_CACHE_DIR}/protected
130
131 for mage in $(find ${INSTALLDB} -name \*.${MAGESUFFIX})
132 do
133 pkgname=$(basename ${mage} .${MAGESUFFIX})
134 pkgname="${pkgname%-*-*}"
135 echo "${pkgname}" > ${BUILDSERVER_CACHE_DIR}/protected/"${pkgname}"
136 done
137 EOF
138 runarch-script ${arch} .runrc || die "${arch} protect-gen failed"
139 if [ -f ${BUILDROOT}/${arch}/.runrc ]
140 then
141 rm ${BUILDROOT}/${arch}/.runrc
142 fi
143
144 # cleanup
145 runarch "${arch}" mage clean || die "${arch} mage clean"
146
147 echo "Buildroot for arch '${arch}' sucessfully created."; echo
148 done

Properties

Name Value
svn:executable *