Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *