Magellan Linux

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

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

revision 497 by niro, Thu Jun 7 13:16:03 2007 UTC revision 1580 by niro, Wed Dec 28 11:58:28 2011 UTC
# Line 1  Line 1 
1  #!/bin/bash  #!/bin/bash
2    # $Id$
3    
4  # compiles/installs .smage2 source install scripts  # compiles/installs .smage2 source install scripts
5  # needs pkgbuild_dir (mage)  # needs pkgbuild_dir (mage)
6    
7  # SMAGE2  # TODO: record dynlib, gz | xz database
 # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.58 2007-06-07 13:16:03 niro Exp $  
8    
 #01.10.2004  
 # added ccache support  
 # added distcc support  
9    
10  # set default user mage.rc  # set default user mage.rc
11  : ${MAGERC="/etc/mage.rc"}  : ${MAGERC="/etc/mage.rc"}
12    
13  ## setup ##  ## setup ##
 PKGSUFFIX="mpk"  
 SRCPKGSUFFIX="mpks"  
14  SMAGENAME="$1"  SMAGENAME="$1"
 SMAGESUFFIX="smage2"  
 MLIBDIR=/usr/lib/mage  
15  SMAGEVERSION="$( < ${MLIBDIR}/version)"  SMAGEVERSION="$( < ${MLIBDIR}/version)"
16    
 ## only for tests -> normally in /etc/rc.d/init.d/functions  
 COLRED="\033[1;6m\033[31m"  
 COLGREEN="\033[1;6m\033[32m"  
 COLYELLOW="\033[1;6m\033[33m"  
 COLBLUE="\033[1;6m\033[34m"  
 COLMAGENTA="\033[1;6m\033[35m"  
 COLWHITE="\033[1;6m\033[37m"  
 COLGRAY="\033[0;6m\033[37m"  
 COLBOLD="\033[1m"  
 COLDEFAULT="\033[0m"  
   
 if [[ ${NOCOLORS} = true ]]  
 then  
  COLRED=""  
  COLGREEN=""  
  COLYELLOW=""  
  COLBLUE=""  
  COLMAGENTA=""  
  COLWHITE=""  
  COLGRAY=""  
  COLBOLD=""  
  COLDEFAULT=""  
 fi  
   
17  # export default C locale  # export default C locale
18  export LC_ALL=C  export LC_ALL=C
19    
20  source /etc/mage.rc.global  source /etc/mage.rc.global
21  source ${MAGERC}  source ${MAGERC}
22    source ${MLIBDIR}/mage4.functions.sh
23    
24  # set PKGDIR and BUILDDIR and BINDIR to MROOT  # set PKGDIR and BUILDDIR and BINDIR to MROOT
25  if [[ -n ${MROOT} ]]  if [[ -n ${MROOT} ]]
# Line 59  then Line 29  then
29   export BINDIR=${MROOT}/${BINDIR}   export BINDIR=${MROOT}/${BINDIR}
30  fi  fi
31    
32    # sources the smage file and uses state from distribution file if exist
33    # may helpful for repository support later on
34    smagesource()
35    {
36     local file="$1"
37     local mystate
38     local mycodename
39    
40     source ${file}
41    
42     [[ -n ${STATE} ]] && mystate="${STATE}"
43    
44     # do not overide if local state was broken or disabled!
45     case ${STATE} in
46     broken) return ;;
47     disabled) return ;;
48     esac
49    
50     if [ -f ${SMAGESCRIPTSDIR}/distribution ]
51     then
52     source ${SMAGESCRIPTSDIR}/distribution
53     [[ -n ${STATE} ]] && mystate="${STATE}"
54     fi
55     # now switch state and export it
56     STATE="${mystate}"
57    }
58    
59  showversion()  showversion()
60  {  {
61   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
# Line 73  die() Line 70  die()
70   exit 1   exit 1
71  }  }
72    
73    die_pipestatus()
74    {
75     # the status change if we do any parameter declarations!!
76     # dont do this anymore, keep this in mind!
77     #
78     # local pos="$1"
79     # local comment="$2"
80     #
81     # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}"
82     #
83     [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2"
84    }
85    
86  xtitle()  xtitle()
87  {  {
88   if [[ ${TERM} = xterm ]]   if [[ ${TERM} = xterm ]]
# Line 129  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  
   
  # 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 \  
  --directory-prefix="${my_SOURCEDIR}" \  
  "${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 \  
  --directory-prefix="${my_SOURCEDIR}" \  
  "${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 \  
  --directory-prefix="${my_SOURCEDIR}" \  
  "${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 \  
  --directory-prefix="${my_SOURCEDIR}" \  
  "${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 \  
  --directory-prefix="${my_SOURCEDIR}" \  
  "${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 \  
  --directory-prefix="${my_SOURCEDIR}" \  
  "${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   mdownload --uri "${uri}" --dir "${outputdir}" || die "Could not download '${uri}'"
  unset my_SRC_URI_DEST  
  unset my_SRC_URI_MIRROR  
  unset my_SOURCEDIR  
  done  
181    
182   # recheck md5 sums   # unset them to be sure
183   echo   unset uri
184   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   unset subdir
185   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   unset outputdir
186   echo   done
187    
188     # recheck md5 sums after download
189     echo
190     echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
191     mchecksum --rundir "${SOURCEDIR}/${PNAME}" --file "${db_md5_file}" --method md5 || die "md5 failed"
192     echo
193     else
194     echo -e "${COLBLUE}===${COLGREEN} All sources already fetched, nothing to do${COLDEFAULT}"
195     fi
196    
197   # not needed anymore   # not needed anymore
198   unset SRC_URI   unset SRC_URI
199  }  }
200    
201  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
202  src_prepare()  src_prepare()
203  {  {
204   echo "no src_prepare defined"   echo "no src_prepare defined"
  sleep 2  
205   return 0   return 0
206  }  }
207    
208  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
209  src_compile()  src_compile()
210  {  {
211   echo "no src_compile defined"   echo "no src_compile defined"
  sleep 2  
212   return 0   return 0
213  }  }
214    
215  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
216    src_check()
217    {
218     echo "no src_check defined"
219     return 0
220    }
221    
222    # dummy function, used if that does not exist in smage file
223  src_install()  src_install()
224  {  {
225   echo "no src_install defined"   echo "no src_install defined"
  sleep 2  
226   return 0   return 0
227  }  }
228    
# Line 362  mconfigure() Line 241  mconfigure()
241   ./configure \   ./configure \
242   --prefix=/usr \   --prefix=/usr \
243   --host=${CHOST} \   --host=${CHOST} \
244     --build=${CHOST} \
245   --mandir=/usr/share/man \   --mandir=/usr/share/man \
246   --infodir=/usr/share/info \   --infodir=/usr/share/info \
247   --datadir=/usr/share \   --datadir=/usr/share \
# Line 405  munpack() Line 285  munpack()
285    
286   SRCFILE=$1   SRCFILE=$1
287    
288   if [ -z "$2" ]   if [[ -z $2 ]]
289   then   then
290   DEST=${BUILDDIR}   DEST=${BUILDDIR}
291   else   else
# Line 420  munpack() Line 300  munpack()
300   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
301   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
302   then   then
303   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed."
304     else
305     pushd ${DEST} > /dev/null
306     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
307     popd > /dev/null
308   fi   fi
309   ;;   ;;
310   gz)   gz)
# Line 428  munpack() Line 312  munpack()
312   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
313   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
314   then   then
315   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed."
316     else
317     pushd ${DEST} > /dev/null
318     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
319     popd > /dev/null
320   fi   fi
321   ;;   ;;
322   tbz2)   xz)
323   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   IFTAR="$(basename $SRCFILE .xz)"
324     IFTAR="${IFTAR##*.}"
325     if [[ ${IFTAR} = tar ]]
326     then
327     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
328     else
329     pushd ${DEST} > /dev/null
330     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
331     popd > /dev/null
332     fi
333     ;;
334     tbz2|mpks|mpk)
335     tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
336   ;;   ;;
337   tgz)   tgz)
338   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
339     ;;
340     txz|mpkzs|mpkz)
341     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
342     ;;
343     rar)
344     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
345     ;;
346     zip|xpi)
347     unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
348     ;;
349     rpm)
350     pushd ${DEST} > /dev/null
351     rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
352     tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
353     if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
354     then
355     rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
356     fi
357   ;;   ;;
358   *)   *)
359   die "munpack failed"   die "munpack failed"
# Line 475  mpatch() Line 393  mpatch()
393  mlibtoolize()  mlibtoolize()
394  {  {
395   local opts="$@"   local opts="$@"
396   [[ -z ${opts} ]] && opts="--copy --force"   [[ -z ${opts} ]] && opts="--verbose --install --force"
397    
398   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
399  }  }
400    
401    mautoreconf()
402    {
403     local opts="$@"
404     [[ -z ${opts} ]] && opts="--verbose --install --force"
405    
406     autoreconf ${opts} || die "running: mautoreconf ${opts}"
407    }
408    
409  minstalldocs()  minstalldocs()
410  {  {
411   local docfiles   local docfiles
# Line 490  minstalldocs() Line 416  minstalldocs()
416   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
417   fi   fi
418    
419     local i
420   for i in ${docfiles}   for i in ${docfiles}
421   do   do
422   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${i} ]
423   install -m 0644 ${SRCDIR}/${i}.gz \   then
424   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
425     install -m 0644 ${SRCDIR}/${i}.gz \
426     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
427     fi
428   done   done
429  }  }
430    
# Line 502  mstriplibs() Line 432  mstriplibs()
432  {  {
433   local stripdir="$@"   local stripdir="$@"
434    
435   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
436   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"
437     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
438  }  }
439    
440  mstripbins()  mstripbins()
441  {  {
442   local stripdir="$@"   local stripdir="$@"
443    
444   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
445   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"
446     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
447    }
448    
449    mstripstatic()
450    {
451     local stripdir="$@"
452    
453     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
454     [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug"
455     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
456    }
457    
458    mstriplibtoolarchive()
459    {
460     local stripdir="$@"
461    
462     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
463     find ${stripdir} ! -type d -name \*.la | xargs file | grep "libtool library" | cut -f 1 -d : | xargs --no-run-if-empty rm -f -- 2> /dev/null
464    }
465    
466    mpurgetargets()
467    {
468     local stripdir="$@"
469     local target
470    
471     [[ -z ${stripdir} ]] && stripdir=${BINDIR}
472     # nothing to do in this case
473     [[ -z ${PURGE_TARGETS[*]} ]] && return
474    
475     for target in ${PURGE_TARGETS[*]}
476     do
477     # check if target is a regex pattern without any slashes
478     if [[ ${target} = ${target//\/} ]]
479     then
480     find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null
481     else
482     rm -f -- ${target} 2> /dev/null
483     fi
484     done
485    }
486    
487    mcompressdocs()
488    {
489     local bindir="$@"
490    
491     if [ -d ${bindir}/usr/share/man ]
492     then
493     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
494     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
495     fi
496    
497     if [ -d ${bindir}/usr/share/info ]
498     then
499     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
500     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
501     fi
502  }  }
503    
504  sminclude()  sminclude()
# Line 627  EOF Line 614  EOF
614  # special tags:  # special tags:
615  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
616  #   INHERITS              which functions get included  #   INHERITS              which functions get included
617  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
618  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
619    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
620    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
621    #                         (only in the resulting magefile}
622  #  #
623  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
624  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 639  build_mage_script() Line 629  build_mage_script()
629   local magefile   local magefile
630   local dest   local dest
631   local target   local target
632     local split_pkg_base
633   local sym   local sym
634   local depname   local depname
635    
# Line 646  build_mage_script() Line 637  build_mage_script()
637   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
638    
639   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
640   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
641    
642     # mark package as splitpackage
643     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
644    
645   # name of magefile   # name of magefile
646   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 662  build_mage_script() Line 656  build_mage_script()
656   # now build the mage file   # now build the mage file
657   > ${dest}   > ${dest}
658    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.58 2007-06-07 13:16:03 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
659   # pgkname and state   # pgkname and state
660   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
661   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
662    
663   # description and homepage   # description and homepage
664   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
665   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
666    
667   # special tags and vars   # special tags and vars
668   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
669    
670   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
671   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
672   echo >> ${dest}  
673     # split package base
674     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
675    
676   # add special vars   # add special vars
677   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 692  build_mage_script() Line 682  build_mage_script()
682   # being tricky here :)   # being tricky here :)
683   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
684   done   done
  echo  >> ${dest}  
685   fi   fi
686    
687   # add at least all includes   # add at least all includes
# Line 704  build_mage_script() Line 693  build_mage_script()
693   do   do
694   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
695   done   done
696   echo  >> ${dest}   # a CRLF is needed here!
697     echo >> ${dest}
698   fi   fi
  echo >> ${dest}  
699    
700   # deps and provides   # deps and provides
701   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
702   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
703   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
704    
705   # add special functions   # add special functions
706   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 724  build_mage_script() Line 710  build_mage_script()
710   do   do
711   # add to mage (quotes needed !)   # add to mage (quotes needed !)
712   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
713   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
714   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
715   done   done
  echo  >> ${dest}  
716   fi   fi
717    
718   # pre|post-install|removes   # pre|post-install|removes
719   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
720   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
721   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
722   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
723  }  }
724    
725  regen_mage_tree()  regen_mage_tree()
726  {  {
727   local i   local subpackage
728    
729   # build them only if requested   # build them only if requested
730   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
731   then   then
732   # run it without targets   # run it without targets
733   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
734   then   then
735     # build for each target a mage file
736     # run it with several targets
737   echo   echo
738   build_mage_script   for subpackage in ${MAGE_TARGETS}
739     do
740     build_mage_script --target "${subpackage}"
741     done
742   echo   echo
  else  
743    
744   # build for each target an mage file   # run it for splitpackages
745     elif [[ -n ${SPLIT_PACKAGES} ]]
746     then
747     local split_pkg_base="${PNAME}"
748     # save smage environment
749     split_save_variables
750     # build for each subpackage a mage file
751   # run it with several targets   # run it with several targets
752   for i in ${MAGE_TARGETS}   echo
753     for subpackage in ${SPLIT_PACKAGES}
754   do   do
755   echo   # get the right variables for the split
756   build_mage_script "${i}"   export PNAME="${subpackage}"
757   echo   split_info_${subpackage}
758     # get the preinstall etc
759     split_export_inherits ${subpackage}
760     build_mage_script --split-pkg-base "${split_pkg_base}"
761     # delete split preinstall etc
762     split_delete_inherits ${subpackage}
763     # restore smage environment
764     split_restore_variables
765   done   done
766     echo
767     # unset all saved smage variables
768     split_unset_variables
769    
770     else
771     echo
772     build_mage_script
773     echo
774   fi   fi
775   fi   fi
776    
# Line 795  regen_mage_tree() Line 801  regen_mage_tree()
801   unset postremove   unset postremove
802  }  }
803    
804    split_save_variables()
805    {
806     export SAVED_PNAME="${PNAME}"
807     export SAVED_PVER="${PVER}"
808     export SAVED_PBUILD="${PBUILD}"
809     export SAVED_PCATEGORIE="${PCATEGORIE}"
810     export SAVED_DESCRIPTION="${DESCRIPTION}"
811     export SAVED_HOMEPAGE="${HOMEPAGE}"
812     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
813     export SAVED_STATE="${STATE}"
814     export SAVED_PKGTYPE="${PKGTYPE}"
815     export SAVED_INHERITS="${INHERITS}"
816     export SAVED_DEPEND="${DEPEND}"
817     export SAVED_SDEPEND="${SDEPEND}"
818     export SAVED_PROVIDE="${PROVIDE}"
819     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
820    
821     # bindir too
822     export SAVED_BINDIR="${BINDIR}"
823    
824     # export the SPLIT_PACKAGE_BASE
825     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
826    
827     # functions
828     if [[ ! -z $(typeset -f preinstall) ]]
829     then
830     # rename the old one
831     local saved_preinstall
832     saved_preinstall=SAVED_$(typeset -f preinstall)
833     eval "${saved_preinstall}"
834     export -f SAVED_preinstall
835     fi
836    
837     if [[ ! -z $(typeset -f postinstall) ]]
838     then
839     # rename the old one
840     local saved_postinstall
841     saved_postinstall=SAVED_$(typeset -f postinstall)
842     eval "${saved_postinstall}"
843     export -f SAVED_postinstall
844     fi
845    
846     if [[ ! -z $(typeset -f preremove) ]]
847     then
848     # rename the old one
849     local saved_preremove
850     saved_preremove=SAVED_$(typeset -f preremove)
851     eval "${saved_preremove}"
852     export -f SAVED_preremove
853     fi
854    
855     if [[ ! -z $(typeset -f postremove) ]]
856     then
857     # rename the old one
858     local saved_postremove
859     saved_postremove=SAVED_$(typeset -f postremove)
860     eval "${saved_postremove}"
861     export -f SAVED_postremove
862     fi
863    }
864    
865    split_restore_variables()
866    {
867     export PNAME="${SAVED_PNAME}"
868     export PVER="${SAVED_PVER}"
869     export PBUILD="${SAVED_PBUILD}"
870     export PCATEGORIE="${SAVED_PCATEGORIE}"
871     export DESCRIPTION="${SAVED_DESCRIPTION}"
872     export HOMEPAGE="${SAVED_HOMEPAGE}"
873     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
874     export STATE="${SAVED_STATE}"
875     export PKGTYPE="${SAVED_PKGTYPE}"
876     export INHERITS="${SAVED_INHERITS}"
877     export DEPEND="${SAVED_DEPEND}"
878     export SDEPEND="${SAVED_SDEPEND}"
879     export PROVIDE="${SAVED_PROVIDE}"
880     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
881    
882     # bindir too
883     export BINDIR="${SAVED_BINDIR}"
884    
885     # functions
886     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
887     then
888     # rename the old one
889     local saved_preinstall
890     saved_preinstall=$(typeset -f SAVED_preinstall)
891     eval "${saved_preinstall/SAVED_/}"
892     export -f preinstall
893     fi
894    
895     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
896     then
897     # rename the old one
898     local saved_postinstall
899     saved_postinstall=$(typeset -f SAVED_postinstall)
900     eval "${saved_postinstall/SAVED_/}"
901     export -f postinstall
902     fi
903    
904     if [[ ! -z $(typeset -f SAVED_preremove) ]]
905     then
906     # rename the old one
907     local saved_preremove
908     saved_preremove=$(typeset -f SAVED_preremove)
909     eval "${saved_preremove/SAVED_/}"
910     export -f preremove
911     fi
912    
913     if [[ ! -z $(typeset -f SAVED_postremove) ]]
914     then
915     # rename the old one
916     local saved_postremove
917     saved_postremove=$(typeset -f SAVED_postremove)
918     eval "${saved_postremove/SAVED_/}"
919     export -f postremove
920     fi
921    }
922    
923    split_unset_variables()
924    {
925     # unset saved vars; not needed anymore
926     unset SAVED_PNAME
927     unset SAVED_PVER
928     unset SAVED_PBUILD
929     unset SAVED_PCATEGORIE
930     unset SAVED_DESCRIPTION
931     unset SAVED_HOMEPAGE
932     unset SAVED_SPECIAL_VARS
933     unset SAVED_STATE
934     unset SAVED_PKGTYPE
935     unset SAVED_INHERITS
936     unset SAVED_DEPEND
937     unset SAVED_SDEPEND
938     unset SAVED_PROVIDE
939     unset SAVED_BINDIR
940     unset SAVED_NOPKGBUILD
941     unset SPLIT_PACKAGE_BASE
942     unset -f SAVED_preinstall
943     unset -f SAVED_postinstall
944     unset -f SAVED_preremove
945     unset -f SAVED_postremove
946    }
947    
948    split_export_inherits()
949    {
950     local subpackage="$1"
951     local func
952     local newfunc
953    
954     for func in preinstall postinstall preremove postremove
955     do
956     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
957     then
958     newfunc=$(typeset -f ${func}_${subpackage})
959     newfunc="${newfunc/_${subpackage} (/ (}"
960     eval "${newfunc}"
961     fi
962     done
963    }
964    
965    split_delete_inherits()
966    {
967     local subpackage="$1"
968     local func
969    
970     for func in preinstall postinstall preremove postremove
971     do
972     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
973     then
974     unset -f ${func}
975     fi
976     done
977     }
978    
979  export_inherits()  export_inherits()
980  {  {
981   local include="$1"   local include="$1"
# Line 856  generate_package_md5sum() Line 1037  generate_package_md5sum()
1037   # fix target as it may be empty !   # fix target as it may be empty !
1038   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1039    
1040    
1041   # build pkgname   # build pkgname
1042   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1043    
# Line 875  generate_package_md5sum() Line 1057  generate_package_md5sum()
1057   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1058    
1059   # setup md5 dir   # setup md5 dir
1060   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1061   install -d ${dest}   install -d ${dest}
1062    
1063   # gen md5sum   # gen md5sum
# Line 913  source_pkg_build() Line 1095  source_pkg_build()
1095   echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"   echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
1096  }  }
1097    
1098    step_by_step()
1099    {
1100     if [[ ${STEP_BY_STEP} = true ]]
1101     then
1102     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1103     echo "Press [enter] to continue"
1104     read
1105     fi
1106    }
1107    
1108    
1109  # print out our version  # print out our version
1110  showversion  showversion
# Line 939  fi Line 1131  fi
1131  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1132  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1133  then  then
1134   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1135   then   then
1136   SMAGENAME="$2"   SMAGENAME="$2"
1137   MD5DIR="$3"   MD5DIR="$3"
1138   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1139    
1140     smagesource ${SMAGENAME} || die "download source failed"
1141    
1142   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1143   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 995  then Line 1189  then
1189   echo   echo
1190   else   else
1191   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1192   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1193   echo   echo
1194   echo   echo
1195   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1017  then Line 1211  then
1211   # get smage   # get smage
1212   SMAGENAME="$2"   SMAGENAME="$2"
1213   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1214   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1215    
1216   download_sources   download_sources
1217   exit 0   exit 0
# Line 1029  then Line 1223  then
1223   # set correct SMAGENAME   # set correct SMAGENAME
1224   SMAGENAME="$2"   SMAGENAME="$2"
1225   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1226   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1227    
1228   regen_mage_tree   regen_mage_tree
1229    
1230   # build md5sum for existing packages   # build several targets
1231   generate_package_md5sum \   if [[ -n ${MAGE_TARGETS} ]]
1232   --pcat "${PCATEGORIE}" \   then
1233   --pname "${PNAME}" \   for target in ${MAGE_TARGETS}
1234   --pver "${PVER}" \   do
1235   --pbuild "${PBUILD}" \   # build md5sum for existing packages
1236   --parch "${ARCH}" \   generate_package_md5sum \
1237   --target "${target}"   --pcat "${PCATEGORIE}" \
1238     --pname "${PNAME}" \
1239     --pver "${PVER}" \
1240     --pbuild "${PBUILD}" \
1241     --parch "${ARCH}" \
1242     --target "${target}"
1243     done
1244    
1245     # build several subpackages
1246     elif [[ -n ${SPLIT_PACKAGES} ]]
1247     then
1248     split_save_variables
1249     for subpackage in ${SPLIT_PACKAGES}
1250     do
1251     # get the right variables for the split
1252     export PNAME="${subpackage}"
1253     split_info_${subpackage}
1254     # build md5sum for existing packages
1255     generate_package_md5sum \
1256     --pcat "${PCATEGORIE}" \
1257     --pname "${PNAME}" \
1258     --pver "${PVER}" \
1259     --pbuild "${PBUILD}" \
1260     --parch "${ARCH}"
1261     # restore smage environment
1262     split_restore_variables
1263     done
1264     # unset all saved smage variables
1265     split_unset_variables
1266    
1267     else
1268     # build md5sum for existing packages
1269     generate_package_md5sum \
1270     --pcat "${PCATEGORIE}" \
1271     --pname "${PNAME}" \
1272     --pver "${PVER}" \
1273     --pbuild "${PBUILD}" \
1274     --parch "${ARCH}"
1275     fi
1276    
1277   exit 0   exit 0
1278  fi  fi
# Line 1053  then Line 1285  then
1285    
1286   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1287    
1288   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1289    
1290   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1291   then   then
# Line 1102  fi Line 1334  fi
1334  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1335  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1336    
1337  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1338  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1339  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1340    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1341    
1342  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1343  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
# Line 1127  fi Line 1360  fi
1360  # fixes some issues with these functions  # fixes some issues with these functions
1361  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
1362  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
1363    export -f src_check || die "src_check export failed"
1364  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
1365    
1366  # fixes some compile issues  # fixes some compile issues
# Line 1144  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 1378  export MAKEOPTS="${MAKEOPTS}" || die "MA
1378  # setup ccache  # setup ccache
1379  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
1380    
1381  # small sleep to show our settings  # clean up builddir if a previously one exist
 sleep 1  
   
 # cleans up build if a previously one exists  
1382  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
1383  then  then
1384   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1385  fi  fi
1386  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1387    
1388  # cleans up srcdir if a previously unpacked one exists  # clean up srcdir if a previously unpacked one exist
1389  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
1390  then  then
1391   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
1392  fi  fi
1393    
1394  # 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
1395  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
1396  then  then
1397   rm -rf ${BINDIR}   rm -rf ${BINDIR}
1398  fi  fi
1399  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
1400    
1401  # cleans up package temp dir if a previous build exists  # clean up package temp dir if a previous build exist
1402  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
1403  then  then
1404   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
1405  fi  fi
1406    
1407  # cleans up timestamp if one exists  # setup build logging
1408  if [ -f /var/tmp/timestamp ]  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1409    echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1410    
1411    src_prepare | ${SMAGE_LOG_CMD}
1412    die_pipestatus 0 "src_prepare failed"
1413    step_by_step $_
1414    
1415    src_compile | ${SMAGE_LOG_CMD}
1416    die_pipestatus 0 "src_compile failed"
1417    step_by_step $_
1418    
1419    # only run checks if requested
1420    if [[ ${MAGE_CHECK} != true ]]
1421  then  then
1422   mage rmstamp   echo "MAGE_CHECK not requested; src_check() will not be run!" | ${SMAGE_LOG_CMD}
1423     step_by_step src_check
1424    else
1425     src_check | ${SMAGE_LOG_CMD}
1426     die_pipestatus 0 "src_check failed"
1427     step_by_step $_
1428  fi  fi
1429    
1430  src_prepare || die "src_prepare failed"  # build several subpackages
1431  src_compile || die "src_compile failed"  if [[ -n ${SPLIT_PACKAGES} ]]
1432  src_install || die "src_install failed"  then
1433     # save bindir & pname
1434     split_save_variables
1435     export SAVED_BINDIR="${BINDIR}"
1436     for subpackage in ${SPLIT_PACKAGES}
1437     do
1438     if typeset -f src_install_${subpackage} > /dev/null
1439     then
1440     # export subpackage bindir
1441     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1442     # export PNAME, several internal function and include
1443     # rely on this variable
1444     export PNAME="${subpackage}"
1445    
1446     echo
1447     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1448     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1449     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1450     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1451    
1452     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1453     die_pipestatus 0 "src_install_${subpackage} failed"
1454     step_by_step $_
1455     fi
1456     done
1457     # restore bindir & pname
1458     split_restore_variables
1459     # unset all saved smage variables
1460     split_unset_variables
1461    else
1462     src_install | ${SMAGE_LOG_CMD}
1463     die_pipestatus 0 "src_install failed"
1464     step_by_step $_
1465    fi
1466    
1467  # compressing doc, info & man files  # compressing doc, info & man files
1468  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [[ -n ${SPLIT_PACKAGES} ]]
1469  then  then
1470   echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1471   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   do
1472     mcompressdocs ${BINDIR}_${subpackage}
1473     done
1474    else
1475     mcompressdocs ${BINDIR}
1476    fi
1477    
1478    if [[ ${SMAGE_STRIP_LIBTOOL} = true ]]
1479    then
1480     if [[ -n ${SPLIT_PACKAGES} ]]
1481     then
1482     for subpackage in ${SPLIT_PACKAGES}
1483     do
1484     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}"
1485     mstriplibtoolarchive ${BINDIR}_${subpackage}
1486     done
1487     else
1488     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}"
1489     mstriplibtoolarchive ${BINDIR}
1490     fi
1491  fi  fi
1492    
1493  if [ -d ${BUILDDIR}/builded/usr/share/info ]  if [[ ${SMAGE_PURGE} = true ]]
1494  then  then
1495   echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"   if [[ -n ${SPLIT_PACKAGES} ]]
1496   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   then
1497     for subpackage in ${SPLIT_PACKAGES}
1498     do
1499     echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}"
1500     mpurgetargets ${BINDIR}_${subpackage}
1501     done
1502     else
1503     echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}"
1504     mpurgetargets ${BINDIR}
1505     fi
1506  fi  fi
1507    
1508  # stripping all bins and libs  # stripping all bins and libs
# Line 1203  case ${NOSTRIP} in Line 1511  case ${NOSTRIP} in
1511   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1512   ;;   ;;
1513   *)   *)
1514   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   if [[ -n ${SPLIT_PACKAGES} ]]
1515   mstripbins ${BINDIR}   then
1516   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1517   mstriplibs ${BINDIR}   do
1518     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1519     mstripbins ${BINDIR}_${subpackage}
1520     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1521     mstriplibs ${BINDIR}_${subpackage}
1522     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1523     mstripstatic ${BINDIR}_${subpackage}
1524     done
1525     else
1526     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1527     mstripbins ${BINDIR}
1528     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1529     mstriplibs ${BINDIR}
1530     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1531     mstripstatic ${BINDIR}
1532     fi
1533   ;;   ;;
1534  esac  esac
1535    
# Line 1217  case ${NOPKGBUILD} in Line 1540  case ${NOPKGBUILD} in
1540   ;;   ;;
1541   *)   *)
1542   # build several targets   # build several targets
1543   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1544   then   then
1545   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1546   do   do
1547   # check if an special target_pkgbuild exists   # check if a special target_pkgbuild exists
1548   if typeset -f ${target}_pkgbuild > /dev/null   if typeset -f ${target}_pkgbuild > /dev/null
1549   then   then
1550   # run it   # run it
# Line 1243  case ${NOPKGBUILD} in Line 1566  case ${NOPKGBUILD} in
1566    
1567   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}"
1568   done   done
1569    
1570     # build several subpackages
1571     elif [[ -n ${SPLIT_PACKAGES} ]]
1572     then
1573     split_save_variables
1574     for subpackage in ${SPLIT_PACKAGES}
1575     do
1576     # get the right variables for the split
1577     export PNAME="${subpackage}"
1578     split_info_${PNAME}
1579    
1580     # jump to next one if NOPKGBUILD is set in split_info
1581     case ${NOPKGBUILD} in
1582     true|TRUE|yes|y) continue ;;
1583     esac
1584    
1585     # check if an special subpackage_pkgbuild exists
1586     if typeset -f ${PNAME}_pkgbuild > /dev/null
1587     then
1588     # run it
1589     ${PNAME}_pkgbuild
1590     fi
1591     # now create the target package
1592     ${MLIBDIR}/pkgbuild_dir.sh \
1593     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1594     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1595    
1596     # build pkg-md5-sum if requested
1597     generate_package_md5sum \
1598     --pcat "${PCATEGORIE}" \
1599     --pname "${PNAME}" \
1600     --pver "${PVER}" \
1601     --pbuild "${PBUILD}" \
1602     --parch "${ARCH}"
1603    
1604     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1605    
1606     # restore smage environment
1607     split_restore_variables
1608     done
1609     # unset all saved smage variables
1610     split_unset_variables
1611    
1612   else   else
1613   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1614    
# Line 1262  case ${NOPKGBUILD} in Line 1628  case ${NOPKGBUILD} in
1628   ;;   ;;
1629  esac  esac
1630    
1631    if [[ ${SMAGE_BUILD_LOGGING} != false ]]
1632    then
1633     bzip2 -9f /var/log/smage/${PKGNAME}.log
1634    else
1635     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1636    fi
1637    
1638  # for sure  # for sure
1639  unset NOPKGBUILD  unset NOPKGBUILD
1640  unset NOSTRIP  unset NOSTRIP

Legend:
Removed from v.497  
changed lines
  Added in v.1580