Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 412 by niro, Fri Jan 19 23:11:17 2007 UTC revision 1579 by niro, Wed Dec 28 10:56:10 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3    
4  # compiles/installs .smage2 source install scripts  # compiles/installs .smage2 source install scripts
5  # needs pkgbuild_dir (mage)  # needs pkgbuild_dir (mage)
6    
7  # SMAGE2  # TODO: record dynlib, gz | xz database
 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.49 2007-01-19 23:11:17 niro Exp $  
8    
9  #01.10.2004  
10  # added ccache support  # set default user mage.rc
11  # added distcc support  : ${MAGERC="/etc/mage.rc"}
12    
13  ## setup ##  ## setup ##
 PKGSUFFIX="mpk"  
 SRCPKGSUFFIX="mpks"  
14  SMAGENAME="$1"  SMAGENAME="$1"
 SMAGESUFFIX="smage2"  
 MLIBDIR=/usr/lib/mage  
15  SMAGEVERSION="$( < ${MLIBDIR}/version)"  SMAGEVERSION="$( < ${MLIBDIR}/version)"
16    
 ## only for tests -> normally in /etc/rc.d/init.d/functions  
 COLRED="\033[1;6m\033[31m"  
 COLGREEN="\033[1;6m\033[32m"  
 COLYELLOW="\033[1;6m\033[33m"  
 COLBLUE="\033[1;6m\033[34m"  
 COLMAGENTA="\033[1;6m\033[35m"  
 COLWHITE="\033[1;6m\033[37m"  
 COLGRAY="\033[0;6m\033[37m"  
 COLBOLD="\033[1m"  
 COLDEFAULT="\033[0m"  
   
 if [[ ${NOCOLORS} = true ]]  
 then  
  COLRED=""  
  COLGREEN=""  
  COLYELLOW=""  
  COLBLUE=""  
  COLMAGENTA=""  
  COLWHITE=""  
  COLGRAY=""  
  COLBOLD=""  
  COLDEFAULT=""  
 fi  
   
17  # export default C locale  # export default C locale
18  export LC_ALL=C  export LC_ALL=C
19    
20  source /etc/mage.rc  source /etc/mage.rc.global
21    source ${MAGERC}
22    source ${MLIBDIR}/mage4.functions.sh
23    
24  # set PKGDIR and BUILDDIR and BINDIR to MROOT  # set PKGDIR and BUILDDIR and BINDIR to MROOT
25  if [[ -n ${MROOT} ]]  if [[ -n ${MROOT} ]]
# Line 55  then Line 29  then
29   export BINDIR=${MROOT}/${BINDIR}   export BINDIR=${MROOT}/${BINDIR}
30  fi  fi
31    
32    # 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    
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     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  showversion()  showversion()
60  {  {
61   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
# Line 64  showversion() Line 65  showversion()
65  die()  die()
66  {  {
67   xtitleclean   xtitleclean
68     echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
69   echo "SMAGE failed: $@"   echo "SMAGE failed: $@"
70   exit 1   exit 1
71  }  }
72    
73    die_pipestatus()
74    {
75     # 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    }
85    
86  xtitle()  xtitle()
87  {  {
88   if [[ ${TERM} = xterm ]]   if [[ ${TERM} = xterm ]]
# Line 135  download_sources() Line 150  download_sources()
150   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
151   local FETCHING   local FETCHING
152   local i mirror   local i mirror
153     local wget_opts
154    
155     # filter wget command if busybox was found
156     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
157    
158   # install SRCDIR/PNAME if not exist   # install SRCDIR/PNAME if not exist
159   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
160    
161   # check if FETCHING is needed   # check if FETCHING is needed
162   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null )
163   if [[ $? = 0 ]]   if [[ $? = 0 ]]
164   then   then
165   # md5's ok, not fetching needed   # md5's ok, no fetching needed
166   FETCHING=false   FETCHING=false
167   else   else
168   FETCHING=true   FETCHING=true
# Line 166  download_sources() Line 184  download_sources()
184   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"
185   fi   fi
186    
187     # create the SOURCEDIR
188     install -d ${my_SOURCEDIR}
189    
190   # if an mirrored file than replace first the mirror uri   # if an mirrored file than replace first the mirror uri
191   if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ]   if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]
192   then   then
193   for mirror in ${MIRRORS}   for mirror in ${MIRRORS}
194   do   do
# Line 175  download_sources() Line 196  download_sources()
196    
197   if [[ ${FETCHING} = true ]]   if [[ ${FETCHING} = true ]]
198   then   then
199   echo "==> fetching ${my_SRC_URI_MIRROR}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
200     wget \
201     ${wget_opts} \
202     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
203     "${my_SRC_URI_MIRROR}"
204     if [[ $? = 0 ]]
205     then
206     break
207     else
208     continue
209     fi
210     fi
211     done
212     elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]]
213     then
214     for mirror in ${SOURCEFORGE_MIRRORS}
215     do
216     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")"
217    
218     if [[ ${FETCHING} = true ]]
219     then
220     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
221     wget \
222     ${wget_opts} \
223     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
224     "${my_SRC_URI_MIRROR}"
225     if [[ $? = 0 ]]
226     then
227     break
228     else
229     continue
230     fi
231     fi
232     done
233     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]]
234     then
235     for mirror in ${GNU_MIRRORS}
236     do
237     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")"
238    
239     if [[ ${FETCHING} = true ]]
240     then
241     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
242     wget \
243     ${wget_opts} \
244     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
245     "${my_SRC_URI_MIRROR}"
246     if [[ $? = 0 ]]
247     then
248     break
249     else
250     continue
251     fi
252     fi
253     done
254     elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]
255     then
256     for mirror in ${KDE_MIRRORS}
257     do
258     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"
259    
260     if [[ ${FETCHING} = true ]]
261     then
262     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
263   wget \   wget \
264   --passive-ftp \   ${wget_opts} \
265   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
266   --continue \   "${my_SRC_URI_MIRROR}"
267   --progress bar \   if [[ $? = 0 ]]
268   --directory-prefix="${my_SOURCEDIR}" \   then
269     break
270     else
271     continue
272     fi
273     fi
274     done
275     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]
276     then
277     for mirror in ${GNOME_MIRRORS}
278     do
279     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"
280    
281     if [[ ${FETCHING} = true ]]
282     then
283     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
284     wget \
285     ${wget_opts} \
286     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
287   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
288   if [[ $? = 0 ]]   if [[ $? = 0 ]]
289   then   then
# Line 194  download_sources() Line 296  download_sources()
296   else   else
297   if [[ ${FETCHING} = true ]]   if [[ ${FETCHING} = true ]]
298   then   then
299   echo "==> fetching ${my_SRC_URI}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
300   wget \   wget \
301   --passive-ftp \   ${wget_opts} \
302   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
303   "${my_SRC_URI}"   "${my_SRC_URI}"
304   fi   fi
305   fi   fi
# Line 214  download_sources() Line 313  download_sources()
313    
314   # recheck md5 sums   # recheck md5 sums
315   echo   echo
316   echo ">== Checking MD5 sums:"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
317   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed"
318   echo   echo
319    
320   # not needed anymore   # not needed anymore
321   unset SRC_URI   unset SRC_URI
322  }  }
323    
324  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
325  src_prepare()  src_prepare()
326  {  {
327   echo "no src_prepare defined"   echo "no src_prepare defined"
  sleep 2  
328   return 0   return 0
329  }  }
330    
331  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
332  src_compile()  src_compile()
333  {  {
334   echo "no src_compile defined"   echo "no src_compile defined"
  sleep 2  
335   return 0   return 0
336  }  }
337    
338  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
339    src_check()
340    {
341     echo "no src_check defined"
342     return 0
343    }
344    
345    # dummy function, used if that does not exist in smage file
346  src_install()  src_install()
347  {  {
348   echo "no src_install defined"   echo "no src_install defined"
  sleep 2  
349   return 0   return 0
350  }  }
351    
# Line 261  mconfigure() Line 364  mconfigure()
364   ./configure \   ./configure \
365   --prefix=/usr \   --prefix=/usr \
366   --host=${CHOST} \   --host=${CHOST} \
367     --build=${CHOST} \
368   --mandir=/usr/share/man \   --mandir=/usr/share/man \
369   --infodir=/usr/share/info \   --infodir=/usr/share/info \
370   --datadir=/usr/share \   --datadir=/usr/share \
# Line 304  munpack() Line 408  munpack()
408    
409   SRCFILE=$1   SRCFILE=$1
410    
411   if [ -z "$2" ]   if [[ -z $2 ]]
412   then   then
413   DEST=${BUILDDIR}   DEST=${BUILDDIR}
414   else   else
# Line 319  munpack() Line 423  munpack()
423   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
424   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
425   then   then
426   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   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   fi   fi
432   ;;   ;;
433   gz)   gz)
# Line 327  munpack() Line 435  munpack()
435   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
436   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
437   then   then
438   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   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     fi
444     ;;
445     xz)
446     IFTAR="$(basename $SRCFILE .xz)"
447     IFTAR="${IFTAR##*.}"
448     if [[ ${IFTAR} = tar ]]
449     then
450     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
451     else
452     pushd ${DEST} > /dev/null
453     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
454     popd > /dev/null
455   fi   fi
456   ;;   ;;
457   tbz2)   tbz2|mpks|mpk)
458   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
459   ;;   ;;
460   tgz)   tgz)
461   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
462     ;;
463     txz|mpkzs|mpkz)
464     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
465     ;;
466     rar)
467     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
468     ;;
469     zip|xpi)
470     unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
471     ;;
472     rpm)
473     pushd ${DEST} > /dev/null
474     rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
475     tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
476     if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
477     then
478     rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
479     fi
480   ;;   ;;
481   *)   *)
482   die "munpack failed"   die "munpack failed"
# Line 346  mpatch() Line 488  mpatch()
488  {  {
489   local PATCHOPTS   local PATCHOPTS
490   local PATCHFILE   local PATCHFILE
491     local i
492    
493   PATCHOPTS=$1   PATCHOPTS=$1
494   PATCHFILE=$2   PATCHFILE=$2
495    
496     if [[ -z $2 ]]
497     then
498     PATCHFILE=$1
499    
500     ## patch level auto-detection, get patch level
501     for ((i=0; i < 10; i++))
502     do
503     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
504     if [[ $? = 0 ]]
505     then
506     PATCHOPTS="-Np${i}"
507     break
508     fi
509     done
510     fi
511    
512   echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"   echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
513   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
514  }  }
515    
516    mlibtoolize()
517    {
518     local opts="$@"
519     [[ -z ${opts} ]] && opts="--verbose --install --force"
520    
521     libtoolize ${opts} || die "running: mlibtoolize ${opts}"
522    }
523    
524    mautoreconf()
525    {
526     local opts="$@"
527     [[ -z ${opts} ]] && opts="--verbose --install --force"
528    
529     autoreconf ${opts} || die "running: mautoreconf ${opts}"
530    }
531    
532  minstalldocs()  minstalldocs()
533  {  {
# Line 365  minstalldocs() Line 539  minstalldocs()
539   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
540   fi   fi
541    
542     local i
543   for i in ${docfiles}   for i in ${docfiles}
544   do   do
545   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${i} ]
546   install -m 0644 ${SRCDIR}/${i}.gz \   then
547   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
548     install -m 0644 ${SRCDIR}/${i}.gz \
549     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
550     fi
551   done   done
552  }  }
553    
# Line 377  mstriplibs() Line 555  mstriplibs()
555  {  {
556   local stripdir="$@"   local stripdir="$@"
557    
558   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
559   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug"
560     find ${stripdir} ! -type d | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null
561  }  }
562    
563  mstripbins()  mstripbins()
564  {  {
565   local stripdir="$@"   local stripdir="$@"
566    
567   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
568   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug"
569     find ${stripdir} ! -type d | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null
570    }
571    
572    mstripstatic()
573    {
574     local stripdir="$@"
575    
576     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
577     [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug"
578     find ${stripdir} ! -type d | xargs file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null
579    }
580    
581    mcompressdocs()
582    {
583     local bindir="$@"
584    
585     if [ -d ${bindir}/usr/share/man ]
586     then
587     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
588     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
589     fi
590    
591     if [ -d ${bindir}/usr/share/info ]
592     then
593     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
594     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
595     fi
596  }  }
597    
598  sminclude()  sminclude()
# Line 408  setup_distcc_environment() Line 614  setup_distcc_environment()
614  {  {
615   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
616   then   then
617   echo "Using DistCC for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
618   export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"   export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
619    
620   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
# Line 423  setup_ccache_environment() Line 629  setup_ccache_environment()
629  {  {
630   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
631   then   then
632   echo "Using CCache for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
633   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
634   fi   fi
635  }  }
# Line 447  fix_mage_deps() Line 653  fix_mage_deps()
653   # fix DEPEND   # fix DEPEND
654   while read sym dep   while read sym dep
655   do   do
656     # ignore empty lines
657     [[ -z ${dep} ]] && continue
658    
659   cat="$(dirname ${dep})"   cat="$(dirname ${dep})"
660   # change if not virtual   # change if not virtual
661   if [[ ${cat} = virtual ]]   if [[ ${cat} = virtual ]]
# Line 499  EOF Line 708  EOF
708  # special tags:  # special tags:
709  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
710  #   INHERITS              which functions get included  #   INHERITS              which functions get included
711  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
712  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
713    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
714    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
715    #                         (only in the resulting magefile}
716  #  #
717  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
718  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 511  build_mage_script() Line 723  build_mage_script()
723   local magefile   local magefile
724   local dest   local dest
725   local target   local target
726     local split_pkg_base
727   local sym   local sym
728   local depname   local depname
729    
# Line 518  build_mage_script() Line 731  build_mage_script()
731   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
732    
733   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
734   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
735    
736     # mark package as splitpackage
737     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
738    
739   # name of magefile   # name of magefile
740   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 527  build_mage_script() Line 743  build_mage_script()
743   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
744    
745   # show what we are doing   # show what we are doing
746   echo "Generating Mage file:"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
747   echo "  ${dest}"   echo "${dest}"
748    
749   install -d "$(dirname ${dest})"   install -d "$(dirname ${dest})"
750   # now build the mage file   # now build the mage file
751   > ${dest}   > ${dest}
752    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.49 2007-01-19 23:11:17 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
753   # pgkname and state   # pgkname and state
754   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
755   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
756    
757   # description and homepage   # description and homepage
758   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
759   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
760    
761   # special tags and vars   # special tags and vars
762   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
763    
764   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
765   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
766   echo >> ${dest}  
767     # split package base
768     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
769    
770   # add special vars   # add special vars
771   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 564  build_mage_script() Line 776  build_mage_script()
776   # being tricky here :)   # being tricky here :)
777   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
778   done   done
  echo  >> ${dest}  
779   fi   fi
780    
781   # add at least all includes   # add at least all includes
# Line 576  build_mage_script() Line 787  build_mage_script()
787   do   do
788   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
789   done   done
790   echo  >> ${dest}   # a CRLF is needed here!
791     echo >> ${dest}
792   fi   fi
  echo >> ${dest}  
793    
794   # deps and provides   # deps and provides
795   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
796   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
797   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
798    
799   # add special functions   # add special functions
800   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 596  build_mage_script() Line 804  build_mage_script()
804   do   do
805   # add to mage (quotes needed !)   # add to mage (quotes needed !)
806   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
807   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
808   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
809   done   done
  echo  >> ${dest}  
810   fi   fi
811    
812   # pre|post-install|removes   # pre|post-install|removes
813   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
814   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
815   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
816   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
817  }  }
818    
819  regen_mage_tree()  regen_mage_tree()
820  {  {
821   local i   local subpackage
822    
823   # build them only if requested   # build them only if requested
824   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
825   then   then
826   # run it without targets   # run it without targets
827   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
828   then   then
829     # build for each target a mage file
830     # run it with several targets
831   echo   echo
832   build_mage_script   for subpackage in ${MAGE_TARGETS}
833     do
834     build_mage_script --target "${subpackage}"
835     done
836   echo   echo
  else  
837    
838   # build for each target an mage file   # run it for splitpackages
839     elif [[ -n ${SPLIT_PACKAGES} ]]
840     then
841     local split_pkg_base="${PNAME}"
842     # save smage environment
843     split_save_variables
844     # build for each subpackage a mage file
845   # run it with several targets   # run it with several targets
846   for i in ${MAGE_TARGETS}   echo
847     for subpackage in ${SPLIT_PACKAGES}
848   do   do
849   echo   # get the right variables for the split
850   build_mage_script "${i}"   export PNAME="${subpackage}"
851   echo   split_info_${subpackage}
852     # get the preinstall etc
853     split_export_inherits ${subpackage}
854     build_mage_script --split-pkg-base "${split_pkg_base}"
855     # delete split preinstall etc
856     split_delete_inherits ${subpackage}
857     # restore smage environment
858     split_restore_variables
859   done   done
860     echo
861     # unset all saved smage variables
862     split_unset_variables
863    
864     else
865     echo
866     build_mage_script
867     echo
868   fi   fi
869   fi   fi
870    
871   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
872   # unset PKGNAME <-- don't do that; smage needs this var   # unset PKGNAME <-- don't do that; smage needs this var
873   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
874   for i in ${SPECIAL_FUNCTIONS}  # for i in ${SPECIAL_FUNCTIONS}
875   do  # do
876   unset "${i}"  # unset "${i}"
877   done  # done
878   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
879   for i in ${SPECIAL_VARS}  # for i in ${SPECIAL_VARS}
880   do  # do
881   unset "${i}"  # unset "${i}"
882   done  # done
883   unset SPECIAL_VARS   unset SPECIAL_VARS
884   unset STATE   unset STATE
885   unset DESCRIPTION   unset DESCRIPTION
# Line 667  regen_mage_tree() Line 895  regen_mage_tree()
895   unset postremove   unset postremove
896  }  }
897    
898    split_save_variables()
899    {
900     export SAVED_PNAME="${PNAME}"
901     export SAVED_PVER="${PVER}"
902     export SAVED_PBUILD="${PBUILD}"
903     export SAVED_PCATEGORIE="${PCATEGORIE}"
904     export SAVED_DESCRIPTION="${DESCRIPTION}"
905     export SAVED_HOMEPAGE="${HOMEPAGE}"
906     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
907     export SAVED_STATE="${STATE}"
908     export SAVED_PKGTYPE="${PKGTYPE}"
909     export SAVED_INHERITS="${INHERITS}"
910     export SAVED_DEPEND="${DEPEND}"
911     export SAVED_SDEPEND="${SDEPEND}"
912     export SAVED_PROVIDE="${PROVIDE}"
913     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
914    
915     # bindir too
916     export SAVED_BINDIR="${BINDIR}"
917    
918     # export the SPLIT_PACKAGE_BASE
919     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
920    
921     # functions
922     if [[ ! -z $(typeset -f preinstall) ]]
923     then
924     # rename the old one
925     local saved_preinstall
926     saved_preinstall=SAVED_$(typeset -f preinstall)
927     eval "${saved_preinstall}"
928     export -f SAVED_preinstall
929     fi
930    
931     if [[ ! -z $(typeset -f postinstall) ]]
932     then
933     # rename the old one
934     local saved_postinstall
935     saved_postinstall=SAVED_$(typeset -f postinstall)
936     eval "${saved_postinstall}"
937     export -f SAVED_postinstall
938     fi
939    
940     if [[ ! -z $(typeset -f preremove) ]]
941     then
942     # rename the old one
943     local saved_preremove
944     saved_preremove=SAVED_$(typeset -f preremove)
945     eval "${saved_preremove}"
946     export -f SAVED_preremove
947     fi
948    
949     if [[ ! -z $(typeset -f postremove) ]]
950     then
951     # rename the old one
952     local saved_postremove
953     saved_postremove=SAVED_$(typeset -f postremove)
954     eval "${saved_postremove}"
955     export -f SAVED_postremove
956     fi
957    }
958    
959    split_restore_variables()
960    {
961     export PNAME="${SAVED_PNAME}"
962     export PVER="${SAVED_PVER}"
963     export PBUILD="${SAVED_PBUILD}"
964     export PCATEGORIE="${SAVED_PCATEGORIE}"
965     export DESCRIPTION="${SAVED_DESCRIPTION}"
966     export HOMEPAGE="${SAVED_HOMEPAGE}"
967     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
968     export STATE="${SAVED_STATE}"
969     export PKGTYPE="${SAVED_PKGTYPE}"
970     export INHERITS="${SAVED_INHERITS}"
971     export DEPEND="${SAVED_DEPEND}"
972     export SDEPEND="${SAVED_SDEPEND}"
973     export PROVIDE="${SAVED_PROVIDE}"
974     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
975    
976     # bindir too
977     export BINDIR="${SAVED_BINDIR}"
978    
979     # functions
980     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
981     then
982     # rename the old one
983     local saved_preinstall
984     saved_preinstall=$(typeset -f SAVED_preinstall)
985     eval "${saved_preinstall/SAVED_/}"
986     export -f preinstall
987     fi
988    
989     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
990     then
991     # rename the old one
992     local saved_postinstall
993     saved_postinstall=$(typeset -f SAVED_postinstall)
994     eval "${saved_postinstall/SAVED_/}"
995     export -f postinstall
996     fi
997    
998     if [[ ! -z $(typeset -f SAVED_preremove) ]]
999     then
1000     # rename the old one
1001     local saved_preremove
1002     saved_preremove=$(typeset -f SAVED_preremove)
1003     eval "${saved_preremove/SAVED_/}"
1004     export -f preremove
1005     fi
1006    
1007     if [[ ! -z $(typeset -f SAVED_postremove) ]]
1008     then
1009     # rename the old one
1010     local saved_postremove
1011     saved_postremove=$(typeset -f SAVED_postremove)
1012     eval "${saved_postremove/SAVED_/}"
1013     export -f postremove
1014     fi
1015    }
1016    
1017    split_unset_variables()
1018    {
1019     # unset saved vars; not needed anymore
1020     unset SAVED_PNAME
1021     unset SAVED_PVER
1022     unset SAVED_PBUILD
1023     unset SAVED_PCATEGORIE
1024     unset SAVED_DESCRIPTION
1025     unset SAVED_HOMEPAGE
1026     unset SAVED_SPECIAL_VARS
1027     unset SAVED_STATE
1028     unset SAVED_PKGTYPE
1029     unset SAVED_INHERITS
1030     unset SAVED_DEPEND
1031     unset SAVED_SDEPEND
1032     unset SAVED_PROVIDE
1033     unset SAVED_BINDIR
1034     unset SAVED_NOPKGBUILD
1035     unset SPLIT_PACKAGE_BASE
1036     unset -f SAVED_preinstall
1037     unset -f SAVED_postinstall
1038     unset -f SAVED_preremove
1039     unset -f SAVED_postremove
1040    }
1041    
1042    split_export_inherits()
1043    {
1044     local subpackage="$1"
1045     local func
1046     local newfunc
1047    
1048     for func in preinstall postinstall preremove postremove
1049     do
1050     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1051     then
1052     newfunc=$(typeset -f ${func}_${subpackage})
1053     newfunc="${newfunc/_${subpackage} (/ (}"
1054     eval "${newfunc}"
1055     fi
1056     done
1057    }
1058    
1059    split_delete_inherits()
1060    {
1061     local subpackage="$1"
1062     local func
1063    
1064     for func in preinstall postinstall preremove postremove
1065     do
1066     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1067     then
1068     unset -f ${func}
1069     fi
1070     done
1071     }
1072    
1073  export_inherits()  export_inherits()
1074  {  {
1075   local include="$1"   local include="$1"
# Line 728  generate_package_md5sum() Line 1131  generate_package_md5sum()
1131   # fix target as it may be empty !   # fix target as it may be empty !
1132   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1133    
1134    
1135   # build pkgname   # build pkgname
1136   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1137    
1138   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
1139   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
1140   then   then
1141   echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... "   echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
1142    
1143   # abort if not exist   # abort if not exist
1144   if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]   if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
1145   then   then
1146   echo "! exists"   echo -e "${COLRED}! exists${COLDEFAULT}"
1147   return 0   return 0
1148   fi   fi
1149    
# Line 747  generate_package_md5sum() Line 1151  generate_package_md5sum()
1151   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1152    
1153   # setup md5 dir   # setup md5 dir
1154   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1155   install -d ${dest}   install -d ${dest}
1156    
1157   # gen md5sum   # gen md5sum
1158   ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \   ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
1159   > ${dest}/${pkgname}.md5   > ${dest}/${pkgname}.md5
1160   echo "done"   echo -e "${COLGREEN}done${COLDEFAULT}"
1161   fi   fi
1162  }  }
1163    
# Line 771  source_pkg_build() Line 1175  source_pkg_build()
1175   return 0   return 0
1176   fi   fi
1177    
1178   [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your mage.rc correctly."   [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."
1179    
1180   echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"   echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"
1181    
# Line 785  source_pkg_build() Line 1189  source_pkg_build()
1189   echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"   echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
1190  }  }
1191    
1192    step_by_step()
1193    {
1194     if [[ ${STEP_BY_STEP} = true ]]
1195     then
1196     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1197     echo "Press [enter] to continue"
1198     read
1199     fi
1200    }
1201    
1202    
1203  # print out our version  # print out our version
1204  showversion  showversion
# Line 811  fi Line 1225  fi
1225  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1226  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1227  then  then
1228   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1229   then   then
1230   SMAGENAME="$2"   SMAGENAME="$2"
1231   MD5DIR="$3"   MD5DIR="$3"
1232   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1233    
1234     smagesource ${SMAGENAME} || die "download source failed"
1235    
1236   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1237   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 867  then Line 1283  then
1283   echo   echo
1284   else   else
1285   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1286   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1287   echo   echo
1288   echo   echo
1289   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 889  then Line 1305  then
1305   # get smage   # get smage
1306   SMAGENAME="$2"   SMAGENAME="$2"
1307   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1308   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1309    
1310   download_sources   download_sources
1311   exit 0   exit 0
# Line 901  then Line 1317  then
1317   # set correct SMAGENAME   # set correct SMAGENAME
1318   SMAGENAME="$2"   SMAGENAME="$2"
1319   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1320   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1321    
1322   regen_mage_tree   regen_mage_tree
1323    
1324   # build md5sum for existing packages   # build several targets
1325   generate_package_md5sum \   if [[ -n ${MAGE_TARGETS} ]]
1326   --pcat "${PCATEGORIE}" \   then
1327   --pname "${PNAME}" \   for target in ${MAGE_TARGETS}
1328   --pver "${PVER}" \   do
1329   --pbuild "${PBUILD}" \   # build md5sum for existing packages
1330   --parch "${ARCH}" \   generate_package_md5sum \
1331   --target "${target}"   --pcat "${PCATEGORIE}" \
1332     --pname "${PNAME}" \
1333     --pver "${PVER}" \
1334     --pbuild "${PBUILD}" \
1335     --parch "${ARCH}" \
1336     --target "${target}"
1337     done
1338    
1339     # build several subpackages
1340     elif [[ -n ${SPLIT_PACKAGES} ]]
1341     then
1342     split_save_variables
1343     for subpackage in ${SPLIT_PACKAGES}
1344     do
1345     # get the right variables for the split
1346     export PNAME="${subpackage}"
1347     split_info_${subpackage}
1348     # build md5sum for existing packages
1349     generate_package_md5sum \
1350     --pcat "${PCATEGORIE}" \
1351     --pname "${PNAME}" \
1352     --pver "${PVER}" \
1353     --pbuild "${PBUILD}" \
1354     --parch "${ARCH}"
1355     # restore smage environment
1356     split_restore_variables
1357     done
1358     # unset all saved smage variables
1359     split_unset_variables
1360    
1361     else
1362     # build md5sum for existing packages
1363     generate_package_md5sum \
1364     --pcat "${PCATEGORIE}" \
1365     --pname "${PNAME}" \
1366     --pver "${PVER}" \
1367     --pbuild "${PBUILD}" \
1368     --parch "${ARCH}"
1369     fi
1370    
1371   exit 0   exit 0
1372  fi  fi
# Line 925  then Line 1379  then
1379    
1380   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1381    
1382   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1383    
1384   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1385   then   then
# Line 966  fi Line 1420  fi
1420  [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."  [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
1421  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
1422   die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."   die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
1423  [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your mage.rc correctly."  [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
1424  [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."  [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly."
1425  [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."  [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly."
1426  [ -z "${BINDIR}" ] && die "no BINDIR variable found in /etc/mage.rc"  [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}"
1427  [ -z "${CHOST}" ] && die "no CHOST variable found in /etc/mage.rc"  [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}"
1428  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in /etc/mage.rc"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1429  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in /etc/mage.rc"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1430    
1431  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1432  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1433  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1434    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1435    
1436  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1437  echo "Compiling ${PKGNAME}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1438    
1439  # auto regen mage tree if requested  # auto regen mage tree if requested
1440  regen_mage_tree  regen_mage_tree
# Line 988  if [[ ${CREATE_SRC_PKG_TARBALL} = true ] Line 1443  if [[ ${CREATE_SRC_PKG_TARBALL} = true ]
1443  then  then
1444   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1445   then   then
1446   echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1447   rm -rf ${SOURCEDIR}/${PNAME}   rm -rf ${SOURCEDIR}/${PNAME}
1448   fi   fi
1449  fi  fi
# Line 999  fi Line 1454  fi
1454  # fixes some issues with these functions  # fixes some issues with these functions
1455  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
1456  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
1457    export -f src_check || die "src_check export failed"
1458  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
1459    
1460  # fixes some compile issues  # fixes some compile issues
# Line 1016  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 1472  export MAKEOPTS="${MAKEOPTS}" || die "MA
1472  # setup ccache  # setup ccache
1473  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
1474    
1475  # small sleep to show our settings  # clean up builddir if a previously one exist
 sleep 1  
   
 # cleans up build if a previously one exists  
1476  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
1477  then  then
1478   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1479  fi  fi
1480  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1481    
1482  # cleans up srcdir if a previously unpacked one exists  # clean up srcdir if a previously unpacked one exist
1483  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
1484  then  then
1485   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
1486  fi  fi
1487    
1488  # cleans up bindir if a previous build exists or creates a new one  # clean up bindir if a previous build exist or create a new one
1489  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
1490  then  then
1491   rm -rf ${BINDIR}   rm -rf ${BINDIR}
1492  fi  fi
1493  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
1494    
1495  # cleans up package temp dir if a previous build exists  # clean up package temp dir if a previous build exist
1496  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
1497  then  then
1498   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
1499  fi  fi
1500    
1501  # cleans up timestamp if one exists  # setup build logging
1502  if [ -f /var/tmp/timestamp ]  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1503    echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1504    
1505    src_prepare | ${SMAGE_LOG_CMD}
1506    die_pipestatus 0 "src_prepare failed"
1507    step_by_step $_
1508    
1509    src_compile | ${SMAGE_LOG_CMD}
1510    die_pipestatus 0 "src_compile failed"
1511    step_by_step $_
1512    
1513    # only run checks if requested
1514    if [[ ${MAGE_CHECK} != true ]]
1515  then  then
1516   mage rmstamp   echo "MAGE_CHECK not requested; src_check() will not be run!" | ${SMAGE_LOG_CMD}
1517     step_by_step src_check
1518    else
1519     src_check | ${SMAGE_LOG_CMD}
1520     die_pipestatus 0 "src_check failed"
1521     step_by_step $_
1522  fi  fi
1523    
1524  src_prepare || die "src_prepare failed"  # build several subpackages
1525  src_compile || die "src_compile failed"  if [[ -n ${SPLIT_PACKAGES} ]]
1526  src_install || die "src_install failed"  then
1527     # save bindir & pname
1528     split_save_variables
1529     export SAVED_BINDIR="${BINDIR}"
1530     for subpackage in ${SPLIT_PACKAGES}
1531     do
1532     if typeset -f src_install_${subpackage} > /dev/null
1533     then
1534     # export subpackage bindir
1535     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1536     # export PNAME, several internal function and include
1537     # rely on this variable
1538     export PNAME="${subpackage}"
1539    
1540     echo
1541     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1542     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1543     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1544     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1545    
1546     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1547     die_pipestatus 0 "src_install_${subpackage} failed"
1548     step_by_step $_
1549     fi
1550     done
1551     # restore bindir & pname
1552     split_restore_variables
1553     # unset all saved smage variables
1554     split_unset_variables
1555    else
1556     src_install | ${SMAGE_LOG_CMD}
1557     die_pipestatus 0 "src_install failed"
1558     step_by_step $_
1559    fi
1560    
1561  # compressing doc, info & man files  # compressing doc, info & man files
1562  echo -e "Compressing man-pages ..."  if [[ -n ${SPLIT_PACKAGES} ]]
 if [ -d ${BUILDDIR}/builded/usr/share/man ]  
1563  then  then
1564   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   for subpackage in ${SPLIT_PACKAGES}
1565     do
1566     mcompressdocs ${BINDIR}_${subpackage}
1567     done
1568    else
1569     mcompressdocs ${BINDIR}
1570  fi  fi
1571    
 echo -e "Compressing info-pages ..."  
 if [ -d ${BUILDDIR}/builded/usr/share/info ]  
 then  
  ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info  
 fi  
1572    
1573  # stripping all bins and libs  # stripping all bins and libs
1574  case ${NOSTRIP} in  case ${NOSTRIP} in
# Line 1075  case ${NOSTRIP} in Line 1576  case ${NOSTRIP} in
1576   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1577   ;;   ;;
1578   *)   *)
1579   echo -e "Stripping binaries ..."   if [[ -n ${SPLIT_PACKAGES} ]]
1580   mstripbins ${BINDIR}   then
1581   echo -e "Stripping libraries ..."   for subpackage in ${SPLIT_PACKAGES}
1582   mstriplibs ${BINDIR}   do
1583     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1584     mstripbins ${BINDIR}_${subpackage}
1585     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1586     mstriplibs ${BINDIR}_${subpackage}
1587     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1588     mstripstatic ${BINDIR}_${subpackage}
1589     done
1590     else
1591     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1592     mstripbins ${BINDIR}
1593     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1594     mstriplibs ${BINDIR}
1595     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1596     mstripstatic ${BINDIR}
1597     fi
1598   ;;   ;;
1599  esac  esac
1600    
# Line 1089  case ${NOPKGBUILD} in Line 1605  case ${NOPKGBUILD} in
1605   ;;   ;;
1606   *)   *)
1607   # build several targets   # build several targets
1608   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1609   then   then
1610   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1611   do   do
1612   # check if an special target_pkgbuild exists   # check if a special target_pkgbuild exists
1613   if typeset -f ${target}_pkgbuild > /dev/null   if typeset -f ${target}_pkgbuild > /dev/null
1614   then   then
1615   # run it   # run it
# Line 1113  case ${NOPKGBUILD} in Line 1629  case ${NOPKGBUILD} in
1629   --parch "${ARCH}" \   --parch "${ARCH}" \
1630   --target "${target}"   --target "${target}"
1631    
1632   echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n"   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1633   done   done
1634    
1635     # build several subpackages
1636     elif [[ -n ${SPLIT_PACKAGES} ]]
1637     then
1638     split_save_variables
1639     for subpackage in ${SPLIT_PACKAGES}
1640     do
1641     # get the right variables for the split
1642     export PNAME="${subpackage}"
1643     split_info_${PNAME}
1644    
1645     # jump to next one if NOPKGBUILD is set in split_info
1646     case ${NOPKGBUILD} in
1647     true|TRUE|yes|y) continue ;;
1648     esac
1649    
1650     # check if an special subpackage_pkgbuild exists
1651     if typeset -f ${PNAME}_pkgbuild > /dev/null
1652     then
1653     # run it
1654     ${PNAME}_pkgbuild
1655     fi
1656     # now create the target package
1657     ${MLIBDIR}/pkgbuild_dir.sh \
1658     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1659     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1660    
1661     # build pkg-md5-sum if requested
1662     generate_package_md5sum \
1663     --pcat "${PCATEGORIE}" \
1664     --pname "${PNAME}" \
1665     --pver "${PVER}" \
1666     --pbuild "${PBUILD}" \
1667     --parch "${ARCH}"
1668    
1669     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1670    
1671     # restore smage environment
1672     split_restore_variables
1673     done
1674     # unset all saved smage variables
1675     split_unset_variables
1676    
1677   else   else
1678   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1679    
# Line 1126  case ${NOPKGBUILD} in Line 1685  case ${NOPKGBUILD} in
1685   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1686   --parch "${ARCH}"   --parch "${ARCH}"
1687    
1688   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1689   fi   fi
1690    
1691   # build src-pkg-tarball if requested   # build src-pkg-tarball if requested
# Line 1134  case ${NOPKGBUILD} in Line 1693  case ${NOPKGBUILD} in
1693   ;;   ;;
1694  esac  esac
1695    
1696    if [[ ${SMAGE_BUILD_LOGGING} != false ]]
1697    then
1698     bzip2 -9f /var/log/smage/${PKGNAME}.log
1699    else
1700     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1701    fi
1702    
1703  # for sure  # for sure
1704  unset NOPKGBUILD  unset NOPKGBUILD
1705  unset NOSTRIP  unset NOSTRIP

Legend:
Removed from v.412  
changed lines
  Added in v.1579