Magellan Linux

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

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

revision 951 by niro, Sat Nov 21 14:31:50 2009 UTC revision 1574 by niro, Wed Dec 28 10:44:37 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.62 2007-11-28 10:47:50 niro Exp $  
8    
 #01.10.2004  
 # added ccache support  
 # added distcc support  
9    
10  # set default user mage.rc  # set default user mage.rc
11  : ${MAGERC="/etc/mage.rc"}  : ${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.global  source /etc/mage.rc.global
21  source ${MAGERC}  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 59  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 153  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, no fetching needed   # md5's ok, no fetching needed
# Line 198  download_sources() Line 198  download_sources()
198   then   then
199   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
200   wget \   wget \
201   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
202   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
203   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
204   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 222  download_sources() Line 219  download_sources()
219   then   then
220   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
221   wget \   wget \
222   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
223   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
224   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
225   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 246  download_sources() Line 240  download_sources()
240   then   then
241   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
242   wget \   wget \
243   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
244   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
245   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
246   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 270  download_sources() Line 261  download_sources()
261   then   then
262   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
263   wget \   wget \
264   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
265   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
266   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
267   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 294  download_sources() Line 282  download_sources()
282   then   then
283   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
284   wget \   wget \
285   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
286   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
287   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
288   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 313  download_sources() Line 298  download_sources()
298   then   then
299   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
300   wget \   wget \
301   --passive-ftp \   ${wget_opts} \
  --tries 3 \  
  --continue \  
  --progress bar \  
302   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
303   "${my_SRC_URI}"   "${my_SRC_URI}"
304   fi   fi
# Line 332  download_sources() Line 314  download_sources()
314   # recheck md5 sums   # recheck md5 sums
315   echo   echo
316   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   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_install()  src_install()
340  {  {
341   echo "no src_install defined"   echo "no src_install defined"
  sleep 2  
342   return 0   return 0
343  }  }
344    
# Line 456  munpack() Line 435  munpack()
435   popd > /dev/null   popd > /dev/null
436   fi   fi
437   ;;   ;;
438     xz)
439     IFTAR="$(basename $SRCFILE .xz)"
440     IFTAR="${IFTAR##*.}"
441     if [[ ${IFTAR} = tar ]]
442     then
443     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
444     else
445     pushd ${DEST} > /dev/null
446     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
447     popd > /dev/null
448     fi
449     ;;
450   tbz2|mpks|mpk)   tbz2|mpks|mpk)
451   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
452   ;;   ;;
453   tgz)   tgz)
454   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
455   ;;   ;;
456     txz|mpkzs|mpkz)
457     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
458     ;;
459   rar)   rar)
460   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
461   ;;   ;;
# Line 515  mpatch() Line 509  mpatch()
509  mlibtoolize()  mlibtoolize()
510  {  {
511   local opts="$@"   local opts="$@"
512   [[ -z ${opts} ]] && opts="--copy --force"   [[ -z ${opts} ]] && opts="--verbose --install --force"
513    
514   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
515  }  }
516    
517    mautoreconf()
518    {
519     local opts="$@"
520     [[ -z ${opts} ]] && opts="--verbose --install --force"
521    
522     autoreconf ${opts} || die "running: mautoreconf ${opts}"
523    }
524    
525  minstalldocs()  minstalldocs()
526  {  {
527   local docfiles   local docfiles
# Line 530  minstalldocs() Line 532  minstalldocs()
532   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
533   fi   fi
534    
535     local i
536   for i in ${docfiles}   for i in ${docfiles}
537   do   do
538   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${i} ]
539   install -m 0644 ${SRCDIR}/${i}.gz \   then
540   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
541     install -m 0644 ${SRCDIR}/${i}.gz \
542     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
543     fi
544   done   done
545  }  }
546    
# Line 543  mstriplibs() Line 549  mstriplibs()
549   local stripdir="$@"   local stripdir="$@"
550    
551   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
552   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_LIB} 2> /dev/null
553  }  }
554    
555  mstripbins()  mstripbins()
# Line 551  mstripbins() Line 557  mstripbins()
557   local stripdir="$@"   local stripdir="$@"
558    
559   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
560   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_BIN} 2> /dev/null
561    }
562    
563    mstripstatic()
564    {
565     local stripdir="$@"
566    
567     [ -z "${stripdir}" ] && stripdir=${BINDIR}
568     find ${stripdir} | xargs file | grep "ar archive" | cut -f 1 -d : | xargs strip ${STRIP_STATIC_LIB} 2> /dev/null
569  }  }
570    
571  mcompressdocs()  mcompressdocs()
# Line 726  build_mage_script() Line 740  build_mage_script()
740   # now build the mage file   # now build the mage file
741   > ${dest}   > ${dest}
742    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
743   # pgkname and state   # pgkname and state
744   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
745   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
746    
747   # description and homepage   # description and homepage
748   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
749   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
750    
751   # special tags and vars   # special tags and vars
752   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
753    
754   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
755   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
  echo >> ${dest}  
756    
757   # split package base   # split package base
758   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
  echo >> ${dest}  
759    
760   # add special vars   # add special vars
761   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 760  build_mage_script() Line 766  build_mage_script()
766   # being tricky here :)   # being tricky here :)
767   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
768   done   done
  echo  >> ${dest}  
769   fi   fi
770    
771   # add at least all includes   # add at least all includes
# Line 772  build_mage_script() Line 777  build_mage_script()
777   do   do
778   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
779   done   done
780   echo  >> ${dest}   # a CRLF is needed here!
781     echo >> ${dest}
782   fi   fi
  echo >> ${dest}  
783    
784   # deps and provides   # deps and provides
785   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
786   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
787   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
788    
789   # add special functions   # add special functions
790   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 792  build_mage_script() Line 794  build_mage_script()
794   do   do
795   # add to mage (quotes needed !)   # add to mage (quotes needed !)
796   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
797   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
798   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
799   done   done
  echo  >> ${dest}  
800   fi   fi
801    
802   # pre|post-install|removes   # pre|post-install|removes
803   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
804   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
805   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
806   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
807  }  }
808    
809  regen_mage_tree()  regen_mage_tree()
810  {  {
811   local i   local subpackage
812    
813   # build them only if requested   # build them only if requested
814   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
# Line 823  regen_mage_tree() Line 819  regen_mage_tree()
819   # build for each target a mage file   # build for each target a mage file
820   # run it with several targets   # run it with several targets
821   echo   echo
822   for i in ${MAGE_TARGETS}   for subpackage in ${MAGE_TARGETS}
823   do   do
824   build_mage_script --target "${i}"   build_mage_script --target "${subpackage}"
825   done   done
826   echo   echo
827    
# Line 838  regen_mage_tree() Line 834  regen_mage_tree()
834   # build for each subpackage a mage file   # build for each subpackage a mage file
835   # run it with several targets   # run it with several targets
836   echo   echo
837   for i in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
838   do   do
839   # get the right variables for the split   # get the right variables for the split
840   export PNAME="${i}"   export PNAME="${subpackage}"
841   split_info_${i}   split_info_${subpackage}
842     # get the preinstall etc
843     split_export_inherits ${subpackage}
844   build_mage_script --split-pkg-base "${split_pkg_base}"   build_mage_script --split-pkg-base "${split_pkg_base}"
845     # delete split preinstall etc
846     split_delete_inherits ${subpackage}
847   # restore smage environment   # restore smage environment
848   split_restore_variables   split_restore_variables
849   done   done
# Line 1029  split_unset_variables() Line 1029  split_unset_variables()
1029   unset -f SAVED_postremove   unset -f SAVED_postremove
1030  }  }
1031    
1032    split_export_inherits()
1033    {
1034     local subpackage="$1"
1035     local func
1036     local newfunc
1037    
1038     for func in preinstall postinstall preremove postremove
1039     do
1040     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1041     then
1042     newfunc=$(typeset -f ${func}_${subpackage})
1043     newfunc="${newfunc/_${subpackage} (/ (}"
1044     eval "${newfunc}"
1045     fi
1046     done
1047    }
1048    
1049    split_delete_inherits()
1050    {
1051     local subpackage="$1"
1052     local func
1053    
1054     for func in preinstall postinstall preremove postremove
1055     do
1056     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1057     then
1058     unset -f ${func}
1059     fi
1060     done
1061     }
1062    
1063  export_inherits()  export_inherits()
1064  {  {
1065   local include="$1"   local include="$1"
# Line 1184  fi Line 1215  fi
1215  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1216  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1217  then  then
1218   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1219   then   then
1220   SMAGENAME="$2"   SMAGENAME="$2"
1221   MD5DIR="$3"   MD5DIR="$3"
1222   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1223    
1224     smagesource ${SMAGENAME} || die "download source failed"
1225    
1226   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1227   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1240  then Line 1273  then
1273   echo   echo
1274   else   else
1275   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1276   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1277   echo   echo
1278   echo   echo
1279   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1262  then Line 1295  then
1295   # get smage   # get smage
1296   SMAGENAME="$2"   SMAGENAME="$2"
1297   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1298   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1299    
1300   download_sources   download_sources
1301   exit 0   exit 0
# Line 1274  then Line 1307  then
1307   # set correct SMAGENAME   # set correct SMAGENAME
1308   SMAGENAME="$2"   SMAGENAME="$2"
1309   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1310   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1311    
1312   regen_mage_tree   regen_mage_tree
1313    
# Line 1297  then Line 1330  then
1330   elif [[ -n ${SPLIT_PACKAGES} ]]   elif [[ -n ${SPLIT_PACKAGES} ]]
1331   then   then
1332   split_save_variables   split_save_variables
1333   for subpackage in ${SPLIT_PACKAGE}   for subpackage in ${SPLIT_PACKAGES}
1334   do   do
1335   # get the right variables for the split   # get the right variables for the split
1336   export PNAME="${subpackage}"   export PNAME="${subpackage}"
# Line 1336  then Line 1369  then
1369    
1370   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1371    
1372   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1373    
1374   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1375   then   then
# Line 1385  fi Line 1418  fi
1418  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1419  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1420    
1421  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1422  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1423  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1424  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
# Line 1428  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 1461  export MAKEOPTS="${MAKEOPTS}" || die "MA
1461  # setup ccache  # setup ccache
1462  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
1463    
1464  # small sleep to show our settings  # clean up builddir if a previously one exist
 sleep 1  
   
 # cleans up build if a previously one exists  
1465  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
1466  then  then
1467   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1468  fi  fi
1469  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1470    
1471  # cleans up srcdir if a previously unpacked one exists  # clean up srcdir if a previously unpacked one exist
1472  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
1473  then  then
1474   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
1475  fi  fi
1476    
1477  # 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
1478  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
1479  then  then
1480   rm -rf ${BINDIR}   rm -rf ${BINDIR}
# Line 1463  then Line 1493  then
1493   mage rmstamp   mage rmstamp
1494  fi  fi
1495    
1496  # setup build loggins  # setup build logging
1497  [[ ! -d /var/log/smage ]] && install -d /var/log/smage  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1498  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1499    
# Line 1515  fi Line 1545  fi
1545  # compressing doc, info & man files  # compressing doc, info & man files
1546  if [[ -n ${SPLIT_PACKAGES} ]]  if [[ -n ${SPLIT_PACKAGES} ]]
1547  then  then
1548   for subpackage in ${SPLIT_PACKAGE}   for subpackage in ${SPLIT_PACKAGES}
1549   do   do
1550   mcompressdocs ${BINDIR}_${subpackage}   mcompressdocs ${BINDIR}_${subpackage}
1551   done   done
# Line 1532  case ${NOSTRIP} in Line 1562  case ${NOSTRIP} in
1562   *)   *)
1563   if [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
1564   then   then
1565   for subpackage in ${SPLIT_PACKAGE}   for subpackage in ${SPLIT_PACKAGES}
1566   do   do
1567   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1568   mstripbins ${BINDIR}_${subpackage}   mstripbins ${BINDIR}_${subpackage}
1569   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1570   mstriplibs ${BINDIR}_${subpackage}   mstriplibs ${BINDIR}_${subpackage}
1571     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1572     mstripstatic ${BINDIR}_${subpackage}
1573   done   done
1574   else   else
1575   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1576   mstripbins ${BINDIR}   mstripbins ${BINDIR}
1577   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1578   mstriplibs ${BINDIR}   mstriplibs ${BINDIR}
1579     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1580     mstripstatic ${BINDIR}
1581   fi   fi
1582   ;;   ;;
1583  esac  esac
# Line 1559  case ${NOPKGBUILD} in Line 1593  case ${NOPKGBUILD} in
1593   then   then
1594   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1595   do   do
1596   # check if an special target_pkgbuild exists   # check if a special target_pkgbuild exists
1597   if typeset -f ${target}_pkgbuild > /dev/null   if typeset -f ${target}_pkgbuild > /dev/null
1598   then   then
1599   # run it   # run it

Legend:
Removed from v.951  
changed lines
  Added in v.1574