Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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

Properties

Name Value
svn:executable *