Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 597 - (hide annotations) (download) (as text)
Mon Nov 5 16:47:10 2007 UTC (16 years, 6 months ago) by niro
File MIME type: application/x-sh
File size: 30375 byte(s)
-support more unpack methods: .rar .zip .gz .bz2 .rpm

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

Properties

Name Value
svn:executable *