Magellan Linux

Contents of /trunk/mage/usr/lib/mage/smage2.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 193 - (show annotations) (download) (as text)
Fri Aug 19 14:14:59 2005 UTC (18 years, 8 months ago) by niro
File MIME type: application/x-sh
File size: 19962 byte(s)
fixed regen module-dependencies

1 #!/bin/bash
2
3 # compiles/installs .smage2 source install scripts
4 # needs pkgbuild_dir (mage)
5
6 # SMAGE2
7 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.24 2005-08-19 14:14:59 niro Exp $
8
9 #01.10.2004
10 # added ccache support
11 # added distcc support
12
13 ## setup ##
14 PKGSUFFIX="mpk"
15 SMAGENAME="$1"
16 SMAGESUFFIX="smage2"
17 #SOURCEDIR="/bootstrap/sources"
18 #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"
19 #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"
20 MLIBDIR=/usr/lib/mage
21 SMAGEVERSION="$( < ${MLIBDIR}/version)"
22
23 # export default C locale
24 export LC_ALL=C
25
26 source /etc/mage.rc
27
28 showversion() {
29 echo -en "Magellan Source Install v${SMAGEVERSION} "
30 echo -e "-- Niels Rogalla (niro@magellan-linux.de)"
31 }
32
33 die() {
34 xtitleclean
35 echo "SMAGE failed: $@"
36 exit 1
37 }
38
39 xtitle() {
40 if [ ${TERM} == "xterm" ]
41 then
42 echo -ne "\033]0;[sMage: $@]\007"
43 fi
44 return 0
45 }
46
47 xtitleclean() {
48 if [ ${TERM} == "xterm" ]
49 then
50 echo -ne "\033]0;\007"
51 fi
52 return 0
53 }
54
55 syncsmage2() {
56 xtitle "Updating smage2-script tree ..."
57 local i
58 for i in ${SMAGE2RSYNC}
59 do
60 rsync \
61 --recursive \
62 --links \
63 --perms \
64 --times \
65 --devices \
66 --timeout=600 \
67 --verbose \
68 --compress \
69 --progress \
70 --stats \
71 --delete \
72 --delete-after \
73 ${i} ${SMAGESCRIPTSDIR}
74
75 if [ "$?" == "0" ]
76 then
77 break
78 else
79 continue
80 fi
81
82 done
83
84 #clean up backup files (foo~)
85 find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'
86
87 xtitleclean
88 }
89
90 # $1 filename
91 get_db_md5_sum() {
92 local DB_FILE
93 local MD5_FILE
94 local i
95
96 DB_ENTRY="$(basename $1)"
97 MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})"
98
99 i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)"
100
101 echo "${i}"
102 }
103
104 download_sources() {
105
106 [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
107
108 local EOA=${#SRC_URI[*]}
109 local my_SRC_URI
110 local my_SRC_URI_DEST
111 local my_SRC_URI_MIRROR
112 local my_SOURCEDIR
113 local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
114 local FETCHING
115 local i mirror
116
117
118 #install SRCDIR/PNAME if not exist
119 [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
120
121 # check if FETCHING is needed
122 ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )
123 if [[ $? == 0 ]]
124 then
125 # md5's ok, not fetching needed
126 FETCHING=false
127 else
128 FETCHING=true
129 fi
130
131 for ((i=0; i < EOA; i++))
132 do
133 # url to file
134 my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
135
136 # subdir in sources dir; the my_SRCI_URI file goes to there
137 my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
138
139 # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
140 if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
141 then
142 my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}"
143 else
144 my_SOURCEDIR="${SOURCEDIR}/${PNAME}"
145 fi
146
147 # if an mirrored file than replace first the mirror uri
148 if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ]
149 then
150 for mirror in ${MIRRORS}
151 do
152 my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"
153
154 #echo "DEBUG: ${MY_SRC_URI}"
155 if [[ ${FETCHING} == true ]]
156 then
157 echo "==> fetching ${my_SRC_URI_MIRROR}"
158 wget \
159 --passive-ftp \
160 --tries 3 \
161 --continue \
162 --progress bar \
163 --directory-prefix="${my_SOURCEDIR}" \
164 "${my_SRC_URI_MIRROR}"
165 if [ "$?" == "0" ]
166 then
167 break
168 else
169 continue
170 fi
171 fi
172 done
173 else
174 #echo "DEBUG: ${SRC_URI[${i}]}"
175 if [[ ${FETCHING} == true ]]
176 then
177 echo "==> fetching ${my_SRC_URI}"
178 wget \
179 --passive-ftp \
180 --tries 3 \
181 --continue \
182 --progress bar \
183 --directory-prefix="${my_SOURCEDIR}" \
184 "${my_SRC_URI}"
185 # only needed to run through a list of mirrors
186 # if [ "$?" == "0" ]
187 # then
188 # break
189 # else
190 # continue
191 # fi
192 fi
193 fi
194
195 # unset them to be shure
196 unset my_SRC_URI
197 unset my_SRC_URI_DEST
198 unset my_SRC_URI_MIRROR
199 unset my_SOURCEDIR
200 done
201
202 # recheck md5 sums
203 echo
204 echo ">== Checking MD5 sums:"
205 ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"
206 echo
207
208 # not needed anymore
209 unset SRC_URI
210 }
211
212 # dummy function, used if that not exist in smage file
213 src_prepare() {
214 echo "no src_prepare defined"
215 sleep 2
216 return 0
217 }
218
219 # dummy function, used if that not exist in smage file
220 src_compile() {
221 echo "no src_compile defined"
222 sleep 2
223 return 0
224 }
225
226 # dummy function, used if that not exist in smage file
227 src_install() {
228 echo "no src_install defined"
229 sleep 2
230 return 0
231 }
232
233 mconfigure() {
234 if [ -x ./configure ]
235 then
236 ./configure \
237 --prefix=/usr \
238 --host=${CHOST} \
239 --mandir=/usr/share/man \
240 --infodir=/usr/share/info \
241 --datadir=/usr/share \
242 --sysconfdir=/etc \
243 --localstatedir=/var/lib \
244 "$@" || die "mconfigure failed"
245 else
246 echo "configure is not an executable ..."
247 exit 1
248 fi
249 }
250
251 minstall() {
252 if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then
253 make prefix=${BINDIR}/usr \
254 datadir=${BINDIR}/usr/share \
255 infodir=${BINDIR}/usr/share/info \
256 localstatedir=${BINDIR}/var/lib \
257 mandir=${BINDIR}/usr/share/man \
258 sysconfdir=${BINDIR}/etc \
259 "$@" install || die "minstall failed"
260 else
261 die "no Makefile found"
262 fi
263 }
264
265 mmake() {
266 make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
267 }
268
269 munpack() {
270 local SRCFILE
271 local IFTAR
272 local DEST
273
274 SRCFILE=$1
275
276 if [ -z "$2" ]
277 then
278 DEST=${BUILDDIR}
279 else
280 DEST=$2
281 fi
282
283 case "${SRCFILE##*.}" in
284 bz2)
285 IFTAR="$(basename $SRCFILE .bz2)"
286 IFTAR="${IFTAR##*.}"
287 if [ "${IFTAR}" == "tar" ]
288 then
289 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
290 fi
291 ;;
292 gz)
293 IFTAR="$(basename $SRCFILE .gz)"
294 IFTAR="${IFTAR##*.}"
295 if [ "${IFTAR}" == "tar" ]
296 then
297 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
298 fi
299 ;;
300 tbz2)
301 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
302 ;;
303 tgz)
304 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
305 ;;
306 *)
307 die "munpack failed"
308 ;;
309 esac
310 }
311
312 mpatch() {
313 local PATCHOPTS
314 local PATCHFILE
315
316 PATCHOPTS=$1
317 PATCHFILE=$2
318
319 patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
320 }
321
322
323 minstalldocs() {
324 local docfiles
325
326 docfiles="$@"
327
328 if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
329 then
330 install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
331 fi
332
333 for i in ${docfiles}
334 do
335 cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
336 install -m 0644 ${SRCDIR}/${i}.gz \
337 ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
338 done
339 }
340
341 mstriplibs() {
342 local stripdir="$@"
343
344 [ -z "${stripdir}" ] && stripdir=${BINDIR}
345 find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
346 }
347
348 mstripbins() {
349 local stripdir="$@"
350
351 [ -z "${stripdir}" ] && stripdir=${BINDIR}
352 find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
353 }
354
355 sminclude() {
356 local i
357
358 if [[ -n "$@" ]]
359 then
360 for i in $@
361 do
362 echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
363 source ${SMAGESCRIPTSDIR}/include/${i}.sminc
364 done
365 echo
366 fi
367 }
368
369 setup_distcc_environment(){
370 if [ -x /usr/bin/distcc ]
371 then
372 echo "Using DistCC for compilation ..."
373 export PATH=/usr/lib/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
374
375 #export distcc as compiler
376 # export CC="distcc"
377 # export CXX=distcc
378
379 export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
380
381
382 #ccache + distcc together
383 if [ "${SMAGE_USE_CCACHE}" == "true" ]
384 then
385 if [ -x /usr/bin/ccache ]
386 then
387 echo "Preparing DistCC to work together with CCache ..."
388 #export CCACHE_PREFIX="distcc" || die "distcc: could not set ccach_prefix"
389 # export CC="ccache distcc"
390 # export CXX="ccache distcc"
391 fi
392 fi
393
394 #creating distcc tempdir
395 install -o distcc -g daemon -d ${DISTCC_DIR}
396 chmod 1777 ${DISTCC_DIR}
397 fi
398 }
399
400 setup_ccache_environment(){
401 if [ -x /usr/bin/ccache ]
402 then
403 echo "Using CCache for compilation ..."
404 export PATH=/usr/lib/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
405 #unset CC CXX
406 fi
407 }
408
409
410 # fixes given dependencies to match a MAGE_TARGET
411 # fix_mage_deps -target s/depend # <-- '-' is essential ! (build_mage_script needs this)
412 fix_mage_deps() {
413 local target="$1"
414 local depend="$2"
415 local NDEPEND
416 local sym dep cat pver pname
417
418 # deps and provides are special
419 # they must be fixed to match the target
420
421 # run this only if target and depend is not empty
422 if [ -n "${target}" ] && [ -n "${depend}" ]
423 then
424 # fix DEPEND
425 while read sym dep
426 do
427 cat="$(dirname ${dep})"
428 # abort on virtual
429 [[ ${cat} = virtual ]] && continue
430
431 # fix pver to target-pver
432 # to get pname-target-pver
433
434 # doing it backwards !
435 pver="${dep##*-}"
436 pname=$(basename ${dep/-${pver}/})
437
438 # do not add empty lines
439 if [ -z "${NDEPEND}" ]
440 then
441 NDEPEND="${sym} ${cat}/${pname}${target}-${pver}"
442 else
443 NDEPEND="${NDEPEND}
444 ${sym} ${cat}/${pname}${target}-${pver}"
445 fi
446
447 unset cat pname pver
448 done << EOF
449 ${depend}
450 EOF
451 # set NDEPEND to DEPEND
452 depend="${NDEPEND}"
453 fi
454
455 echo "${depend}"
456 }
457
458 # build_mage_script(): helper functions for regen_mage_tree()
459 # generates an mage file with given information in smage file
460 # needs at least:
461 # PNAME name of pkg
462 # PVER version
463 # PBUILD revision
464 # PCATEGORIE categorie of the pkg
465 # STATE state of pkg stable|unstable|old
466 # DESCRIPTION va short description (opt)
467 # HOMEPAGE homepage (opt)
468 # DEPEND runtime dependencies (opt)
469 # SDEPEND add. needed deps to build the pkg (opt)
470 # PROVIDE provides a virtual (opt)
471 #
472 # special tags:
473 # PKGTYPE type of pkg
474 # INHERITS which functions get included
475 # SPECIAL_FUNCTIONS special functions wich should also be added
476 # warning: they get killed before the build starts !
477 #
478 # MAGE_TREE_DEST target destination of the generated tree
479 # REGEN_MAGE_TREE set to 'true' to enable this
480 #
481 # gets called with build_mage_script target # <-- '-' is essential !
482 build_mage_script()
483 {
484 local magefile
485 local dest
486 local target
487 local sym
488 local depname
489
490 # if MAGE_TREE_DEST not set use BUILDDIR
491 : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
492
493 # determinate which suffix this mage file should get, if any
494 target="$1"
495
496 # name of magefile
497 magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
498
499 # destination to magefile
500 dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
501
502 # show what we are doing
503 echo "Generating Mage file:"
504 echo " ${dest}"
505
506 install -d "$(dirname ${dest})"
507 # now build the mage file
508 > ${dest}
509
510 # header
511 echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.24 2005-08-19 14:14:59 niro Exp $' >> ${dest}
512 echo >> ${dest}
513
514 # pgkname and state
515 echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
516 echo "STATE=\"${STATE}\"" >> ${dest}
517 echo >> ${dest}
518
519 # description and homepage
520 echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
521 echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
522 echo >> ${dest}
523
524 # special tags
525 echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest}
526 if [ -n "${INHERITS}" ]
527 then
528 echo -n "minclude" >> ${dest}
529 local i
530 for i in ${INHERITS}
531 do
532 echo -n " ${i}" >> ${dest}
533 done
534 echo >> ${dest}
535 fi
536 echo >> ${dest}
537
538 # deps and provides
539 echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
540 echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
541 echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
542 echo >> ${dest}
543
544 # add special functions
545 if [ -n "${SPECIAL_FUNCTIONS}" ]
546 then
547 local i
548 for i in ${SPECIAL_FUNCTIONS}
549 do
550 # add to mage (quotes needed !)
551 typeset -f "${i}" >> ${dest}
552 # unset to be safe (quotes needed !)
553 #unset "${i}" <-- later to get every target built
554 done
555 fi
556
557 # pre|post-install|removes
558 typeset -f preinstall >> ${dest}
559 echo >> ${dest}
560 typeset -f postinstall >> ${dest}
561 echo >> ${dest}
562 typeset -f preremove >> ${dest}
563 echo >> ${dest}
564 typeset -f postremove >> ${dest}
565 echo >> ${dest}
566 }
567
568 regen_mage_tree()
569 {
570 local i
571
572 # build them only if requested
573 if [[ ${REGEN_MAGE_TREE} = true ]]
574 then
575 # build for each target an mage file
576 for i in ${MAGE_TARGETS}
577 do
578 echo
579 build_mage_script "-${i}"
580 echo
581 done
582 fi
583
584 # now unset all uneeded vars to be safe
585 # unset PKGNAME <-- don't do that; smage needs this var
586 # unset to be safe (quotes needed !)
587 for i in ${SPECIAL_FUNCTIONS}
588 do
589 unset "${i}"
590 done
591 unset SPECIAL_FUNCTIONS
592 unset STATE
593 unset DESCRIPTION
594 unset HOMEPAGE
595 unset PKGTYPE
596 unset INHERITS
597 unset DEPEND
598 unset SDEPEND
599 unset PROVIDE
600 unset preinstall
601 unset postinstall
602 unset preremove
603 unset postremove
604 }
605
606 # print out our version
607 showversion
608 echo
609
610 if [ -z "$1" ]
611 then
612 echo "No .smage2 file given. Exiting."
613 echo
614 exit 1
615 fi
616
617 # updating smage2-scripts
618 if [ "$1" == "update" ]
619 then
620 if [ ! -d ${SOURCEDIR} ]
621 then
622 install -d ${SOURCEDIR}
623 fi
624 syncsmage2
625 exit 0
626 fi
627
628 # creates md5sums for smages to given dir
629 if [ "$1" == "calcmd5" ]
630 then
631 if [ $# -ge 3 ]
632 then
633 SMAGENAME="$2"
634 MD5DIR="$3"
635 source ${SMAGENAME} || die "download source failed"
636
637 # overridable sourcedir; must be declared after source of the smage2
638 CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
639
640 [ -z "${SRC_URI}" ] && die "Nothing declared to calculate."
641
642 # end of array
643 EOA=${#SRC_URI[*]}
644
645 [ ! -d ${MD5DIR} ] && install -d ${MD5DIR}
646
647 # clear md5sum file
648 MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
649 echo -n > ${MY_MD5_FILE}
650
651 for ((i=0; i < EOA; i++))
652 do
653 # url to file
654 my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
655
656 # subdir in sources dir; the my_SRCI_URI file goes to there
657 my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
658
659 # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
660 if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
661 then
662 MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})"
663 else
664 MY_SRC_FILE="$(basename ${SRC_URI[${i}]})"
665 fi
666
667 if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ]
668 then
669 echo "calculating $(basename ${MY_SRC_FILE}) ..."
670 ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE}
671 else
672 echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}."
673 fi
674
675 # unset them to be shure
676 unset my_SRC_URI
677 unset my_SRC_URI_DEST
678 unset my_SRC_URI_MIRROR
679 unset my_SOURCEDIR
680 done
681
682 echo
683 echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
684 echo
685 else
686 echo "Usage: Calculating MD5 Sums:"
687 echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"
688 echo
689 echo
690 echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
691 echo
692 exit 1
693 fi
694
695 exit 0
696 fi
697
698 # download sources
699 if [ "$1" == "download" -a -n "$2" ]
700 then
701 if [ ! -d ${SMAGESCRIPTSDIR} ]
702 then
703 install -d ${SMAGESCRIPTSDIR}
704 fi
705
706 # get smage
707 SMAGENAME="$2"
708 MD5DIR="$(dirname ${SMAGENAME})/md5"
709 source ${SMAGENAME} || die "download source failed"
710
711 download_sources
712 exit 0
713 fi
714
715 if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]
716 then
717 die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
718 fi
719
720 if [ -z "`basename ${SMAGENAME}|grep .${SMAGESUFFIX}`" ]
721 then
722 die "File '`basename ${SMAGENAME}`' is not a sMage v${SMAGEVERSION} file. Aborting."
723 fi
724
725 if [ -z "${SOURCEDIR}" ]
726 then
727 die "\$SOURCEDIR not found. Please setup your mage.rc correctly."
728 fi
729
730 if [ -z "${SMAGESCRIPTSDIR}" ]
731 then
732 die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."
733 fi
734
735 if [ -z "${SMAGE2RSYNC}" ]
736 then
737 echo "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."
738 exit 1
739 fi
740
741 if [ -z "${BINDIR}" ]
742 then
743 die "no BINDIR variable found in /etc/mage.rc"
744 fi
745
746 if [ -z "${CHOST}" ]
747 then
748 die "no CHOST variable found in /etc/mage.rc"
749 fi
750
751 if [ -z "${CFLAGS}" ]
752 then
753 die "no CFLAGS variable found in /etc/mage.rc"
754 fi
755
756 if [ -z "${CXXFLAGS}" ]
757 then
758 die "no CXXFLAGS variable found in /etc/mage.rc"
759 fi
760
761
762 source ${SMAGENAME} || die "source failed"
763 PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"
764 MD5DIR="$(dirname ${SMAGENAME})/md5"
765
766 xtitle "Compiling ${PKGNAME}"
767 echo "Compiling ${PKGNAME}"
768
769 # auto regen mage tree if requested
770 regen_mage_tree
771
772 # download sources
773 download_sources
774
775 # fixes some issues with these functions
776 export -f src_prepare || die "src_prepare export failed"
777 export -f src_compile || die "src_compile export failed"
778 export -f src_install || die "src_install export failed"
779
780 # fixes some compile issues
781 export CHOST="${CHOST}" || die "CHOST export failed"
782 export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
783 export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
784 export BINDIR="${BINDIR}" || die "BINDIR export failed"
785 export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
786
787
788 # setup distcc
789 # distcc mus be setup *before* ccache, as ccache need to be before distcc in path
790 if [ "${SMAGE_USE_DISTCC}" == "true" ]
791 then
792 setup_distcc_environment
793 fi
794
795 # setup ccache
796 if [ "${SMAGE_USE_CCACHE}" == "true" ]
797 then
798 setup_ccache_environment
799 fi
800
801
802 # small sleep to show our settings
803 sleep 1
804
805 #debug
806 #echo "CC=${CC}"
807 #echo "CXX=${CXX}"
808 #echo "DISTCC_DIR=${DISTCC_DIR}"
809 #echo "PATH: ${PATH}"
810 #echo "--------------------------------------"
811 #env
812 #echo "--------------------------------------"
813 #read
814 #debug end
815
816 # cleans up build if a previously one exists
817 if [ -d ${BUILDDIR} ]
818 then
819 rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
820 fi
821 install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
822
823 # cleans up srcdir if a previously unpacked one exists
824 if [ -d ${SRCDIR} ]
825 then
826 rm -rf ${SRCDIR}
827 fi
828
829 # cleans up bindir if a previous build exists or creates a new one
830 if [ -d ${BINDIR} ]
831 then
832 rm -rf ${BINDIR}
833 fi
834 install -d ${BINDIR} || die "couldn't create \$BINDIR."
835
836 # cleans up package temp dir if a previous build exists
837 if [ -d ${BUILDDIR}/${PKGNAME} ]
838 then
839 rm -rf ${BUILDDIR}/${PKGNAME}
840 fi
841
842 # cleans up timestamp if one exists
843 if [ -f /var/tmp/timestamp ]
844 then
845 mage rmstamp
846 fi
847
848 src_prepare || die "src_prepare failed"
849 src_compile || die "src_compile failed"
850 src_install || die "src_install failed"
851
852
853 # compressing doc, info & man files
854 echo -e "Compressing man-pages ..."
855 if [ -d ${BUILDDIR}/builded/usr/share/man ]
856 then
857 ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man
858 fi
859
860 echo -e "Compressing info-pages ..."
861 if [ -d ${BUILDDIR}/builded/usr/share/info ]
862 then
863 ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info
864 fi
865
866 # stripping all bins and libs
867 case ${NOSTRIP} in
868 true|TRUE|yes|y)
869 echo -e "NOSTRIP=true detected; Package will not be stripped ..."
870 ;;
871 *)
872 echo -e "Stripping binaries ..."
873 mstripbins ${BINDIR}
874 echo -e "Stripping libraries ..."
875 mstriplibs ${BINDIR}
876 ;;
877 esac
878
879 # the new buildpkg command
880 case ${NOPKGBUILD} in
881 true|TRUE|yes|y)
882 echo -e "NOPGKBUILD=true detected; Package will not be build ..."
883 ;;
884 *)
885 # build serveral targets
886 if [ -n "${MAGE_TARGETS}" ]
887 then
888 for target in ${MAGE_TARGETS}
889 do
890 # check if an special target_pkgbuild exists
891 if typeset -f ${target}_pkgbuild > /dev/null
892 then
893 # run it
894 ${target}_pkgbuild
895 fi
896 # now create the target package
897 ${MLIBDIR}/pkgbuild_dir.sh \
898 "${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \
899 ${BINDIR} || die "target: ${target} package-build failed"
900 echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n"
901 done
902 else
903 ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
904 echo -e "\nPackage ${PKGNAME} successfully builded.\n"
905 fi
906 ;;
907 esac
908
909 # for sure
910 unset NOPKGBUILD
911 unset NOSTRIP
912
913 xtitleclean
914 #echo -e "\nPackage ${PKGNAME} successfully builded.\n"

Properties

Name Value
svn:executable *