Magellan Linux

Annotation of /trunk/mage-buildserver/buildserver-compile-smage.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2730 - (hide annotations) (download) (as text)
Sun Aug 10 19:35:40 2014 UTC (9 years, 9 months ago) by niro
File MIME type: application/x-sh
File size: 7599 byte(s)
-protect buildserver essential packages from uninstallation like the compiler libc etc
1 niro 2588 #!/bin/bash
2    
3     # get configuration
4     BUILDSERVER_CONFIG_DIR="/etc/mage-buildserver"
5     source ${BUILDSERVER_CONFIG_DIR}/buildserver.conf
6    
7     source ${BUILDSERVER_LIB_DIR}/buildserver-functions.sh
8    
9     # override
10     #BUILDROOT="/mnt/test-buildroot"
11     #BUILD_ARCH=( x86_64 i686 )
12     #BUILDROOT_PROFILE="R11"
13     #SMAGE_SVN_REPO="svn://cvs.magellan-linux.de/smage/trunk"
14     #MAGE_SVN_REPO="svn://cvs.magellan-linux.de/mage/trunk"
15    
16     SMAGEFILE="$1"
17    
18     if [[ -z ${SMAGEFILE} ]]
19     then
20     die "no smage file given. call '$(basename $0) with/relative/path/from/buildroot/svn/smage/to/smagefile'"
21     fi
22    
23     if [[ ! -f ${BUILDROOT}/svn/smage/${SMAGEFILE} ]]
24     then
25     die "given smage file does not exist"
26     fi
27    
28     if [ ! -f ${BUILDROOT}/.stamps/mage_svn-checkout-ok ]
29     then
30     die "svn checkout of mage required. run buildserver-svn first."
31     fi
32     if [ ! -f ${BUILDROOT}/.stamps/smage_svn-checkout-ok ]
33     then
34     die "svn checkout of smage required. run buildserver-svn first."
35     fi
36     for arch in ${BUILD_ARCH[*]} src
37     do
38     if [ ! -f ${BUILDROOT}/.stamps/${arch}_bootstrap-ok ]
39     then
40     die "bootstrap of buildsystem required for arch '${arch}'. run buildserver-prepare first."
41     fi
42     if [ ! -f ${BUILDROOT}/.stamps/${arch}_initial-mage-tree-ok ]
43     then
44     die "initial regen of mage-tree required for '${arch}'. run buildserver-setup-mage-tree first."
45     fi
46     done
47     for arch in ${BUILD_ARCH[*]}
48     do
49     if [ ! -f ${BUILDROOT}/.stamps/${arch}_common-devutils-ok ]
50     then
51     die "common-devutils package for '${arch}' not installed. run buildserver-prepare first."
52     fi
53     done
54    
55    
56     # create src package tarball
57     runarch src smage2 --create-src-tarball /var/cache/mage/smage/${SMAGEFILE} || die "src creating src-tarball"
58    
59     for arch in ${BUILD_ARCH[*]}
60     do
61     echo "SMAGEFILE=\"${SMAGEFILE}\"" > ${BUILDROOT}/${arch}/.runrc
62 niro 2730 echo "BUILDSERVER_CONFIG_DIR=\"${BUILDSERVER_CONFIG_DIR}\"" >> ${BUILDROOT}/${arch}/.runrc
63 niro 2588 cat >> ${BUILDROOT}/${arch}/.runrc << "EOF"
64     env-rebuild
65     source /etc/profile
66    
67     if [ -f /etc/rc.d/init.d/functions ]
68     then
69     source /etc/rc.d/init.d/functions
70     else
71     die "/etc/rc.d/init.d/functions not found"
72     fi
73     if [ -f /etc/mage.rc.global ]
74     then
75     source /etc/mage.rc.global
76     else
77     die "/etc/mage.rc.global not found"
78     fi
79     if [ -f /etc/mage.rc ]
80     then
81     source /etc/mage.rc
82     else
83     die "/etc/mage.rc not found"
84     fi
85     if [ -f ${MLIBDIR}/mage4.functions.sh ]
86     then
87     source ${MLIBDIR}/mage4.functions.sh
88     else
89     die "${MLIBDIR}/mage4.functions.sh not found"
90     fi
91     if [ -f ${MLIBDIR}/smage2.functions.sh ]
92     then
93     source ${MLIBDIR}/smage2.functions.sh
94     else
95     die "${MLIBDIR}/smage2.functions.sh not found"
96     fi
97    
98     # override die function
99     die()
100     {
101     echo "ERROR: $@"
102     return 1
103     }
104    
105     is_split_target_magefile()
106     {
107     local mage="$1"
108    
109     for target_mage in ${MY_SPLIT_TARGET_MAGEFILES}
110     do
111     if [[ ${mage} = ${target_mage} ]]
112     then
113     return 0
114     fi
115     done
116    
117     return 1
118     }
119    
120     load_mage_features
121     mage_setup
122    
123     if [ -f /var/cache/mage/smage/${SMAGEFILE} ]
124     then
125     smagesource /var/cache/mage/smage/${SMAGEFILE}
126     else
127     die "smagefile '/var/cache/mage/smage/${SMAGEFILE}' not found."
128     fi
129    
130     # save STATE, gets deleted by regen_mage_tree
131     BUILDSERVER_SAVED_STATE="${STATE}"
132    
133     #regen_mage_tree # do this after dep install
134     TARGET_MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}"
135     TARGET_SRC_TARBALL="/var/cache/mage/src-packages/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}"
136    
137     if [ ! -f ${TARGET_SRC_TARBALL} ]
138     then
139     die "${TARGET_SRC_TARBALL} is missing"
140     fi
141    
142     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
143     then
144     echo -en "Package "
145     echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
146     echo -e " already installed. try a revup."
147     exit 3
148     fi
149    
150     # get all dependencies of this package
151     echo
152     echo -n "Calculating dependencies ... "
153     INSTALL_DEPS="$(${MLIBDIR}/depwalker.sh \
154     --method install-build-prerequisites \
155     --smage /var/cache/mage/smage/${SMAGEFILE})"
156    
157     # honor split packages
158     if [[ -n ${SPLIT_PACKAGES} ]]
159     then
160     split_save_variables
161     for subpackage in ${SPLIT_PACKAGES}
162     do
163     # get the right variables for the split
164     export PNAME="${subpackage}"
165     split_info_${PNAME}
166    
167     if [[ -z ${SRC_INSTALL_DEPS} ]]
168     then
169     SRC_INSTALL_DEPS="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}"
170     else
171     SRC_INSTALL_DEPS+=" ${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}"
172     fi
173     # restore smage environment
174     split_restore_variables
175     done
176     # unset all saved smage variables
177     split_unset_variables
178     else
179     SRC_INSTALL_DEPS="${TARGET_MAGEFILE}"
180     fi
181     echo "done"
182    
183     echo
184     echo "---- environment -----"
185     echo "MROOT: ${FAKE_MROOT}"
186     echo "PKGDIR: ${PKGDIR}"
187     echo "BUILDDIR: ${BUILDDIR}"
188     echo "BINDIR: ${BINDIR}"
189     echo "$(mprintfeatures)"
190     echo "----------------------"
191     echo
192     echo "---- dependencies ----"
193     echo "INSTALL_DEPS:"
194     for i in ${INSTALL_DEPS}
195     do
196     echo " * ${i}"
197     done
198     echo "SRC_INSTALL_DEPS:"
199     for i in ${SRC_INSTALL_DEPS}
200     do
201     echo " * ${i}"
202     done
203     echo "----------------------"
204    
205 niro 2730 #echo "DEBUG: paused"; read
206 niro 2588
207     # override packages path
208     SAVED_PKGDIR="${PKGDIR}"
209     PKGDIR="/var/cache/mage/tmp-packages"
210     install -d "${PKGDIR}"
211    
212     # now install the packages (no srcinstall, when the user not explcitly want this)
213     fetch_packages ${INSTALL_DEPS} || die "fetching packages"
214     md5sum_packages ${INSTALL_DEPS} || die "md5 sum packages"
215     unpack_packages ${INSTALL_DEPS} || die "unpacking packages"
216     install_packages ${INSTALL_DEPS} || die "installing packages"
217     cleanpkg
218     # restore packages path
219     PKGDIR="${SAVED_PKGDIR}"
220    
221     ## always run auto etc-update
222     echo "running etc-update"
223     echo "-5" | etc-update
224    
225     #### building target package from src-pkg tarball####
226     if smage2 --src-tarball ${TARGET_SRC_TARBALL}
227     then
228     build_retval=0
229     echo "Build successfull!"
230     regen_mage_tree
231     if install_packages ${SRC_INSTALL_DEPS} || die "installing packages"
232     then
233     install_retval=0
234     echo "Install successfull!"
235     else
236     install_retval=1
237     echo "Installation *not* successfull!"
238     fi
239     else
240     build_retval=1
241     echo "Build failed"
242     fi
243    
244     ## always run auto etc-update
245     echo "running etc-update"
246     echo "-5" | etc-update
247    
248     #reverse dep order
249     unset REV_INSTALL_DEPS
250     for dep in ${INSTALL_DEPS}
251     do
252     if [[ -z ${REV_INSTALL_DEPS} ]]
253     then
254     REV_INSTALL_DEPS="${dep}"
255     else
256     REV_INSTALL_DEPS="${dep} ${REV_INSTALL_DEPS}"
257     fi
258     done
259    
260     # remove all previously installed packages
261     echo
262     echo "Cleaning buildroot - removing previously installed packages in reversed order:"
263     echo "---- dependencies ----"
264     echo "SRC_INSTALL_DEPS:"
265     for i in ${SRC_INSTALL_DEPS}
266     do
267     echo " * ${i}"
268     done
269     echo "INSTALL_DEPS:"
270     for i in ${REV_INSTALL_DEPS}
271     do
272     echo " * ${i}"
273     done
274     echo "----------------------"
275    
276     for pkg in ${SRC_INSTALL_DEPS} ${REV_INSTALL_DEPS}
277     do
278     uninstall_list=""
279     pname="$(magename2pname ${pkg})"
280     pcat="$(magename2pcat ${pkg})"
281     pver="$(magename2pver ${pkg})"
282     pbuild="$(magename2pbuild ${pkg})"
283 niro 2730 if [ -f ${BUILDSERVER_CONFIG_DIR}/protected/${pname} ]
284 niro 2588 then
285 niro 2730 echo "'${pcat}/${pname}-${pver}-${pbuild}' is protected - ignoring"
286     else
287     if is_installed ${pcat}/${pname}-${pver}-${pbuild}
288 niro 2588 then
289 niro 2730 if [[ -z ${uninstall_list} ]]
290     then
291     uninstall_list="${pcat}/${pname}-${pver}-${pbuild}"
292     else
293     uninstall_list="${uninstall_list} ${pcat}/${pname}-${pver}-${pbuild}"
294     fi
295 niro 2588 else
296 niro 2730 echo "'${pcat}/${pname}-${pver}-${pbuild}' not installed - ignoring"
297 niro 2588 fi
298 niro 2730
299     if [[ -n ${uninstall_list} ]]
300     then
301     uninstall_packages "${uninstall_list}" || die "cleaning buildroot: ${pkg}"
302     else
303     echo "uninstall_list is empty for pkg '${pcat}/${pname}-${pver}-${pbuild}' - doing nothing"
304     fi
305 niro 2588 fi
306     done
307    
308     exit ${build_retval}
309     EOF
310     runarch-script ${arch} .runrc || die "${arch} package build failed"
311     if [ -f ${BUILDROOT}/${arch}/.runrc ]
312     then
313     rm ${BUILDROOT}/${arch}/.runrc
314     fi
315     done
316    
317     echo
318     echo "smage '${SMAGEFILE}' sucessfully build on all arches."