Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 832 - (hide annotations) (download) (as text)
Sun Apr 26 15:57:42 2009 UTC (15 years ago) by niro
File MIME type: application/x-sh
File size: 30392 byte(s)
-fixed a minor typo
1 niro 24 #!/bin/bash
2    
3     # compiles/installs .smage2 source install scripts
4     # needs pkgbuild_dir (mage)
5    
6     # SMAGE2
7 niro 635 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $
8 niro 24
9     #01.10.2004
10     # added ccache support
11     # added distcc support
12    
13 niro 419 # set default user mage.rc
14     : ${MAGERC="/etc/mage.rc"}
15    
16 niro 24 ## setup ##
17     PKGSUFFIX="mpk"
18 niro 403 SRCPKGSUFFIX="mpks"
19 niro 24 SMAGENAME="$1"
20     SMAGESUFFIX="smage2"
21     MLIBDIR=/usr/lib/mage
22 niro 186 SMAGEVERSION="$( < ${MLIBDIR}/version)"
23 niro 24
24 niro 351 ## only for tests -> normally in /etc/rc.d/init.d/functions
25     COLRED="\033[1;6m\033[31m"
26     COLGREEN="\033[1;6m\033[32m"
27     COLYELLOW="\033[1;6m\033[33m"
28     COLBLUE="\033[1;6m\033[34m"
29     COLMAGENTA="\033[1;6m\033[35m"
30     COLWHITE="\033[1;6m\033[37m"
31     COLGRAY="\033[0;6m\033[37m"
32     COLBOLD="\033[1m"
33     COLDEFAULT="\033[0m"
34    
35     if [[ ${NOCOLORS} = true ]]
36     then
37     COLRED=""
38     COLGREEN=""
39     COLYELLOW=""
40     COLBLUE=""
41     COLMAGENTA=""
42     COLWHITE=""
43     COLGRAY=""
44     COLBOLD=""
45     COLDEFAULT=""
46     fi
47    
48 niro 169 # export default C locale
49     export LC_ALL=C
50    
51 niro 439 source /etc/mage.rc.global
52 niro 419 source ${MAGERC}
53 niro 24
54 niro 347 # set PKGDIR and BUILDDIR and BINDIR to MROOT
55     if [[ -n ${MROOT} ]]
56     then
57     export PKGDIR=${MROOT}/${PKGDIR}
58     export BUILDDIR=${MROOT}/${BUILDDIR}
59     export BINDIR=${MROOT}/${BINDIR}
60     fi
61    
62 niro 306 showversion()
63     {
64 niro 24 echo -en "Magellan Source Install v${SMAGEVERSION} "
65     echo -e "-- Niels Rogalla (niro@magellan-linux.de)"
66     }
67    
68 niro 306 die()
69     {
70 niro 24 xtitleclean
71 niro 413 echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
72 niro 24 echo "SMAGE failed: $@"
73     exit 1
74     }
75    
76 niro 306 xtitle()
77     {
78     if [[ ${TERM} = xterm ]]
79 niro 24 then
80     echo -ne "\033]0;[sMage: $@]\007"
81     fi
82     return 0
83     }
84    
85 niro 306 xtitleclean()
86     {
87     if [[ ${TERM} = xterm ]]
88 niro 24 then
89     echo -ne "\033]0;\007"
90     fi
91     return 0
92     }
93    
94 niro 306 syncsmage2()
95     {
96 niro 24 xtitle "Updating smage2-script tree ..."
97     local i
98     for i in ${SMAGE2RSYNC}
99     do
100 niro 386 rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR}
101 niro 306 if [[ $? = 0 ]]
102 niro 24 then
103     break
104     else
105     continue
106     fi
107     done
108 niro 306
109     # clean up backup files (foo~)
110 niro 24 find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'
111 niro 306
112 niro 24 xtitleclean
113     }
114    
115 niro 59 # $1 filename
116 niro 306 get_db_md5_sum()
117     {
118 niro 59 local DB_FILE
119     local MD5_FILE
120     local i
121    
122     DB_ENTRY="$(basename $1)"
123     MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})"
124    
125     i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)"
126    
127     echo "${i}"
128     }
129    
130 niro 306 download_sources()
131     {
132 niro 59
133 niro 61 [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
134 niro 59
135     local EOA=${#SRC_URI[*]}
136 niro 66 local my_SRC_URI
137     local my_SRC_URI_DEST
138     local my_SRC_URI_MIRROR
139     local my_SOURCEDIR
140 niro 59 local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
141     local FETCHING
142     local i mirror
143    
144 niro 306
145     # install SRCDIR/PNAME if not exist
146 niro 59 [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
147    
148     # check if FETCHING is needed
149 niro 66 ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )
150 niro 306 if [[ $? = 0 ]]
151 niro 59 then
152 niro 439 # md5's ok, no fetching needed
153 niro 59 FETCHING=false
154     else
155     FETCHING=true
156     fi
157 niro 306
158 niro 59 for ((i=0; i < EOA; i++))
159     do
160 niro 66 # url to file
161     my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
162 niro 59
163 niro 66 # subdir in sources dir; the my_SRCI_URI file goes to there
164     my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
165    
166     # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
167     if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
168     then
169     my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}"
170     else
171     my_SOURCEDIR="${SOURCEDIR}/${PNAME}"
172     fi
173    
174 niro 59 # if an mirrored file than replace first the mirror uri
175 niro 439 if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]
176 niro 59 then
177     for mirror in ${MIRRORS}
178     do
179 niro 66 my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"
180 niro 59
181 niro 306 if [[ ${FETCHING} = true ]]
182 niro 59 then
183 niro 439 echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
184 niro 59 wget \
185     --passive-ftp \
186     --tries 3 \
187     --continue \
188     --progress bar \
189 niro 66 --directory-prefix="${my_SOURCEDIR}" \
190     "${my_SRC_URI_MIRROR}"
191 niro 306 if [[ $? = 0 ]]
192 niro 59 then
193     break
194     else
195     continue
196     fi
197     fi
198     done
199 niro 439 elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]]
200     then
201     for mirror in ${SOURCEFORGE_MIRRORS}
202     do
203     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")"
204    
205     if [[ ${FETCHING} = true ]]
206     then
207     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
208     wget \
209     --passive-ftp \
210     --tries 3 \
211     --continue \
212     --progress bar \
213     --directory-prefix="${my_SOURCEDIR}" \
214     "${my_SRC_URI_MIRROR}"
215     if [[ $? = 0 ]]
216     then
217     break
218     else
219     continue
220     fi
221     fi
222     done
223     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]]
224     then
225     for mirror in ${GNU_MIRRORS}
226     do
227     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")"
228    
229     if [[ ${FETCHING} = true ]]
230     then
231     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
232     wget \
233     --passive-ftp \
234     --tries 3 \
235     --continue \
236     --progress bar \
237     --directory-prefix="${my_SOURCEDIR}" \
238     "${my_SRC_URI_MIRROR}"
239     if [[ $? = 0 ]]
240     then
241     break
242     else
243     continue
244     fi
245     fi
246     done
247 niro 459 elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]
248     then
249     for mirror in ${KDE_MIRRORS}
250     do
251     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"
252    
253     if [[ ${FETCHING} = true ]]
254     then
255     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
256     wget \
257     --passive-ftp \
258     --tries 3 \
259     --continue \
260     --progress bar \
261     --directory-prefix="${my_SOURCEDIR}" \
262     "${my_SRC_URI_MIRROR}"
263     if [[ $? = 0 ]]
264     then
265     break
266     else
267     continue
268     fi
269     fi
270     done
271     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]
272     then
273     for mirror in ${GNOME_MIRRORS}
274     do
275     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"
276    
277     if [[ ${FETCHING} = true ]]
278     then
279     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
280     wget \
281     --passive-ftp \
282     --tries 3 \
283     --continue \
284     --progress bar \
285     --directory-prefix="${my_SOURCEDIR}" \
286     "${my_SRC_URI_MIRROR}"
287     if [[ $? = 0 ]]
288     then
289     break
290     else
291     continue
292     fi
293     fi
294     done
295 niro 59 else
296 niro 306 if [[ ${FETCHING} = true ]]
297 niro 59 then
298 niro 439 echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
299 niro 59 wget \
300     --passive-ftp \
301     --tries 3 \
302     --continue \
303     --progress bar \
304 niro 66 --directory-prefix="${my_SOURCEDIR}" \
305     "${my_SRC_URI}"
306 niro 59 fi
307     fi
308 niro 306
309 niro 66 # unset them to be shure
310     unset my_SRC_URI
311     unset my_SRC_URI_DEST
312     unset my_SRC_URI_MIRROR
313     unset my_SOURCEDIR
314 niro 59 done
315    
316     # recheck md5 sums
317     echo
318 niro 439 echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
319 niro 63 ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"
320 niro 59 echo
321    
322     # not needed anymore
323     unset SRC_URI
324     }
325    
326 niro 24 # dummy function, used if that not exist in smage file
327 niro 306 src_prepare()
328     {
329 niro 24 echo "no src_prepare defined"
330     sleep 2
331     return 0
332     }
333    
334     # dummy function, used if that not exist in smage file
335 niro 306 src_compile()
336     {
337 niro 24 echo "no src_compile defined"
338     sleep 2
339     return 0
340     }
341    
342     # dummy function, used if that not exist in smage file
343 niro 306 src_install()
344     {
345 niro 24 echo "no src_install defined"
346     sleep 2
347     return 0
348     }
349    
350 niro 351 mlibdir()
351     {
352     local libdir=lib
353     [[ ${ARCH} = x86_64 ]] && libdir=lib64
354    
355     echo "${libdir}"
356     }
357    
358 niro 306 mconfigure()
359     {
360 niro 24 if [ -x ./configure ]
361     then
362 niro 306 ./configure \
363     --prefix=/usr \
364     --host=${CHOST} \
365     --mandir=/usr/share/man \
366     --infodir=/usr/share/info \
367     --datadir=/usr/share \
368     --sysconfdir=/etc \
369     --localstatedir=/var/lib \
370 niro 351 --libdir=/usr/$(mlibdir) \
371 niro 306 "$@" || die "mconfigure failed"
372 niro 24 else
373     echo "configure is not an executable ..."
374     exit 1
375     fi
376     }
377    
378 niro 306 minstall()
379     {
380     if [ -f ./[mM]akefile -o -f ./GNUmakefile ]
381     then
382 niro 24 make prefix=${BINDIR}/usr \
383     datadir=${BINDIR}/usr/share \
384     infodir=${BINDIR}/usr/share/info \
385     localstatedir=${BINDIR}/var/lib \
386     mandir=${BINDIR}/usr/share/man \
387     sysconfdir=${BINDIR}/etc \
388 niro 351 libdir=${BINDIR}/usr/$(mlibdir) \
389 niro 24 "$@" install || die "minstall failed"
390     else
391     die "no Makefile found"
392     fi
393     }
394    
395 niro 306 mmake()
396     {
397 niro 24 make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
398     }
399    
400 niro 306 munpack()
401     {
402 niro 24 local SRCFILE
403     local IFTAR
404     local DEST
405    
406     SRCFILE=$1
407 niro 306
408 niro 597 if [[ -z $2 ]]
409 niro 24 then
410     DEST=${BUILDDIR}
411     else
412     DEST=$2
413     fi
414 niro 306
415 niro 411 [[ ! -d ${DEST} ]] && install -d ${DEST}
416    
417 niro 24 case "${SRCFILE##*.}" in
418     bz2)
419     IFTAR="$(basename $SRCFILE .bz2)"
420     IFTAR="${IFTAR##*.}"
421 niro 306 if [[ ${IFTAR} = tar ]]
422 niro 24 then
423 niro 597 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed."
424     else
425     pushd ${DEST} > /dev/null
426     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
427     popd > /dev/null
428 niro 24 fi
429     ;;
430     gz)
431     IFTAR="$(basename $SRCFILE .gz)"
432     IFTAR="${IFTAR##*.}"
433 niro 306 if [[ ${IFTAR} = tar ]]
434 niro 24 then
435 niro 597 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed."
436     else
437     pushd ${DEST} > /dev/null
438     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
439     popd > /dev/null
440 niro 24 fi
441     ;;
442 niro 600 tbz2|mpks|mpk)
443 niro 597 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
444 niro 24 ;;
445     tgz)
446 niro 597 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
447 niro 24 ;;
448 niro 597 rar)
449     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed."
450     ;;
451 niro 600 zip|xpi)
452 niro 597 unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
453     ;;
454     rpm)
455 niro 635 pushd ${DEST} > /dev/null
456 niro 597 rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
457 niro 602 tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
458 niro 635 if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
459 niro 602 then
460 niro 635 rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
461 niro 602 fi
462 niro 597 ;;
463 niro 24 *)
464     die "munpack failed"
465     ;;
466     esac
467     }
468    
469 niro 306 mpatch()
470     {
471 niro 24 local PATCHOPTS
472     local PATCHFILE
473 niro 447 local i
474 niro 24
475     PATCHOPTS=$1
476     PATCHFILE=$2
477    
478 niro 447 if [[ -z $2 ]]
479     then
480     PATCHFILE=$1
481    
482     ## patch level auto-detection, get patch level
483     for ((i=0; i < 10; i++))
484     do
485     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
486     if [[ $? = 0 ]]
487     then
488     PATCHOPTS="-Np${i}"
489     break
490     fi
491     done
492     fi
493    
494 niro 384 echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
495 niro 24 patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
496     }
497    
498 niro 497 mlibtoolize()
499     {
500     local opts="$@"
501     [[ -z ${opts} ]] && opts="--copy --force"
502 niro 24
503 niro 497 libtoolize ${opts} || die "running: mlibtoolize ${opts}"
504     }
505    
506 niro 306 minstalldocs()
507     {
508 niro 24 local docfiles
509     docfiles="$@"
510 niro 306
511 niro 24 if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
512     then
513     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
514     fi
515 niro 306
516 niro 24 for i in ${docfiles}
517     do
518     cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
519     install -m 0644 ${SRCDIR}/${i}.gz \
520     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
521     done
522     }
523    
524 niro 306 mstriplibs()
525     {
526 niro 79 local stripdir="$@"
527    
528     [ -z "${stripdir}" ] && stripdir=${BINDIR}
529     find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
530     }
531    
532 niro 306 mstripbins()
533     {
534 niro 79 local stripdir="$@"
535    
536     [ -z "${stripdir}" ] && stripdir=${BINDIR}
537     find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
538     }
539    
540 niro 306 sminclude()
541     {
542 niro 172 local i
543    
544 niro 183 if [[ -n "$@" ]]
545 niro 172 then
546     for i in $@
547     do
548 niro 175 echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
549 niro 172 source ${SMAGESCRIPTSDIR}/include/${i}.sminc
550     done
551 niro 177 echo
552 niro 172 fi
553     }
554    
555 niro 306 setup_distcc_environment()
556     {
557 niro 24 if [ -x /usr/bin/distcc ]
558     then
559 niro 441 echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
560 niro 351 export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
561 niro 24
562     export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
563    
564 niro 306 # creating distcc tempdir
565 niro 24 install -o distcc -g daemon -d ${DISTCC_DIR}
566     chmod 1777 ${DISTCC_DIR}
567     fi
568     }
569    
570 niro 306 setup_ccache_environment()
571     {
572 niro 24 if [ -x /usr/bin/ccache ]
573     then
574 niro 441 echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
575 niro 351 export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
576 niro 24 fi
577     }
578    
579 niro 193
580     # fixes given dependencies to match a MAGE_TARGET
581 niro 198 # fix_mage_deps -target s/depend # <-- note -target !
582 niro 306 fix_mage_deps()
583     {
584 niro 193 local target="$1"
585     local depend="$2"
586     local NDEPEND
587     local sym dep cat pver pname
588    
589     # deps and provides are special
590     # they must be fixed to match the target
591    
592     # run this only if target and depend is not empty
593     if [ -n "${target}" ] && [ -n "${depend}" ]
594     then
595     # fix DEPEND
596     while read sym dep
597     do
598 niro 427 # ignore empty lines
599     [[ -z ${dep} ]] && continue
600    
601 niro 193 cat="$(dirname ${dep})"
602 niro 199 # change if not virtual
603 niro 200 if [[ ${cat} = virtual ]]
604 niro 199 then
605 niro 200 pname="$(basename ${dep})"
606     else
607 niro 199 # fix pver to target-pver
608     # to get pname-target-pver
609 niro 193
610 niro 199 # doing it backwards !
611     pver="${dep##*-}"
612 niro 200 # full pver
613     pname="$(basename ${dep/-${pver}/})${target}-${pver}"
614 niro 199 fi
615 niro 193
616     # do not add empty lines
617     if [ -z "${NDEPEND}" ]
618     then
619 niro 200 NDEPEND="${sym} ${cat}/${pname}"
620 niro 193 else
621     NDEPEND="${NDEPEND}
622 niro 201 ${sym} ${cat}/${pname}"
623 niro 193 fi
624    
625     unset cat pname pver
626     done << EOF
627     ${depend}
628     EOF
629     # set NDEPEND to DEPEND
630     depend="${NDEPEND}"
631     fi
632    
633     echo "${depend}"
634     }
635    
636 niro 192 # build_mage_script(): helper functions for regen_mage_tree()
637 niro 191 # generates an mage file with given information in smage file
638     # needs at least:
639     # PNAME name of pkg
640     # PVER version
641     # PBUILD revision
642     # PCATEGORIE categorie of the pkg
643     # STATE state of pkg stable|unstable|old
644     # DESCRIPTION va short description (opt)
645     # HOMEPAGE homepage (opt)
646     # DEPEND runtime dependencies (opt)
647     # SDEPEND add. needed deps to build the pkg (opt)
648     # PROVIDE provides a virtual (opt)
649     #
650     # special tags:
651     # PKGTYPE type of pkg
652     # INHERITS which functions get included
653 niro 832 # SPECIAL_FUNCTIONS special functions which should also be added
654 niro 191 # warning: they get killed before the build starts !
655     #
656     # MAGE_TREE_DEST target destination of the generated tree
657     # REGEN_MAGE_TREE set to 'true' to enable this
658 niro 193 #
659 niro 195 # gets called with build_mage_script target
660 niro 192 build_mage_script()
661 niro 191 {
662     local magefile
663     local dest
664 niro 193 local target
665 niro 191 local sym
666     local depname
667    
668     # if MAGE_TREE_DEST not set use BUILDDIR
669     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
670    
671     # determinate which suffix this mage file should get, if any
672 niro 195 [ -n "$1" ] && target="-$1"
673 niro 191
674     # name of magefile
675 niro 193 magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
676 niro 191
677     # destination to magefile
678 niro 193 dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
679 niro 191
680     # show what we are doing
681 niro 439 echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
682     echo "${dest}"
683 niro 191
684     install -d "$(dirname ${dest})"
685     # now build the mage file
686     > ${dest}
687    
688     # header
689 niro 635 echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest}
690 niro 191 echo >> ${dest}
691    
692     # pgkname and state
693 niro 193 echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
694 niro 191 echo "STATE=\"${STATE}\"" >> ${dest}
695     echo >> ${dest}
696    
697     # description and homepage
698     echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
699     echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
700     echo >> ${dest}
701    
702 niro 196 # special tags and vars
703 niro 191 echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest}
704 niro 214
705     # echo MAGE_TARGETS ## note -target is needed !
706     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
707     echo >> ${dest}
708    
709 niro 197 # add special vars
710     if [ -n "${SPECIAL_VARS}" ]
711 niro 191 then
712     local i
713 niro 197 for i in ${SPECIAL_VARS}
714 niro 191 do
715 niro 197 # being tricky here :)
716     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
717 niro 191 done
718     echo >> ${dest}
719     fi
720 niro 214
721 niro 197 # add at least all includes
722     if [ -n "${INHERITS}" ]
723 niro 196 then
724 niro 197 echo -n "minclude" >> ${dest}
725 niro 196 local i
726 niro 197 for i in ${INHERITS}
727 niro 196 do
728 niro 197 echo -n " ${i}" >> ${dest}
729 niro 196 done
730     echo >> ${dest}
731     fi
732 niro 197 echo >> ${dest}
733 niro 196
734 niro 191 # deps and provides
735 niro 193 echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
736 niro 196 echo >> ${dest}
737 niro 193 echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
738 niro 196 echo >> ${dest}
739 niro 191 echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
740     echo >> ${dest}
741    
742     # add special functions
743     if [ -n "${SPECIAL_FUNCTIONS}" ]
744     then
745     local i
746     for i in ${SPECIAL_FUNCTIONS}
747     do
748     # add to mage (quotes needed !)
749     typeset -f "${i}" >> ${dest}
750 niro 214 echo >> ${dest}
751 niro 191 # unset to be safe (quotes needed !)
752 niro 192 #unset "${i}" <-- later to get every target built
753 niro 191 done
754 niro 196 echo >> ${dest}
755 niro 191 fi
756    
757     # pre|post-install|removes
758     typeset -f preinstall >> ${dest}
759     echo >> ${dest}
760     typeset -f postinstall >> ${dest}
761     echo >> ${dest}
762     typeset -f preremove >> ${dest}
763     echo >> ${dest}
764     typeset -f postremove >> ${dest}
765     echo >> ${dest}
766     }
767    
768     regen_mage_tree()
769     {
770     local i
771    
772     # build them only if requested
773     if [[ ${REGEN_MAGE_TREE} = true ]]
774     then
775 niro 195 # run it without targets
776     if [ -z "${MAGE_TARGETS}" ]
777     then
778 niro 191 echo
779 niro 195 build_mage_script
780 niro 191 echo
781 niro 195 else
782    
783     # build for each target an mage file
784     # run it with several targets
785     for i in ${MAGE_TARGETS}
786     do
787     echo
788     build_mage_script "${i}"
789     echo
790     done
791     fi
792 niro 191 fi
793    
794     # now unset all uneeded vars to be safe
795 niro 192 # unset PKGNAME <-- don't do that; smage needs this var
796     # unset to be safe (quotes needed !)
797 niro 477 # for i in ${SPECIAL_FUNCTIONS}
798     # do
799     # unset "${i}"
800     # done
801 niro 192 unset SPECIAL_FUNCTIONS
802 niro 477 # for i in ${SPECIAL_VARS}
803     # do
804     # unset "${i}"
805     # done
806 niro 194 unset SPECIAL_VARS
807 niro 191 unset STATE
808     unset DESCRIPTION
809     unset HOMEPAGE
810     unset PKGTYPE
811     unset INHERITS
812     unset DEPEND
813     unset SDEPEND
814     unset PROVIDE
815     unset preinstall
816     unset postinstall
817     unset preremove
818     unset postremove
819     }
820    
821 niro 253 export_inherits()
822     {
823     local include="$1"
824     shift
825    
826     while [ "$1" ]
827     do
828     local functions="$1"
829    
830     # sanity checks
831     [ -z "${include}" ] && die "export_inherits(): \$include not given."
832     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
833    
834     eval "${functions}() { ${include}_${functions} ; }"
835    
836     # debug
837     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
838    
839     shift
840     done
841     }
842    
843 niro 255 generate_package_md5sum()
844     {
845     local dest
846     local pcat
847     local pname
848     local pver
849     local pbuild
850     local parch
851     local target
852     local pkgname
853    
854     # very basic getops
855     for i in $*
856     do
857     case $1 in
858     --pcat|-c) shift; pcat="$1" ;;
859     --pname|-n) shift; pname="$1" ;;
860     --pver|-v) shift; pver="$1" ;;
861     --pbuild|-b) shift; pbuild="$1" ;;
862     --parch|a) shift; parch="$1" ;;
863     --target|t) shift; target="$1" ;;
864     esac
865     shift
866     done
867    
868     # sanity checks; abort if not given
869     [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given."
870     [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given."
871     [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given."
872     [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given."
873     [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given."
874    
875     # check needed global vars
876     [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
877     [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
878    
879     # fix target as it may be empty !
880     [ -n "${target}" ] && target="-${target}"
881    
882     # build pkgname
883     pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
884    
885     # build pkg-md5-sum only if requested
886     if [[ ${REGEN_MAGE_TREE} = true ]]
887     then
888 niro 439 echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
889 niro 255
890     # abort if not exist
891     if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
892     then
893 niro 439 echo -e "${COLRED}! exists${COLDEFAULT}"
894 niro 255 return 0
895     fi
896    
897     # if MAGE_TREE_DEST not set use BUILDDIR
898     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
899    
900     # setup md5 dir
901     dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"
902     install -d ${dest}
903    
904     # gen md5sum
905     ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
906 niro 256 > ${dest}/${pkgname}.md5
907 niro 439 echo -e "${COLGREEN}done${COLDEFAULT}"
908 niro 255 fi
909     }
910    
911 niro 403 source_pkg_build()
912     {
913     if [[ ${PKGTYPE} = virtual ]]
914     then
915     echo "Virtual package detected; src-pkg-tarball not necessary ..."
916     return 0
917     fi
918    
919     if [[ ! -d ${SOURCEDIR}/${PNAME} ]]
920     then
921     echo "No SRC_URI defined; src-pkg-tarball not necessary ..."
922     return 0
923     fi
924    
925 niro 419 [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."
926 niro 406
927 niro 403 echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"
928 niro 412
929     # include the smage2 file
930     cp ${SMAGENAME} ${SOURCEDIR}/${PNAME}
931    
932 niro 403 ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; )
933 niro 406 [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR}
934     mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}
935 niro 403
936     echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
937     }
938    
939    
940 niro 59 # print out our version
941     showversion
942     echo
943    
944 niro 24 if [ -z "$1" ]
945     then
946     echo "No .smage2 file given. Exiting."
947     echo
948     exit 1
949     fi
950    
951 niro 192 # updating smage2-scripts
952 niro 306 if [[ $1 = update ]]
953 niro 24 then
954 niro 59 if [ ! -d ${SOURCEDIR} ]
955     then
956     install -d ${SOURCEDIR}
957     fi
958     syncsmage2
959     exit 0
960     fi
961    
962 niro 192 # creates md5sums for smages to given dir
963 niro 306 if [[ $1 = calcmd5 ]]
964 niro 59 then
965     if [ $# -ge 3 ]
966     then
967     SMAGENAME="$2"
968     MD5DIR="$3"
969     source ${SMAGENAME} || die "download source failed"
970    
971 niro 66 # overridable sourcedir; must be declared after source of the smage2
972     CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
973    
974 niro 59 [ -z "${SRC_URI}" ] && die "Nothing declared to calculate."
975    
976     # end of array
977     EOA=${#SRC_URI[*]}
978    
979     [ ! -d ${MD5DIR} ] && install -d ${MD5DIR}
980    
981     # clear md5sum file
982     MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
983     echo -n > ${MY_MD5_FILE}
984    
985     for ((i=0; i < EOA; i++))
986     do
987 niro 66 # url to file
988     my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
989    
990     # subdir in sources dir; the my_SRCI_URI file goes to there
991     my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
992    
993     # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
994     if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
995     then
996     MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})"
997     else
998     MY_SRC_FILE="$(basename ${SRC_URI[${i}]})"
999     fi
1000    
1001 niro 59 if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ]
1002     then
1003     echo "calculating $(basename ${MY_SRC_FILE}) ..."
1004     ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE}
1005     else
1006     echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}."
1007     fi
1008 niro 66
1009     # unset them to be shure
1010     unset my_SRC_URI
1011     unset my_SRC_URI_DEST
1012     unset my_SRC_URI_MIRROR
1013     unset my_SOURCEDIR
1014 niro 59 done
1015 niro 306
1016 niro 59 echo
1017     echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
1018     echo
1019     else
1020     echo "Usage: Calculating MD5 Sums:"
1021     echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"
1022     echo
1023     echo
1024     echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
1025     echo
1026     exit 1
1027     fi
1028 niro 306
1029 niro 59 exit 0
1030     fi
1031    
1032 niro 192 # download sources
1033 niro 59 if [ "$1" == "download" -a -n "$2" ]
1034     then
1035 niro 24 if [ ! -d ${SMAGESCRIPTSDIR} ]
1036     then
1037     install -d ${SMAGESCRIPTSDIR}
1038     fi
1039 niro 59
1040     # get smage
1041     SMAGENAME="$2"
1042     MD5DIR="$(dirname ${SMAGENAME})/md5"
1043     source ${SMAGENAME} || die "download source failed"
1044    
1045     download_sources
1046 niro 24 exit 0
1047     fi
1048    
1049 niro 202 # regen-mage-tree
1050     if [ "$1" == "only-regen-tree" -a -n "$2" ]
1051     then
1052     # set correct SMAGENAME
1053     SMAGENAME="$2"
1054     MD5DIR="$(dirname ${SMAGENAME})/md5"
1055     source ${SMAGENAME} || die "regen: smage2 not found"
1056    
1057     regen_mage_tree
1058 niro 255
1059     # build md5sum for existing packages
1060     generate_package_md5sum \
1061     --pcat "${PCATEGORIE}" \
1062     --pname "${PNAME}" \
1063     --pver "${PVER}" \
1064     --pbuild "${PBUILD}" \
1065     --parch "${ARCH}" \
1066     --target "${target}"
1067    
1068 niro 202 exit 0
1069     fi
1070    
1071 niro 412 if [ "$1" == "--create-src-tarball" -a -n "$2" ]
1072 niro 403 then
1073     # set correct SMAGENAME
1074     SMAGENAME="$2"
1075     MD5DIR="$(dirname ${SMAGENAME})/md5"
1076    
1077 niro 412 echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1078 niro 403
1079     source ${SMAGENAME} || die "regen: smage2 not found"
1080    
1081     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1082     then
1083     echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1084     rm -rf ${SOURCEDIR}/${PKGNAME}
1085     fi
1086    
1087     download_sources
1088     source_pkg_build ${SMAGENAME}
1089     exit 0
1090     fi
1091    
1092 niro 406 if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1093 niro 403 then
1094 niro 412 SRCPKGTARBALL="${2}"
1095 niro 403 USE_SRC_PKG_TARBALL=true
1096    
1097 niro 412 # abort if given file is not a source pkg
1098     [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
1099    
1100     # set correct SMAGENAME; use the one that the src_pkg provide
1101     # /path/to/SOURCEDIR/PNAME/SMAGENAME
1102     SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}"
1103    
1104 niro 403 echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}"
1105    
1106     [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR}
1107    
1108     # unpack srctarball
1109     [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting."
1110    
1111     tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}"
1112 niro 412
1113     [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"
1114 niro 403 fi
1115    
1116    
1117 niro 306 [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
1118     [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
1119     die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
1120 niro 419 [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
1121     [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly."
1122     [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly."
1123     [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}"
1124     [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}"
1125     [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1126     [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1127 niro 24
1128     source ${SMAGENAME} || die "source failed"
1129 niro 255 PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1130 niro 59 MD5DIR="$(dirname ${SMAGENAME})/md5"
1131 niro 24
1132     xtitle "Compiling ${PKGNAME}"
1133 niro 439 echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1134 niro 59
1135 niro 191 # auto regen mage tree if requested
1136     regen_mage_tree
1137    
1138 niro 403 if [[ ${CREATE_SRC_PKG_TARBALL} = true ]]
1139     then
1140     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1141     then
1142 niro 441 echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1143 niro 408 rm -rf ${SOURCEDIR}/${PNAME}
1144 niro 403 fi
1145     fi
1146    
1147 niro 192 # download sources
1148 niro 403 [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources
1149 niro 59
1150 niro 192 # fixes some issues with these functions
1151 niro 24 export -f src_prepare || die "src_prepare export failed"
1152     export -f src_compile || die "src_compile export failed"
1153     export -f src_install || die "src_install export failed"
1154    
1155 niro 192 # fixes some compile issues
1156 niro 24 export CHOST="${CHOST}" || die "CHOST export failed"
1157     export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
1158     export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
1159     export BINDIR="${BINDIR}" || die "BINDIR export failed"
1160     export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
1161    
1162    
1163 niro 192 # setup distcc
1164 niro 351 # setup for distcc goes *before* ccache, so ccache comes before distcc in path
1165 niro 306 [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment
1166 niro 24
1167 niro 192 # setup ccache
1168 niro 306 [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
1169 niro 24
1170     # small sleep to show our settings
1171     sleep 1
1172    
1173 niro 192 # cleans up build if a previously one exists
1174 niro 24 if [ -d ${BUILDDIR} ]
1175     then
1176     rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1177     fi
1178     install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1179    
1180 niro 192 # cleans up srcdir if a previously unpacked one exists
1181 niro 24 if [ -d ${SRCDIR} ]
1182     then
1183     rm -rf ${SRCDIR}
1184     fi
1185    
1186 niro 192 # cleans up bindir if a previous build exists or creates a new one
1187 niro 24 if [ -d ${BINDIR} ]
1188     then
1189     rm -rf ${BINDIR}
1190     fi
1191     install -d ${BINDIR} || die "couldn't create \$BINDIR."
1192    
1193 niro 192 # cleans up package temp dir if a previous build exists
1194 niro 24 if [ -d ${BUILDDIR}/${PKGNAME} ]
1195     then
1196     rm -rf ${BUILDDIR}/${PKGNAME}
1197     fi
1198    
1199 niro 192 # cleans up timestamp if one exists
1200 niro 24 if [ -f /var/tmp/timestamp ]
1201     then
1202     mage rmstamp
1203     fi
1204    
1205     src_prepare || die "src_prepare failed"
1206     src_compile || die "src_compile failed"
1207     src_install || die "src_install failed"
1208    
1209    
1210 niro 192 # compressing doc, info & man files
1211 niro 24 if [ -d ${BUILDDIR}/builded/usr/share/man ]
1212     then
1213 niro 439 echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
1214 niro 24 ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man
1215     fi
1216    
1217     if [ -d ${BUILDDIR}/builded/usr/share/info ]
1218     then
1219 niro 439 echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
1220 niro 24 ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info
1221     fi
1222    
1223 niro 79 # stripping all bins and libs
1224     case ${NOSTRIP} in
1225     true|TRUE|yes|y)
1226     echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1227     ;;
1228     *)
1229 niro 439 echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1230 niro 79 mstripbins ${BINDIR}
1231 niro 439 echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1232 niro 79 mstriplibs ${BINDIR}
1233     ;;
1234     esac
1235    
1236 niro 192 # the new buildpkg command
1237 niro 24 case ${NOPKGBUILD} in
1238     true|TRUE|yes|y)
1239     echo -e "NOPGKBUILD=true detected; Package will not be build ..."
1240     ;;
1241 niro 192 *)
1242 niro 306 # build several targets
1243 niro 192 if [ -n "${MAGE_TARGETS}" ]
1244     then
1245     for target in ${MAGE_TARGETS}
1246     do
1247     # check if an special target_pkgbuild exists
1248     if typeset -f ${target}_pkgbuild > /dev/null
1249     then
1250     # run it
1251     ${target}_pkgbuild
1252     fi
1253     # now create the target package
1254     ${MLIBDIR}/pkgbuild_dir.sh \
1255 niro 255 "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \
1256 niro 192 ${BINDIR} || die "target: ${target} package-build failed"
1257 niro 255
1258     # build pkg-md5-sum if requested
1259     generate_package_md5sum \
1260     --pcat "${PCATEGORIE}" \
1261     --pname "${PNAME}" \
1262     --pver "${PVER}" \
1263     --pbuild "${PBUILD}" \
1264     --parch "${ARCH}" \
1265     --target "${target}"
1266    
1267 niro 439 echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1268 niro 192 done
1269     else
1270     ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1271 niro 255
1272     # build pkg-md5-sum if requested
1273     generate_package_md5sum \
1274     --pcat "${PCATEGORIE}" \
1275     --pname "${PNAME}" \
1276     --pver "${PVER}" \
1277     --pbuild "${PBUILD}" \
1278     --parch "${ARCH}"
1279    
1280 niro 439 echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1281 niro 192 fi
1282 niro 403
1283     # build src-pkg-tarball if requested
1284     [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME}
1285 niro 24 ;;
1286     esac
1287    
1288 niro 192 # for sure
1289 niro 24 unset NOPKGBUILD
1290 niro 85 unset NOSTRIP
1291 niro 351
1292 niro 24 xtitleclean

Properties

Name Value
svn:executable *