Magellan Linux

Annotation of /branches/mage-next/src/smage2.in

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *