Magellan Linux

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

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

revision 1081 by niro, Mon Jun 28 17:47:38 2010 UTC revision 1614 by niro, Mon Jan 9 20:08:17 2012 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    
 ## setup ##  
 PKGSUFFIX="mpk"  
 SRCPKGSUFFIX="mpks"  
 SMAGENAME="$1"  
 SMAGESUFFIX="smage2"  
 MLIBDIR=/usr/lib/mage  
 SMAGEVERSION="$( < ${MLIBDIR}/version)"  
   
 ## 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  
   
13  # export default C locale  # export default C locale
14  export LC_ALL=C  export LC_ALL=C
15    
16  source /etc/mage.rc.global  source /etc/mage.rc.global
17  source ${MAGERC}  source ${MAGERC}
18    source ${MLIBDIR}/mage4.functions.sh
19    
20    ## setup ##
21    SMAGENAME="$1"
22    SMAGEVERSION="$(< ${MLIBDIR}/version)"
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 142  get_db_md5_sum() Line 139  get_db_md5_sum()
139    
140  download_sources()  download_sources()
141  {  {
   
142   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
143    
144   local EOA=${#SRC_URI[*]}   local count=${#SRC_URI[*]}
145   local my_SRC_URI   local uri
146   local my_SRC_URI_DEST   local subdir
147   local my_SRC_URI_MIRROR   local outputdir
148   local my_SOURCEDIR   local db_md5_file="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
149   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local fetching
150   local FETCHING   local i
  local i mirror  
   
   
  # install SRCDIR/PNAME if not exist  
  [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}  
151    
152   # check if FETCHING is needed   # check if FETCHING is needed
153   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   if mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5
  if [[ $? = 0 ]]  
154   then   then
155   # md5's ok, no fetching needed   # md5's ok, no fetching needed
156   FETCHING=false   fetching=false
157   else   else
158   FETCHING=true   fetching=true
159   fi   fi
160    
161   for ((i=0; i < EOA; i++))   if [[ ${fetching} = true ]]
162   do   then
163   # url to file   for ((i=0; i < count; i++))
164   my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"   do
165     # url to file
166   # subdir in sources dir; the my_SRCI_URI file goes to there   uri="${SRC_URI[${i}]%%' '*}"
  my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"  
   
  # if my_src_uri_dest is not equal my_src_uri; than an other dir is used  
  if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]  
  then  
  my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}"  
  else  
  my_SOURCEDIR="${SOURCEDIR}/${PNAME}"  
  fi  
   
  # create the SOURCEDIR  
  install -d ${my_SOURCEDIR}  
   
  # if an mirrored file than replace first the mirror uri  
  if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]  
  then  
  for mirror in ${MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"  
   
  if [[ ${FETCHING} = true ]]  
  then  
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  --passive-ftp \  
  --tries 3 \  
  --continue \  
  --progress bar \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]]  
  then  
  for mirror in ${SOURCEFORGE_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")"  
   
  if [[ ${FETCHING} = true ]]  
  then  
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  --passive-ftp \  
  --tries 3 \  
  --continue \  
  --progress bar \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]]  
  then  
  for mirror in ${GNU_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")"  
   
  if [[ ${FETCHING} = true ]]  
  then  
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  --passive-ftp \  
  --tries 3 \  
  --continue \  
  --progress bar \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]  
  then  
  for mirror in ${KDE_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"  
167    
168   if [[ ${FETCHING} = true ]]   # subdir in sources dir; the my_SRCI_URI file goes to there
169   then   subdir="${SRC_URI[${i}]##*' '}"
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  --passive-ftp \  
  --tries 3 \  
  --continue \  
  --progress bar \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]  
  then  
  for mirror in ${GNOME_MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"  
170    
171   if [[ ${FETCHING} = true ]]   # if $subdir is not equal with $uri then an other dir is used
172   then   if [[ ${uri} != ${subdir} ]]
  echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"  
  wget \  
  --passive-ftp \  
  --tries 3 \  
  --continue \  
  --progress bar \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \  
  "${my_SRC_URI_MIRROR}"  
  if [[ $? = 0 ]]  
  then  
  break  
  else  
  continue  
  fi  
  fi  
  done  
  else  
  if [[ ${FETCHING} = true ]]  
173   then   then
174   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"   outputdir="${SOURCEDIR}/${PNAME}/${subdir}"
175   wget \   else
176   --passive-ftp \   outputdir="${SOURCEDIR}/${PNAME}"
  --tries 3 \  
  --continue \  
  --progress bar \  
  --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \  
  "${my_SRC_URI}"  
177   fi   fi
  fi  
178    
179   # unset them to be shure   echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}"
180   unset my_SRC_URI   # do not die here, mchecksum catches download errors
181   unset my_SRC_URI_DEST   mdownload --uri "${uri}" --dir "${outputdir}"
182   unset my_SRC_URI_MIRROR  
183   unset my_SOURCEDIR   # unset them to be sure
184   done   unset uri
185     unset subdir
186     unset outputdir
187     done
188    
189   # recheck md5 sums   # recheck md5 sums after download
190   echo   echo
191   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
192   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed"
193   echo   echo
194     else
195     echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}"
196     fi
197    
198   # not needed anymore   # not needed anymore
199   unset SRC_URI   unset SRC_URI
200  }  }
201    
202  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
203  src_prepare()  src_prepare()
204  {  {
205   echo "no src_prepare defined"   echo "no src_prepare defined; doing nothing ..."
  sleep 2  
206   return 0   return 0
207  }  }
208    
209  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
210  src_compile()  src_compile()
211  {  {
212   echo "no src_compile defined"   echo "no src_compile defined; doing nothing ..."
213   sleep 2   return 0
214    }
215    
216    # dummy function, used if that does not exist in smage file
217    src_check()
218    {
219     echo "no src_check defined; doing nothing ..."
220   return 0   return 0
221  }  }
222    
223  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
224  src_install()  src_install()
225  {  {
226   echo "no src_install defined"   echo "no src_install defined; doing nothing ..."
  sleep 2  
227   return 0   return 0
228  }  }
229    
# Line 373  mlibdir() Line 237  mlibdir()
237    
238  mconfigure()  mconfigure()
239  {  {
240     local myopts
241     if [[ ! -z ${CTARGET} ]]
242     then
243     myopts="--target=${CTARGET}"
244     fi
245    
246   if [ -x ./configure ]   if [ -x ./configure ]
247   then   then
248   ./configure \   ./configure \
# Line 385  mconfigure() Line 255  mconfigure()
255   --sysconfdir=/etc \   --sysconfdir=/etc \
256   --localstatedir=/var/lib \   --localstatedir=/var/lib \
257   --libdir=/usr/$(mlibdir) \   --libdir=/usr/$(mlibdir) \
258     ${myopts} \
259   "$@" || die "mconfigure failed"   "$@" || die "mconfigure failed"
260   else   else
261   echo "configure is not an executable ..."   echo "configure is not an executable ..."
# Line 456  munpack() Line 327  munpack()
327   popd > /dev/null   popd > /dev/null
328   fi   fi
329   ;;   ;;
330     xz)
331     IFTAR="$(basename $SRCFILE .xz)"
332     IFTAR="${IFTAR##*.}"
333     if [[ ${IFTAR} = tar ]]
334     then
335     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
336     else
337     pushd ${DEST} > /dev/null
338     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
339     popd > /dev/null
340     fi
341     ;;
342   tbz2|mpks|mpk)   tbz2|mpks|mpk)
343   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."
344   ;;   ;;
345   tgz)   tgz)
346   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."
347   ;;   ;;
348     txz|mpkzs|mpkz)
349     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
350     ;;
351   rar)   rar)
352   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
353   ;;   ;;
354   zip|xpi)   zip|xpi|jar)
355   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
356   ;;   ;;
357   rpm)   rpm)
# Line 515  mpatch() Line 401  mpatch()
401  mlibtoolize()  mlibtoolize()
402  {  {
403   local opts="$@"   local opts="$@"
404   [[ -z ${opts} ]] && opts="--copy --force"   [[ -z ${opts} ]] && opts="--verbose --install --force"
405    
406   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
407  }  }
408    
409    mautoreconf()
410    {
411     local opts="$@"
412     [[ -z ${opts} ]] && opts="--verbose --install --force"
413    
414     autoreconf ${opts} || die "running: mautoreconf ${opts}"
415    }
416    
417  minstalldocs()  minstalldocs()
418  {  {
419   local docfiles   local docfiles
420     local doc
421   docfiles="$@"   docfiles="$@"
422    
423   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
# Line 530  minstalldocs() Line 425  minstalldocs()
425   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
426   fi   fi
427    
428   local i   for doc in ${docfiles}
  for i in ${docfiles}  
429   do   do
430   if [ -f ${i} ]   if [ -f ${doc} ]
431   then   then
432   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if mqueryfeature "compressdoc"
433   install -m 0644 ${SRCDIR}/${i}.gz \   then
434   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/${doc}.gz || die "gzipping +installing ${doc}."
435     chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/${doc}.gz || die "fixing permissions of ${doc}."
436     else
437     install -m 0644 ${SRCDIR}/${i} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}."
438     fi
439   fi   fi
440   done   done
441  }  }
# Line 546  mstriplibs() Line 444  mstriplibs()
444  {  {
445   local stripdir="$@"   local stripdir="$@"
446    
447   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
448   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"
449     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
450  }  }
451    
452  mstripbins()  mstripbins()
453  {  {
454   local stripdir="$@"   local stripdir="$@"
455    
456   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
457   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"
458     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
459    }
460    
461    mstripstatic()
462    {
463     local stripdir="$@"
464    
465     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
466     [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug"
467     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
468    }
469    
470    mstriplibtoolarchive()
471    {
472     local stripdir="$@"
473    
474     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
475     find ${stripdir} ! -type d -name \*.la | xargs | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null
476    }
477    
478    mpurgetargets()
479    {
480     local stripdir="$@"
481     local target
482    
483     [[ -z ${stripdir} ]] && stripdir=${BINDIR}
484     # nothing to do in this case
485     [[ -z ${PURGE_TARGETS[*]} ]] && return
486    
487     for target in ${PURGE_TARGETS[*]}
488     do
489     # check if target is a regex pattern without any slashes
490     if [[ ${target} = ${target//\/} ]]
491     then
492     find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null
493     else
494     rm -f -- ${target} 2> /dev/null
495     fi
496     done
497  }  }
498    
499  mcompressdocs()  mcompressdocs()
# Line 614  setup_ccache_environment() Line 552  setup_ccache_environment()
552   fi   fi
553  }  }
554    
   
555  # fixes given dependencies to match a MAGE_TARGET  # fixes given dependencies to match a MAGE_TARGET
556  # fix_mage_deps -target s/depend # <-- note -target !  # fix_mage_deps -target s/depend # <-- note -target !
557  fix_mage_deps()  fix_mage_deps()
# Line 730  build_mage_script() Line 667  build_mage_script()
667   # now build the mage file   # now build the mage file
668   > ${dest}   > ${dest}
669    
  # 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}  
   
670   # pgkname and state   # pgkname and state
671   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
672   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
673    
674   # description and homepage   # description and homepage
675   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
676   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
677    
678   # special tags and vars   # special tags and vars
679   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
680    
681   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
682   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
  echo >> ${dest}  
683    
684   # split package base   # split package base
685   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
  echo >> ${dest}  
686    
687   # add special vars   # add special vars
688   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 764  build_mage_script() Line 693  build_mage_script()
693   # being tricky here :)   # being tricky here :)
694   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
695   done   done
  echo  >> ${dest}  
696   fi   fi
697    
698   # add at least all includes   # add at least all includes
# Line 776  build_mage_script() Line 704  build_mage_script()
704   do   do
705   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
706   done   done
707   echo  >> ${dest}   # a CRLF is needed here!
708     echo >> ${dest}
709   fi   fi
  echo >> ${dest}  
710    
711   # deps and provides   # deps and provides
712   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
713   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
714   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
715    
716   # add special functions   # add special functions
717   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 796  build_mage_script() Line 721  build_mage_script()
721   do   do
722   # add to mage (quotes needed !)   # add to mage (quotes needed !)
723   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
724   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
725   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
726   done   done
  echo  >> ${dest}  
727   fi   fi
728    
729   # pre|post-install|removes   # pre|post-install|removes
730   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
731   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
732   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
733   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
734  }  }
735    
736  regen_mage_tree()  regen_mage_tree()
737  {  {
738   local i   local subpackage
739    
740   # build them only if requested   # build them only if requested
741   if [[ ${REGEN_MAGE_TREE} = true ]]   if mqueryfeature regentree
742   then   then
743   # run it without targets   # run it without targets
744   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
# Line 827  regen_mage_tree() Line 746  regen_mage_tree()
746   # build for each target a mage file   # build for each target a mage file
747   # run it with several targets   # run it with several targets
748   echo   echo
749   for i in ${MAGE_TARGETS}   for subpackage in ${MAGE_TARGETS}
750   do   do
751   build_mage_script --target "${i}"   build_mage_script --target "${subpackage}"
752   done   done
753   echo   echo
754    
# Line 842  regen_mage_tree() Line 761  regen_mage_tree()
761   # build for each subpackage a mage file   # build for each subpackage a mage file
762   # run it with several targets   # run it with several targets
763   echo   echo
764   for i in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
765   do   do
766   # get the right variables for the split   # get the right variables for the split
767   export PNAME="${i}"   export PNAME="${subpackage}"
768   split_info_${i}   split_info_${subpackage}
769     # get the preinstall etc
770     split_export_inherits ${subpackage}
771   build_mage_script --split-pkg-base "${split_pkg_base}"   build_mage_script --split-pkg-base "${split_pkg_base}"
772     # delete split preinstall etc
773     split_delete_inherits ${subpackage}
774   # restore smage environment   # restore smage environment
775   split_restore_variables   split_restore_variables
776   done   done
# Line 878  regen_mage_tree() Line 801  regen_mage_tree()
801   unset STATE   unset STATE
802   unset DESCRIPTION   unset DESCRIPTION
803   unset HOMEPAGE   unset HOMEPAGE
804   unset PKGTYPE   # unset PKGTYPE <-- don't do that either; smage needs this var
805   unset INHERITS   unset INHERITS
806   unset DEPEND   unset DEPEND
807   unset SDEPEND   unset SDEPEND
# Line 904  split_save_variables() Line 827  split_save_variables()
827   export SAVED_DEPEND="${DEPEND}"   export SAVED_DEPEND="${DEPEND}"
828   export SAVED_SDEPEND="${SDEPEND}"   export SAVED_SDEPEND="${SDEPEND}"
829   export SAVED_PROVIDE="${PROVIDE}"   export SAVED_PROVIDE="${PROVIDE}"
830   export SAVED_NOPKGBUILD="${NOPKGBUILD}"   export SAVED_PKGTYPE="${PKGTYPE}"
831    
832     # special handling needed for mage features
833     # pkgbuild
834     mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild"
835     mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild"
836     # strip
837     mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip"
838     mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip"
839     # libtool
840     mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool"
841     mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool"
842     # compressdoc
843     mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc"
844     mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc"
845    
846   # bindir too   # bindir too
847   export SAVED_BINDIR="${BINDIR}"   export SAVED_BINDIR="${BINDIR}"
# Line 965  split_restore_variables() Line 902  split_restore_variables()
902   export DEPEND="${SAVED_DEPEND}"   export DEPEND="${SAVED_DEPEND}"
903   export SDEPEND="${SAVED_SDEPEND}"   export SDEPEND="${SAVED_SDEPEND}"
904   export PROVIDE="${SAVED_PROVIDE}"   export PROVIDE="${SAVED_PROVIDE}"
905   export NOPKGBUILD="${SAVED_NOPKGBUILD}"   export PKGTYPE="${SAVED_PKGTYPE}"
906    
907     # special handling needed for mage features
908     # pkgbuild
909     FVERBOSE=off msetfeature "${SAVED_FEATURE_PKGBUILD}"
910     # strip
911     FVERBOSE=off msetfeature "${SAVED_FEATURE_STRIP}"
912     # libtool
913     FVERBOSE=off msetfeature "${SAVED_FEATURE_LIBTOOL}"
914     # compressdoc
915     FVERBOSE=off msetfeature "${SAVED_FEATURE_COMPRESSDOC}"
916    
917   # bindir too   # bindir too
918   export BINDIR="${SAVED_BINDIR}"   export BINDIR="${SAVED_BINDIR}"
# Line 1025  split_unset_variables() Line 972  split_unset_variables()
972   unset SAVED_SDEPEND   unset SAVED_SDEPEND
973   unset SAVED_PROVIDE   unset SAVED_PROVIDE
974   unset SAVED_BINDIR   unset SAVED_BINDIR
975   unset SAVED_NOPKGBUILD   unset SAVED_PKGTYPE
976     unset SAVED_FEATURE_PKGBUILD
977     unset SAVED_FEATURE_STRIP
978     unset SAVED_FEATURE_LIBTOOL
979     unset SAVED_FEATURE_COMPRESSDOC
980   unset SPLIT_PACKAGE_BASE   unset SPLIT_PACKAGE_BASE
981   unset -f SAVED_preinstall   unset -f SAVED_preinstall
982   unset -f SAVED_postinstall   unset -f SAVED_postinstall
# Line 1033  split_unset_variables() Line 984  split_unset_variables()
984   unset -f SAVED_postremove   unset -f SAVED_postremove
985  }  }
986    
987    split_export_inherits()
988    {
989     local subpackage="$1"
990     local func
991     local newfunc
992    
993     for func in preinstall postinstall preremove postremove
994     do
995     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
996     then
997     newfunc=$(typeset -f ${func}_${subpackage})
998     newfunc="${newfunc/_${subpackage} (/ (}"
999     eval "${newfunc}"
1000     fi
1001     done
1002    }
1003    
1004    split_delete_inherits()
1005    {
1006     local subpackage="$1"
1007     local func
1008    
1009     for func in preinstall postinstall preremove postremove
1010     do
1011     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1012     then
1013     unset -f ${func}
1014     fi
1015     done
1016     }
1017    
1018  export_inherits()  export_inherits()
1019  {  {
1020   local include="$1"   local include="$1"
# Line 1094  generate_package_md5sum() Line 1076  generate_package_md5sum()
1076   # fix target as it may be empty !   # fix target as it may be empty !
1077   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1078    
   
1079   # build pkgname   # build pkgname
1080   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1081    
1082   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
1083   if [[ ${REGEN_MAGE_TREE} = true ]]   if mqueryfeature regentree
1084   then   then
1085   echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"   echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
1086    
# Line 1154  source_pkg_build() Line 1135  source_pkg_build()
1135    
1136  step_by_step()  step_by_step()
1137  {  {
1138   if [[ ${STEP_BY_STEP} = true ]]   if mqueryfeature stepbystep
1139   then   then
1140   echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"   echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1141   echo "Press [enter] to continue"   echo "Press [enter] to continue"
# Line 1174  then Line 1155  then
1155   exit 1   exit 1
1156  fi  fi
1157    
1158    # load supported mage features
1159    load_mage_features
1160    
1161  # updating smage2-scripts  # updating smage2-scripts
1162  if [[ $1 = update ]]  if [[ $1 = update ]]
1163  then  then
# Line 1188  fi Line 1172  fi
1172  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1173  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1174  then  then
1175   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1176   then   then
1177   SMAGENAME="$2"   SMAGENAME="$2"
1178   MD5DIR="$3"   MD5DIR="$3"
1179   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1180    
1181     smagesource ${SMAGENAME} || die "download source failed"
1182    
1183   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1184   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1244  then Line 1230  then
1230   echo   echo
1231   else   else
1232   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1233   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1234   echo   echo
1235   echo   echo
1236   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1266  then Line 1252  then
1252   # get smage   # get smage
1253   SMAGENAME="$2"   SMAGENAME="$2"
1254   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1255   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1256    
1257   download_sources   download_sources
1258   exit 0   exit 0
# Line 1278  then Line 1264  then
1264   # set correct SMAGENAME   # set correct SMAGENAME
1265   SMAGENAME="$2"   SMAGENAME="$2"
1266   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1267   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1268    
1269   regen_mage_tree   regen_mage_tree
1270    
# Line 1340  then Line 1326  then
1326    
1327   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1328    
1329   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1330    
1331   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1332   then   then
# Line 1356  fi Line 1342  fi
1342  if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]  if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1343  then  then
1344   SRCPKGTARBALL="${2}"   SRCPKGTARBALL="${2}"
1345   USE_SRC_PKG_TARBALL=true   msetfeature "srcpkgtarball"
1346    
1347   # abort if given file is not a source pkg   # abort if given file is not a source pkg
1348   [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."   [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
# Line 1389  fi Line 1375  fi
1375  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1376  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1377    
1378  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1379  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1380  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1381  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
# Line 1400  echo -e "${COLGREEN}Compiling ${PKGNAME} Line 1386  echo -e "${COLGREEN}Compiling ${PKGNAME}
1386  # auto regen mage tree if requested  # auto regen mage tree if requested
1387  regen_mage_tree  regen_mage_tree
1388    
1389  if [[ ${CREATE_SRC_PKG_TARBALL} = true ]]  if mqueryfeature "srcpkg"
1390  then  then
1391   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1392   then   then
# Line 1410  then Line 1396  then
1396  fi  fi
1397    
1398  # download sources  # download sources
1399  [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources  mqueryfeature "srcpkgtarball" || download_sources
1400    
1401  # fixes some issues with these functions  # fixes some issues with these functions
1402  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
1403  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
1404    export -f src_check || die "src_check export failed"
1405  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
1406    
1407  # fixes some compile issues  # fixes some compile issues
# Line 1424  export CXXFLAGS="${CFLAGS}" || die "CXXF Line 1411  export CXXFLAGS="${CFLAGS}" || die "CXXF
1411  export BINDIR="${BINDIR}" || die "BINDIR export failed"  export BINDIR="${BINDIR}" || die "BINDIR export failed"
1412  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
1413    
   
1414  # setup distcc  # setup distcc
1415  # setup for distcc goes *before* ccache, so ccache comes before distcc in path  # setup for distcc goes *before* ccache, so ccache comes before distcc in path
1416  [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment  mqueryfeature "distcc" && setup_distcc_environment
1417    
1418  # setup ccache  # setup ccache
1419  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment  mqueryfeature "ccache" && setup_ccache_environment
1420    
1421  # small sleep to show our settings  # clean up builddir if a previously one exist
 sleep 1  
   
 # cleans up build if a previously one exists  
1422  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
1423  then  then
1424   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1425  fi  fi
1426  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1427    
1428  # cleans up srcdir if a previously unpacked one exists  # clean up srcdir if a previously unpacked one exist
1429  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
1430  then  then
1431   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
1432  fi  fi
1433    
1434  # 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
1435  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
1436  then  then
1437   rm -rf ${BINDIR}   rm -rf ${BINDIR}
1438  fi  fi
1439  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
1440    
1441  # cleans up package temp dir if a previous build exists  # clean up package temp dir if a previous build exist
1442  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
1443  then  then
1444   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
1445  fi  fi
1446    
1447  # cleans up timestamp if one exists  # setup build logging
 if [ -f /var/tmp/timestamp ]  
 then  
  mage rmstamp  
 fi  
   
 # setup build loggins  
1448  [[ ! -d /var/log/smage ]] && install -d /var/log/smage  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1449  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1450    
1451  src_prepare | ${SMAGE_LOG_CMD}  if [[ ${PKGTYPE} = virtual ]]
 die_pipestatus 0 "src_prepare failed"  
 step_by_step $_  
   
 src_compile | ${SMAGE_LOG_CMD}  
 die_pipestatus 0 "src_compile failed"  
 step_by_step $_  
   
 # build several subpackages  
 if [[ -n ${SPLIT_PACKAGES} ]]  
1452  then  then
1453   # save bindir & pname   echo "virtual package detected; nothing will be build ..."
1454   split_save_variables   # automatically set !pkgbuild here too
1455   export SAVED_BINDIR="${BINDIR}"   msetfeature "!pkgbuild"
  for subpackage in ${SPLIT_PACKAGES}  
  do  
  if typeset -f src_install_${subpackage} > /dev/null  
  then  
  # export subpackage bindir  
  export BINDIR="${SAVED_BINDIR}_${subpackage}"  
  # export PNAME, several internal function and include  
  # rely on this variable  
  export PNAME="${subpackage}"  
   
  echo  
  echo -en "${COLBLUE}*** ${COLDEFAULT}"  
  echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"  
  echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"  
  echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."  
   
  src_install_${subpackage} | ${SMAGE_LOG_CMD}  
  die_pipestatus 0 "src_install_${subpackage} failed"  
  step_by_step $_  
  fi  
  done  
  # restore bindir & pname  
  split_restore_variables  
  # unset all saved smage variables  
  split_unset_variables  
1456  else  else
1457   src_install | ${SMAGE_LOG_CMD}   src_prepare | ${SMAGE_LOG_CMD}
1458   die_pipestatus 0 "src_install failed"   die_pipestatus 0 "src_prepare failed"
1459   step_by_step $_   step_by_step $_
1460    
1461     src_compile | ${SMAGE_LOG_CMD}
1462     die_pipestatus 0 "src_compile failed"
1463     step_by_step $_
1464    
1465     # only run checks if requested
1466     if mqueryfeature "!check"
1467     then
1468     echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD}
1469     step_by_step src_check
1470     else
1471     src_check | ${SMAGE_LOG_CMD}
1472     die_pipestatus 0 "src_check failed"
1473     step_by_step $_
1474     fi
1475    
1476     # build several subpackages
1477     if [[ -n ${SPLIT_PACKAGES} ]]
1478     then
1479     # save bindir & pname
1480     split_save_variables
1481     export SAVED_BINDIR="${BINDIR}"
1482     for subpackage in ${SPLIT_PACKAGES}
1483     do
1484     if typeset -f src_install_${subpackage} > /dev/null
1485     then
1486     # export subpackage bindir
1487     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1488     # export PNAME, several internal function and include
1489     # rely on this variable
1490     export PNAME="${subpackage}"
1491    
1492     echo
1493     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1494     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1495     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1496     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1497    
1498     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1499     die_pipestatus 0 "src_install_${subpackage} failed"
1500     step_by_step $_
1501     fi
1502     done
1503     # restore bindir & pname
1504     split_restore_variables
1505     # unset all saved smage variables
1506     split_unset_variables
1507     else
1508     src_install | ${SMAGE_LOG_CMD}
1509     die_pipestatus 0 "src_install failed"
1510     step_by_step $_
1511     fi
1512  fi  fi
1513    
1514  # compressing doc, info & man files  # echo for sake of good-looking
1515  if [[ -n ${SPLIT_PACKAGES} ]]  echo
1516    
1517    if mqueryfeature "!compressdoc"
1518  then  then
1519   for subpackage in ${SPLIT_PACKAGES}   echo -e "!compressdoc detected; documentation will not be compressed ..."
1520   do  elif mqueryfeature "!pkgbuild"
1521   mcompressdocs ${BINDIR}_${subpackage}  then
1522   done   echo "!pkgbuild detected; skipping documentation compression..."
1523  else  else
1524   mcompressdocs ${BINDIR}   # compressing doc, info & man files
1525     if [[ -n ${SPLIT_PACKAGES} ]]
1526     then
1527     for subpackage in ${SPLIT_PACKAGES}
1528     do
1529     mcompressdocs ${BINDIR}_${subpackage}
1530     done
1531     else
1532     mcompressdocs ${BINDIR}
1533     fi
1534  fi  fi
1535    
1536    if mqueryfeature "!libtool"
1537    then
1538     if mqueryfeature "!pkgbuild"
1539     then
1540     echo "!pkgbuild detected; skipping libtool archive stripping ..."
1541     else
1542     if [[ -n ${SPLIT_PACKAGES} ]]
1543     then
1544     for subpackage in ${SPLIT_PACKAGES}
1545     do
1546     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}"
1547     mstriplibtoolarchive ${BINDIR}_${subpackage}
1548     done
1549     else
1550     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}"
1551     mstriplibtoolarchive ${BINDIR}
1552     fi
1553     fi
1554    fi
1555    
1556  # stripping all bins and libs  if mqueryfeature "purge"
1557  case ${NOSTRIP} in  then
1558   true|TRUE|yes|y)   if mqueryfeature "!pkgbuild"
1559   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   then
1560   ;;   echo "!pkgbuild detected; skipping file purgation..."
1561   *)   else
1562   if [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
1563   then   then
1564   for subpackage in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
1565   do   do
1566   echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}"
1567   mstripbins ${BINDIR}_${subpackage}   mpurgetargets ${BINDIR}_${subpackage}
  echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}"  
  mstriplibs ${BINDIR}_${subpackage}  
1568   done   done
1569   else   else
1570   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}"
1571   mstripbins ${BINDIR}   mpurgetargets ${BINDIR}
  echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"  
  mstriplibs ${BINDIR}  
1572   fi   fi
1573   ;;   fi
1574  esac  fi
1575    
1576  # the new buildpkg command  # stripping all bins and libs
1577  case ${NOPKGBUILD} in  if mqueryfeature "!strip"
1578   true|TRUE|yes|y)  then
1579   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "!strip detected; Package will not be stripped ..."
1580   ;;  elif mqueryfeature "!pkgbuild"
1581   *)  then
1582     echo "!pkgbuild detected; skipping stripping of the package ..."
1583    else
1584     if [[ -n ${SPLIT_PACKAGES} ]]
1585     then
1586     for subpackage in ${SPLIT_PACKAGES}
1587     do
1588     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1589     mstripbins ${BINDIR}_${subpackage}
1590     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1591     mstriplibs ${BINDIR}_${subpackage}
1592     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1593     mstripstatic ${BINDIR}_${subpackage}
1594     done
1595     else
1596     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1597     mstripbins ${BINDIR}
1598     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1599     mstriplibs ${BINDIR}
1600     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1601     mstripstatic ${BINDIR}
1602     fi
1603    fi
1604    
1605    if mqueryfeature "!pkgbuild"
1606    then
1607     echo -e "!pkgbuild detected; Package will not be build ..."
1608    else
1609   # build several targets   # build several targets
1610   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
1611   then   then
1612   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1613   do   do
1614   # check if an special target_pkgbuild exists   # check if a special target_pkgbuild exists
1615   if typeset -f ${target}_pkgbuild > /dev/null   if typeset -f ${target}_pkgbuild > /dev/null
1616   then   then
1617   # run it   # run it
# Line 1596  case ${NOPKGBUILD} in Line 1644  case ${NOPKGBUILD} in
1644   export PNAME="${subpackage}"   export PNAME="${subpackage}"
1645   split_info_${PNAME}   split_info_${PNAME}
1646    
1647   # jump to next one if NOPKGBUILD is set in split_info   # jump to next one if !pkgbuild is set in split_info
1648   case ${NOPKGBUILD} in   mqueryfeature "!pkgbuild" && continue
  true|TRUE|yes|y) continue ;;  
  esac  
1649    
1650   # check if an special subpackage_pkgbuild exists   # check if an special subpackage_pkgbuild exists
1651   if typeset -f ${PNAME}_pkgbuild > /dev/null   if typeset -f ${PNAME}_pkgbuild > /dev/null
# Line 1643  case ${NOPKGBUILD} in Line 1689  case ${NOPKGBUILD} in
1689   fi   fi
1690    
1691   # build src-pkg-tarball if requested   # build src-pkg-tarball if requested
1692   [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME}   mqueryfeature "srcpkg" && source_pkg_build ${SMAGENAME}
1693   ;;  fi
 esac  
1694    
1695  if [[ ${SMAGE_BUILD_LOGGING} != false ]]  if mqueryfeature "buildlog"
1696  then  then
1697   bzip2 -9f /var/log/smage/${PKGNAME}.log   bzip2 -9f /var/log/smage/${PKGNAME}.log
1698  else  else
1699   [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log   [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1700  fi  fi
1701    
 # for sure  
 unset NOPKGBUILD  
 unset NOSTRIP  
   
1702  xtitleclean  xtitleclean

Legend:
Removed from v.1081  
changed lines
  Added in v.1614