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 1631 by niro, Fri Jan 13 13:20:22 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   # always use verbose mode for source downloads
181   unset my_SRC_URI_DEST   FVERBOSE=off msetfeature "verbose"
182   unset my_SRC_URI_MIRROR   # do not die here, mchecksum catches download errors
183   unset my_SOURCEDIR   mdownload --uri "${uri}" --dir "${outputdir}"
184   done  
185     # unset them to be sure
186     unset uri
187     unset subdir
188     unset outputdir
189     done
190    
191   # recheck md5 sums   # recheck md5 sums after download
192   echo   echo
193   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
194   ( 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"
195   echo   echo
196     else
197     echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}"
198     fi
199    
200   # not needed anymore   # not needed anymore
201   unset SRC_URI   unset SRC_URI
202  }  }
203    
204  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
205  src_prepare()  src_prepare()
206  {  {
207   echo "no src_prepare defined"   echo "no src_prepare defined; doing nothing ..."
  sleep 2  
208   return 0   return 0
209  }  }
210    
211  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
212  src_compile()  src_compile()
213  {  {
214   echo "no src_compile defined"   echo "no src_compile defined; doing nothing ..."
215   sleep 2   return 0
216    }
217    
218    # dummy function, used if that does not exist in smage file
219    src_check()
220    {
221     echo "no src_check defined; doing nothing ..."
222   return 0   return 0
223  }  }
224    
225  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
226  src_install()  src_install()
227  {  {
228   echo "no src_install defined"   echo "no src_install defined; doing nothing ..."
  sleep 2  
229   return 0   return 0
230  }  }
231    
# Line 373  mlibdir() Line 239  mlibdir()
239    
240  mconfigure()  mconfigure()
241  {  {
242     local myopts
243     if [[ ! -z ${CTARGET} ]]
244     then
245     myopts+=" --target=${CTARGET}"
246     fi
247     # if requested disable-static
248     if [[ ! -z $(./configure --help | grep -- '--.*able-static') ]]
249     then
250     if mqueryfeature '!static'
251     then
252     myopts+=" --disable-static"
253     else
254     myopts+=" --enable-static"
255     fi
256     fi
257    
258     # always enable shared by default
259     if [[ ! -z $(./configure --help | grep -- '--.*able-shared') ]]
260     then
261     myopts+=" --enable-shared"
262     fi
263    
264   if [ -x ./configure ]   if [ -x ./configure ]
265   then   then
266   ./configure \   ./configure \
# Line 385  mconfigure() Line 273  mconfigure()
273   --sysconfdir=/etc \   --sysconfdir=/etc \
274   --localstatedir=/var/lib \   --localstatedir=/var/lib \
275   --libdir=/usr/$(mlibdir) \   --libdir=/usr/$(mlibdir) \
276     ${myopts} \
277   "$@" || die "mconfigure failed"   "$@" || die "mconfigure failed"
278   else   else
279   echo "configure is not an executable ..."   echo "configure is not an executable ..."
# Line 456  munpack() Line 345  munpack()
345   popd > /dev/null   popd > /dev/null
346   fi   fi
347   ;;   ;;
348     xz)
349     IFTAR="$(basename $SRCFILE .xz)"
350     IFTAR="${IFTAR##*.}"
351     if [[ ${IFTAR} = tar ]]
352     then
353     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
354     else
355     pushd ${DEST} > /dev/null
356     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
357     popd > /dev/null
358     fi
359     ;;
360   tbz2|mpks|mpk)   tbz2|mpks|mpk)
361   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."
362   ;;   ;;
363   tgz)   tgz)
364   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."
365   ;;   ;;
366     txz|mpkzs|mpkz)
367     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
368     ;;
369   rar)   rar)
370   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
371   ;;   ;;
372   zip|xpi)   zip|xpi|jar)
373   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
374   ;;   ;;
375   rpm)   rpm)
# Line 515  mpatch() Line 419  mpatch()
419  mlibtoolize()  mlibtoolize()
420  {  {
421   local opts="$@"   local opts="$@"
422   [[ -z ${opts} ]] && opts="--copy --force"   [[ -z ${opts} ]] && opts="--verbose --install --force"
423    
424   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
425  }  }
426    
427    mautoreconf()
428    {
429     local opts="$@"
430     [[ -z ${opts} ]] && opts="--verbose --install --force"
431    
432     autoreconf ${opts} || die "running: mautoreconf ${opts}"
433    }
434    
435  minstalldocs()  minstalldocs()
436  {  {
437   local docfiles   local docfiles
438     local doc
439   docfiles="$@"   docfiles="$@"
440    
441   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
# Line 530  minstalldocs() Line 443  minstalldocs()
443   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
444   fi   fi
445    
446   local i   for doc in ${docfiles}
  for i in ${docfiles}  
447   do   do
448   if [ -f ${i} ]   if [ -f ${doc} ]
449   then   then
450   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if mqueryfeature "compressdoc"
451   install -m 0644 ${SRCDIR}/${i}.gz \   then
452   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "gzipping +installing ${doc}."
453     chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/$(basename ${doc}).gz || die "fixing permissions of ${doc}."
454     else
455     install -m 0644 ${SRCDIR}/${i} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}."
456     fi
457   fi   fi
458   done   done
459  }  }
# Line 546  mstriplibs() Line 462  mstriplibs()
462  {  {
463   local stripdir="$@"   local stripdir="$@"
464    
465   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
466   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"
467     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
468  }  }
469    
470  mstripbins()  mstripbins()
471  {  {
472   local stripdir="$@"   local stripdir="$@"
473    
474   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
475   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"
476     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
477    }
478    
479    mstripstatic()
480    {
481     local stripdir="$@"
482    
483     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
484     [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug"
485     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
486    }
487    
488    mstriplibtoolarchive()
489    {
490     local stripdir="$@"
491    
492     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
493     find ${stripdir} ! -type d -name \*.la | xargs | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null
494    }
495    
496    mpurgetargets()
497    {
498     local stripdir="$@"
499     local target
500    
501     [[ -z ${stripdir} ]] && stripdir=${BINDIR}
502     # nothing to do in this case
503     [[ -z ${PURGE_TARGETS[*]} ]] && return
504    
505     for target in ${PURGE_TARGETS[*]}
506     do
507     # check if target is a regex pattern without any slashes
508     if [[ ${target} = ${target//\/} ]]
509     then
510     find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null
511     else
512     rm -f -- ${target} 2> /dev/null
513     fi
514     done
515  }  }
516    
517  mcompressdocs()  mcompressdocs()
# Line 614  setup_ccache_environment() Line 570  setup_ccache_environment()
570   fi   fi
571  }  }
572    
   
573  # fixes given dependencies to match a MAGE_TARGET  # fixes given dependencies to match a MAGE_TARGET
574  # fix_mage_deps -target s/depend # <-- note -target !  # fix_mage_deps -target s/depend # <-- note -target !
575  fix_mage_deps()  fix_mage_deps()
# Line 730  build_mage_script() Line 685  build_mage_script()
685   # now build the mage file   # now build the mage file
686   > ${dest}   > ${dest}
687    
  # 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}  
   
688   # pgkname and state   # pgkname and state
689   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
690   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
691    
692   # description and homepage   # description and homepage
693   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
694   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
695    
696   # special tags and vars   # special tags and vars
697   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
698    
699   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
700   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
  echo >> ${dest}  
701    
702   # split package base   # split package base
703   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
  echo >> ${dest}  
704    
705   # add special vars   # add special vars
706   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 764  build_mage_script() Line 711  build_mage_script()
711   # being tricky here :)   # being tricky here :)
712   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
713   done   done
  echo  >> ${dest}  
714   fi   fi
715    
716   # add at least all includes   # add at least all includes
# Line 776  build_mage_script() Line 722  build_mage_script()
722   do   do
723   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
724   done   done
725   echo  >> ${dest}   # a CRLF is needed here!
726     echo >> ${dest}
727   fi   fi
  echo >> ${dest}  
728    
729   # deps and provides   # deps and provides
730   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
731   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
732   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
733    
734   # add special functions   # add special functions
735   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 796  build_mage_script() Line 739  build_mage_script()
739   do   do
740   # add to mage (quotes needed !)   # add to mage (quotes needed !)
741   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
742   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
743   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
744   done   done
  echo  >> ${dest}  
745   fi   fi
746    
747   # pre|post-install|removes   # pre|post-install|removes
748   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
749   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
750   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
751   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
752  }  }
753    
754  regen_mage_tree()  regen_mage_tree()
755  {  {
756   local i   local subpackage
757    
758   # build them only if requested   # build them only if requested
759   if [[ ${REGEN_MAGE_TREE} = true ]]   if mqueryfeature regentree
760   then   then
761   # run it without targets   # run it without targets
762   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
# Line 827  regen_mage_tree() Line 764  regen_mage_tree()
764   # build for each target a mage file   # build for each target a mage file
765   # run it with several targets   # run it with several targets
766   echo   echo
767   for i in ${MAGE_TARGETS}   for subpackage in ${MAGE_TARGETS}
768   do   do
769   build_mage_script --target "${i}"   build_mage_script --target "${subpackage}"
770   done   done
771   echo   echo
772    
# Line 842  regen_mage_tree() Line 779  regen_mage_tree()
779   # build for each subpackage a mage file   # build for each subpackage a mage file
780   # run it with several targets   # run it with several targets
781   echo   echo
782   for i in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
783   do   do
784   # get the right variables for the split   # get the right variables for the split
785   export PNAME="${i}"   export PNAME="${subpackage}"
786   split_info_${i}   split_info_${subpackage}
787     # get the preinstall etc
788     split_export_inherits ${subpackage}
789   build_mage_script --split-pkg-base "${split_pkg_base}"   build_mage_script --split-pkg-base "${split_pkg_base}"
790     # delete split preinstall etc
791     split_delete_inherits ${subpackage}
792   # restore smage environment   # restore smage environment
793   split_restore_variables   split_restore_variables
794   done   done
# Line 878  regen_mage_tree() Line 819  regen_mage_tree()
819   unset STATE   unset STATE
820   unset DESCRIPTION   unset DESCRIPTION
821   unset HOMEPAGE   unset HOMEPAGE
822   unset PKGTYPE   # unset PKGTYPE <-- don't do that either; smage needs this var
823   unset INHERITS   unset INHERITS
824   unset DEPEND   unset DEPEND
825   unset SDEPEND   unset SDEPEND
# Line 904  split_save_variables() Line 845  split_save_variables()
845   export SAVED_DEPEND="${DEPEND}"   export SAVED_DEPEND="${DEPEND}"
846   export SAVED_SDEPEND="${SDEPEND}"   export SAVED_SDEPEND="${SDEPEND}"
847   export SAVED_PROVIDE="${PROVIDE}"   export SAVED_PROVIDE="${PROVIDE}"
848   export SAVED_NOPKGBUILD="${NOPKGBUILD}"   export SAVED_PKGTYPE="${PKGTYPE}"
849    
850     # special handling needed for mage features
851     # pkgbuild
852     mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild"
853     mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild"
854     # strip
855     mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip"
856     mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip"
857     # libtool
858     mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool"
859     mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool"
860     # compressdoc
861     mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc"
862     mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc"
863    
864   # bindir too   # bindir too
865   export SAVED_BINDIR="${BINDIR}"   export SAVED_BINDIR="${BINDIR}"
# Line 965  split_restore_variables() Line 920  split_restore_variables()
920   export DEPEND="${SAVED_DEPEND}"   export DEPEND="${SAVED_DEPEND}"
921   export SDEPEND="${SAVED_SDEPEND}"   export SDEPEND="${SAVED_SDEPEND}"
922   export PROVIDE="${SAVED_PROVIDE}"   export PROVIDE="${SAVED_PROVIDE}"
923   export NOPKGBUILD="${SAVED_NOPKGBUILD}"   export PKGTYPE="${SAVED_PKGTYPE}"
924    
925     # special handling needed for mage features
926     # pkgbuild
927     FVERBOSE=off msetfeature "${SAVED_FEATURE_PKGBUILD}"
928     # strip
929     FVERBOSE=off msetfeature "${SAVED_FEATURE_STRIP}"
930     # libtool
931     FVERBOSE=off msetfeature "${SAVED_FEATURE_LIBTOOL}"
932     # compressdoc
933     FVERBOSE=off msetfeature "${SAVED_FEATURE_COMPRESSDOC}"
934    
935   # bindir too   # bindir too
936   export BINDIR="${SAVED_BINDIR}"   export BINDIR="${SAVED_BINDIR}"
# Line 1025  split_unset_variables() Line 990  split_unset_variables()
990   unset SAVED_SDEPEND   unset SAVED_SDEPEND
991   unset SAVED_PROVIDE   unset SAVED_PROVIDE
992   unset SAVED_BINDIR   unset SAVED_BINDIR
993   unset SAVED_NOPKGBUILD   unset SAVED_PKGTYPE
994     unset SAVED_FEATURE_PKGBUILD
995     unset SAVED_FEATURE_STRIP
996     unset SAVED_FEATURE_LIBTOOL
997     unset SAVED_FEATURE_COMPRESSDOC
998   unset SPLIT_PACKAGE_BASE   unset SPLIT_PACKAGE_BASE
999   unset -f SAVED_preinstall   unset -f SAVED_preinstall
1000   unset -f SAVED_postinstall   unset -f SAVED_postinstall
# Line 1033  split_unset_variables() Line 1002  split_unset_variables()
1002   unset -f SAVED_postremove   unset -f SAVED_postremove
1003  }  }
1004    
1005    split_export_inherits()
1006    {
1007     local subpackage="$1"
1008     local func
1009     local newfunc
1010    
1011     for func in preinstall postinstall preremove postremove
1012     do
1013     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1014     then
1015     newfunc=$(typeset -f ${func}_${subpackage})
1016     newfunc="${newfunc/_${subpackage} (/ (}"
1017     eval "${newfunc}"
1018     fi
1019     done
1020    }
1021    
1022    split_delete_inherits()
1023    {
1024     local subpackage="$1"
1025     local func
1026    
1027     for func in preinstall postinstall preremove postremove
1028     do
1029     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1030     then
1031     unset -f ${func}
1032     fi
1033     done
1034     }
1035    
1036  export_inherits()  export_inherits()
1037  {  {
1038   local include="$1"   local include="$1"
# Line 1094  generate_package_md5sum() Line 1094  generate_package_md5sum()
1094   # fix target as it may be empty !   # fix target as it may be empty !
1095   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1096    
   
1097   # build pkgname   # build pkgname
1098   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1099    
1100   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
1101   if [[ ${REGEN_MAGE_TREE} = true ]]   if mqueryfeature regentree
1102   then   then
1103   echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"   echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
1104    
# Line 1154  source_pkg_build() Line 1153  source_pkg_build()
1153    
1154  step_by_step()  step_by_step()
1155  {  {
1156   if [[ ${STEP_BY_STEP} = true ]]   if mqueryfeature stepbystep
1157   then   then
1158   echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"   echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1159   echo "Press [enter] to continue"   echo "Press [enter] to continue"
# Line 1162  step_by_step() Line 1161  step_by_step()
1161   fi   fi
1162  }  }
1163    
1164    resume_stamp()
1165    {
1166     local step="$1"
1167     [[ ! -d ${BUILDDIR}/.stamps ]] && install -d ${BUILDDIR}/.stamps
1168     touch ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step}
1169    }
1170    
1171    run_resume()
1172    {
1173     local step="$1"
1174    
1175     if mqueryfeature "resume" && [[ -f ${BUILDDIR}/.stamps/smage-${PKGNAME}-${step} ]]
1176     then
1177     echo -e "${COLMAGENTA}${step} already processed; doing nothing${COLDEFAULT}"
1178     return 0
1179     else
1180     return 1
1181     fi
1182    }
1183    
1184  # print out our version  # print out our version
1185  showversion  showversion
# Line 1174  then Line 1192  then
1192   exit 1   exit 1
1193  fi  fi
1194    
1195    # load supported mage features
1196    load_mage_features
1197    
1198  # updating smage2-scripts  # updating smage2-scripts
1199  if [[ $1 = update ]]  if [[ $1 = update ]]
1200  then  then
# Line 1188  fi Line 1209  fi
1209  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1210  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1211  then  then
1212   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1213   then   then
1214   SMAGENAME="$2"   SMAGENAME="$2"
1215   MD5DIR="$3"   MD5DIR="$3"
1216   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1217    
1218     smagesource ${SMAGENAME} || die "download source failed"
1219    
1220   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1221   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1244  then Line 1267  then
1267   echo   echo
1268   else   else
1269   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1270   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1271   echo   echo
1272   echo   echo
1273   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1266  then Line 1289  then
1289   # get smage   # get smage
1290   SMAGENAME="$2"   SMAGENAME="$2"
1291   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1292   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1293    
1294   download_sources   download_sources
1295   exit 0   exit 0
# Line 1278  then Line 1301  then
1301   # set correct SMAGENAME   # set correct SMAGENAME
1302   SMAGENAME="$2"   SMAGENAME="$2"
1303   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1304   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1305    
1306   regen_mage_tree   regen_mage_tree
1307    
# Line 1340  then Line 1363  then
1363    
1364   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1365    
1366   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1367    
1368   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1369   then   then
# Line 1356  fi Line 1379  fi
1379  if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]  if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1380  then  then
1381   SRCPKGTARBALL="${2}"   SRCPKGTARBALL="${2}"
1382   USE_SRC_PKG_TARBALL=true   msetfeature "srcpkgtarball"
1383    
1384   # abort if given file is not a source pkg   # abort if given file is not a source pkg
1385   [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."   [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
# Line 1377  then Line 1400  then
1400   [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"   [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"
1401  fi  fi
1402    
1403    if [ "$1" == "--resume" -a -n "$2" ]
1404    then
1405     msetfeature "resume"
1406     SMAGENAME="$2"
1407    fi
1408    
1409  [ ! -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."
1410  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
# Line 1389  fi Line 1417  fi
1417  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1418  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1419    
1420  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1421  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1422  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1423  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 1428  echo -e "${COLGREEN}Compiling ${PKGNAME}
1428  # auto regen mage tree if requested  # auto regen mage tree if requested
1429  regen_mage_tree  regen_mage_tree
1430    
1431  if [[ ${CREATE_SRC_PKG_TARBALL} = true ]]  if mqueryfeature "srcpkg"
1432  then  then
1433   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1434   then   then
# Line 1410  then Line 1438  then
1438  fi  fi
1439    
1440  # download sources  # download sources
1441  [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources  mqueryfeature "srcpkgtarball" || download_sources
1442    
1443  # fixes some issues with these functions  # fixes some issues with these functions
1444  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
1445  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
1446    export -f src_check || die "src_check export failed"
1447  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
1448    
1449  # fixes some compile issues  # fixes some compile issues
1450  export CHOST="${CHOST}" || die "CHOST export failed"  export CHOST="${CHOST}" || die "CHOST export failed"
1451  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
1452  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"  if [[ -z ${CXXFLAGS} ]]
1453    then
1454     export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
1455    else
1456     export CXXFLAGS="${CXXFLAGS}" || die "CXXFLAGS export failed"
1457    fi
1458    export LDFLAGS="${LDFLAGS}" || die "LDFLAGS export failed"
1459  export BINDIR="${BINDIR}" || die "BINDIR export failed"  export BINDIR="${BINDIR}" || die "BINDIR export failed"
1460  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
1461    
   
1462  # setup distcc  # setup distcc
1463  # 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
1464  [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment  mqueryfeature "distcc" && setup_distcc_environment
1465    
1466  # setup ccache  # setup ccache
1467  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment  mqueryfeature "ccache" && setup_ccache_environment
1468    
1469  # small sleep to show our settings  if mqueryfeature "resume"
 sleep 1  
   
 # cleans up build if a previously one exists  
 if [ -d ${BUILDDIR} ]  
1470  then  then
1471   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   echo -e "${COLMAGENTA}Resume requested; continuing previous build${COLDEFAULT}"
 fi  
 install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  
1472    
1473  # cleans up srcdir if a previously unpacked one exists   # setup build logging
1474  if [ -d ${SRCDIR} ]   [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1475  then   if [[ -f /var/log/smage/${PKGNAME}.log.bz2 ]]
1476   rm -rf ${SRCDIR}   then
1477  fi   bunzip2 -f /var/log/smage/${PKGNAME}.log.bz2
1478     fi
1479     echo -e "### Resume started on $(date) ###\n" >> /var/log/smage/${PKGNAME}.log
1480    
1481  # cleans up bindir if a previous build exists or creates a new one  else
1482  if [ -d ${BINDIR} ]   # clean up builddir if a previously one exist
1483  then   if [ -d ${BUILDDIR} ]
1484   rm -rf ${BINDIR}   then
1485  fi   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1486  install -d ${BINDIR} || die "couldn't create \$BINDIR."   fi
1487     install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1488    
1489  # cleans up package temp dir if a previous build exists   # clean up srcdir if a previously unpacked one exist
1490  if [ -d ${BUILDDIR}/${PKGNAME} ]   if [ -d ${SRCDIR} ]
1491  then   then
1492   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${SRCDIR}
1493     fi
1494    
1495     # clean up bindir if a previous build exist or create a new one
1496     if [ -d ${BINDIR} ]
1497     then
1498     rm -rf ${BINDIR}
1499     fi
1500     install -d ${BINDIR} || die "couldn't create \$BINDIR."
1501    
1502     # clean up package temp dir if a previous build exist
1503     if [ -d ${BUILDDIR}/${PKGNAME} ]
1504     then
1505     rm -rf ${BUILDDIR}/${PKGNAME}
1506     fi
1507    
1508     # clean up stamps dir
1509     if [ -d ${BUILDDIR}/.stamps ]
1510     then
1511     rm -rf ${BUILDDIR}/.stamps
1512     fi
1513    
1514     # setup build logging
1515     [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1516     echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1517  fi  fi
1518    
1519  # cleans up timestamp if one exists  if [[ ${PKGTYPE} = virtual ]]
 if [ -f /var/tmp/timestamp ]  
1520  then  then
1521   mage rmstamp   echo "virtual package detected; nothing will be build ..."
1522  fi   # automatically set !pkgbuild here too
1523     msetfeature "!pkgbuild"
1524    else
1525     ( run_resume src_prepare || src_prepare ) | ${SMAGE_LOG_CMD}
1526     die_pipestatus 0 "src_prepare failed"
1527     resume_stamp src_prepare
1528     step_by_step src_prepare
1529    
1530     ( run_resume src_compile || src_compile ) | ${SMAGE_LOG_CMD}
1531     die_pipestatus 0 "src_compile failed"
1532     resume_stamp src_compile
1533     step_by_step src_compile
1534    
1535  # setup build loggins   # only run checks if requested
1536  [[ ! -d /var/log/smage ]] && install -d /var/log/smage   if mqueryfeature "!check"
1537  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log   then
1538     echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD}
1539  src_prepare | ${SMAGE_LOG_CMD}   else
1540  die_pipestatus 0 "src_prepare failed"   ( run_resume src_check || src_check ) | ${SMAGE_LOG_CMD}
1541  step_by_step $_   die_pipestatus 0 "src_check failed"
1542     resume_stamp src_check
1543  src_compile | ${SMAGE_LOG_CMD}   fi
1544  die_pipestatus 0 "src_compile failed"   step_by_step src_check
 step_by_step $_  
1545    
1546  # build several subpackages   # build several subpackages
1547  if [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
1548  then   then
1549   # save bindir & pname   # save bindir & pname
1550   split_save_variables   split_save_variables
1551   export SAVED_BINDIR="${BINDIR}"   export SAVED_BINDIR="${BINDIR}"
1552   for subpackage in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
1553   do   do
1554   if typeset -f src_install_${subpackage} > /dev/null   if typeset -f src_install_${subpackage} > /dev/null
1555   then   then
1556   # export subpackage bindir   # export subpackage bindir
1557   export BINDIR="${SAVED_BINDIR}_${subpackage}"   export BINDIR="${SAVED_BINDIR}_${subpackage}"
1558   # export PNAME, several internal function and include   # export PNAME, several internal function and include
1559   # rely on this variable   # rely on this variable
1560   export PNAME="${subpackage}"   export PNAME="${subpackage}"
1561    
1562   echo   echo
1563   echo -en "${COLBLUE}*** ${COLDEFAULT}"   echo -en "${COLBLUE}*** ${COLDEFAULT}"
1564   echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"   echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1565   echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"   echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1566   echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."   echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1567    
1568   src_install_${subpackage} | ${SMAGE_LOG_CMD}   ( run_resume src_install_${subpackage} || src_install_${subpackage} ) | ${SMAGE_LOG_CMD}
1569   die_pipestatus 0 "src_install_${subpackage} failed"   die_pipestatus 0 "src_install_${subpackage} failed"
1570   step_by_step $_   resume_stamp src_install_${subpackage}
1571   fi   step_by_step src_install_${subpackage}
1572   done   fi
1573   # restore bindir & pname   done
1574   split_restore_variables   # restore bindir & pname
1575   # unset all saved smage variables   split_restore_variables
1576   split_unset_variables   # unset all saved smage variables
1577  else   split_unset_variables
1578   src_install | ${SMAGE_LOG_CMD}   else
1579   die_pipestatus 0 "src_install failed"   ( run_resume src_install || src_install ) | ${SMAGE_LOG_CMD}
1580   step_by_step $_   die_pipestatus 0 "src_install failed"
1581     resume_stamp src_install
1582     step_by_step src_install
1583     fi
1584  fi  fi
1585    
1586  # compressing doc, info & man files  # echo for sake of good-looking
1587  if [[ -n ${SPLIT_PACKAGES} ]]  echo
1588    
1589    if mqueryfeature "!compressdoc"
1590  then  then
1591   for subpackage in ${SPLIT_PACKAGES}   echo -e "!compressdoc detected; documentation will not be compressed ..."
1592   do  elif mqueryfeature "!pkgbuild"
1593   mcompressdocs ${BINDIR}_${subpackage}  then
1594   done   echo "!pkgbuild detected; skipping documentation compression..."
1595  else  else
1596   mcompressdocs ${BINDIR}   # compressing doc, info & man files
1597     if [[ -n ${SPLIT_PACKAGES} ]]
1598     then
1599     for subpackage in ${SPLIT_PACKAGES}
1600     do
1601     run_resume mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage}
1602     resume_stamp mcompressdoc_${subpackage}
1603     done
1604     else
1605     run_resume mcompressdoc || mcompressdocs ${BINDIR}
1606     resume_stamp mcompressdoc
1607     fi
1608  fi  fi
1609    
1610    if mqueryfeature "!libtool"
1611    then
1612     if mqueryfeature "!pkgbuild"
1613     then
1614     echo "!pkgbuild detected; skipping libtool archive stripping ..."
1615     else
1616     if [[ -n ${SPLIT_PACKAGES} ]]
1617     then
1618     for subpackage in ${SPLIT_PACKAGES}
1619     do
1620     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}"
1621     run_resume mstriplibtoolarchive_${subpackage} || mstriplibtoolarchive ${BINDIR}_${subpackage}
1622     resume_stamp mstriplibtoolarchive_${subpackage}
1623     done
1624     else
1625     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}"
1626     run_resume mstriplibtoolarchive || mstriplibtoolarchive ${BINDIR}
1627     resume_stamp mstriplibtoolarchive
1628     fi
1629     fi
1630    fi
1631    
1632  # stripping all bins and libs  if mqueryfeature "purge"
1633  case ${NOSTRIP} in  then
1634   true|TRUE|yes|y)   if mqueryfeature "!pkgbuild"
1635   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   then
1636   ;;   echo "!pkgbuild detected; skipping file purgation..."
1637   *)   else
1638   if [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
1639   then   then
1640   for subpackage in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
1641   do   do
1642   echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}"
1643   mstripbins ${BINDIR}_${subpackage}   run_resume mpurgetargets_${subpackage} || mpurgetargets ${BINDIR}_${subpackage}
1644   echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}"   resume_stamp mpurgetargets_${subpackage}
  mstriplibs ${BINDIR}_${subpackage}  
1645   done   done
1646   else   else
1647   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}"
1648   mstripbins ${BINDIR}   run_resume mpurgetargets || mpurgetargets ${BINDIR}
1649   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   resume_stamp mpurgetargets
  mstriplibs ${BINDIR}  
1650   fi   fi
1651   ;;   fi
1652  esac  fi
1653    
1654  # the new buildpkg command  # stripping all bins and libs
1655  case ${NOPKGBUILD} in  if mqueryfeature "!strip"
1656   true|TRUE|yes|y)  then
1657   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "!strip detected; Package will not be stripped ..."
1658   ;;  elif mqueryfeature "!pkgbuild"
1659   *)  then
1660     echo "!pkgbuild detected; skipping stripping of the package ..."
1661    else
1662     if [[ -n ${SPLIT_PACKAGES} ]]
1663     then
1664     for subpackage in ${SPLIT_PACKAGES}
1665     do
1666     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1667     run_resume mstripbins_${subpackage} || mstripbins ${BINDIR}_${subpackage}
1668     resume_stamp mstripbins_${subpackage}
1669     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1670     run_resume mstriplibs_${subpackage} || mstriplibs ${BINDIR}_${subpackage}
1671     resume_stamp mstriplibs_${subpackage}
1672     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1673     run_resume mstripstatic_${subpackage} || mstripstatic ${BINDIR}_${subpackage}
1674     resume_stamp mstripstatic_${subpackage}
1675     done
1676     else
1677     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1678     run_resume mstripbins || mstripbins ${BINDIR}
1679     resume_stamp mstripbins
1680     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1681     run_resume mstriplibs || mstriplibs ${BINDIR}
1682     resume_stamp mstriplibs
1683     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1684     run_resume mstripstatic || mstripstatic ${BINDIR}
1685     resume_stamp mstripstatic
1686     fi
1687    fi
1688    
1689    if mqueryfeature "!pkgbuild"
1690    then
1691     echo -e "!pkgbuild detected; Package will not be build ..."
1692    else
1693   # build several targets   # build several targets
1694   if [[ -n ${MAGE_TARGETS} ]]   if [[ -n ${MAGE_TARGETS} ]]
1695   then   then
1696   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1697   do   do
1698   # check if an special target_pkgbuild exists   # check if a special target_pkgbuild exists
1699   if typeset -f ${target}_pkgbuild > /dev/null   if typeset -f ${target}_pkgbuild > /dev/null
1700   then   then
1701   # run it   # run it
1702   ${target}_pkgbuild   run_resume ${target}_pkgbuild || ${target}_pkgbuild
1703     resume_stamp ${target}_pkgbuild
1704   fi   fi
1705   # now create the target package   # now create the target package
1706   ${MLIBDIR}/pkgbuild_dir.sh \   run_resume pkg_builddir_${target} || ${MLIBDIR}/pkgbuild_dir.sh \
1707   "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \   "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \
1708   ${BINDIR} || die "target: ${target} package-build failed"   ${BINDIR} || die "target: ${target} package-build failed"
1709     resume_stamp pkg_builddir_${target}
1710    
1711   # build pkg-md5-sum if requested   # build pkg-md5-sum if requested
1712   generate_package_md5sum \   run_resume md5sum_${target} || generate_package_md5sum \
1713   --pcat "${PCATEGORIE}" \   --pcat "${PCATEGORIE}" \
1714   --pname "${PNAME}" \   --pname "${PNAME}" \
1715   --pver "${PVER}" \   --pver "${PVER}" \
1716   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1717   --parch "${ARCH}" \   --parch "${ARCH}" \
1718   --target "${target}"   --target "${target}"
1719     resume_stamp md5sum_${target}
1720    
1721   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1722   done   done
# Line 1596  case ${NOPKGBUILD} in Line 1731  case ${NOPKGBUILD} in
1731   export PNAME="${subpackage}"   export PNAME="${subpackage}"
1732   split_info_${PNAME}   split_info_${PNAME}
1733    
1734   # jump to next one if NOPKGBUILD is set in split_info   # jump to next one if !pkgbuild is set in split_info
1735   case ${NOPKGBUILD} in   mqueryfeature "!pkgbuild" && continue
  true|TRUE|yes|y) continue ;;  
  esac  
1736    
1737   # check if an special subpackage_pkgbuild exists   # check if an special subpackage_pkgbuild exists
1738   if typeset -f ${PNAME}_pkgbuild > /dev/null   if typeset -f ${PNAME}_pkgbuild > /dev/null
1739   then   then
1740   # run it   # run it
1741   ${PNAME}_pkgbuild   run_resume ${PNAME}_pkgbuild || ${PNAME}_pkgbuild
1742     resume_stamp ${PNAME}_pkgbuild
1743   fi   fi
1744   # now create the target package   # now create the target package
1745   ${MLIBDIR}/pkgbuild_dir.sh \   run_resume pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir.sh \
1746   "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \   "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1747   "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"   "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1748     resume_stamp pkg_builddir_${PNAME}
1749    
1750   # build pkg-md5-sum if requested   # build pkg-md5-sum if requested
1751   generate_package_md5sum \   run_resume md5sum_${PNAME} || generate_package_md5sum \
1752   --pcat "${PCATEGORIE}" \   --pcat "${PCATEGORIE}" \
1753   --pname "${PNAME}" \   --pname "${PNAME}" \
1754   --pver "${PVER}" \   --pver "${PVER}" \
1755   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1756   --parch "${ARCH}"   --parch "${ARCH}"
1757     resume_stamp md5sum_${PNAME}
1758    
1759   echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"   echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1760    
# Line 1629  case ${NOPKGBUILD} in Line 1765  case ${NOPKGBUILD} in
1765   split_unset_variables   split_unset_variables
1766    
1767   else   else
1768   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   run_resume pkg_builddir || ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1769     resume_stamp pkg_builddir
1770    
1771   # build pkg-md5-sum if requested   # build pkg-md5-sum if requested
1772   generate_package_md5sum \   run_resume md5sum || generate_package_md5sum \
1773   --pcat "${PCATEGORIE}" \   --pcat "${PCATEGORIE}" \
1774   --pname "${PNAME}" \   --pname "${PNAME}" \
1775   --pver "${PVER}" \   --pver "${PVER}" \
1776   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1777   --parch "${ARCH}"   --parch "${ARCH}"
1778     resume_stamp md5sum
1779    
1780   echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"   echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1781   fi   fi
1782    
1783   # build src-pkg-tarball if requested   # build src-pkg-tarball if requested
1784   [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME}   if mqueryfeature "srcpkg"
1785   ;;   then
1786  esac   run_resume srcpkgbuild || source_pkg_build ${SMAGENAME}
1787     resume_stamp srcpkgbuild
1788     fi
1789    fi
1790    
1791  if [[ ${SMAGE_BUILD_LOGGING} != false ]]  if mqueryfeature "buildlog"
1792  then  then
1793   bzip2 -9f /var/log/smage/${PKGNAME}.log   bzip2 -9f /var/log/smage/${PKGNAME}.log
1794  else  else
1795   [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log   [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1796  fi  fi
1797    
 # for sure  
 unset NOPKGBUILD  
 unset NOSTRIP  
   
1798  xtitleclean  xtitleclean

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