Contents of /branches/mage-next/src/smage2.in
Parent Directory | Revision Log
Revision 2616 -
(show annotations)
(download)
Tue Mar 4 15:29:32 2014 UTC (10 years, 6 months ago) by niro
File size: 21714 byte(s)
Tue Mar 4 15:29:32 2014 UTC (10 years, 6 months ago) by niro
File size: 21714 byte(s)
-call common.functions.sh
1 | #!/bin/bash |
2 | # $Id$ |
3 | |
4 | # compiles/installs .smage2 source install scripts |
5 | # needs pkgbuild_dir (mage) |
6 | |
7 | # TODO: record dynlib, gz | xz database |
8 | |
9 | |
10 | # set default variables |
11 | : ${MAGERC="@@SYSCONFDIR@@/mage.rc"} |
12 | : ${MLIBDIR="@@MAGELIBDIR@@"} |
13 | |
14 | # export default C locale |
15 | export LC_ALL=C |
16 | |
17 | # first of all include common functions |
18 | source ${MLIBDIR}/common.functions.sh |
19 | source @@SYSCONFDIR@@/mage.rc.global |
20 | source ${MAGERC} |
21 | source ${MLIBDIR}/mage4.functions.sh |
22 | source ${MLIBDIR}/smage2.functions.sh |
23 | |
24 | # export default path |
25 | export PATH="${PATH}:${MLIBDIR}" |
26 | |
27 | ## setup ## |
28 | SMAGENAME="$1" |
29 | |
30 | # expand PKGDIR, BUILDDIR and BINDIR with MROOT |
31 | if [[ -n ${MROOT} ]] |
32 | then |
33 | export PKGDIR=${MROOT}/${PKGDIR} |
34 | export BUILDDIR=${MROOT}/${BUILDDIR} |
35 | export BINDIR=${MROOT}/${BINDIR} |
36 | fi |
37 | |
38 | # print out our version |
39 | showversion |
40 | echo |
41 | |
42 | if [[ -z ${SMAGENAME} ]] |
43 | then |
44 | echo "No .smage2 file given. Exiting." |
45 | echo |
46 | exit 1 |
47 | fi |
48 | |
49 | # load supported mage features |
50 | load_mage_features |
51 | |
52 | # updating smage2-scripts |
53 | if [[ $1 = update ]] |
54 | then |
55 | if [ ! -d ${SOURCEDIR} ] |
56 | then |
57 | install -d ${SOURCEDIR} |
58 | fi |
59 | syncsmage2 |
60 | exit 0 |
61 | fi |
62 | |
63 | # creates md5sums for smages to given dir |
64 | if [[ $1 = calcmd5 ]] |
65 | then |
66 | if [ $# -ge 2 ] |
67 | then |
68 | SMAGENAME="$2" |
69 | MD5DIR="$3" |
70 | [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
71 | |
72 | smagesource ${SMAGENAME} || die "download source failed" |
73 | |
74 | # overridable sourcedir; must be declared after source of the smage2 |
75 | CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
76 | |
77 | [ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
78 | |
79 | # end of array |
80 | EOA=${#SRC_URI[*]} |
81 | |
82 | [ ! -d ${MD5DIR} ] && install -d ${MD5DIR} |
83 | |
84 | # clear md5sum file |
85 | MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
86 | echo -n > ${MY_MD5_FILE} |
87 | |
88 | for ((i=0; i < EOA; i++)) |
89 | do |
90 | # url to file |
91 | my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
92 | |
93 | # subdir in sources dir; the my_SRCI_URI file goes to there |
94 | my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
95 | |
96 | # if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
97 | if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
98 | then |
99 | MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" |
100 | else |
101 | MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
102 | fi |
103 | |
104 | if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
105 | then |
106 | echo "calculating $(basename ${MY_SRC_FILE}) ..." |
107 | ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} |
108 | else |
109 | echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
110 | fi |
111 | |
112 | # unset them to be shure |
113 | unset my_SRC_URI |
114 | unset my_SRC_URI_DEST |
115 | unset my_SRC_URI_MIRROR |
116 | unset my_SOURCEDIR |
117 | done |
118 | |
119 | echo |
120 | echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." |
121 | echo |
122 | else |
123 | echo "Usage: Calculating MD5 Sums:" |
124 | echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
125 | echo |
126 | echo |
127 | echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
128 | echo |
129 | exit 1 |
130 | fi |
131 | |
132 | exit 0 |
133 | fi |
134 | |
135 | # download sources |
136 | if [ "$1" == "download" -a -n "$2" ] |
137 | then |
138 | if [ ! -d ${SMAGESCRIPTSDIR} ] |
139 | then |
140 | install -d ${SMAGESCRIPTSDIR} |
141 | fi |
142 | |
143 | # get smage |
144 | SMAGENAME="$2" |
145 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
146 | smagesource ${SMAGENAME} || die "download source failed" |
147 | |
148 | download_sources |
149 | exit 0 |
150 | fi |
151 | |
152 | # regen-mage-tree |
153 | if [ "$1" == "only-regen-tree" -a -n "$2" ] |
154 | then |
155 | # set correct SMAGENAME |
156 | SMAGENAME="$2" |
157 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
158 | smagesource ${SMAGENAME} || die "regen: smage2 not found" |
159 | |
160 | regen_mage_tree |
161 | |
162 | # build several subpackages |
163 | if [[ -n ${SPLIT_PACKAGES} ]] |
164 | then |
165 | split_save_variables |
166 | for subpackage in ${SPLIT_PACKAGES} |
167 | do |
168 | # get the right variables for the split |
169 | export PNAME="${subpackage}" |
170 | split_info_${subpackage} |
171 | # fix PCATEGORIE -> PCAT |
172 | if [[ ! -z ${PCATEGORIE} ]] |
173 | then |
174 | PCAT="${PCATEGORIE}" |
175 | unset PCATEGORIE |
176 | fi |
177 | # build md5sum for existing packages |
178 | generate_package_md5sum \ |
179 | --pcat "${PCAT}" \ |
180 | --pname "${PNAME}" \ |
181 | --pver "${PVER}" \ |
182 | --pbuild "${PBUILD}" \ |
183 | --parch "${ARCH}" |
184 | # restore smage environment |
185 | split_restore_variables |
186 | done |
187 | # unset all saved smage variables |
188 | split_unset_variables |
189 | |
190 | else |
191 | # build md5sum for existing packages |
192 | generate_package_md5sum \ |
193 | --pcat "${PCAT}" \ |
194 | --pname "${PNAME}" \ |
195 | --pver "${PVER}" \ |
196 | --pbuild "${PBUILD}" \ |
197 | --parch "${ARCH}" |
198 | fi |
199 | |
200 | exit 0 |
201 | fi |
202 | |
203 | if [ "$1" == "--create-src-tarball" -a -n "$2" ] |
204 | then |
205 | # set correct SMAGENAME |
206 | SMAGENAME="$2" |
207 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
208 | |
209 | echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
210 | |
211 | smagesource ${SMAGENAME} || die "regen: smage2 not found" |
212 | |
213 | if [[ -d ${SOURCEDIR}/${PNAME} ]] |
214 | then |
215 | echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
216 | rm -rf ${SOURCEDIR}/${PKGNAME} |
217 | fi |
218 | |
219 | download_sources |
220 | source_pkg_build ${SMAGENAME} |
221 | exit 0 |
222 | fi |
223 | |
224 | if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ] |
225 | then |
226 | SRCPKGTARBALL="${2}" |
227 | msetfeature "srcpkgtarball" |
228 | |
229 | # abort if given file is not a source pkg |
230 | [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file." |
231 | |
232 | # set correct SMAGENAME; use the one that the src_pkg provide |
233 | # /path/to/SOURCEDIR/PNAME/SMAGENAME |
234 | SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}" |
235 | |
236 | echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}" |
237 | |
238 | [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR} |
239 | |
240 | # unpack srctarball |
241 | [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting." |
242 | |
243 | tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}" |
244 | |
245 | [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}" |
246 | fi |
247 | |
248 | if [ "$1" == "--resume" -a -n "$2" ] |
249 | then |
250 | msetfeature "resume" |
251 | SMAGENAME="$2" |
252 | fi |
253 | |
254 | [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
255 | [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && |
256 | die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." |
257 | [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly." |
258 | [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly." |
259 | [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly." |
260 | [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}" |
261 | [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}" |
262 | [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
263 | [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
264 | |
265 | smagesource ${SMAGENAME} || die "source failed" |
266 | PKGNAME="${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" |
267 | MD5DIR="$(dirname ${SMAGENAME})/md5" |
268 | SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
269 | |
270 | xtitle "Compiling ${PKGNAME}" |
271 | echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
272 | |
273 | if mqueryfeature "srcpkgbuild" |
274 | then |
275 | if [[ -d ${SOURCEDIR}/${PNAME} ]] |
276 | then |
277 | echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
278 | rm -rf ${SOURCEDIR}/${PNAME} |
279 | fi |
280 | fi |
281 | |
282 | # download sources |
283 | mqueryfeature "srcpkgtarball" || download_sources |
284 | |
285 | # fixes some issues with these functions |
286 | export -f src_prepare || die "src_prepare export failed" |
287 | export -f src_compile || die "src_compile export failed" |
288 | export -f src_check || die "src_check export failed" |
289 | export -f src_install || die "src_install export failed" |
290 | |
291 | # fixes some compile issues |
292 | export CHOST="${CHOST}" || die "CHOST export failed" |
293 | export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
294 | if [[ -z ${CXXFLAGS} ]] |
295 | then |
296 | export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
297 | else |
298 | export CXXFLAGS="${CXXFLAGS}" || die "CXXFLAGS export failed" |
299 | fi |
300 | export LDFLAGS="${LDFLAGS}" || die "LDFLAGS export failed" |
301 | export BINDIR="${BINDIR}" || die "BINDIR export failed" |
302 | export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
303 | |
304 | # setup distcc |
305 | # setup for distcc goes *before* ccache, so ccache comes before distcc in path |
306 | mqueryfeature "distcc" && setup_distcc_environment |
307 | |
308 | # setup icecc |
309 | # setup for icecc goes *before* ccache, so ccache comes before icecc in path |
310 | mqueryfeature "icecc" && setup_icecc_environment |
311 | |
312 | # setup ccache |
313 | mqueryfeature "ccache" && setup_ccache_environment |
314 | |
315 | if mqueryfeature "resume" |
316 | then |
317 | echo -e "${COLMAGENTA}Resume requested; continuing previous build${COLDEFAULT}" |
318 | |
319 | # setup build logging |
320 | [[ ! -d /var/log/smage ]] && install -d /var/log/smage |
321 | if [[ -f /var/log/smage/${PKGNAME}.log.bz2 ]] |
322 | then |
323 | bunzip2 -f /var/log/smage/${PKGNAME}.log.bz2 |
324 | fi |
325 | echo -e "### Resume started on $(date) ###\n" >> /var/log/smage/${PKGNAME}.log |
326 | |
327 | else |
328 | # clean up builddir if a previously one exist |
329 | if [ -d ${BUILDDIR} ] |
330 | then |
331 | rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
332 | fi |
333 | install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
334 | |
335 | # clean up srcdir if a previously unpacked one exist |
336 | if [ -d ${SRCDIR} ] |
337 | then |
338 | rm -rf ${SRCDIR} |
339 | fi |
340 | |
341 | # clean up bindir if a previous build exist or create a new one |
342 | if [ -d ${BINDIR} ] |
343 | then |
344 | rm -rf ${BINDIR} |
345 | fi |
346 | install -d ${BINDIR} || die "couldn't create \$BINDIR." |
347 | |
348 | # clean up package temp dir if a previous build exist |
349 | if [ -d ${BUILDDIR}/${PKGNAME} ] |
350 | then |
351 | rm -rf ${BUILDDIR}/${PKGNAME} |
352 | fi |
353 | |
354 | # clean up stamps dir |
355 | if [ -d ${BUILDDIR}/.stamps ] |
356 | then |
357 | rm -rf ${BUILDDIR}/.stamps |
358 | fi |
359 | |
360 | # setup build logging |
361 | [[ ! -d /var/log/smage ]] && install -d /var/log/smage |
362 | echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
363 | fi |
364 | |
365 | if [[ ${PKGTYPE} = virtual ]] |
366 | then |
367 | echo "virtual package detected; nothing will be build ..." |
368 | # automatically set !pkgbuild here too |
369 | msetfeature "!pkgbuild" |
370 | else |
371 | ( run_resume src_prepare || src_prepare ) | ${SMAGE_LOG_CMD} |
372 | die_pipestatus 0 "src_prepare failed" |
373 | resume_stamp src_prepare |
374 | step_by_step src_prepare |
375 | |
376 | ( run_resume src_compile || src_compile ) | ${SMAGE_LOG_CMD} |
377 | die_pipestatus 0 "src_compile failed" |
378 | resume_stamp src_compile |
379 | step_by_step src_compile |
380 | |
381 | # only run checks if requested |
382 | if mqueryfeature "!check" |
383 | then |
384 | echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD} |
385 | else |
386 | ( run_resume src_check || src_check ) | ${SMAGE_LOG_CMD} |
387 | die_pipestatus 0 "src_check failed" |
388 | resume_stamp src_check |
389 | fi |
390 | step_by_step src_check |
391 | |
392 | # build several subpackages |
393 | if [[ -n ${SPLIT_PACKAGES} ]] |
394 | then |
395 | # save bindir & pname |
396 | split_save_variables |
397 | export SAVED_BINDIR="${BINDIR}" |
398 | for subpackage in ${SPLIT_PACKAGES} |
399 | do |
400 | split_info_${subpackage} |
401 | if [[ ${PKGTYPE} = virtual ]] |
402 | then |
403 | echo |
404 | echo -en "${COLBLUE}*** ${COLDEFAULT}" |
405 | echo -en "Virtual package detected" |
406 | echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
407 | echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
408 | |
409 | echo "virtual package detected; nothing will be build ..." |
410 | # automatically set !pkgbuild here too |
411 | msetfeature "!pkgbuild" |
412 | else |
413 | if typeset -f src_install_${subpackage} > /dev/null |
414 | then |
415 | # export subpackage bindir |
416 | export BINDIR="${SAVED_BINDIR}_${subpackage}" |
417 | # export PNAME, several internal function and include |
418 | # rely on this variable |
419 | export PNAME="${subpackage}" |
420 | |
421 | echo |
422 | echo -en "${COLBLUE}*** ${COLDEFAULT}" |
423 | echo -en "Running ${COLGREEN}split src_install()${COLDEFAULT}" |
424 | echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
425 | echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
426 | |
427 | ( run_resume src_install_${subpackage} || src_install_${subpackage} ) | ${SMAGE_LOG_CMD} |
428 | die_pipestatus 0 "src_install_${subpackage} failed" |
429 | resume_stamp src_install_${subpackage} |
430 | step_by_step src_install_${subpackage} |
431 | fi |
432 | fi |
433 | # restore smage environment |
434 | split_restore_variables |
435 | done |
436 | # unset all saved smage variables |
437 | split_unset_variables |
438 | else |
439 | ( run_resume src_install || src_install ) | ${SMAGE_LOG_CMD} |
440 | die_pipestatus 0 "src_install failed" |
441 | resume_stamp src_install |
442 | step_by_step src_install |
443 | fi |
444 | fi |
445 | |
446 | # echo for sake of good-looking |
447 | echo |
448 | |
449 | if mqueryfeature "!compressdoc" |
450 | then |
451 | echo -e "!compressdoc detected; documentation will not be compressed ..." |
452 | elif mqueryfeature "!pkgbuild" |
453 | then |
454 | echo "!pkgbuild detected; skipping documentation compression..." |
455 | else |
456 | # compressing doc, info & man files |
457 | if [[ -n ${SPLIT_PACKAGES} ]] |
458 | then |
459 | # save smage environment |
460 | split_save_variables |
461 | for subpackage in ${SPLIT_PACKAGES} |
462 | do |
463 | # honor split_info |
464 | split_info_${subpackage} |
465 | if [[ ${PKGTYPE} = virtual ]] |
466 | then |
467 | # automatically set !pkgbuild here too |
468 | msetfeature "!pkgbuild" |
469 | fi |
470 | |
471 | if mqueryfeature "!compressdoc" |
472 | then |
473 | echo -e "!compressdoc detected; documentation of '${subpackage}' will not be compressed ..." |
474 | elif mqueryfeature "!pkgbuild" |
475 | then |
476 | echo "!pkgbuild detected; skipping documentation compression for '${subpackage}' ..." |
477 | else |
478 | run_resume post-mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage} |
479 | resume_stamp post-mcompressdoc_${subpackage} |
480 | fi |
481 | # restore smage environment |
482 | split_restore_variables |
483 | done |
484 | # unset saved variables |
485 | split_unset_variables |
486 | else |
487 | run_resume post-mcompressdoc || mcompressdocs ${BINDIR} |
488 | resume_stamp post-mcompressdoc |
489 | fi |
490 | fi |
491 | |
492 | if mqueryfeature "!libtool" |
493 | then |
494 | if mqueryfeature "!pkgbuild" |
495 | then |
496 | echo "!pkgbuild detected; skipping libtool archive stripping ..." |
497 | else |
498 | if [[ -n ${SPLIT_PACKAGES} ]] |
499 | then |
500 | # save smage environment |
501 | split_save_variables |
502 | for subpackage in ${SPLIT_PACKAGES} |
503 | do |
504 | # honor split_info |
505 | split_info_${subpackage} |
506 | if [[ ${PKGTYPE} = virtual ]] |
507 | then |
508 | # automatically set !pkgbuild here too |
509 | msetfeature "!pkgbuild" |
510 | fi |
511 | |
512 | if mqueryfeature "!libtool" |
513 | then |
514 | if mqueryfeature "!pkgbuild" |
515 | then |
516 | echo "!pkgbuild detected; skipping libtool archive stripping for '${subpackage}'..." |
517 | else |
518 | echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}" |
519 | run_resume post-mstriplibtoolarchive_${subpackage} || mstriplibtoolarchive ${BINDIR}_${subpackage} |
520 | resume_stamp post-mstriplibtoolarchive_${subpackage} |
521 | fi |
522 | fi |
523 | |
524 | # restore smage environment |
525 | split_restore_variables |
526 | done |
527 | # unset saved variables |
528 | split_unset_variables |
529 | else |
530 | echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}" |
531 | run_resume post-mstriplibtoolarchive || mstriplibtoolarchive ${BINDIR} |
532 | resume_stamp post-mstriplibtoolarchive |
533 | fi |
534 | fi |
535 | fi |
536 | |
537 | if mqueryfeature "purge" |
538 | then |
539 | if mqueryfeature "!pkgbuild" |
540 | then |
541 | echo "!pkgbuild detected; skipping file purgation ..." |
542 | else |
543 | if [[ -n ${SPLIT_PACKAGES} ]] |
544 | then |
545 | # save smage environment |
546 | split_save_variables |
547 | for subpackage in ${SPLIT_PACKAGES} |
548 | do |
549 | # honor split_info |
550 | split_info_${subpackage} |
551 | if [[ ${PKGTYPE} = virtual ]] |
552 | then |
553 | # automatically set !pkgbuild here too |
554 | msetfeature "!pkgbuild" |
555 | fi |
556 | |
557 | if mqueryfeature "purge" |
558 | then |
559 | if mqueryfeature "!pkgbuild" |
560 | then |
561 | echo "!pkgbuild detected; skipping file purgation for '${subpackage}' ..." |
562 | else |
563 | echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}" |
564 | run_resume post-mpurgetargets_${subpackage} || mpurgetargets ${BINDIR}_${subpackage} |
565 | resume_stamp post-mpurgetargets_${subpackage} |
566 | fi |
567 | fi |
568 | |
569 | # restore smage environment |
570 | split_restore_variables |
571 | done |
572 | # unset saved variables |
573 | split_unset_variables |
574 | else |
575 | echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}" |
576 | run_resume post-mpurgetargets || mpurgetargets ${BINDIR} |
577 | resume_stamp post-mpurgetargets |
578 | fi |
579 | fi |
580 | fi |
581 | |
582 | # stripping all bins and libs |
583 | if mqueryfeature "!strip" |
584 | then |
585 | echo -e "!strip detected; package will not be stripped ..." |
586 | elif mqueryfeature "!pkgbuild" |
587 | then |
588 | echo "!pkgbuild detected; skipping stripping of the package ..." |
589 | else |
590 | if [[ -n ${SPLIT_PACKAGES} ]] |
591 | then |
592 | # save smage environment |
593 | split_save_variables |
594 | for subpackage in ${SPLIT_PACKAGES} |
595 | do |
596 | # honor split_info |
597 | split_info_${subpackage} |
598 | if [[ ${PKGTYPE} = virtual ]] |
599 | then |
600 | # automatically set !pkgbuild here too |
601 | msetfeature "!pkgbuild" |
602 | fi |
603 | |
604 | if mqueryfeature "!strip" |
605 | then |
606 | echo -e "!strip detected; package '${subpackage}' will not be stripped ..." |
607 | elif mqueryfeature "!pkgbuild" |
608 | then |
609 | echo "!pkgbuild detected; skipping stripping of the package '${subpackage}' ..." |
610 | else |
611 | echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
612 | run_resume post-mstripbins_${subpackage} || mstripbins ${BINDIR}_${subpackage} |
613 | resume_stamp post-mstripbins_${subpackage} |
614 | echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" |
615 | run_resume post-mstriplibs_${subpackage} || mstriplibs ${BINDIR}_${subpackage} |
616 | resume_stamp post-mstriplibs_${subpackage} |
617 | echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" |
618 | run_resume post-mstripstatic_${subpackage} || mstripstatic ${BINDIR}_${subpackage} |
619 | resume_stamp post-mstripstatic_${subpackage} |
620 | fi |
621 | |
622 | # restore smage environment |
623 | split_restore_variables |
624 | done |
625 | # unset saved variables |
626 | split_unset_variables |
627 | else |
628 | echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
629 | run_resume post-mstripbins || mstripbins ${BINDIR} |
630 | resume_stamp post-mstripbins |
631 | echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" |
632 | run_resume post-mstriplibs || mstriplibs ${BINDIR} |
633 | resume_stamp post-mstriplibs |
634 | echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" |
635 | run_resume post-mstripstatic || mstripstatic ${BINDIR} |
636 | resume_stamp post-mstripstatic |
637 | fi |
638 | fi |
639 | |
640 | if mqueryfeature "qalint" |
641 | then |
642 | if mqueryfeature "!pkgbuild" |
643 | then |
644 | echo "!pkgbuild detected; skipping QA lint checks ..." |
645 | else |
646 | if [[ -n ${SPLIT_PACKAGES} ]] |
647 | then |
648 | # save smage environment |
649 | split_save_variables |
650 | for subpackage in ${SPLIT_PACKAGES} |
651 | do |
652 | # honor split_info |
653 | split_info_${subpackage} |
654 | if [[ ${PKGTYPE} = virtual ]] |
655 | then |
656 | # automatically set !pkgbuild here too |
657 | msetfeature "!pkgbuild" |
658 | fi |
659 | |
660 | if mqueryfeature "qalint" |
661 | then |
662 | if mqueryfeature "!pkgbuild" |
663 | then |
664 | echo "!pkgbuild detected; skipping QA lint checks for '${subpackage}' ..." |
665 | else |
666 | echo -e "${COLBLUE}===${COLGREEN} running QA lint checks for '${subpackage}' ...${COLDEFAULT}" |
667 | mqalint ${BINDIR}_${subpackage} |
668 | fi |
669 | fi |
670 | |
671 | # restore smage environment |
672 | split_restore_variables |
673 | done |
674 | # unset saved variables |
675 | split_unset_variables |
676 | else |
677 | echo -e "${COLBLUE}===${COLGREEN} running QA lint checks ...${COLDEFAULT}" |
678 | mqalint ${BINDIR} |
679 | fi |
680 | fi |
681 | fi |
682 | |
683 | if mqueryfeature "!pkgbuild" |
684 | then |
685 | echo -e "!pkgbuild detected; Package will not be build ..." |
686 | else |
687 | # build several subpackages |
688 | if [[ -n ${SPLIT_PACKAGES} ]] |
689 | then |
690 | split_save_variables |
691 | for subpackage in ${SPLIT_PACKAGES} |
692 | do |
693 | # get the right variables for the split |
694 | export PNAME="${subpackage}" |
695 | split_info_${PNAME} |
696 | # fix PCATEGORIE -> PCAT |
697 | if [[ ! -z ${PCATEGORIE} ]] |
698 | then |
699 | PCAT="${PCATEGORIE}" |
700 | unset PCATEGORIE |
701 | fi |
702 | if [[ ${PKGTYPE} = virtual ]] |
703 | then |
704 | # automatically set !pkgbuild here too |
705 | msetfeature "!pkgbuild" |
706 | fi |
707 | |
708 | # jump to next one if !pkgbuild is set in split_info |
709 | if mqueryfeature "!pkgbuild" |
710 | then |
711 | # restore smage environment |
712 | split_restore_variables |
713 | continue |
714 | fi |
715 | |
716 | # check if an special subpackage_pkgbuild exists |
717 | if typeset -f ${PNAME}_pkgbuild > /dev/null |
718 | then |
719 | # run it |
720 | run_resume post-${PNAME}_pkgbuild || ${PNAME}_pkgbuild |
721 | resume_stamp post-${PNAME}_pkgbuild |
722 | fi |
723 | # now create the target package |
724 | run_resume post-pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir.sh \ |
725 | "${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" \ |
726 | "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" |
727 | resume_stamp post-pkg_builddir_${PNAME} |
728 | |
729 | # build pkg-md5-sum if requested |
730 | run_resume post-md5sum_${PNAME} || generate_package_md5sum \ |
731 | --pcat "${PCAT}" \ |
732 | --pname "${PNAME}" \ |
733 | --pver "${PVER}" \ |
734 | --pbuild "${PBUILD}" \ |
735 | --parch "${ARCH}" |
736 | resume_stamp post-md5sum_${PNAME} |
737 | |
738 | echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD} successfully builded.\n${COLDEFAULT}" |
739 | |
740 | # restore smage environment |
741 | split_restore_variables |
742 | done |
743 | # unset all saved smage variables |
744 | split_unset_variables |
745 | |
746 | else |
747 | run_resume post-pkg_builddir || ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
748 | resume_stamp post-pkg_builddir |
749 | |
750 | # build pkg-md5-sum if requested |
751 | run_resume post-md5sum || generate_package_md5sum \ |
752 | --pcat "${PCAT}" \ |
753 | --pname "${PNAME}" \ |
754 | --pver "${PVER}" \ |
755 | --pbuild "${PBUILD}" \ |
756 | --parch "${ARCH}" |
757 | resume_stamp post-md5sum |
758 | |
759 | echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}" |
760 | fi |
761 | |
762 | # build src-pkg-tarball if requested |
763 | if mqueryfeature "srcpkgbuild" |
764 | then |
765 | run_resume post-srcpkgbuild || source_pkg_build ${SMAGENAME} |
766 | resume_stamp post-srcpkgbuild |
767 | fi |
768 | fi |
769 | |
770 | # auto regen mage tree if requested |
771 | regen_mage_tree |
772 | |
773 | if mqueryfeature "buildlog" |
774 | then |
775 | bzip2 -9f /var/log/smage/${PKGNAME}.log |
776 | else |
777 | [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log |
778 | fi |
779 | |
780 | xtitleclean |