Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 859 - (hide annotations) (download) (as text)
Fri May 8 07:06:12 2009 UTC (15 years ago) by niro
File MIME type: application/x-sh
File size: 30637 byte(s)
-added step-by-step support
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 niro 833 --build=${CHOST} \
366 niro 306 --mandir=/usr/share/man \
367     --infodir=/usr/share/info \
368     --datadir=/usr/share \
369     --sysconfdir=/etc \
370     --localstatedir=/var/lib \
371 niro 351 --libdir=/usr/$(mlibdir) \
372 niro 306 "$@" || die "mconfigure failed"
373 niro 24 else
374     echo "configure is not an executable ..."
375     exit 1
376     fi
377     }
378    
379 niro 306 minstall()
380     {
381     if [ -f ./[mM]akefile -o -f ./GNUmakefile ]
382     then
383 niro 24 make prefix=${BINDIR}/usr \
384     datadir=${BINDIR}/usr/share \
385     infodir=${BINDIR}/usr/share/info \
386     localstatedir=${BINDIR}/var/lib \
387     mandir=${BINDIR}/usr/share/man \
388     sysconfdir=${BINDIR}/etc \
389 niro 351 libdir=${BINDIR}/usr/$(mlibdir) \
390 niro 24 "$@" install || die "minstall failed"
391     else
392     die "no Makefile found"
393     fi
394     }
395    
396 niro 306 mmake()
397     {
398 niro 24 make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
399     }
400    
401 niro 306 munpack()
402     {
403 niro 24 local SRCFILE
404     local IFTAR
405     local DEST
406    
407     SRCFILE=$1
408 niro 306
409 niro 597 if [[ -z $2 ]]
410 niro 24 then
411     DEST=${BUILDDIR}
412     else
413     DEST=$2
414     fi
415 niro 306
416 niro 411 [[ ! -d ${DEST} ]] && install -d ${DEST}
417    
418 niro 24 case "${SRCFILE##*.}" in
419     bz2)
420     IFTAR="$(basename $SRCFILE .bz2)"
421     IFTAR="${IFTAR##*.}"
422 niro 306 if [[ ${IFTAR} = tar ]]
423 niro 24 then
424 niro 597 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed."
425     else
426     pushd ${DEST} > /dev/null
427     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
428     popd > /dev/null
429 niro 24 fi
430     ;;
431     gz)
432     IFTAR="$(basename $SRCFILE .gz)"
433     IFTAR="${IFTAR##*.}"
434 niro 306 if [[ ${IFTAR} = tar ]]
435 niro 24 then
436 niro 597 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed."
437     else
438     pushd ${DEST} > /dev/null
439     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
440     popd > /dev/null
441 niro 24 fi
442     ;;
443 niro 600 tbz2|mpks|mpk)
444 niro 597 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
445 niro 24 ;;
446     tgz)
447 niro 597 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
448 niro 24 ;;
449 niro 597 rar)
450     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed."
451     ;;
452 niro 600 zip|xpi)
453 niro 597 unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
454     ;;
455     rpm)
456 niro 635 pushd ${DEST} > /dev/null
457 niro 597 rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
458 niro 602 tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
459 niro 635 if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
460 niro 602 then
461 niro 635 rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
462 niro 602 fi
463 niro 597 ;;
464 niro 24 *)
465     die "munpack failed"
466     ;;
467     esac
468     }
469    
470 niro 306 mpatch()
471     {
472 niro 24 local PATCHOPTS
473     local PATCHFILE
474 niro 447 local i
475 niro 24
476     PATCHOPTS=$1
477     PATCHFILE=$2
478    
479 niro 447 if [[ -z $2 ]]
480     then
481     PATCHFILE=$1
482    
483     ## patch level auto-detection, get patch level
484     for ((i=0; i < 10; i++))
485     do
486     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
487     if [[ $? = 0 ]]
488     then
489     PATCHOPTS="-Np${i}"
490     break
491     fi
492     done
493     fi
494    
495 niro 384 echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
496 niro 24 patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
497     }
498    
499 niro 497 mlibtoolize()
500     {
501     local opts="$@"
502     [[ -z ${opts} ]] && opts="--copy --force"
503 niro 24
504 niro 497 libtoolize ${opts} || die "running: mlibtoolize ${opts}"
505     }
506    
507 niro 306 minstalldocs()
508     {
509 niro 24 local docfiles
510     docfiles="$@"
511 niro 306
512 niro 24 if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
513     then
514     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
515     fi
516 niro 306
517 niro 24 for i in ${docfiles}
518     do
519     cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
520     install -m 0644 ${SRCDIR}/${i}.gz \
521     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
522     done
523     }
524    
525 niro 306 mstriplibs()
526     {
527 niro 79 local stripdir="$@"
528    
529     [ -z "${stripdir}" ] && stripdir=${BINDIR}
530     find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
531     }
532    
533 niro 306 mstripbins()
534     {
535 niro 79 local stripdir="$@"
536    
537     [ -z "${stripdir}" ] && stripdir=${BINDIR}
538     find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
539     }
540    
541 niro 306 sminclude()
542     {
543 niro 172 local i
544    
545 niro 183 if [[ -n "$@" ]]
546 niro 172 then
547     for i in $@
548     do
549 niro 175 echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
550 niro 172 source ${SMAGESCRIPTSDIR}/include/${i}.sminc
551     done
552 niro 177 echo
553 niro 172 fi
554     }
555    
556 niro 306 setup_distcc_environment()
557     {
558 niro 24 if [ -x /usr/bin/distcc ]
559     then
560 niro 441 echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
561 niro 351 export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
562 niro 24
563     export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
564    
565 niro 306 # creating distcc tempdir
566 niro 24 install -o distcc -g daemon -d ${DISTCC_DIR}
567     chmod 1777 ${DISTCC_DIR}
568     fi
569     }
570    
571 niro 306 setup_ccache_environment()
572     {
573 niro 24 if [ -x /usr/bin/ccache ]
574     then
575 niro 441 echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
576 niro 351 export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
577 niro 24 fi
578     }
579    
580 niro 193
581     # fixes given dependencies to match a MAGE_TARGET
582 niro 198 # fix_mage_deps -target s/depend # <-- note -target !
583 niro 306 fix_mage_deps()
584     {
585 niro 193 local target="$1"
586     local depend="$2"
587     local NDEPEND
588     local sym dep cat pver pname
589    
590     # deps and provides are special
591     # they must be fixed to match the target
592    
593     # run this only if target and depend is not empty
594     if [ -n "${target}" ] && [ -n "${depend}" ]
595     then
596     # fix DEPEND
597     while read sym dep
598     do
599 niro 427 # ignore empty lines
600     [[ -z ${dep} ]] && continue
601    
602 niro 193 cat="$(dirname ${dep})"
603 niro 199 # change if not virtual
604 niro 200 if [[ ${cat} = virtual ]]
605 niro 199 then
606 niro 200 pname="$(basename ${dep})"
607     else
608 niro 199 # fix pver to target-pver
609     # to get pname-target-pver
610 niro 193
611 niro 199 # doing it backwards !
612     pver="${dep##*-}"
613 niro 200 # full pver
614     pname="$(basename ${dep/-${pver}/})${target}-${pver}"
615 niro 199 fi
616 niro 193
617     # do not add empty lines
618     if [ -z "${NDEPEND}" ]
619     then
620 niro 200 NDEPEND="${sym} ${cat}/${pname}"
621 niro 193 else
622     NDEPEND="${NDEPEND}
623 niro 201 ${sym} ${cat}/${pname}"
624 niro 193 fi
625    
626     unset cat pname pver
627     done << EOF
628     ${depend}
629     EOF
630     # set NDEPEND to DEPEND
631     depend="${NDEPEND}"
632     fi
633    
634     echo "${depend}"
635     }
636    
637 niro 192 # build_mage_script(): helper functions for regen_mage_tree()
638 niro 191 # generates an mage file with given information in smage file
639     # needs at least:
640     # PNAME name of pkg
641     # PVER version
642     # PBUILD revision
643     # PCATEGORIE categorie of the pkg
644     # STATE state of pkg stable|unstable|old
645     # DESCRIPTION va short description (opt)
646     # HOMEPAGE homepage (opt)
647     # DEPEND runtime dependencies (opt)
648     # SDEPEND add. needed deps to build the pkg (opt)
649     # PROVIDE provides a virtual (opt)
650     #
651     # special tags:
652     # PKGTYPE type of pkg
653     # INHERITS which functions get included
654 niro 832 # SPECIAL_FUNCTIONS special functions which should also be added
655 niro 191 # warning: they get killed before the build starts !
656     #
657     # MAGE_TREE_DEST target destination of the generated tree
658     # REGEN_MAGE_TREE set to 'true' to enable this
659 niro 193 #
660 niro 195 # gets called with build_mage_script target
661 niro 192 build_mage_script()
662 niro 191 {
663     local magefile
664     local dest
665 niro 193 local target
666 niro 191 local sym
667     local depname
668    
669     # if MAGE_TREE_DEST not set use BUILDDIR
670     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
671    
672     # determinate which suffix this mage file should get, if any
673 niro 195 [ -n "$1" ] && target="-$1"
674 niro 191
675     # name of magefile
676 niro 193 magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
677 niro 191
678     # destination to magefile
679 niro 193 dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
680 niro 191
681     # show what we are doing
682 niro 439 echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
683     echo "${dest}"
684 niro 191
685     install -d "$(dirname ${dest})"
686     # now build the mage file
687     > ${dest}
688    
689     # header
690 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}
691 niro 191 echo >> ${dest}
692    
693     # pgkname and state
694 niro 193 echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
695 niro 191 echo "STATE=\"${STATE}\"" >> ${dest}
696     echo >> ${dest}
697    
698     # description and homepage
699     echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
700     echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
701     echo >> ${dest}
702    
703 niro 196 # special tags and vars
704 niro 191 echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest}
705 niro 214
706     # echo MAGE_TARGETS ## note -target is needed !
707     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
708     echo >> ${dest}
709    
710 niro 197 # add special vars
711     if [ -n "${SPECIAL_VARS}" ]
712 niro 191 then
713     local i
714 niro 197 for i in ${SPECIAL_VARS}
715 niro 191 do
716 niro 197 # being tricky here :)
717     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
718 niro 191 done
719     echo >> ${dest}
720     fi
721 niro 214
722 niro 197 # add at least all includes
723     if [ -n "${INHERITS}" ]
724 niro 196 then
725 niro 197 echo -n "minclude" >> ${dest}
726 niro 196 local i
727 niro 197 for i in ${INHERITS}
728 niro 196 do
729 niro 197 echo -n " ${i}" >> ${dest}
730 niro 196 done
731     echo >> ${dest}
732     fi
733 niro 197 echo >> ${dest}
734 niro 196
735 niro 191 # deps and provides
736 niro 193 echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
737 niro 196 echo >> ${dest}
738 niro 193 echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
739 niro 196 echo >> ${dest}
740 niro 191 echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
741     echo >> ${dest}
742    
743     # add special functions
744     if [ -n "${SPECIAL_FUNCTIONS}" ]
745     then
746     local i
747     for i in ${SPECIAL_FUNCTIONS}
748     do
749     # add to mage (quotes needed !)
750     typeset -f "${i}" >> ${dest}
751 niro 214 echo >> ${dest}
752 niro 191 # unset to be safe (quotes needed !)
753 niro 192 #unset "${i}" <-- later to get every target built
754 niro 191 done
755 niro 196 echo >> ${dest}
756 niro 191 fi
757    
758     # pre|post-install|removes
759     typeset -f preinstall >> ${dest}
760     echo >> ${dest}
761     typeset -f postinstall >> ${dest}
762     echo >> ${dest}
763     typeset -f preremove >> ${dest}
764     echo >> ${dest}
765     typeset -f postremove >> ${dest}
766     echo >> ${dest}
767     }
768    
769     regen_mage_tree()
770     {
771     local i
772    
773     # build them only if requested
774     if [[ ${REGEN_MAGE_TREE} = true ]]
775     then
776 niro 195 # run it without targets
777     if [ -z "${MAGE_TARGETS}" ]
778     then
779 niro 191 echo
780 niro 195 build_mage_script
781 niro 191 echo
782 niro 195 else
783    
784     # build for each target an mage file
785     # run it with several targets
786     for i in ${MAGE_TARGETS}
787     do
788     echo
789     build_mage_script "${i}"
790     echo
791     done
792     fi
793 niro 191 fi
794    
795     # now unset all uneeded vars to be safe
796 niro 192 # unset PKGNAME <-- don't do that; smage needs this var
797     # unset to be safe (quotes needed !)
798 niro 477 # for i in ${SPECIAL_FUNCTIONS}
799     # do
800     # unset "${i}"
801     # done
802 niro 192 unset SPECIAL_FUNCTIONS
803 niro 477 # for i in ${SPECIAL_VARS}
804     # do
805     # unset "${i}"
806     # done
807 niro 194 unset SPECIAL_VARS
808 niro 191 unset STATE
809     unset DESCRIPTION
810     unset HOMEPAGE
811     unset PKGTYPE
812     unset INHERITS
813     unset DEPEND
814     unset SDEPEND
815     unset PROVIDE
816     unset preinstall
817     unset postinstall
818     unset preremove
819     unset postremove
820     }
821    
822 niro 253 export_inherits()
823     {
824     local include="$1"
825     shift
826    
827     while [ "$1" ]
828     do
829     local functions="$1"
830    
831     # sanity checks
832     [ -z "${include}" ] && die "export_inherits(): \$include not given."
833     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
834    
835     eval "${functions}() { ${include}_${functions} ; }"
836    
837     # debug
838     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
839    
840     shift
841     done
842     }
843    
844 niro 255 generate_package_md5sum()
845     {
846     local dest
847     local pcat
848     local pname
849     local pver
850     local pbuild
851     local parch
852     local target
853     local pkgname
854    
855     # very basic getops
856     for i in $*
857     do
858     case $1 in
859     --pcat|-c) shift; pcat="$1" ;;
860     --pname|-n) shift; pname="$1" ;;
861     --pver|-v) shift; pver="$1" ;;
862     --pbuild|-b) shift; pbuild="$1" ;;
863     --parch|a) shift; parch="$1" ;;
864     --target|t) shift; target="$1" ;;
865     esac
866     shift
867     done
868    
869     # sanity checks; abort if not given
870     [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given."
871     [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given."
872     [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given."
873     [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given."
874     [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given."
875    
876     # check needed global vars
877     [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
878     [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
879    
880     # fix target as it may be empty !
881     [ -n "${target}" ] && target="-${target}"
882    
883     # build pkgname
884     pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
885    
886     # build pkg-md5-sum only if requested
887     if [[ ${REGEN_MAGE_TREE} = true ]]
888     then
889 niro 439 echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
890 niro 255
891     # abort if not exist
892     if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
893     then
894 niro 439 echo -e "${COLRED}! exists${COLDEFAULT}"
895 niro 255 return 0
896     fi
897    
898     # if MAGE_TREE_DEST not set use BUILDDIR
899     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
900    
901     # setup md5 dir
902     dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"
903     install -d ${dest}
904    
905     # gen md5sum
906     ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
907 niro 256 > ${dest}/${pkgname}.md5
908 niro 439 echo -e "${COLGREEN}done${COLDEFAULT}"
909 niro 255 fi
910     }
911    
912 niro 403 source_pkg_build()
913     {
914     if [[ ${PKGTYPE} = virtual ]]
915     then
916     echo "Virtual package detected; src-pkg-tarball not necessary ..."
917     return 0
918     fi
919    
920     if [[ ! -d ${SOURCEDIR}/${PNAME} ]]
921     then
922     echo "No SRC_URI defined; src-pkg-tarball not necessary ..."
923     return 0
924     fi
925    
926 niro 419 [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."
927 niro 406
928 niro 403 echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"
929 niro 412
930     # include the smage2 file
931     cp ${SMAGENAME} ${SOURCEDIR}/${PNAME}
932    
933 niro 403 ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; )
934 niro 406 [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR}
935     mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}
936 niro 403
937     echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
938     }
939    
940 niro 859 step_by_step()
941     {
942     if [[ ${STEP_BY_STEP} = true ]]
943     then
944     echo "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
945     echo "Press [enter] to continue"
946     read
947     fi
948     }
949 niro 403
950 niro 859
951 niro 59 # print out our version
952     showversion
953     echo
954    
955 niro 24 if [ -z "$1" ]
956     then
957     echo "No .smage2 file given. Exiting."
958     echo
959     exit 1
960     fi
961    
962 niro 192 # updating smage2-scripts
963 niro 306 if [[ $1 = update ]]
964 niro 24 then
965 niro 59 if [ ! -d ${SOURCEDIR} ]
966     then
967     install -d ${SOURCEDIR}
968     fi
969     syncsmage2
970     exit 0
971     fi
972    
973 niro 192 # creates md5sums for smages to given dir
974 niro 306 if [[ $1 = calcmd5 ]]
975 niro 59 then
976     if [ $# -ge 3 ]
977     then
978     SMAGENAME="$2"
979     MD5DIR="$3"
980     source ${SMAGENAME} || die "download source failed"
981    
982 niro 66 # overridable sourcedir; must be declared after source of the smage2
983     CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
984    
985 niro 59 [ -z "${SRC_URI}" ] && die "Nothing declared to calculate."
986    
987     # end of array
988     EOA=${#SRC_URI[*]}
989    
990     [ ! -d ${MD5DIR} ] && install -d ${MD5DIR}
991    
992     # clear md5sum file
993     MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
994     echo -n > ${MY_MD5_FILE}
995    
996     for ((i=0; i < EOA; i++))
997     do
998 niro 66 # url to file
999     my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
1000    
1001     # subdir in sources dir; the my_SRCI_URI file goes to there
1002     my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
1003    
1004     # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
1005     if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
1006     then
1007     MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})"
1008     else
1009     MY_SRC_FILE="$(basename ${SRC_URI[${i}]})"
1010     fi
1011    
1012 niro 59 if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ]
1013     then
1014     echo "calculating $(basename ${MY_SRC_FILE}) ..."
1015     ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE}
1016     else
1017     echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}."
1018     fi
1019 niro 66
1020     # unset them to be shure
1021     unset my_SRC_URI
1022     unset my_SRC_URI_DEST
1023     unset my_SRC_URI_MIRROR
1024     unset my_SOURCEDIR
1025 niro 59 done
1026 niro 306
1027 niro 59 echo
1028     echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
1029     echo
1030     else
1031     echo "Usage: Calculating MD5 Sums:"
1032     echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"
1033     echo
1034     echo
1035     echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
1036     echo
1037     exit 1
1038     fi
1039 niro 306
1040 niro 59 exit 0
1041     fi
1042    
1043 niro 192 # download sources
1044 niro 59 if [ "$1" == "download" -a -n "$2" ]
1045     then
1046 niro 24 if [ ! -d ${SMAGESCRIPTSDIR} ]
1047     then
1048     install -d ${SMAGESCRIPTSDIR}
1049     fi
1050 niro 59
1051     # get smage
1052     SMAGENAME="$2"
1053     MD5DIR="$(dirname ${SMAGENAME})/md5"
1054     source ${SMAGENAME} || die "download source failed"
1055    
1056     download_sources
1057 niro 24 exit 0
1058     fi
1059    
1060 niro 202 # regen-mage-tree
1061     if [ "$1" == "only-regen-tree" -a -n "$2" ]
1062     then
1063     # set correct SMAGENAME
1064     SMAGENAME="$2"
1065     MD5DIR="$(dirname ${SMAGENAME})/md5"
1066     source ${SMAGENAME} || die "regen: smage2 not found"
1067    
1068     regen_mage_tree
1069 niro 255
1070     # build md5sum for existing packages
1071     generate_package_md5sum \
1072     --pcat "${PCATEGORIE}" \
1073     --pname "${PNAME}" \
1074     --pver "${PVER}" \
1075     --pbuild "${PBUILD}" \
1076     --parch "${ARCH}" \
1077     --target "${target}"
1078    
1079 niro 202 exit 0
1080     fi
1081    
1082 niro 412 if [ "$1" == "--create-src-tarball" -a -n "$2" ]
1083 niro 403 then
1084     # set correct SMAGENAME
1085     SMAGENAME="$2"
1086     MD5DIR="$(dirname ${SMAGENAME})/md5"
1087    
1088 niro 412 echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1089 niro 403
1090     source ${SMAGENAME} || die "regen: smage2 not found"
1091    
1092     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1093     then
1094     echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1095     rm -rf ${SOURCEDIR}/${PKGNAME}
1096     fi
1097    
1098     download_sources
1099     source_pkg_build ${SMAGENAME}
1100     exit 0
1101     fi
1102    
1103 niro 406 if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1104 niro 403 then
1105 niro 412 SRCPKGTARBALL="${2}"
1106 niro 403 USE_SRC_PKG_TARBALL=true
1107    
1108 niro 412 # abort if given file is not a source pkg
1109     [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
1110    
1111     # set correct SMAGENAME; use the one that the src_pkg provide
1112     # /path/to/SOURCEDIR/PNAME/SMAGENAME
1113     SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}"
1114    
1115 niro 403 echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}"
1116    
1117     [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR}
1118    
1119     # unpack srctarball
1120     [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting."
1121    
1122     tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}"
1123 niro 412
1124     [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"
1125 niro 403 fi
1126    
1127    
1128 niro 306 [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
1129     [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
1130     die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
1131 niro 419 [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
1132     [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly."
1133     [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly."
1134     [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}"
1135     [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}"
1136     [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1137     [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1138 niro 24
1139     source ${SMAGENAME} || die "source failed"
1140 niro 255 PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1141 niro 59 MD5DIR="$(dirname ${SMAGENAME})/md5"
1142 niro 24
1143     xtitle "Compiling ${PKGNAME}"
1144 niro 439 echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1145 niro 59
1146 niro 191 # auto regen mage tree if requested
1147     regen_mage_tree
1148    
1149 niro 403 if [[ ${CREATE_SRC_PKG_TARBALL} = true ]]
1150     then
1151     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1152     then
1153 niro 441 echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1154 niro 408 rm -rf ${SOURCEDIR}/${PNAME}
1155 niro 403 fi
1156     fi
1157    
1158 niro 192 # download sources
1159 niro 403 [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources
1160 niro 59
1161 niro 192 # fixes some issues with these functions
1162 niro 24 export -f src_prepare || die "src_prepare export failed"
1163     export -f src_compile || die "src_compile export failed"
1164     export -f src_install || die "src_install export failed"
1165    
1166 niro 192 # fixes some compile issues
1167 niro 24 export CHOST="${CHOST}" || die "CHOST export failed"
1168     export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
1169     export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
1170     export BINDIR="${BINDIR}" || die "BINDIR export failed"
1171     export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
1172    
1173    
1174 niro 192 # setup distcc
1175 niro 351 # setup for distcc goes *before* ccache, so ccache comes before distcc in path
1176 niro 306 [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment
1177 niro 24
1178 niro 192 # setup ccache
1179 niro 306 [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
1180 niro 24
1181     # small sleep to show our settings
1182     sleep 1
1183    
1184 niro 192 # cleans up build if a previously one exists
1185 niro 24 if [ -d ${BUILDDIR} ]
1186     then
1187     rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1188     fi
1189     install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1190    
1191 niro 192 # cleans up srcdir if a previously unpacked one exists
1192 niro 24 if [ -d ${SRCDIR} ]
1193     then
1194     rm -rf ${SRCDIR}
1195     fi
1196    
1197 niro 192 # cleans up bindir if a previous build exists or creates a new one
1198 niro 24 if [ -d ${BINDIR} ]
1199     then
1200     rm -rf ${BINDIR}
1201     fi
1202     install -d ${BINDIR} || die "couldn't create \$BINDIR."
1203    
1204 niro 192 # cleans up package temp dir if a previous build exists
1205 niro 24 if [ -d ${BUILDDIR}/${PKGNAME} ]
1206     then
1207     rm -rf ${BUILDDIR}/${PKGNAME}
1208     fi
1209    
1210 niro 192 # cleans up timestamp if one exists
1211 niro 24 if [ -f /var/tmp/timestamp ]
1212     then
1213     mage rmstamp
1214     fi
1215    
1216     src_prepare || die "src_prepare failed"
1217 niro 859 step_by_step $_
1218 niro 24 src_compile || die "src_compile failed"
1219 niro 859 step_by_step $_
1220 niro 24 src_install || die "src_install failed"
1221 niro 859 step_by_step $_
1222 niro 24
1223    
1224 niro 192 # compressing doc, info & man files
1225 niro 24 if [ -d ${BUILDDIR}/builded/usr/share/man ]
1226     then
1227 niro 439 echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
1228 niro 24 ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man
1229     fi
1230    
1231     if [ -d ${BUILDDIR}/builded/usr/share/info ]
1232     then
1233 niro 439 echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
1234 niro 24 ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info
1235     fi
1236    
1237 niro 79 # stripping all bins and libs
1238     case ${NOSTRIP} in
1239     true|TRUE|yes|y)
1240     echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1241     ;;
1242     *)
1243 niro 439 echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1244 niro 79 mstripbins ${BINDIR}
1245 niro 439 echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1246 niro 79 mstriplibs ${BINDIR}
1247     ;;
1248     esac
1249    
1250 niro 192 # the new buildpkg command
1251 niro 24 case ${NOPKGBUILD} in
1252     true|TRUE|yes|y)
1253     echo -e "NOPGKBUILD=true detected; Package will not be build ..."
1254     ;;
1255 niro 192 *)
1256 niro 306 # build several targets
1257 niro 192 if [ -n "${MAGE_TARGETS}" ]
1258     then
1259     for target in ${MAGE_TARGETS}
1260     do
1261     # check if an special target_pkgbuild exists
1262     if typeset -f ${target}_pkgbuild > /dev/null
1263     then
1264     # run it
1265     ${target}_pkgbuild
1266     fi
1267     # now create the target package
1268     ${MLIBDIR}/pkgbuild_dir.sh \
1269 niro 255 "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \
1270 niro 192 ${BINDIR} || die "target: ${target} 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     --target "${target}"
1280    
1281 niro 439 echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1282 niro 192 done
1283     else
1284     ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1285 niro 255
1286     # build pkg-md5-sum if requested
1287     generate_package_md5sum \
1288     --pcat "${PCATEGORIE}" \
1289     --pname "${PNAME}" \
1290     --pver "${PVER}" \
1291     --pbuild "${PBUILD}" \
1292     --parch "${ARCH}"
1293    
1294 niro 439 echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1295 niro 192 fi
1296 niro 403
1297     # build src-pkg-tarball if requested
1298     [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME}
1299 niro 24 ;;
1300     esac
1301    
1302 niro 192 # for sure
1303 niro 24 unset NOPKGBUILD
1304 niro 85 unset NOSTRIP
1305 niro 351
1306 niro 24 xtitleclean

Properties

Name Value
svn:executable *