Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1635 - (hide annotations) (download) (as text)
Fri Jan 13 13:26:43 2012 UTC (12 years, 4 months ago) by niro
Original Path: trunk/mage/usr/lib/mage/smage2.sh
File MIME type: application/x-sh
File size: 45479 byte(s)
-fixed wrong feature name srcpkg -> srcpkgbuild
1 niro 24 #!/bin/bash
2 niro 1571 # $Id$
3 niro 24
4     # compiles/installs .smage2 source install scripts
5     # needs pkgbuild_dir (mage)
6    
7 niro 1571 # TODO: record dynlib, gz | xz database
8 niro 24
9    
10 niro 419 # set default user mage.rc
11     : ${MAGERC="/etc/mage.rc"}
12    
13 niro 169 # export default C locale
14     export LC_ALL=C
15    
16 niro 439 source /etc/mage.rc.global
17 niro 419 source ${MAGERC}
18 niro 1273 source ${MLIBDIR}/mage4.functions.sh
19 niro 24
20 niro 1589 ## setup ##
21     SMAGENAME="$1"
22     SMAGEVERSION="$(< ${MLIBDIR}/version)"
23    
24 niro 347 # set PKGDIR and BUILDDIR and BINDIR to MROOT
25     if [[ -n ${MROOT} ]]
26     then
27     export PKGDIR=${MROOT}/${PKGDIR}
28     export BUILDDIR=${MROOT}/${BUILDDIR}
29     export BINDIR=${MROOT}/${BINDIR}
30     fi
31    
32 niro 1346 # sources the smage file and uses state from distribution file if exist
33     # may helpful for repository support later on
34     smagesource()
35     {
36     local file="$1"
37     local mystate
38     local mycodename
39    
40     source ${file}
41    
42     [[ -n ${STATE} ]] && mystate="${STATE}"
43 niro 1349
44     # do not overide if local state was broken or disabled!
45     case ${STATE} in
46     broken) return ;;
47     disabled) return ;;
48     esac
49    
50 niro 1346 if [ -f ${SMAGESCRIPTSDIR}/distribution ]
51     then
52     source ${SMAGESCRIPTSDIR}/distribution
53     [[ -n ${STATE} ]] && mystate="${STATE}"
54     fi
55     # now switch state and export it
56     STATE="${mystate}"
57     }
58    
59 niro 306 showversion()
60     {
61 niro 24 echo -en "Magellan Source Install v${SMAGEVERSION} "
62     echo -e "-- Niels Rogalla (niro@magellan-linux.de)"
63     }
64    
65 niro 306 die()
66     {
67 niro 24 xtitleclean
68 niro 413 echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
69 niro 24 echo "SMAGE failed: $@"
70     exit 1
71     }
72    
73 niro 941 die_pipestatus()
74     {
75 niro 943 # the status change if we do any parameter declarations!!
76     # dont do this anymore, keep this in mind!
77     #
78     # local pos="$1"
79     # local comment="$2"
80     #
81     # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}"
82     #
83     [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2"
84 niro 941 }
85    
86 niro 306 xtitle()
87     {
88     if [[ ${TERM} = xterm ]]
89 niro 24 then
90     echo -ne "\033]0;[sMage: $@]\007"
91     fi
92     return 0
93     }
94    
95 niro 306 xtitleclean()
96     {
97     if [[ ${TERM} = xterm ]]
98 niro 24 then
99     echo -ne "\033]0;\007"
100     fi
101     return 0
102     }
103    
104 niro 306 syncsmage2()
105     {
106 niro 24 xtitle "Updating smage2-script tree ..."
107     local i
108     for i in ${SMAGE2RSYNC}
109     do
110 niro 386 rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR}
111 niro 306 if [[ $? = 0 ]]
112 niro 24 then
113     break
114     else
115     continue
116     fi
117     done
118 niro 306
119     # clean up backup files (foo~)
120 niro 24 find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'
121 niro 306
122 niro 24 xtitleclean
123     }
124    
125 niro 59 # $1 filename
126 niro 306 get_db_md5_sum()
127     {
128 niro 59 local DB_FILE
129     local MD5_FILE
130     local i
131    
132     DB_ENTRY="$(basename $1)"
133     MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})"
134    
135     i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)"
136    
137     echo "${i}"
138     }
139    
140 niro 306 download_sources()
141     {
142 niro 61 [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
143 niro 59
144 niro 1580 local count=${#SRC_URI[*]}
145     local uri
146     local subdir
147     local outputdir
148     local db_md5_file="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
149     local fetching
150     local i
151 niro 59
152     # check if FETCHING is needed
153 niro 1580 if mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5
154 niro 59 then
155 niro 439 # md5's ok, no fetching needed
156 niro 1580 fetching=false
157 niro 59 else
158 niro 1580 fetching=true
159 niro 59 fi
160 niro 306
161 niro 1580 if [[ ${fetching} = true ]]
162     then
163     for ((i=0; i < count; i++))
164     do
165     # url to file
166     uri="${SRC_URI[${i}]%%' '*}"
167 niro 59
168 niro 1580 # subdir in sources dir; the my_SRCI_URI file goes to there
169     subdir="${SRC_URI[${i}]##*' '}"
170 niro 66
171 niro 1580 # if $subdir is not equal with $uri then an other dir is used
172     if [[ ${uri} != ${subdir} ]]
173 niro 59 then
174 niro 1580 outputdir="${SOURCEDIR}/${PNAME}/${subdir}"
175     else
176     outputdir="${SOURCEDIR}/${PNAME}"
177 niro 59 fi
178 niro 306
179 niro 1580 echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}"
180 niro 1630 # always use verbose mode for source downloads
181     FVERBOSE=off msetfeature "verbose"
182 niro 1600 # do not die here, mchecksum catches download errors
183     mdownload --uri "${uri}" --dir "${outputdir}"
184 niro 59
185 niro 1580 # unset them to be sure
186     unset uri
187     unset subdir
188     unset outputdir
189     done
190 niro 59
191 niro 1580 # recheck md5 sums after download
192     echo
193     echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
194     mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed"
195     echo
196     else
197     echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}"
198     fi
199    
200 niro 59 # not needed anymore
201     unset SRC_URI
202     }
203    
204 niro 1573 # dummy function, used if that does not exist in smage file
205 niro 306 src_prepare()
206     {
207 niro 1592 echo "no src_prepare defined; doing nothing ..."
208 niro 24 return 0
209     }
210    
211 niro 1573 # dummy function, used if that does not exist in smage file
212 niro 1577 src_compile()
213 niro 1575 {
214 niro 1591 echo "no src_compile defined; doing nothing ..."
215 niro 1575 return 0
216     }
217    
218     # dummy function, used if that does not exist in smage file
219 niro 1577 src_check()
220 niro 306 {
221 niro 1591 echo "no src_check defined; doing nothing ..."
222 niro 24 return 0
223     }
224    
225 niro 1573 # dummy function, used if that does not exist in smage file
226 niro 306 src_install()
227     {
228 niro 1591 echo "no src_install defined; doing nothing ..."
229 niro 24 return 0
230     }
231    
232 niro 351 mlibdir()
233     {
234     local libdir=lib
235     [[ ${ARCH} = x86_64 ]] && libdir=lib64
236    
237     echo "${libdir}"
238     }
239    
240 niro 306 mconfigure()
241     {
242 niro 1613 local myopts
243     if [[ ! -z ${CTARGET} ]]
244     then
245 niro 1631 myopts+=" --target=${CTARGET}"
246 niro 1613 fi
247 niro 1632
248     if [ -x ./configure ]
249     then
250 niro 1631 # if requested disable-static
251     if [[ ! -z $(./configure --help | grep -- '--.*able-static') ]]
252     then
253     if mqueryfeature '!static'
254     then
255     myopts+=" --disable-static"
256     else
257     myopts+=" --enable-static"
258     fi
259     fi
260 niro 1613
261 niro 1631 # always enable shared by default
262     if [[ ! -z $(./configure --help | grep -- '--.*able-shared') ]]
263     then
264     myopts+=" --enable-shared"
265     fi
266    
267 niro 306 ./configure \
268     --prefix=/usr \
269     --host=${CHOST} \
270 niro 833 --build=${CHOST} \
271 niro 306 --mandir=/usr/share/man \
272     --infodir=/usr/share/info \
273     --datadir=/usr/share \
274     --sysconfdir=/etc \
275     --localstatedir=/var/lib \
276 niro 351 --libdir=/usr/$(mlibdir) \
277 niro 1613 ${myopts} \
278 niro 306 "$@" || die "mconfigure failed"
279 niro 24 else
280     echo "configure is not an executable ..."
281     exit 1
282     fi
283     }
284    
285 niro 306 minstall()
286     {
287     if [ -f ./[mM]akefile -o -f ./GNUmakefile ]
288     then
289 niro 24 make prefix=${BINDIR}/usr \
290     datadir=${BINDIR}/usr/share \
291     infodir=${BINDIR}/usr/share/info \
292     localstatedir=${BINDIR}/var/lib \
293     mandir=${BINDIR}/usr/share/man \
294     sysconfdir=${BINDIR}/etc \
295 niro 351 libdir=${BINDIR}/usr/$(mlibdir) \
296 niro 24 "$@" install || die "minstall failed"
297     else
298     die "no Makefile found"
299     fi
300     }
301    
302 niro 306 mmake()
303     {
304 niro 24 make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
305     }
306    
307 niro 306 munpack()
308     {
309 niro 24 local SRCFILE
310     local IFTAR
311     local DEST
312    
313     SRCFILE=$1
314 niro 306
315 niro 597 if [[ -z $2 ]]
316 niro 24 then
317     DEST=${BUILDDIR}
318     else
319     DEST=$2
320     fi
321 niro 306
322 niro 411 [[ ! -d ${DEST} ]] && install -d ${DEST}
323    
324 niro 24 case "${SRCFILE##*.}" in
325     bz2)
326     IFTAR="$(basename $SRCFILE .bz2)"
327     IFTAR="${IFTAR##*.}"
328 niro 306 if [[ ${IFTAR} = tar ]]
329 niro 24 then
330 niro 597 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed."
331     else
332     pushd ${DEST} > /dev/null
333     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
334     popd > /dev/null
335 niro 24 fi
336     ;;
337     gz)
338     IFTAR="$(basename $SRCFILE .gz)"
339     IFTAR="${IFTAR##*.}"
340 niro 306 if [[ ${IFTAR} = tar ]]
341 niro 24 then
342 niro 597 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed."
343     else
344     pushd ${DEST} > /dev/null
345     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
346     popd > /dev/null
347 niro 24 fi
348     ;;
349 niro 1351 xz)
350     IFTAR="$(basename $SRCFILE .xz)"
351     IFTAR="${IFTAR##*.}"
352     if [[ ${IFTAR} = tar ]]
353     then
354     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
355     else
356     pushd ${DEST} > /dev/null
357     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
358     popd > /dev/null
359     fi
360     ;;
361 niro 600 tbz2|mpks|mpk)
362 niro 597 tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
363 niro 24 ;;
364     tgz)
365 niro 597 tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
366 niro 24 ;;
367 niro 1351 txz|mpkzs|mpkz)
368     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
369     ;;
370 niro 597 rar)
371     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed."
372     ;;
373 niro 1604 zip|xpi|jar)
374 niro 597 unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
375     ;;
376     rpm)
377 niro 635 pushd ${DEST} > /dev/null
378 niro 597 rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
379 niro 602 tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
380 niro 635 if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
381 niro 602 then
382 niro 635 rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
383 niro 602 fi
384 niro 597 ;;
385 niro 24 *)
386     die "munpack failed"
387     ;;
388     esac
389     }
390    
391 niro 306 mpatch()
392     {
393 niro 24 local PATCHOPTS
394     local PATCHFILE
395 niro 447 local i
396 niro 24
397     PATCHOPTS=$1
398     PATCHFILE=$2
399    
400 niro 447 if [[ -z $2 ]]
401     then
402     PATCHFILE=$1
403    
404     ## patch level auto-detection, get patch level
405     for ((i=0; i < 10; i++))
406     do
407     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
408     if [[ $? = 0 ]]
409     then
410     PATCHOPTS="-Np${i}"
411     break
412     fi
413     done
414     fi
415    
416 niro 384 echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
417 niro 24 patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
418     }
419    
420 niro 497 mlibtoolize()
421     {
422     local opts="$@"
423 niro 1435 [[ -z ${opts} ]] && opts="--verbose --install --force"
424 niro 24
425 niro 497 libtoolize ${opts} || die "running: mlibtoolize ${opts}"
426     }
427    
428 niro 1291 mautoreconf()
429     {
430     local opts="$@"
431     [[ -z ${opts} ]] && opts="--verbose --install --force"
432    
433     autoreconf ${opts} || die "running: mautoreconf ${opts}"
434     }
435    
436 niro 306 minstalldocs()
437     {
438 niro 24 local docfiles
439 niro 1581 local doc
440 niro 24 docfiles="$@"
441 niro 306
442 niro 24 if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
443     then
444     install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
445     fi
446 niro 306
447 niro 1581 for doc in ${docfiles}
448 niro 24 do
449 niro 1581 if [ -f ${doc} ]
450 niro 953 then
451 niro 1584 if mqueryfeature "compressdoc"
452 niro 1581 then
453 niro 1615 cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "gzipping +installing ${doc}."
454     chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "fixing permissions of ${doc}."
455 niro 1581 else
456 niro 1633 install -m 0644 ${doc} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}."
457 niro 1581 fi
458 niro 953 fi
459 niro 24 done
460     }
461    
462 niro 306 mstriplibs()
463     {
464 niro 79 local stripdir="$@"
465    
466 niro 1578 [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
467     [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug"
468 niro 1634 find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null
469 niro 79 }
470    
471 niro 306 mstripbins()
472     {
473 niro 79 local stripdir="$@"
474    
475 niro 1578 [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
476     [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug"
477 niro 1634 find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null
478 niro 79 }
479    
480 niro 1543 mstripstatic()
481     {
482     local stripdir="$@"
483    
484 niro 1578 [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
485     [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug"
486 niro 1634 find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null
487 niro 1543 }
488    
489 niro 1580 mstriplibtoolarchive()
490     {
491     local stripdir="$@"
492    
493     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
494 niro 1634 find ${stripdir} ! -type d -name \*.la | xargs --no-run-if-empty file | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null
495 niro 1580 }
496    
497     mpurgetargets()
498     {
499     local stripdir="$@"
500     local target
501    
502     [[ -z ${stripdir} ]] && stripdir=${BINDIR}
503     # nothing to do in this case
504     [[ -z ${PURGE_TARGETS[*]} ]] && return
505    
506     for target in ${PURGE_TARGETS[*]}
507     do
508     # check if target is a regex pattern without any slashes
509     if [[ ${target} = ${target//\/} ]]
510     then
511     find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null
512     else
513     rm -f -- ${target} 2> /dev/null
514     fi
515     done
516     }
517    
518 niro 943 mcompressdocs()
519     {
520     local bindir="$@"
521    
522     if [ -d ${bindir}/usr/share/man ]
523     then
524     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
525     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
526     fi
527    
528     if [ -d ${bindir}/usr/share/info ]
529     then
530     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
531     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
532     fi
533     }
534    
535 niro 306 sminclude()
536     {
537 niro 172 local i
538    
539 niro 183 if [[ -n "$@" ]]
540 niro 172 then
541     for i in $@
542     do
543 niro 175 echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
544 niro 172 source ${SMAGESCRIPTSDIR}/include/${i}.sminc
545     done
546 niro 177 echo
547 niro 172 fi
548     }
549    
550 niro 306 setup_distcc_environment()
551     {
552 niro 24 if [ -x /usr/bin/distcc ]
553     then
554 niro 441 echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
555 niro 351 export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
556 niro 24
557     export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
558    
559 niro 306 # creating distcc tempdir
560 niro 24 install -o distcc -g daemon -d ${DISTCC_DIR}
561     chmod 1777 ${DISTCC_DIR}
562     fi
563     }
564    
565 niro 306 setup_ccache_environment()
566     {
567 niro 24 if [ -x /usr/bin/ccache ]
568     then
569 niro 441 echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
570 niro 351 export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
571 niro 24 fi
572     }
573    
574 niro 193 # fixes given dependencies to match a MAGE_TARGET
575 niro 198 # fix_mage_deps -target s/depend # <-- note -target !
576 niro 306 fix_mage_deps()
577     {
578 niro 193 local target="$1"
579     local depend="$2"
580     local NDEPEND
581     local sym dep cat pver pname
582    
583     # deps and provides are special
584     # they must be fixed to match the target
585    
586     # run this only if target and depend is not empty
587     if [ -n "${target}" ] && [ -n "${depend}" ]
588     then
589     # fix DEPEND
590     while read sym dep
591     do
592 niro 427 # ignore empty lines
593     [[ -z ${dep} ]] && continue
594    
595 niro 193 cat="$(dirname ${dep})"
596 niro 199 # change if not virtual
597 niro 200 if [[ ${cat} = virtual ]]
598 niro 199 then
599 niro 200 pname="$(basename ${dep})"
600     else
601 niro 199 # fix pver to target-pver
602     # to get pname-target-pver
603 niro 193
604 niro 199 # doing it backwards !
605     pver="${dep##*-}"
606 niro 200 # full pver
607     pname="$(basename ${dep/-${pver}/})${target}-${pver}"
608 niro 199 fi
609 niro 193
610     # do not add empty lines
611     if [ -z "${NDEPEND}" ]
612     then
613 niro 200 NDEPEND="${sym} ${cat}/${pname}"
614 niro 193 else
615     NDEPEND="${NDEPEND}
616 niro 201 ${sym} ${cat}/${pname}"
617 niro 193 fi
618    
619     unset cat pname pver
620     done << EOF
621     ${depend}
622     EOF
623     # set NDEPEND to DEPEND
624     depend="${NDEPEND}"
625     fi
626    
627     echo "${depend}"
628     }
629    
630 niro 192 # build_mage_script(): helper functions for regen_mage_tree()
631 niro 191 # generates an mage file with given information in smage file
632     # needs at least:
633     # PNAME name of pkg
634     # PVER version
635     # PBUILD revision
636     # PCATEGORIE categorie of the pkg
637     # STATE state of pkg stable|unstable|old
638     # DESCRIPTION va short description (opt)
639     # HOMEPAGE homepage (opt)
640     # DEPEND runtime dependencies (opt)
641     # SDEPEND add. needed deps to build the pkg (opt)
642     # PROVIDE provides a virtual (opt)
643     #
644     # special tags:
645     # PKGTYPE type of pkg
646     # INHERITS which functions get included
647 niro 832 # SPECIAL_FUNCTIONS special functions which should also be added
648 niro 191 # warning: they get killed before the build starts !
649 niro 943 # SPLIT_PACKAGES names of all subpackages which are splitted from parent
650     # SPLIT_PACKAGE_BASE base package name for splitpackages
651     # (only in the resulting magefile}
652 niro 191 #
653     # MAGE_TREE_DEST target destination of the generated tree
654     # REGEN_MAGE_TREE set to 'true' to enable this
655 niro 193 #
656 niro 195 # gets called with build_mage_script target
657 niro 192 build_mage_script()
658 niro 191 {
659     local magefile
660     local dest
661 niro 193 local target
662 niro 943 local split_pkg_base
663 niro 191 local sym
664     local depname
665    
666     # if MAGE_TREE_DEST not set use BUILDDIR
667     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
668    
669     # determinate which suffix this mage file should get, if any
670 niro 943 [[ $1 = --target ]] && shift && target="-$1"
671 niro 191
672 niro 943 # mark package as splitpackage
673     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
674    
675 niro 191 # name of magefile
676 niro 193 magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
677 niro 191
678     # destination to magefile
679 niro 193 dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
680 niro 191
681     # show what we are doing
682 niro 439 echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
683     echo "${dest}"
684 niro 191
685     install -d "$(dirname ${dest})"
686     # now build the mage file
687     > ${dest}
688    
689     # pgkname and state
690 niro 193 echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
691 niro 191 echo "STATE=\"${STATE}\"" >> ${dest}
692    
693     # description and homepage
694     echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
695     echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
696    
697 niro 196 # special tags and vars
698 niro 191 echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest}
699 niro 214
700     # echo MAGE_TARGETS ## note -target is needed !
701     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
702    
703 niro 943 # split package base
704     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
705    
706 niro 197 # add special vars
707     if [ -n "${SPECIAL_VARS}" ]
708 niro 191 then
709     local i
710 niro 197 for i in ${SPECIAL_VARS}
711 niro 191 do
712 niro 197 # being tricky here :)
713     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
714 niro 191 done
715     fi
716 niro 214
717 niro 197 # add at least all includes
718     if [ -n "${INHERITS}" ]
719 niro 196 then
720 niro 197 echo -n "minclude" >> ${dest}
721 niro 196 local i
722 niro 197 for i in ${INHERITS}
723 niro 196 do
724 niro 197 echo -n " ${i}" >> ${dest}
725 niro 196 done
726 niro 1351 # a CRLF is needed here!
727     echo >> ${dest}
728 niro 196 fi
729    
730 niro 191 # deps and provides
731 niro 193 echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
732     echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
733 niro 191 echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
734    
735     # add special functions
736     if [ -n "${SPECIAL_FUNCTIONS}" ]
737     then
738     local i
739     for i in ${SPECIAL_FUNCTIONS}
740     do
741     # add to mage (quotes needed !)
742     typeset -f "${i}" >> ${dest}
743     # unset to be safe (quotes needed !)
744 niro 192 #unset "${i}" <-- later to get every target built
745 niro 191 done
746     fi
747    
748     # pre|post-install|removes
749     typeset -f preinstall >> ${dest}
750     typeset -f postinstall >> ${dest}
751     typeset -f preremove >> ${dest}
752     typeset -f postremove >> ${dest}
753     }
754    
755     regen_mage_tree()
756     {
757 niro 1436 local subpackage
758 niro 191
759     # build them only if requested
760 niro 1584 if mqueryfeature regentree
761 niro 191 then
762 niro 195 # run it without targets
763 niro 943 if [[ -n ${MAGE_TARGETS} ]]
764 niro 195 then
765 niro 943 # build for each target a mage file
766     # run it with several targets
767 niro 191 echo
768 niro 1436 for subpackage in ${MAGE_TARGETS}
769 niro 943 do
770 niro 1436 build_mage_script --target "${subpackage}"
771 niro 943 done
772 niro 191 echo
773 niro 195
774 niro 943 # run it for splitpackages
775     elif [[ -n ${SPLIT_PACKAGES} ]]
776     then
777     local split_pkg_base="${PNAME}"
778     # save smage environment
779     split_save_variables
780     # build for each subpackage a mage file
781 niro 195 # run it with several targets
782 niro 943 echo
783 niro 1436 for subpackage in ${SPLIT_PACKAGES}
784 niro 195 do
785 niro 943 # get the right variables for the split
786 niro 1436 export PNAME="${subpackage}"
787     split_info_${subpackage}
788     # get the preinstall etc
789     split_export_inherits ${subpackage}
790 niro 943 build_mage_script --split-pkg-base "${split_pkg_base}"
791 niro 1436 # delete split preinstall etc
792     split_delete_inherits ${subpackage}
793 niro 951 # restore smage environment
794     split_restore_variables
795 niro 195 done
796 niro 943 echo
797 niro 951 # unset all saved smage variables
798     split_unset_variables
799 niro 943
800     else
801     echo
802     build_mage_script
803     echo
804 niro 195 fi
805 niro 191 fi
806    
807     # now unset all uneeded vars to be safe
808 niro 192 # unset PKGNAME <-- don't do that; smage needs this var
809     # unset to be safe (quotes needed !)
810 niro 477 # for i in ${SPECIAL_FUNCTIONS}
811     # do
812     # unset "${i}"
813     # done
814 niro 192 unset SPECIAL_FUNCTIONS
815 niro 477 # for i in ${SPECIAL_VARS}
816     # do
817     # unset "${i}"
818     # done
819 niro 194 unset SPECIAL_VARS
820 niro 191 unset STATE
821     unset DESCRIPTION
822     unset HOMEPAGE
823 niro 1594 # unset PKGTYPE <-- don't do that either; smage needs this var
824 niro 191 unset INHERITS
825     unset DEPEND
826     unset SDEPEND
827     unset PROVIDE
828     unset preinstall
829     unset postinstall
830     unset preremove
831     unset postremove
832     }
833    
834 niro 943 split_save_variables()
835     {
836     export SAVED_PNAME="${PNAME}"
837     export SAVED_PVER="${PVER}"
838     export SAVED_PBUILD="${PBUILD}"
839     export SAVED_PCATEGORIE="${PCATEGORIE}"
840     export SAVED_DESCRIPTION="${DESCRIPTION}"
841     export SAVED_HOMEPAGE="${HOMEPAGE}"
842     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
843     export SAVED_STATE="${STATE}"
844     export SAVED_PKGTYPE="${PKGTYPE}"
845     export SAVED_INHERITS="${INHERITS}"
846     export SAVED_DEPEND="${DEPEND}"
847     export SAVED_SDEPEND="${SDEPEND}"
848     export SAVED_PROVIDE="${PROVIDE}"
849 niro 1582 export SAVED_PKGTYPE="${PKGTYPE}"
850 niro 943
851 niro 1584 # special handling needed for mage features
852     # pkgbuild
853     mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild"
854     mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild"
855     # strip
856     mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip"
857     mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip"
858     # libtool
859     mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool"
860     mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool"
861     # compressdoc
862     mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc"
863     mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc"
864    
865 niro 945 # bindir too
866     export SAVED_BINDIR="${BINDIR}"
867    
868     # export the SPLIT_PACKAGE_BASE
869     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
870    
871 niro 943 # functions
872     if [[ ! -z $(typeset -f preinstall) ]]
873     then
874     # rename the old one
875     local saved_preinstall
876     saved_preinstall=SAVED_$(typeset -f preinstall)
877     eval "${saved_preinstall}"
878     export -f SAVED_preinstall
879     fi
880    
881     if [[ ! -z $(typeset -f postinstall) ]]
882     then
883     # rename the old one
884     local saved_postinstall
885     saved_postinstall=SAVED_$(typeset -f postinstall)
886     eval "${saved_postinstall}"
887     export -f SAVED_postinstall
888     fi
889    
890     if [[ ! -z $(typeset -f preremove) ]]
891     then
892     # rename the old one
893     local saved_preremove
894     saved_preremove=SAVED_$(typeset -f preremove)
895     eval "${saved_preremove}"
896     export -f SAVED_preremove
897     fi
898    
899     if [[ ! -z $(typeset -f postremove) ]]
900     then
901     # rename the old one
902     local saved_postremove
903     saved_postremove=SAVED_$(typeset -f postremove)
904     eval "${saved_postremove}"
905     export -f SAVED_postremove
906     fi
907     }
908    
909     split_restore_variables()
910     {
911     export PNAME="${SAVED_PNAME}"
912     export PVER="${SAVED_PVER}"
913     export PBUILD="${SAVED_PBUILD}"
914     export PCATEGORIE="${SAVED_PCATEGORIE}"
915     export DESCRIPTION="${SAVED_DESCRIPTION}"
916     export HOMEPAGE="${SAVED_HOMEPAGE}"
917     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
918     export STATE="${SAVED_STATE}"
919     export PKGTYPE="${SAVED_PKGTYPE}"
920     export INHERITS="${SAVED_INHERITS}"
921     export DEPEND="${SAVED_DEPEND}"
922     export SDEPEND="${SAVED_SDEPEND}"
923     export PROVIDE="${SAVED_PROVIDE}"
924 niro 1582 export PKGTYPE="${SAVED_PKGTYPE}"
925 niro 943
926 niro 1584 # special handling needed for mage features
927     # pkgbuild
928 niro 1614 FVERBOSE=off msetfeature "${SAVED_FEATURE_PKGBUILD}"
929 niro 1584 # strip
930 niro 1614 FVERBOSE=off msetfeature "${SAVED_FEATURE_STRIP}"
931 niro 1584 # libtool
932 niro 1614 FVERBOSE=off msetfeature "${SAVED_FEATURE_LIBTOOL}"
933 niro 1584 # compressdoc
934 niro 1614 FVERBOSE=off msetfeature "${SAVED_FEATURE_COMPRESSDOC}"
935 niro 1584
936 niro 945 # bindir too
937     export BINDIR="${SAVED_BINDIR}"
938    
939 niro 943 # functions
940     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
941     then
942     # rename the old one
943     local saved_preinstall
944     saved_preinstall=$(typeset -f SAVED_preinstall)
945     eval "${saved_preinstall/SAVED_/}"
946     export -f preinstall
947     fi
948    
949     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
950     then
951     # rename the old one
952     local saved_postinstall
953     saved_postinstall=$(typeset -f SAVED_postinstall)
954     eval "${saved_postinstall/SAVED_/}"
955     export -f postinstall
956     fi
957    
958     if [[ ! -z $(typeset -f SAVED_preremove) ]]
959     then
960     # rename the old one
961     local saved_preremove
962     saved_preremove=$(typeset -f SAVED_preremove)
963     eval "${saved_preremove/SAVED_/}"
964     export -f preremove
965     fi
966    
967     if [[ ! -z $(typeset -f SAVED_postremove) ]]
968     then
969     # rename the old one
970     local saved_postremove
971     saved_postremove=$(typeset -f SAVED_postremove)
972     eval "${saved_postremove/SAVED_/}"
973     export -f postremove
974     fi
975 niro 951 }
976 niro 943
977 niro 951 split_unset_variables()
978     {
979 niro 943 # unset saved vars; not needed anymore
980     unset SAVED_PNAME
981     unset SAVED_PVER
982     unset SAVED_PBUILD
983     unset SAVED_PCATEGORIE
984     unset SAVED_DESCRIPTION
985     unset SAVED_HOMEPAGE
986     unset SAVED_SPECIAL_VARS
987     unset SAVED_STATE
988     unset SAVED_PKGTYPE
989     unset SAVED_INHERITS
990     unset SAVED_DEPEND
991     unset SAVED_SDEPEND
992     unset SAVED_PROVIDE
993 niro 945 unset SAVED_BINDIR
994 niro 1582 unset SAVED_PKGTYPE
995 niro 1584 unset SAVED_FEATURE_PKGBUILD
996     unset SAVED_FEATURE_STRIP
997     unset SAVED_FEATURE_LIBTOOL
998     unset SAVED_FEATURE_COMPRESSDOC
999 niro 945 unset SPLIT_PACKAGE_BASE
1000 niro 943 unset -f SAVED_preinstall
1001     unset -f SAVED_postinstall
1002     unset -f SAVED_preremove
1003     unset -f SAVED_postremove
1004     }
1005    
1006 niro 1436 split_export_inherits()
1007     {
1008     local subpackage="$1"
1009     local func
1010     local newfunc
1011    
1012     for func in preinstall postinstall preremove postremove
1013     do
1014     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1015     then
1016     newfunc=$(typeset -f ${func}_${subpackage})
1017     newfunc="${newfunc/_${subpackage} (/ (}"
1018     eval "${newfunc}"
1019     fi
1020     done
1021     }
1022    
1023     split_delete_inherits()
1024     {
1025     local subpackage="$1"
1026     local func
1027    
1028     for func in preinstall postinstall preremove postremove
1029     do
1030     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1031     then
1032     unset -f ${func}
1033     fi
1034     done
1035     }
1036    
1037 niro 253 export_inherits()
1038     {
1039     local include="$1"
1040     shift
1041    
1042     while [ "$1" ]
1043     do
1044     local functions="$1"
1045    
1046     # sanity checks
1047     [ -z "${include}" ] && die "export_inherits(): \$include not given."
1048     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
1049    
1050     eval "${functions}() { ${include}_${functions} ; }"
1051    
1052     # debug
1053     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
1054    
1055     shift
1056     done
1057     }
1058    
1059 niro 255 generate_package_md5sum()
1060     {
1061     local dest
1062     local pcat
1063     local pname
1064     local pver
1065     local pbuild
1066     local parch
1067     local target
1068     local pkgname
1069    
1070     # very basic getops
1071     for i in $*
1072     do
1073     case $1 in
1074     --pcat|-c) shift; pcat="$1" ;;
1075     --pname|-n) shift; pname="$1" ;;
1076     --pver|-v) shift; pver="$1" ;;
1077     --pbuild|-b) shift; pbuild="$1" ;;
1078     --parch|a) shift; parch="$1" ;;
1079     --target|t) shift; target="$1" ;;
1080     esac
1081     shift
1082     done
1083    
1084     # sanity checks; abort if not given
1085     [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given."
1086     [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given."
1087     [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given."
1088     [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given."
1089     [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given."
1090    
1091     # check needed global vars
1092     [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
1093     [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
1094    
1095     # fix target as it may be empty !
1096     [ -n "${target}" ] && target="-${target}"
1097    
1098     # build pkgname
1099     pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1100    
1101     # build pkg-md5-sum only if requested
1102 niro 1584 if mqueryfeature regentree
1103 niro 255 then
1104 niro 439 echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
1105 niro 255
1106     # abort if not exist
1107     if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
1108     then
1109 niro 439 echo -e "${COLRED}! exists${COLDEFAULT}"
1110 niro 255 return 0
1111     fi
1112    
1113     # if MAGE_TREE_DEST not set use BUILDDIR
1114     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1115    
1116     # setup md5 dir
1117 niro 891 dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1118 niro 255 install -d ${dest}
1119    
1120     # gen md5sum
1121     ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
1122 niro 256 > ${dest}/${pkgname}.md5
1123 niro 439 echo -e "${COLGREEN}done${COLDEFAULT}"
1124 niro 255 fi
1125     }
1126    
1127 niro 403 source_pkg_build()
1128     {
1129     if [[ ${PKGTYPE} = virtual ]]
1130     then
1131     echo "Virtual package detected; src-pkg-tarball not necessary ..."
1132     return 0
1133     fi
1134    
1135     if [[ ! -d ${SOURCEDIR}/${PNAME} ]]
1136     then
1137     echo "No SRC_URI defined; src-pkg-tarball not necessary ..."
1138     return 0
1139     fi
1140    
1141 niro 419 [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."
1142 niro 406
1143 niro 403 echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"
1144 niro 412
1145     # include the smage2 file
1146     cp ${SMAGENAME} ${SOURCEDIR}/${PNAME}
1147    
1148 niro 403 ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; )
1149 niro 406 [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR}
1150     mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}
1151 niro 403
1152     echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
1153     }
1154    
1155 niro 859 step_by_step()
1156     {
1157 niro 1584 if mqueryfeature stepbystep
1158 niro 859 then
1159 niro 945 echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1160 niro 859 echo "Press [enter] to continue"
1161     read
1162     fi
1163     }
1164 niro 403
1165 niro 1617 resume_stamp()
1166     {
1167     local step="$1"
1168 niro 1621 [[ ! -d ${BUILDDIR}/.stamps ]] && install -d ${BUILDDIR}/.stamps
1169     touch ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step}
1170 niro 1617 }
1171 niro 859
1172 niro 1617 run_resume()
1173     {
1174     local step="$1"
1175    
1176 niro 1621 if mqueryfeature "resume" && [[ -f ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step} ]]
1177 niro 1617 then
1178     echo -e "${COLMAGENTA}${step} already processed; doing nothing${COLDEFAULT}"
1179     return 0
1180     else
1181     return 1
1182     fi
1183     }
1184    
1185 niro 59 # print out our version
1186     showversion
1187     echo
1188    
1189 niro 24 if [ -z "$1" ]
1190     then
1191     echo "No .smage2 file given. Exiting."
1192     echo
1193     exit 1
1194     fi
1195    
1196 niro 1584 # load supported mage features
1197     load_mage_features
1198    
1199 niro 192 # updating smage2-scripts
1200 niro 306 if [[ $1 = update ]]
1201 niro 24 then
1202 niro 59 if [ ! -d ${SOURCEDIR} ]
1203     then
1204     install -d ${SOURCEDIR}
1205     fi
1206     syncsmage2
1207     exit 0
1208     fi
1209    
1210 niro 192 # creates md5sums for smages to given dir
1211 niro 306 if [[ $1 = calcmd5 ]]
1212 niro 59 then
1213 niro 1207 if [ $# -ge 2 ]
1214 niro 59 then
1215     SMAGENAME="$2"
1216     MD5DIR="$3"
1217 niro 1207 [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1218    
1219 niro 1346 smagesource ${SMAGENAME} || die "download source failed"
1220 niro 59
1221 niro 66 # overridable sourcedir; must be declared after source of the smage2
1222     CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
1223    
1224 niro 59 [ -z "${SRC_URI}" ] && die "Nothing declared to calculate."
1225    
1226     # end of array
1227     EOA=${#SRC_URI[*]}
1228    
1229     [ ! -d ${MD5DIR} ] && install -d ${MD5DIR}
1230    
1231     # clear md5sum file
1232     MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
1233     echo -n > ${MY_MD5_FILE}
1234    
1235     for ((i=0; i < EOA; i++))
1236     do
1237 niro 66 # url to file
1238     my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"
1239    
1240     # subdir in sources dir; the my_SRCI_URI file goes to there
1241     my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"
1242    
1243     # if my_src_uri_dest is not equal my_src_uri; than an other dir is used
1244     if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]
1245     then
1246     MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})"
1247     else
1248     MY_SRC_FILE="$(basename ${SRC_URI[${i}]})"
1249     fi
1250    
1251 niro 59 if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ]
1252     then
1253     echo "calculating $(basename ${MY_SRC_FILE}) ..."
1254     ( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE}
1255     else
1256     echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}."
1257     fi
1258 niro 66
1259     # unset them to be shure
1260     unset my_SRC_URI
1261     unset my_SRC_URI_DEST
1262     unset my_SRC_URI_MIRROR
1263     unset my_SOURCEDIR
1264 niro 59 done
1265 niro 306
1266 niro 59 echo
1267     echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
1268     echo
1269     else
1270     echo "Usage: Calculating MD5 Sums:"
1271 niro 1207 echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1272 niro 59 echo
1273     echo
1274     echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
1275     echo
1276     exit 1
1277     fi
1278 niro 306
1279 niro 59 exit 0
1280     fi
1281    
1282 niro 192 # download sources
1283 niro 59 if [ "$1" == "download" -a -n "$2" ]
1284     then
1285 niro 24 if [ ! -d ${SMAGESCRIPTSDIR} ]
1286     then
1287     install -d ${SMAGESCRIPTSDIR}
1288     fi
1289 niro 59
1290     # get smage
1291     SMAGENAME="$2"
1292     MD5DIR="$(dirname ${SMAGENAME})/md5"
1293 niro 1346 smagesource ${SMAGENAME} || die "download source failed"
1294 niro 59
1295     download_sources
1296 niro 24 exit 0
1297     fi
1298    
1299 niro 202 # regen-mage-tree
1300     if [ "$1" == "only-regen-tree" -a -n "$2" ]
1301     then
1302     # set correct SMAGENAME
1303     SMAGENAME="$2"
1304     MD5DIR="$(dirname ${SMAGENAME})/md5"
1305 niro 1346 smagesource ${SMAGENAME} || die "regen: smage2 not found"
1306 niro 202
1307     regen_mage_tree
1308 niro 255
1309 niro 890 # build several targets
1310 niro 943 if [[ -n ${MAGE_TARGETS} ]]
1311 niro 890 then
1312     for target in ${MAGE_TARGETS}
1313     do
1314     # build md5sum for existing packages
1315     generate_package_md5sum \
1316     --pcat "${PCATEGORIE}" \
1317     --pname "${PNAME}" \
1318     --pver "${PVER}" \
1319     --pbuild "${PBUILD}" \
1320     --parch "${ARCH}" \
1321     --target "${target}"
1322     done
1323 niro 943
1324     # build several subpackages
1325     elif [[ -n ${SPLIT_PACKAGES} ]]
1326     then
1327     split_save_variables
1328 niro 964 for subpackage in ${SPLIT_PACKAGES}
1329 niro 943 do
1330     # get the right variables for the split
1331     export PNAME="${subpackage}"
1332     split_info_${subpackage}
1333     # build md5sum for existing packages
1334     generate_package_md5sum \
1335     --pcat "${PCATEGORIE}" \
1336     --pname "${PNAME}" \
1337     --pver "${PVER}" \
1338     --pbuild "${PBUILD}" \
1339     --parch "${ARCH}"
1340 niro 951 # restore smage environment
1341     split_restore_variables
1342 niro 943 done
1343 niro 951 # unset all saved smage variables
1344     split_unset_variables
1345 niro 943
1346 niro 890 else
1347     # build md5sum for existing packages
1348     generate_package_md5sum \
1349     --pcat "${PCATEGORIE}" \
1350     --pname "${PNAME}" \
1351     --pver "${PVER}" \
1352     --pbuild "${PBUILD}" \
1353 niro 943 --parch "${ARCH}"
1354 niro 890 fi
1355 niro 255
1356 niro 202 exit 0
1357     fi
1358    
1359 niro 412 if [ "$1" == "--create-src-tarball" -a -n "$2" ]
1360 niro 403 then
1361     # set correct SMAGENAME
1362     SMAGENAME="$2"
1363     MD5DIR="$(dirname ${SMAGENAME})/md5"
1364    
1365 niro 412 echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1366 niro 403
1367 niro 1346 smagesource ${SMAGENAME} || die "regen: smage2 not found"
1368 niro 403
1369     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1370     then
1371     echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1372     rm -rf ${SOURCEDIR}/${PKGNAME}
1373     fi
1374    
1375     download_sources
1376     source_pkg_build ${SMAGENAME}
1377     exit 0
1378     fi
1379    
1380 niro 406 if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1381 niro 403 then
1382 niro 412 SRCPKGTARBALL="${2}"
1383 niro 1584 msetfeature "srcpkgtarball"
1384 niro 403
1385 niro 412 # abort if given file is not a source pkg
1386     [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
1387    
1388     # set correct SMAGENAME; use the one that the src_pkg provide
1389     # /path/to/SOURCEDIR/PNAME/SMAGENAME
1390     SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}"
1391    
1392 niro 403 echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}"
1393    
1394     [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR}
1395    
1396     # unpack srctarball
1397     [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting."
1398    
1399     tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die "Error unpackung src-tarball ${SRCPKGTARBALL}"
1400 niro 412
1401     [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"
1402 niro 403 fi
1403    
1404 niro 1617 if [ "$1" == "--resume" -a -n "$2" ]
1405     then
1406     msetfeature "resume"
1407     SMAGENAME="$2"
1408     fi
1409 niro 403
1410 niro 306 [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
1411     [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
1412     die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
1413 niro 419 [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
1414     [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly."
1415     [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly."
1416     [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}"
1417     [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}"
1418     [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1419     [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1420 niro 24
1421 niro 1346 smagesource ${SMAGENAME} || die "source failed"
1422 niro 255 PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1423 niro 59 MD5DIR="$(dirname ${SMAGENAME})/md5"
1424 niro 941 SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1425 niro 24
1426     xtitle "Compiling ${PKGNAME}"
1427 niro 439 echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1428 niro 59
1429 niro 191 # auto regen mage tree if requested
1430     regen_mage_tree
1431    
1432 niro 1635 if mqueryfeature "srcpkgbuild"
1433 niro 403 then
1434     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1435     then
1436 niro 441 echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1437 niro 408 rm -rf ${SOURCEDIR}/${PNAME}
1438 niro 403 fi
1439     fi
1440    
1441 niro 192 # download sources
1442 niro 1584 mqueryfeature "srcpkgtarball" || download_sources
1443 niro 59
1444 niro 192 # fixes some issues with these functions
1445 niro 24 export -f src_prepare || die "src_prepare export failed"
1446     export -f src_compile || die "src_compile export failed"
1447 niro 1575 export -f src_check || die "src_check export failed"
1448 niro 24 export -f src_install || die "src_install export failed"
1449    
1450 niro 192 # fixes some compile issues
1451 niro 24 export CHOST="${CHOST}" || die "CHOST export failed"
1452     export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
1453 niro 1616 if [[ -z ${CXXFLAGS} ]]
1454     then
1455     export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
1456     else
1457     export CXXFLAGS="${CXXFLAGS}" || die "CXXFLAGS export failed"
1458     fi
1459     export LDFLAGS="${LDFLAGS}" || die "LDFLAGS export failed"
1460 niro 24 export BINDIR="${BINDIR}" || die "BINDIR export failed"
1461     export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
1462    
1463 niro 192 # setup distcc
1464 niro 351 # setup for distcc goes *before* ccache, so ccache comes before distcc in path
1465 niro 1584 mqueryfeature "distcc" && setup_distcc_environment
1466 niro 24
1467 niro 192 # setup ccache
1468 niro 1584 mqueryfeature "ccache" && setup_ccache_environment
1469 niro 24
1470 niro 1617 if mqueryfeature "resume"
1471 niro 24 then
1472 niro 1617 echo -e "${COLMAGENTA}Resume requested; continuing previous build${COLDEFAULT}"
1473 niro 24
1474 niro 1617 # setup build logging
1475     [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1476     if [[ -f /var/log/smage/${PKGNAME}.log.bz2 ]]
1477     then
1478     bunzip2 -f /var/log/smage/${PKGNAME}.log.bz2
1479     fi
1480     echo -e "### Resume started on $(date) ###\n" >> /var/log/smage/${PKGNAME}.log
1481 niro 24
1482 niro 1617 else
1483     # clean up builddir if a previously one exist
1484     if [ -d ${BUILDDIR} ]
1485     then
1486     rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1487     fi
1488     install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1489 niro 24
1490 niro 1617 # clean up srcdir if a previously unpacked one exist
1491     if [ -d ${SRCDIR} ]
1492     then
1493     rm -rf ${SRCDIR}
1494     fi
1495    
1496     # clean up bindir if a previous build exist or create a new one
1497     if [ -d ${BINDIR} ]
1498     then
1499     rm -rf ${BINDIR}
1500     fi
1501     install -d ${BINDIR} || die "couldn't create \$BINDIR."
1502    
1503     # clean up package temp dir if a previous build exist
1504     if [ -d ${BUILDDIR}/${PKGNAME} ]
1505     then
1506     rm -rf ${BUILDDIR}/${PKGNAME}
1507     fi
1508    
1509 niro 1621 # clean up stamps dir
1510     if [ -d ${BUILDDIR}/.stamps ]
1511     then
1512     rm -rf ${BUILDDIR}/.stamps
1513     fi
1514    
1515 niro 1617 # setup build logging
1516     [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1517     echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1518 niro 24 fi
1519    
1520 niro 1593 if [[ ${PKGTYPE} = virtual ]]
1521 niro 1575 then
1522 niro 1593 echo "virtual package detected; nothing will be build ..."
1523     # automatically set !pkgbuild here too
1524     msetfeature "!pkgbuild"
1525 niro 1575 else
1526 niro 1617 ( run_resume src_prepare || src_prepare ) | ${SMAGE_LOG_CMD}
1527 niro 1593 die_pipestatus 0 "src_prepare failed"
1528 niro 1617 resume_stamp src_prepare
1529     step_by_step src_prepare
1530 niro 1575
1531 niro 1617 ( run_resume src_compile || src_compile ) | ${SMAGE_LOG_CMD}
1532 niro 1593 die_pipestatus 0 "src_compile failed"
1533 niro 1617 resume_stamp src_compile
1534     step_by_step src_compile
1535 niro 945
1536 niro 1593 # only run checks if requested
1537     if mqueryfeature "!check"
1538     then
1539     echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD}
1540     else
1541 niro 1617 ( run_resume src_check || src_check ) | ${SMAGE_LOG_CMD}
1542 niro 1593 die_pipestatus 0 "src_check failed"
1543 niro 1617 resume_stamp src_check
1544 niro 1593 fi
1545 niro 1617 step_by_step src_check
1546 niro 945
1547 niro 1593 # build several subpackages
1548     if [[ -n ${SPLIT_PACKAGES} ]]
1549     then
1550     # save bindir & pname
1551     split_save_variables
1552     export SAVED_BINDIR="${BINDIR}"
1553     for subpackage in ${SPLIT_PACKAGES}
1554     do
1555     if typeset -f src_install_${subpackage} > /dev/null
1556     then
1557     # export subpackage bindir
1558     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1559     # export PNAME, several internal function and include
1560     # rely on this variable
1561     export PNAME="${subpackage}"
1562    
1563     echo
1564     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1565     echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}"
1566     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1567     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1568    
1569 niro 1617 ( run_resume src_install_${subpackage} || src_install_${subpackage} ) | ${SMAGE_LOG_CMD}
1570 niro 1593 die_pipestatus 0 "src_install_${subpackage} failed"
1571 niro 1617 resume_stamp src_install_${subpackage}
1572     step_by_step src_install_${subpackage}
1573 niro 1593 fi
1574     done
1575     # restore bindir & pname
1576     split_restore_variables
1577     # unset all saved smage variables
1578     split_unset_variables
1579     else
1580 niro 1617 ( run_resume src_install || src_install ) | ${SMAGE_LOG_CMD}
1581 niro 1593 die_pipestatus 0 "src_install failed"
1582 niro 1617 resume_stamp src_install
1583     step_by_step src_install
1584 niro 1593 fi
1585 niro 943 fi
1586 niro 24
1587 niro 1593 # echo for sake of good-looking
1588     echo
1589    
1590 niro 1584 if mqueryfeature "!compressdoc"
1591 niro 24 then
1592 niro 1584 echo -e "!compressdoc detected; documentation will not be compressed ..."
1593 niro 1595 elif mqueryfeature "!pkgbuild"
1594     then
1595     echo "!pkgbuild detected; skipping documentation compression..."
1596 niro 943 else
1597 niro 1584 # compressing doc, info & man files
1598     if [[ -n ${SPLIT_PACKAGES} ]]
1599     then
1600     for subpackage in ${SPLIT_PACKAGES}
1601     do
1602 niro 1617 run_resume mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage}
1603     resume_stamp mcompressdoc_${subpackage}
1604 niro 1584 done
1605     else
1606 niro 1617 run_resume mcompressdoc || mcompressdocs ${BINDIR}
1607     resume_stamp mcompressdoc
1608 niro 1584 fi
1609 niro 24 fi
1610    
1611 niro 1584 if mqueryfeature "!libtool"
1612 niro 1580 then
1613 niro 1595 if mqueryfeature "!pkgbuild"
1614     then
1615     echo "!pkgbuild detected; skipping libtool archive stripping ..."
1616     else
1617 niro 1580 if [[ -n ${SPLIT_PACKAGES} ]]
1618     then
1619     for subpackage in ${SPLIT_PACKAGES}
1620     do
1621     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}"
1622 niro 1617 run_resume mstriplibtoolarchive_${subpackage} || mstriplibtoolarchive ${BINDIR}_${subpackage}
1623     resume_stamp mstriplibtoolarchive_${subpackage}
1624 niro 1580 done
1625     else
1626 niro 1617 echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}"
1627     run_resume mstriplibtoolarchive || mstriplibtoolarchive ${BINDIR}
1628     resume_stamp mstriplibtoolarchive
1629 niro 1580 fi
1630 niro 1595 fi
1631 niro 1580 fi
1632 niro 24
1633 niro 1584 if mqueryfeature "purge"
1634 niro 1580 then
1635 niro 1595 if mqueryfeature "!pkgbuild"
1636     then
1637     echo "!pkgbuild detected; skipping file purgation..."
1638     else
1639 niro 1580 if [[ -n ${SPLIT_PACKAGES} ]]
1640     then
1641     for subpackage in ${SPLIT_PACKAGES}
1642     do
1643     echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}"
1644 niro 1617 run_resume mpurgetargets_${subpackage} || mpurgetargets ${BINDIR}_${subpackage}
1645     resume_stamp mpurgetargets_${subpackage}
1646 niro 1580 done
1647     else
1648 niro 1617 echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}"
1649     run_resume mpurgetargets || mpurgetargets ${BINDIR}
1650     resume_stamp mpurgetargets
1651 niro 1580 fi
1652 niro 1595 fi
1653 niro 1580 fi
1654    
1655 niro 79 # stripping all bins and libs
1656 niro 1584 if mqueryfeature "!strip"
1657     then
1658     echo -e "!strip detected; Package will not be stripped ..."
1659 niro 1595 elif mqueryfeature "!pkgbuild"
1660     then
1661     echo "!pkgbuild detected; skipping stripping of the package ..."
1662 niro 1584 else
1663 niro 1595 if [[ -n ${SPLIT_PACKAGES} ]]
1664     then
1665     for subpackage in ${SPLIT_PACKAGES}
1666     do
1667     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1668 niro 1617 run_resume mstripbins_${subpackage} || mstripbins ${BINDIR}_${subpackage}
1669     resume_stamp mstripbins_${subpackage}
1670 niro 1595 echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1671 niro 1617 run_resume mstriplibs_${subpackage} || mstriplibs ${BINDIR}_${subpackage}
1672     resume_stamp mstriplibs_${subpackage}
1673 niro 1595 echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1674 niro 1617 run_resume mstripstatic_${subpackage} || mstripstatic ${BINDIR}_${subpackage}
1675     resume_stamp mstripstatic_${subpackage}
1676 niro 1595 done
1677     else
1678     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1679 niro 1617 run_resume mstripbins || mstripbins ${BINDIR}
1680     resume_stamp mstripbins
1681 niro 1595 echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1682 niro 1617 run_resume mstriplibs || mstriplibs ${BINDIR}
1683     resume_stamp mstriplibs
1684 niro 1595 echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1685 niro 1617 run_resume mstripstatic || mstripstatic ${BINDIR}
1686     resume_stamp mstripstatic
1687 niro 1595 fi
1688 niro 1584 fi
1689 niro 79
1690 niro 1595 if mqueryfeature "!pkgbuild"
1691 niro 1584 then
1692 niro 1595 echo -e "!pkgbuild detected; Package will not be build ..."
1693 niro 1584 else
1694 niro 306 # build several targets
1695 niro 943 if [[ -n ${MAGE_TARGETS} ]]
1696 niro 192 then
1697     for target in ${MAGE_TARGETS}
1698     do
1699 niro 1573 # check if a special target_pkgbuild exists
1700 niro 192 if typeset -f ${target}_pkgbuild > /dev/null
1701     then
1702     # run it
1703 niro 1617 run_resume ${target}_pkgbuild || ${target}_pkgbuild
1704     resume_stamp ${target}_pkgbuild
1705 niro 192 fi
1706     # now create the target package
1707 niro 1617 run_resume pkg_builddir_${target} || ${MLIBDIR}/pkgbuild_dir.sh \
1708 niro 255 "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \
1709 niro 192 ${BINDIR} || die "target: ${target} package-build failed"
1710 niro 1617 resume_stamp pkg_builddir_${target}
1711 niro 255
1712     # build pkg-md5-sum if requested
1713 niro 1617 run_resume md5sum_${target} || generate_package_md5sum \
1714 niro 255 --pcat "${PCATEGORIE}" \
1715     --pname "${PNAME}" \
1716     --pver "${PVER}" \
1717     --pbuild "${PBUILD}" \
1718     --parch "${ARCH}" \
1719     --target "${target}"
1720 niro 1617 resume_stamp md5sum_${target}
1721 niro 255
1722 niro 439 echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1723 niro 192 done
1724 niro 943
1725     # build several subpackages
1726     elif [[ -n ${SPLIT_PACKAGES} ]]
1727     then
1728     split_save_variables
1729     for subpackage in ${SPLIT_PACKAGES}
1730     do
1731     # get the right variables for the split
1732     export PNAME="${subpackage}"
1733     split_info_${PNAME}
1734    
1735 niro 1595 # jump to next one if !pkgbuild is set in split_info
1736     mqueryfeature "!pkgbuild" && continue
1737 niro 947
1738 niro 943 # check if an special subpackage_pkgbuild exists
1739     if typeset -f ${PNAME}_pkgbuild > /dev/null
1740     then
1741     # run it
1742 niro 1617 run_resume ${PNAME}_pkgbuild || ${PNAME}_pkgbuild
1743     resume_stamp ${PNAME}_pkgbuild
1744 niro 943 fi
1745     # now create the target package
1746 niro 1617 run_resume pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir.sh \
1747 niro 943 "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1748     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1749 niro 1617 resume_stamp pkg_builddir_${PNAME}
1750 niro 943
1751     # build pkg-md5-sum if requested
1752 niro 1617 run_resume md5sum_${PNAME} || generate_package_md5sum \
1753 niro 943 --pcat "${PCATEGORIE}" \
1754     --pname "${PNAME}" \
1755     --pver "${PVER}" \
1756     --pbuild "${PBUILD}" \
1757     --parch "${ARCH}"
1758 niro 1617 resume_stamp md5sum_${PNAME}
1759 niro 943
1760     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1761 niro 951
1762     # restore smage environment
1763     split_restore_variables
1764 niro 943 done
1765 niro 951 # unset all saved smage variables
1766     split_unset_variables
1767 niro 943
1768 niro 192 else
1769 niro 1617 run_resume pkg_builddir || ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1770     resume_stamp pkg_builddir
1771 niro 255
1772     # build pkg-md5-sum if requested
1773 niro 1617 run_resume md5sum || generate_package_md5sum \
1774 niro 255 --pcat "${PCATEGORIE}" \
1775     --pname "${PNAME}" \
1776     --pver "${PVER}" \
1777     --pbuild "${PBUILD}" \
1778     --parch "${ARCH}"
1779 niro 1617 resume_stamp md5sum
1780 niro 255
1781 niro 439 echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1782 niro 192 fi
1783 niro 403
1784     # build src-pkg-tarball if requested
1785 niro 1635 if mqueryfeature "srcpkgbuild"
1786 niro 1617 then
1787 niro 1618 run_resume srcpkgbuild || source_pkg_build ${SMAGENAME}
1788 niro 1617 resume_stamp srcpkgbuild
1789     fi
1790 niro 1584 fi
1791 niro 24
1792 niro 1584 if mqueryfeature "buildlog"
1793 niro 875 then
1794     bzip2 -9f /var/log/smage/${PKGNAME}.log
1795     else
1796     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1797     fi
1798    
1799 niro 24 xtitleclean

Properties

Name Value
svn:executable *