Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2588 - (hide annotations) (download) (as text)
Thu Feb 6 13:07:22 2014 UTC (10 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 7346 byte(s)
-initial version
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     cat >> ${BUILDROOT}/${arch}/.runrc << "EOF"
63     env-rebuild
64     source /etc/profile
65    
66     if [ -f /etc/rc.d/init.d/functions ]
67     then
68     source /etc/rc.d/init.d/functions
69     else
70     die "/etc/rc.d/init.d/functions not found"
71     fi
72     if [ -f /etc/mage.rc.global ]
73     then
74     source /etc/mage.rc.global
75     else
76     die "/etc/mage.rc.global not found"
77     fi
78     if [ -f /etc/mage.rc ]
79     then
80     source /etc/mage.rc
81     else
82     die "/etc/mage.rc not found"
83     fi
84     if [ -f ${MLIBDIR}/mage4.functions.sh ]
85     then
86     source ${MLIBDIR}/mage4.functions.sh
87     else
88     die "${MLIBDIR}/mage4.functions.sh not found"
89     fi
90     if [ -f ${MLIBDIR}/smage2.functions.sh ]
91     then
92     source ${MLIBDIR}/smage2.functions.sh
93     else
94     die "${MLIBDIR}/smage2.functions.sh not found"
95     fi
96    
97     # override die function
98     die()
99     {
100     echo "ERROR: $@"
101     return 1
102     }
103    
104     is_split_target_magefile()
105     {
106     local mage="$1"
107    
108     for target_mage in ${MY_SPLIT_TARGET_MAGEFILES}
109     do
110     if [[ ${mage} = ${target_mage} ]]
111     then
112     return 0
113     fi
114     done
115    
116     return 1
117     }
118    
119     load_mage_features
120     mage_setup
121    
122     if [ -f /var/cache/mage/smage/${SMAGEFILE} ]
123     then
124     smagesource /var/cache/mage/smage/${SMAGEFILE}
125     else
126     die "smagefile '/var/cache/mage/smage/${SMAGEFILE}' not found."
127     fi
128    
129     # save STATE, gets deleted by regen_mage_tree
130     BUILDSERVER_SAVED_STATE="${STATE}"
131    
132     #regen_mage_tree # do this after dep install
133     TARGET_MAGEFILE="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}"
134     TARGET_SRC_TARBALL="/var/cache/mage/src-packages/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}"
135    
136     if [ ! -f ${TARGET_SRC_TARBALL} ]
137     then
138     die "${TARGET_SRC_TARBALL} is missing"
139     fi
140    
141     if is_installed ${PCAT}/${PNAME}-${PVER}-${PBUILD}
142     then
143     echo -en "Package "
144     echo -en "${COLRED}${PCAT}/${PNAME}-${PVER}-${PBUILD}${COLDEFAULT}"
145     echo -e " already installed. try a revup."
146     exit 3
147     fi
148    
149     # get all dependencies of this package
150     echo
151     echo -n "Calculating dependencies ... "
152     INSTALL_DEPS="$(${MLIBDIR}/depwalker.sh \
153     --method install-build-prerequisites \
154     --smage /var/cache/mage/smage/${SMAGEFILE})"
155    
156     # honor split packages
157     if [[ -n ${SPLIT_PACKAGES} ]]
158     then
159     split_save_variables
160     for subpackage in ${SPLIT_PACKAGES}
161     do
162     # get the right variables for the split
163     export PNAME="${subpackage}"
164     split_info_${PNAME}
165    
166     if [[ -z ${SRC_INSTALL_DEPS} ]]
167     then
168     SRC_INSTALL_DEPS="${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}"
169     else
170     SRC_INSTALL_DEPS+=" ${MAGEDIR}/${PCAT}/${PNAME}/${PNAME}-${PVER}-${PBUILD}.${MAGESUFFIX}"
171     fi
172     # restore smage environment
173     split_restore_variables
174     done
175     # unset all saved smage variables
176     split_unset_variables
177     else
178     SRC_INSTALL_DEPS="${TARGET_MAGEFILE}"
179     fi
180     echo "done"
181    
182     echo
183     echo "---- environment -----"
184     echo "MROOT: ${FAKE_MROOT}"
185     echo "PKGDIR: ${PKGDIR}"
186     echo "BUILDDIR: ${BUILDDIR}"
187     echo "BINDIR: ${BINDIR}"
188     echo "$(mprintfeatures)"
189     echo "----------------------"
190     echo
191     echo "---- dependencies ----"
192     echo "INSTALL_DEPS:"
193     for i in ${INSTALL_DEPS}
194     do
195     echo " * ${i}"
196     done
197     echo "SRC_INSTALL_DEPS:"
198     for i in ${SRC_INSTALL_DEPS}
199     do
200     echo " * ${i}"
201     done
202     echo "----------------------"
203    
204     echo "DEBUG: paused"; read
205    
206     # override packages path
207     SAVED_PKGDIR="${PKGDIR}"
208     PKGDIR="/var/cache/mage/tmp-packages"
209     install -d "${PKGDIR}"
210    
211     # now install the packages (no srcinstall, when the user not explcitly want this)
212     fetch_packages ${INSTALL_DEPS} || die "fetching packages"
213     md5sum_packages ${INSTALL_DEPS} || die "md5 sum packages"
214     unpack_packages ${INSTALL_DEPS} || die "unpacking packages"
215     install_packages ${INSTALL_DEPS} || die "installing packages"
216     cleanpkg
217     # restore packages path
218     PKGDIR="${SAVED_PKGDIR}"
219    
220     ## always run auto etc-update
221     echo "running etc-update"
222     echo "-5" | etc-update
223    
224     #### building target package from src-pkg tarball####
225     if smage2 --src-tarball ${TARGET_SRC_TARBALL}
226     then
227     build_retval=0
228     echo "Build successfull!"
229     regen_mage_tree
230     if install_packages ${SRC_INSTALL_DEPS} || die "installing packages"
231     then
232     install_retval=0
233     echo "Install successfull!"
234     else
235     install_retval=1
236     echo "Installation *not* successfull!"
237     fi
238     else
239     build_retval=1
240     echo "Build failed"
241     fi
242    
243     ## always run auto etc-update
244     echo "running etc-update"
245     echo "-5" | etc-update
246    
247     #reverse dep order
248     unset REV_INSTALL_DEPS
249     for dep in ${INSTALL_DEPS}
250     do
251     if [[ -z ${REV_INSTALL_DEPS} ]]
252     then
253     REV_INSTALL_DEPS="${dep}"
254     else
255     REV_INSTALL_DEPS="${dep} ${REV_INSTALL_DEPS}"
256     fi
257     done
258    
259     # remove all previously installed packages
260     echo
261     echo "Cleaning buildroot - removing previously installed packages in reversed order:"
262     echo "---- dependencies ----"
263     echo "SRC_INSTALL_DEPS:"
264     for i in ${SRC_INSTALL_DEPS}
265     do
266     echo " * ${i}"
267     done
268     echo "INSTALL_DEPS:"
269     for i in ${REV_INSTALL_DEPS}
270     do
271     echo " * ${i}"
272     done
273     echo "----------------------"
274    
275     for pkg in ${SRC_INSTALL_DEPS} ${REV_INSTALL_DEPS}
276     do
277     uninstall_list=""
278     pname="$(magename2pname ${pkg})"
279     pcat="$(magename2pcat ${pkg})"
280     pver="$(magename2pver ${pkg})"
281     pbuild="$(magename2pbuild ${pkg})"
282     if is_installed ${pcat}/${pname}-${pver}-${pbuild}
283     then
284     if [[ -z ${uninstall_list} ]]
285     then
286     uninstall_list="${pcat}/${pname}-${pver}-${pbuild}"
287     else
288     uninstall_list="${uninstall_list} ${pcat}/${pname}-${pver}-${pbuild}"
289     fi
290     else
291     echo "'${pcat}/${pname}-${pver}-${pbuild}' not installed - ignoring"
292     fi
293     if [[ -n ${uninstall_list} ]]
294     then
295     uninstall_packages "${uninstall_list}" || die "cleaning buildroot: ${pkg}"
296     else
297     echo "uninstall_list is empty for pkg '${pcat}/${pname}-${pver}-${pbuild}' - doing nothing"
298     fi
299     done
300    
301     exit ${build_retval}
302     EOF
303     runarch-script ${arch} .runrc || die "${arch} package build failed"
304     if [ -f ${BUILDROOT}/${arch}/.runrc ]
305     then
306     rm ${BUILDROOT}/${arch}/.runrc
307     fi
308     done
309    
310     echo
311     echo "smage '${SMAGEFILE}' sucessfully build on all arches."