Magellan Linux

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

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

revision 204 by niro, Mon Aug 22 00:07:32 2005 UTC revision 1594 by niro, Thu Dec 29 15:21:25 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.34 2005-08-22 00:07:32 niro Exp $  
8    
 #01.10.2004  
 # added ccache support  
 # added distcc support  
9    
10  ## setup ##  # set default user mage.rc
11  PKGSUFFIX="mpk"  : ${MAGERC="/etc/mage.rc"}
 SMAGENAME="$1"  
 SMAGESUFFIX="smage2"  
 #SOURCEDIR="/bootstrap/sources"  
 #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"  
 #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"  
 MLIBDIR=/usr/lib/mage  
 SMAGEVERSION="$( < ${MLIBDIR}/version)"  
12    
13  # export default C locale  # export default C locale
14  export LC_ALL=C  export LC_ALL=C
15    
16  source /etc/mage.rc  source /etc/mage.rc.global
17    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
25    if [[ -n ${MROOT} ]]
26    then
27     export PKGDIR=${MROOT}/${PKGDIR}
28     export BUILDDIR=${MROOT}/${BUILDDIR}
29     export BINDIR=${MROOT}/${BINDIR}
30    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  showversion() {   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()
60    {
61   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
62   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"
63  }  }
64    
65  die() {  die()
66    {
67   xtitleclean   xtitleclean
68     echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
69   echo "SMAGE failed: $@"   echo "SMAGE failed: $@"
70   exit 1   exit 1
71  }  }
72    
73  xtitle() {  die_pipestatus()
74   if [ ${TERM} == "xterm" ]  {
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()
87    {
88     if [[ ${TERM} = xterm ]]
89   then   then
90   echo -ne "\033]0;[sMage: $@]\007"   echo -ne "\033]0;[sMage: $@]\007"
91   fi   fi
92   return 0   return 0
93  }  }
94    
95  xtitleclean() {  xtitleclean()
96   if [ ${TERM} == "xterm" ]  {
97     if [[ ${TERM} = xterm ]]
98   then   then
99   echo -ne "\033]0;\007"   echo -ne "\033]0;\007"
100   fi   fi
101   return 0   return 0
102  }  }
103    
104  syncsmage2() {  syncsmage2()
105    {
106   xtitle "Updating smage2-script tree ..."   xtitle "Updating smage2-script tree ..."
107   local i   local i
108   for i in ${SMAGE2RSYNC}   for i in ${SMAGE2RSYNC}
109   do   do
110   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR}
111   --recursive \   if [[ $? = 0 ]]
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${SMAGESCRIPTSDIR}  
   
  if [ "$?" == "0" ]  
112   then   then
113   break   break
114   else   else
115   continue   continue
116   fi   fi
   
117   done   done
118    
119   #clean up backup files (foo~)   # clean up backup files (foo~)
120   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'
121    
122   xtitleclean   xtitleclean
123  }  }
124    
125  # $1 filename  # $1 filename
126  get_db_md5_sum() {  get_db_md5_sum()
127    {
128   local DB_FILE   local DB_FILE
129   local MD5_FILE   local MD5_FILE
130   local i   local i
# Line 101  get_db_md5_sum() { Line 137  get_db_md5_sum() {
137   echo "${i}"   echo "${i}"
138  }  }
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, not fetching needed   # md5's ok, no fetching needed
156   FETCHING=false   fetching=false
157   else   else
158   FETCHING=true   fetching=true
159   fi   fi
   
  for ((i=0; i < EOA; i++))  
  do  
  # url to file  
  my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)"  
   
  # subdir in sources dir; the my_SRCI_URI file goes to there  
  my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)"  
160    
161   # if my_src_uri_dest is not equal my_src_uri; than an other dir is used   if [[ ${fetching} = true ]]
162   if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]]   then
163   then   for ((i=0; i < count; i++))
164   my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}"   do
165   else   # url to file
166   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"   uri="${SRC_URI[${i}]%%' '*}"
  fi  
167    
168   # if an mirrored file than replace first the mirror uri   # subdir in sources dir; the my_SRCI_URI file goes to there
169   if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ]   subdir="${SRC_URI[${i}]##*' '}"
  then  
  for mirror in ${MIRRORS}  
  do  
  my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"  
170    
171   #echo "DEBUG: ${MY_SRC_URI}"   # if $subdir is not equal with $uri then an other dir is used
172   if [[ ${FETCHING} == true ]]   if [[ ${uri} != ${subdir} ]]
  then  
  echo "==> fetching ${my_SRC_URI_MIRROR}"  
  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  
  #echo "DEBUG: ${SRC_URI[${i}]}"  
  if [[ ${FETCHING} == true ]]  
173   then   then
174   echo "==> fetching ${my_SRC_URI}"   outputdir="${SOURCEDIR}/${PNAME}/${subdir}"
175   wget \   else
176   --passive-ftp \   outputdir="${SOURCEDIR}/${PNAME}"
177   --tries 3 \   fi
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
  "${my_SRC_URI}"  
 # only needed to run through a list of mirrors  
 # if [ "$?" == "0" ]  
 # then  
 # break  
 # else  
 # continue  
 # fi  
  fi  
  fi  
   
  # unset them to be shure  
  unset my_SRC_URI  
  unset my_SRC_URI_DEST  
  unset my_SRC_URI_MIRROR  
  unset my_SOURCEDIR  
  done  
178    
179   # recheck md5 sums   echo -e "${COLBLUE}==>${COLGREEN} fetching ${uri}${COLDEFAULT}"
180   echo   mdownload --uri "${uri}" --dir "${outputdir}" || die "Could not download '${uri}'"
181   echo ">== Checking MD5 sums:"  
182   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   # unset them to be sure
183   echo   unset uri
184     unset subdir
185     unset outputdir
186     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   echo "no src_prepare defined"  {
204   sleep 2   echo "no src_prepare defined; doing nothing ..."
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   echo "no src_compile defined"  {
211   sleep 2   echo "no src_compile defined; doing nothing ..."
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_install() {  src_check()
217   echo "no src_install defined"  {
218   sleep 2   echo "no src_check defined; doing nothing ..."
219   return 0   return 0
220  }  }
221    
222  mconfigure() {  # dummy function, used if that does not exist in smage file
223    src_install()
224    {
225     echo "no src_install defined; doing nothing ..."
226     return 0
227    }
228    
229    mlibdir()
230    {
231     local libdir=lib
232     [[ ${ARCH} = x86_64 ]] && libdir=lib64
233    
234     echo "${libdir}"
235    }
236    
237    mconfigure()
238    {
239   if [ -x ./configure ]   if [ -x ./configure ]
240   then   then
241   ./configure \   ./configure \
242   --prefix=/usr \   --prefix=/usr \
243   --host=${CHOST} \   --host=${CHOST} \
244   --mandir=/usr/share/man \   --build=${CHOST} \
245   --infodir=/usr/share/info \   --mandir=/usr/share/man \
246   --datadir=/usr/share \   --infodir=/usr/share/info \
247   --sysconfdir=/etc \   --datadir=/usr/share \
248   --localstatedir=/var/lib \   --sysconfdir=/etc \
249   "$@" || die "mconfigure failed"   --localstatedir=/var/lib \
250     --libdir=/usr/$(mlibdir) \
251     "$@" || die "mconfigure failed"
252   else   else
253   echo "configure is not an executable ..."   echo "configure is not an executable ..."
254   exit 1   exit 1
255   fi   fi
256  }  }
257    
258  minstall() {  minstall()
259   if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then  {
260     if [ -f ./[mM]akefile -o -f ./GNUmakefile ]
261     then
262   make prefix=${BINDIR}/usr \   make prefix=${BINDIR}/usr \
263   datadir=${BINDIR}/usr/share \   datadir=${BINDIR}/usr/share \
264   infodir=${BINDIR}/usr/share/info \   infodir=${BINDIR}/usr/share/info \
265   localstatedir=${BINDIR}/var/lib \   localstatedir=${BINDIR}/var/lib \
266   mandir=${BINDIR}/usr/share/man \   mandir=${BINDIR}/usr/share/man \
267   sysconfdir=${BINDIR}/etc \   sysconfdir=${BINDIR}/etc \
268     libdir=${BINDIR}/usr/$(mlibdir) \
269   "$@" install || die "minstall failed"   "$@" install || die "minstall failed"
270          else          else
271                  die "no Makefile found"                  die "no Makefile found"
272          fi          fi
273  }  }
274    
275  mmake() {  mmake()
276    {
277   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
278  }  }
279    
280  munpack() {  munpack()
281    {
282   local SRCFILE   local SRCFILE
283   local IFTAR   local IFTAR
284   local DEST   local DEST
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
292   DEST=$2   DEST=$2
293   fi   fi
294    
295     [[ ! -d ${DEST} ]] && install -d ${DEST}
296    
297   case "${SRCFILE##*.}" in   case "${SRCFILE##*.}" in
298   bz2)   bz2)
299   IFTAR="$(basename $SRCFILE .bz2)"   IFTAR="$(basename $SRCFILE .bz2)"
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)
311   IFTAR="$(basename $SRCFILE .gz)"   IFTAR="$(basename $SRCFILE .gz)"
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 309  munpack() { Line 361  munpack() {
361   esac   esac
362  }  }
363    
364  mpatch() {  mpatch()
365    {
366   local PATCHOPTS   local PATCHOPTS
367   local PATCHFILE   local PATCHFILE
368     local i
369    
370   PATCHOPTS=$1   PATCHOPTS=$1
371   PATCHFILE=$2   PATCHFILE=$2
372    
373     if [[ -z $2 ]]
374     then
375     PATCHFILE=$1
376    
377     ## patch level auto-detection, get patch level
378     for ((i=0; i < 10; i++))
379     do
380     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
381     if [[ $? = 0 ]]
382     then
383     PATCHOPTS="-Np${i}"
384     break
385     fi
386     done
387     fi
388    
389     echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
390   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
391  }  }
392    
393    mlibtoolize()
394    {
395     local opts="$@"
396     [[ -z ${opts} ]] && opts="--verbose --install --force"
397    
398     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
412     local doc
413   docfiles="$@"   docfiles="$@"
414    
415   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
416   then   then
417   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
418   fi   fi
419    
420   for i in ${docfiles}   for doc in ${docfiles}
421   do   do
422   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${doc} ]
423   install -m 0644 ${SRCDIR}/${i}.gz \   then
424   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   if mqueryfeature "compressdoc"
425     then
426     cat ${doc} | gzip -9c > ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/${doc}.gz || die "gzipping +installing ${doc}."
427     chmod 0644 ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/${doc}.gz || die "fixing permissions of ${doc}."
428     else
429     install -m 0644 ${SRCDIR}/${i} ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "installing ${doc}."
430     fi
431     fi
432   done   done
433  }  }
434    
435  mstriplibs() {  mstriplibs()
436    {
437   local stripdir="$@"   local stripdir="$@"
438    
439   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
440   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"
441     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
442  }  }
443    
444  mstripbins() {  mstripbins()
445    {
446   local stripdir="$@"   local stripdir="$@"
447    
448   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
449   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"
450     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
451  }  }
452    
453  sminclude() {  mstripstatic()
454    {
455     local stripdir="$@"
456    
457     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
458     [[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug"
459     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
460    }
461    
462    mstriplibtoolarchive()
463    {
464     local stripdir="$@"
465    
466     [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
467     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
468    }
469    
470    mpurgetargets()
471    {
472     local stripdir="$@"
473     local target
474    
475     [[ -z ${stripdir} ]] && stripdir=${BINDIR}
476     # nothing to do in this case
477     [[ -z ${PURGE_TARGETS[*]} ]] && return
478    
479     for target in ${PURGE_TARGETS[*]}
480     do
481     # check if target is a regex pattern without any slashes
482     if [[ ${target} = ${target//\/} ]]
483     then
484     find ${BINDIR} -type f -name "${target}" | xargs --no-run-if-empty rm -f -- 2> /dev/null
485     else
486     rm -f -- ${target} 2> /dev/null
487     fi
488     done
489    }
490    
491    mcompressdocs()
492    {
493     local bindir="$@"
494    
495     if [ -d ${bindir}/usr/share/man ]
496     then
497     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
498     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
499     fi
500    
501     if [ -d ${bindir}/usr/share/info ]
502     then
503     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
504     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
505     fi
506    }
507    
508    sminclude()
509    {
510   local i   local i
511    
512   if [[ -n "$@" ]]   if [[ -n "$@" ]]
# Line 366  sminclude() { Line 520  sminclude() {
520   fi   fi
521  }  }
522    
523  setup_distcc_environment(){  setup_distcc_environment()
524    {
525   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
526   then   then
527   echo "Using DistCC for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
528   export PATH=/usr/lib/distcc/bin:${PATH} || die "distcc: could not export new $PATH"   export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
   
  #export distcc as compiler  
 # export CC="distcc"  
 # export CXX=distcc  
529    
530   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
531    
532     # creating distcc tempdir
  #ccache + distcc together  
  if [ "${SMAGE_USE_CCACHE}" == "true" ]  
  then  
  if [ -x /usr/bin/ccache ]  
  then  
  echo "Preparing DistCC to work together with CCache ..."  
  #export CCACHE_PREFIX="distcc" || die "distcc: could not set ccach_prefix"  
 # export CC="ccache distcc"  
 # export CXX="ccache distcc"  
  fi  
  fi  
   
  #creating distcc tempdir  
533   install -o distcc -g daemon -d ${DISTCC_DIR}   install -o distcc -g daemon -d ${DISTCC_DIR}
534   chmod 1777 ${DISTCC_DIR}   chmod 1777 ${DISTCC_DIR}
535   fi   fi
536  }  }
537    
538  setup_ccache_environment(){  setup_ccache_environment()
539    {
540   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
541   then   then
542   echo "Using CCache for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
543   export PATH=/usr/lib/ccache/bin:${PATH} || die "ccache: could not export new $PATH"   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
  #unset CC CXX  
544   fi   fi
545  }  }
546    
   
547  # fixes given dependencies to match a MAGE_TARGET  # fixes given dependencies to match a MAGE_TARGET
548  # fix_mage_deps -target s/depend # <-- note -target !  # fix_mage_deps -target s/depend # <-- note -target !
549  fix_mage_deps() {  fix_mage_deps()
550    {
551   local target="$1"   local target="$1"
552   local depend="$2"   local depend="$2"
553   local NDEPEND   local NDEPEND
# Line 424  fix_mage_deps() { Line 562  fix_mage_deps() {
562   # fix DEPEND   # fix DEPEND
563   while read sym dep   while read sym dep
564   do   do
565     # ignore empty lines
566     [[ -z ${dep} ]] && continue
567    
568   cat="$(dirname ${dep})"   cat="$(dirname ${dep})"
569   # change if not virtual   # change if not virtual
570   if [[ ${cat} = virtual ]]   if [[ ${cat} = virtual ]]
# Line 476  EOF Line 617  EOF
617  # special tags:  # special tags:
618  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
619  #   INHERITS              which functions get included  #   INHERITS              which functions get included
620  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
621  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
622    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
623    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
624    #                         (only in the resulting magefile}
625  #  #
626  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
627  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 488  build_mage_script() Line 632  build_mage_script()
632   local magefile   local magefile
633   local dest   local dest
634   local target   local target
635     local split_pkg_base
636   local sym   local sym
637   local depname   local depname
638    
# Line 495  build_mage_script() Line 640  build_mage_script()
640   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
641    
642   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
643   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
644    
645     # mark package as splitpackage
646     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
647    
648   # name of magefile   # name of magefile
649   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 504  build_mage_script() Line 652  build_mage_script()
652   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
653    
654   # show what we are doing   # show what we are doing
655   echo "Generating Mage file:"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
656   echo "  ${dest}"   echo "${dest}"
657    
658   install -d "$(dirname ${dest})"   install -d "$(dirname ${dest})"
659   # now build the mage file   # now build the mage file
660   > ${dest}   > ${dest}
661    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.34 2005-08-22 00:07:32 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
662   # pgkname and state   # pgkname and state
663   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
664   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
665    
666   # description and homepage   # description and homepage
667   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
668   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
669    
670   # special tags and vars   # special tags and vars
671   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
672    
673     # echo MAGE_TARGETS ## note -target is needed !
674     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
675    
676     # split package base
677     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
678    
679   # add special vars   # add special vars
680   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
681   then   then
# Line 536  build_mage_script() Line 685  build_mage_script()
685   # being tricky here :)   # being tricky here :)
686   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
687   done   done
  echo  >> ${dest}  
688   fi   fi
689    
690   # add at least all includes   # add at least all includes
691   if [ -n "${INHERITS}" ]   if [ -n "${INHERITS}" ]
692   then   then
# Line 547  build_mage_script() Line 696  build_mage_script()
696   do   do
697   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
698   done   done
699   echo  >> ${dest}   # a CRLF is needed here!
700     echo >> ${dest}
701   fi   fi
  echo >> ${dest}  
702    
703   # deps and provides   # deps and provides
704   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
705   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
706   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
707    
708   # add special functions   # add special functions
709   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 570  build_mage_script() Line 716  build_mage_script()
716   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
717   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
718   done   done
  echo  >> ${dest}  
719   fi   fi
720    
721   # pre|post-install|removes   # pre|post-install|removes
722   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
723   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
724   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
725   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
   
  # echo MAGE_TARGETS ## note -target is needed !  
  echo "MAGE_TARGETS=\"${targets}\"" >> ${dest}  
726  }  }
727    
728  regen_mage_tree()  regen_mage_tree()
729  {  {
730   local i   local subpackage
731    
732   # build them only if requested   # build them only if requested
733   if [[ ${REGEN_MAGE_TREE} = true ]]   if mqueryfeature regentree
734   then   then
735   # run it without targets   # run it without targets
736   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
737   then   then
738     # build for each target a mage file
739     # run it with several targets
740   echo   echo
741   build_mage_script   for subpackage in ${MAGE_TARGETS}
742     do
743     build_mage_script --target "${subpackage}"
744     done
745   echo   echo
  else  
746    
747   # build for each target an mage file   # run it for splitpackages
748     elif [[ -n ${SPLIT_PACKAGES} ]]
749     then
750     local split_pkg_base="${PNAME}"
751     # save smage environment
752     split_save_variables
753     # build for each subpackage a mage file
754   # run it with several targets   # run it with several targets
755   for i in ${MAGE_TARGETS}   echo
756     for subpackage in ${SPLIT_PACKAGES}
757   do   do
758   echo   # get the right variables for the split
759   build_mage_script "${i}"   export PNAME="${subpackage}"
760   echo   split_info_${subpackage}
761     # get the preinstall etc
762     split_export_inherits ${subpackage}
763     build_mage_script --split-pkg-base "${split_pkg_base}"
764     # delete split preinstall etc
765     split_delete_inherits ${subpackage}
766     # restore smage environment
767     split_restore_variables
768   done   done
769     echo
770     # unset all saved smage variables
771     split_unset_variables
772    
773     else
774     echo
775     build_mage_script
776     echo
777   fi   fi
778   fi   fi
779    
780   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
781   # unset PKGNAME <-- don't do that; smage needs this var   # unset PKGNAME <-- don't do that; smage needs this var
782   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
783   for i in ${SPECIAL_FUNCTIONS}  # for i in ${SPECIAL_FUNCTIONS}
784   do  # do
785   unset "${i}"  # unset "${i}"
786   done  # done
787   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
788   for i in ${SPECIAL_VARS}  # for i in ${SPECIAL_VARS}
789   do  # do
790   unset "${i}"  # unset "${i}"
791   done  # done
792   unset SPECIAL_VARS   unset SPECIAL_VARS
793   unset STATE   unset STATE
794   unset DESCRIPTION   unset DESCRIPTION
795   unset HOMEPAGE   unset HOMEPAGE
796   unset PKGTYPE   # unset PKGTYPE <-- don't do that either; smage needs this var
797   unset INHERITS   unset INHERITS
798   unset DEPEND   unset DEPEND
799   unset SDEPEND   unset SDEPEND
# Line 640  regen_mage_tree() Line 804  regen_mage_tree()
804   unset postremove   unset postremove
805  }  }
806    
807    split_save_variables()
808    {
809     export SAVED_PNAME="${PNAME}"
810     export SAVED_PVER="${PVER}"
811     export SAVED_PBUILD="${PBUILD}"
812     export SAVED_PCATEGORIE="${PCATEGORIE}"
813     export SAVED_DESCRIPTION="${DESCRIPTION}"
814     export SAVED_HOMEPAGE="${HOMEPAGE}"
815     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
816     export SAVED_STATE="${STATE}"
817     export SAVED_PKGTYPE="${PKGTYPE}"
818     export SAVED_INHERITS="${INHERITS}"
819     export SAVED_DEPEND="${DEPEND}"
820     export SAVED_SDEPEND="${SDEPEND}"
821     export SAVED_PROVIDE="${PROVIDE}"
822     export SAVED_PKGTYPE="${PKGTYPE}"
823    
824     # special handling needed for mage features
825     # pkgbuild
826     mqueryfeature "pkgbuild" && export SAVED_FEATURE_PKGBUILD="pkgbuild"
827     mqueryfeature "!pkgbuild" && export SAVED_FEATURE_PKGBUILD="!pkgbuild"
828     # strip
829     mqueryfeature "strip" && export SAVED_FEATURE_STRIP="strip"
830     mqueryfeature "!strip" && export SAVED_FEATURE_STRIP="!strip"
831     # libtool
832     mqueryfeature "libtool" && export SAVED_FEATURE_LIBTOOL="libtool"
833     mqueryfeature "!libtool" && export SAVED_FEATURE_LIBTOOL="!libtool"
834     # compressdoc
835     mqueryfeature "compressdoc" && export SAVED_FEATURE_COMPRESSDOC="compressdoc"
836     mqueryfeature "!compressdoc" && export SAVED_FEATURE_COMPRESSDOC="!compressdoc"
837    
838     # bindir too
839     export SAVED_BINDIR="${BINDIR}"
840    
841     # export the SPLIT_PACKAGE_BASE
842     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
843    
844     # functions
845     if [[ ! -z $(typeset -f preinstall) ]]
846     then
847     # rename the old one
848     local saved_preinstall
849     saved_preinstall=SAVED_$(typeset -f preinstall)
850     eval "${saved_preinstall}"
851     export -f SAVED_preinstall
852     fi
853    
854     if [[ ! -z $(typeset -f postinstall) ]]
855     then
856     # rename the old one
857     local saved_postinstall
858     saved_postinstall=SAVED_$(typeset -f postinstall)
859     eval "${saved_postinstall}"
860     export -f SAVED_postinstall
861     fi
862    
863     if [[ ! -z $(typeset -f preremove) ]]
864     then
865     # rename the old one
866     local saved_preremove
867     saved_preremove=SAVED_$(typeset -f preremove)
868     eval "${saved_preremove}"
869     export -f SAVED_preremove
870     fi
871    
872     if [[ ! -z $(typeset -f postremove) ]]
873     then
874     # rename the old one
875     local saved_postremove
876     saved_postremove=SAVED_$(typeset -f postremove)
877     eval "${saved_postremove}"
878     export -f SAVED_postremove
879     fi
880    }
881    
882    split_restore_variables()
883    {
884     export PNAME="${SAVED_PNAME}"
885     export PVER="${SAVED_PVER}"
886     export PBUILD="${SAVED_PBUILD}"
887     export PCATEGORIE="${SAVED_PCATEGORIE}"
888     export DESCRIPTION="${SAVED_DESCRIPTION}"
889     export HOMEPAGE="${SAVED_HOMEPAGE}"
890     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
891     export STATE="${SAVED_STATE}"
892     export PKGTYPE="${SAVED_PKGTYPE}"
893     export INHERITS="${SAVED_INHERITS}"
894     export DEPEND="${SAVED_DEPEND}"
895     export SDEPEND="${SAVED_SDEPEND}"
896     export PROVIDE="${SAVED_PROVIDE}"
897     export PKGTYPE="${SAVED_PKGTYPE}"
898    
899     # special handling needed for mage features
900     # pkgbuild
901     msetfeature "${SAVED_FEATURE_PKGBUILD}"
902     # strip
903     msetfeature "${SAVED_FEATURE_STRIP}"
904     # libtool
905     msetfeature "${SAVED_FEATURE_LIBTOOL}"
906     # compressdoc
907     msetfeature "${SAVED_FEATURE_COMPRESSDOC}"
908    
909     # bindir too
910     export BINDIR="${SAVED_BINDIR}"
911    
912     # functions
913     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
914     then
915     # rename the old one
916     local saved_preinstall
917     saved_preinstall=$(typeset -f SAVED_preinstall)
918     eval "${saved_preinstall/SAVED_/}"
919     export -f preinstall
920     fi
921    
922     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
923     then
924     # rename the old one
925     local saved_postinstall
926     saved_postinstall=$(typeset -f SAVED_postinstall)
927     eval "${saved_postinstall/SAVED_/}"
928     export -f postinstall
929     fi
930    
931     if [[ ! -z $(typeset -f SAVED_preremove) ]]
932     then
933     # rename the old one
934     local saved_preremove
935     saved_preremove=$(typeset -f SAVED_preremove)
936     eval "${saved_preremove/SAVED_/}"
937     export -f preremove
938     fi
939    
940     if [[ ! -z $(typeset -f SAVED_postremove) ]]
941     then
942     # rename the old one
943     local saved_postremove
944     saved_postremove=$(typeset -f SAVED_postremove)
945     eval "${saved_postremove/SAVED_/}"
946     export -f postremove
947     fi
948    }
949    
950    split_unset_variables()
951    {
952     # unset saved vars; not needed anymore
953     unset SAVED_PNAME
954     unset SAVED_PVER
955     unset SAVED_PBUILD
956     unset SAVED_PCATEGORIE
957     unset SAVED_DESCRIPTION
958     unset SAVED_HOMEPAGE
959     unset SAVED_SPECIAL_VARS
960     unset SAVED_STATE
961     unset SAVED_PKGTYPE
962     unset SAVED_INHERITS
963     unset SAVED_DEPEND
964     unset SAVED_SDEPEND
965     unset SAVED_PROVIDE
966     unset SAVED_BINDIR
967     unset SAVED_PKGTYPE
968     unset SAVED_FEATURE_PKGBUILD
969     unset SAVED_FEATURE_STRIP
970     unset SAVED_FEATURE_LIBTOOL
971     unset SAVED_FEATURE_COMPRESSDOC
972     unset SPLIT_PACKAGE_BASE
973     unset -f SAVED_preinstall
974     unset -f SAVED_postinstall
975     unset -f SAVED_preremove
976     unset -f SAVED_postremove
977    }
978    
979    split_export_inherits()
980    {
981     local subpackage="$1"
982     local func
983     local newfunc
984    
985     for func in preinstall postinstall preremove postremove
986     do
987     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
988     then
989     newfunc=$(typeset -f ${func}_${subpackage})
990     newfunc="${newfunc/_${subpackage} (/ (}"
991     eval "${newfunc}"
992     fi
993     done
994    }
995    
996    split_delete_inherits()
997    {
998     local subpackage="$1"
999     local func
1000    
1001     for func in preinstall postinstall preremove postremove
1002     do
1003     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1004     then
1005     unset -f ${func}
1006     fi
1007     done
1008     }
1009    
1010    export_inherits()
1011    {
1012     local include="$1"
1013     shift
1014    
1015     while [ "$1" ]
1016     do
1017     local functions="$1"
1018    
1019     # sanity checks
1020     [ -z "${include}" ] && die "export_inherits(): \$include not given."
1021     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
1022    
1023     eval "${functions}() { ${include}_${functions} ; }"
1024    
1025     # debug
1026     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
1027    
1028     shift
1029     done
1030    }
1031    
1032    generate_package_md5sum()
1033    {
1034     local dest
1035     local pcat
1036     local pname
1037     local pver
1038     local pbuild
1039     local parch
1040     local target
1041     local pkgname
1042    
1043     # very basic getops
1044     for i in $*
1045     do
1046     case $1 in
1047     --pcat|-c) shift; pcat="$1" ;;
1048     --pname|-n) shift; pname="$1" ;;
1049     --pver|-v) shift; pver="$1" ;;
1050     --pbuild|-b) shift; pbuild="$1" ;;
1051     --parch|a) shift; parch="$1" ;;
1052     --target|t) shift; target="$1" ;;
1053     esac
1054     shift
1055     done
1056    
1057     # sanity checks; abort if not given
1058     [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given."
1059     [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given."
1060     [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given."
1061     [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given."
1062     [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given."
1063    
1064     # check needed global vars
1065     [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
1066     [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
1067    
1068     # fix target as it may be empty !
1069     [ -n "${target}" ] && target="-${target}"
1070    
1071     # build pkgname
1072     pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1073    
1074     # build pkg-md5-sum only if requested
1075     if mqueryfeature regentree
1076     then
1077     echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
1078    
1079     # abort if not exist
1080     if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
1081     then
1082     echo -e "${COLRED}! exists${COLDEFAULT}"
1083     return 0
1084     fi
1085    
1086     # if MAGE_TREE_DEST not set use BUILDDIR
1087     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1088    
1089     # setup md5 dir
1090     dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1091     install -d ${dest}
1092    
1093     # gen md5sum
1094     ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
1095     > ${dest}/${pkgname}.md5
1096     echo -e "${COLGREEN}done${COLDEFAULT}"
1097     fi
1098    }
1099    
1100    source_pkg_build()
1101    {
1102     if [[ ${PKGTYPE} = virtual ]]
1103     then
1104     echo "Virtual package detected; src-pkg-tarball not necessary ..."
1105     return 0
1106     fi
1107    
1108     if [[ ! -d ${SOURCEDIR}/${PNAME} ]]
1109     then
1110     echo "No SRC_URI defined; src-pkg-tarball not necessary ..."
1111     return 0
1112     fi
1113    
1114     [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."
1115    
1116     echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"
1117    
1118     # include the smage2 file
1119     cp ${SMAGENAME} ${SOURCEDIR}/${PNAME}
1120    
1121     ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; )
1122     [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR}
1123     mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}
1124    
1125     echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
1126    }
1127    
1128    step_by_step()
1129    {
1130     if mqueryfeature stepbystep
1131     then
1132     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1133     echo "Press [enter] to continue"
1134     read
1135     fi
1136    }
1137    
1138    
1139  # print out our version  # print out our version
1140  showversion  showversion
1141  echo  echo
# Line 651  then Line 1147  then
1147   exit 1   exit 1
1148  fi  fi
1149    
1150    # load supported mage features
1151    load_mage_features
1152    
1153  # updating smage2-scripts  # updating smage2-scripts
1154  if [ "$1" == "update" ]  if [[ $1 = update ]]
1155  then  then
1156   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
1157   then   then
# Line 663  then Line 1162  then
1162  fi  fi
1163    
1164  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1165  if [ "$1" == "calcmd5" ]  if [[ $1 = calcmd5 ]]
1166  then  then
1167   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1168   then   then
1169   SMAGENAME="$2"   SMAGENAME="$2"
1170   MD5DIR="$3"   MD5DIR="$3"
1171   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1172    
1173     smagesource ${SMAGENAME} || die "download source failed"
1174    
1175   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1176   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 715  then Line 1216  then
1216   unset my_SRC_URI_MIRROR   unset my_SRC_URI_MIRROR
1217   unset my_SOURCEDIR   unset my_SOURCEDIR
1218   done   done
1219    
1220   echo   echo
1221   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
1222   echo   echo
1223   else   else
1224   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1225   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1226   echo   echo
1227   echo   echo
1228   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
1229   echo   echo
1230   exit 1   exit 1
1231   fi   fi
1232    
1233   exit 0   exit 0
1234  fi  fi
1235    
# Line 743  then Line 1244  then
1244   # get smage   # get smage
1245   SMAGENAME="$2"   SMAGENAME="$2"
1246   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1247   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1248    
1249   download_sources   download_sources
1250   exit 0   exit 0
# Line 755  then Line 1256  then
1256   # set correct SMAGENAME   # set correct SMAGENAME
1257   SMAGENAME="$2"   SMAGENAME="$2"
1258   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1259   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1260    
1261   regen_mage_tree   regen_mage_tree
1262    
1263     # build several targets
1264     if [[ -n ${MAGE_TARGETS} ]]
1265     then
1266     for target in ${MAGE_TARGETS}
1267     do
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     --target "${target}"
1276     done
1277    
1278     # build several subpackages
1279     elif [[ -n ${SPLIT_PACKAGES} ]]
1280     then
1281     split_save_variables
1282     for subpackage in ${SPLIT_PACKAGES}
1283     do
1284     # get the right variables for the split
1285     export PNAME="${subpackage}"
1286     split_info_${subpackage}
1287     # build md5sum for existing packages
1288     generate_package_md5sum \
1289     --pcat "${PCATEGORIE}" \
1290     --pname "${PNAME}" \
1291     --pver "${PVER}" \
1292     --pbuild "${PBUILD}" \
1293     --parch "${ARCH}"
1294     # restore smage environment
1295     split_restore_variables
1296     done
1297     # unset all saved smage variables
1298     split_unset_variables
1299    
1300     else
1301     # build md5sum for existing packages
1302     generate_package_md5sum \
1303     --pcat "${PCATEGORIE}" \
1304     --pname "${PNAME}" \
1305     --pver "${PVER}" \
1306     --pbuild "${PBUILD}" \
1307     --parch "${ARCH}"
1308     fi
1309    
1310   exit 0   exit 0
1311  fi  fi
1312    
1313  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  if [ "$1" == "--create-src-tarball" -a -n "$2" ]
1314  then  then
1315   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."   # set correct SMAGENAME
1316  fi   SMAGENAME="$2"
1317     MD5DIR="$(dirname ${SMAGENAME})/md5"
1318    
1319  if [ -z "`basename ${SMAGENAME}|grep .${SMAGESUFFIX}`" ]   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
 then  
  die "File '`basename ${SMAGENAME}`' is not a sMage v${SMAGEVERSION} file. Aborting."  
 fi  
1320    
1321  if [ -z "${SOURCEDIR}" ]   smagesource ${SMAGENAME} || die "regen: smage2 not found"
 then  
  die "\$SOURCEDIR not found. Please setup your mage.rc correctly."  
 fi  
1322    
1323  if [ -z "${SMAGESCRIPTSDIR}" ]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1324  then   then
1325   die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."   echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1326  fi   rm -rf ${SOURCEDIR}/${PKGNAME}
1327     fi
1328    
1329  if [ -z "${SMAGE2RSYNC}" ]   download_sources
1330  then   source_pkg_build ${SMAGENAME}
1331   echo "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."   exit 0
  exit 1  
1332  fi  fi
1333    
1334  if [ -z "${BINDIR}" ]  if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1335  then  then
1336   die "no BINDIR variable found in /etc/mage.rc"   SRCPKGTARBALL="${2}"
1337  fi   msetfeature "srcpkgtarball"
1338    
1339  if [ -z "${CHOST}" ]   # abort if given file is not a source pkg
1340  then   [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
  die "no CHOST variable found in /etc/mage.rc"  
 fi  
1341    
1342  if [ -z "${CFLAGS}" ]   # set correct SMAGENAME; use the one that the src_pkg provide
1343  then   # /path/to/SOURCEDIR/PNAME/SMAGENAME
1344   die "no CFLAGS variable found in /etc/mage.rc"   SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}"
 fi  
1345    
1346  if [ -z "${CXXFLAGS}" ]   echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}"
1347  then  
1348   die "no CXXFLAGS variable found in /etc/mage.rc"   [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR}
1349    
1350     # unpack srctarball
1351     [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting."
1352    
1353     tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die  "Error unpackung src-tarball ${SRCPKGTARBALL}"
1354    
1355     [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"
1356  fi  fi
1357    
1358    
1359  source ${SMAGENAME} || die "source failed"  [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
1360  PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
1361     die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
1362    [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
1363    [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly."
1364    [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly."
1365    [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}"
1366    [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}"
1367    [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1368    [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1369    
1370    smagesource ${SMAGENAME} || die "source failed"
1371    PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1372  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1373    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1374    
1375  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1376  echo "Compiling ${PKGNAME}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1377    
1378  # auto regen mage tree if requested  # auto regen mage tree if requested
1379  regen_mage_tree  regen_mage_tree
1380    
1381    if mqueryfeature "srcpkg"
1382    then
1383     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1384     then
1385     echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1386     rm -rf ${SOURCEDIR}/${PNAME}
1387     fi
1388    fi
1389    
1390  # download sources  # download sources
1391  download_sources  mqueryfeature "srcpkgtarball" || download_sources
1392    
1393  # fixes some issues with these functions  # fixes some issues with these functions
1394  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
1395  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
1396    export -f src_check || die "src_check export failed"
1397  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
1398    
1399  # fixes some compile issues  # fixes some compile issues
# Line 833  export CXXFLAGS="${CFLAGS}" || die "CXXF Line 1403  export CXXFLAGS="${CFLAGS}" || die "CXXF
1403  export BINDIR="${BINDIR}" || die "BINDIR export failed"  export BINDIR="${BINDIR}" || die "BINDIR export failed"
1404  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
1405    
   
1406  # setup distcc  # setup distcc
1407  # distcc mus be setup *before* ccache, as ccache need to be before distcc in path  # setup for distcc goes *before* ccache, so ccache comes before distcc in path
1408  if [ "${SMAGE_USE_DISTCC}" == "true" ]  mqueryfeature "distcc" && setup_distcc_environment
 then  
  setup_distcc_environment  
 fi  
1409    
1410  # setup ccache  # setup ccache
1411  if [ "${SMAGE_USE_CCACHE}" == "true" ]  mqueryfeature "ccache" && setup_ccache_environment
 then  
  setup_ccache_environment  
 fi  
   
1412    
1413  # small sleep to show our settings  # clean up builddir if a previously one exist
 sleep 1  
   
 #debug  
 #echo "CC=${CC}"  
 #echo "CXX=${CXX}"  
 #echo "DISTCC_DIR=${DISTCC_DIR}"  
 #echo "PATH: ${PATH}"  
 #echo "--------------------------------------"  
 #env  
 #echo "--------------------------------------"  
 #read  
 #debug end  
   
 # cleans up build if a previously one exists  
1414  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
1415  then  then
1416   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1417  fi  fi
1418  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1419    
1420  # cleans up srcdir if a previously unpacked one exists  # clean up srcdir if a previously unpacked one exist
1421  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
1422  then  then
1423   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
1424  fi  fi
1425    
1426  # 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
1427  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
1428  then  then
1429   rm -rf ${BINDIR}   rm -rf ${BINDIR}
1430  fi  fi
1431  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
1432    
1433  # cleans up package temp dir if a previous build exists  # clean up package temp dir if a previous build exist
1434  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
1435  then  then
1436   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
1437  fi  fi
1438    
1439  # cleans up timestamp if one exists  # setup build logging
1440  if [ -f /var/tmp/timestamp ]  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1441  then  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1442   mage rmstamp  
1443    if [[ ${PKGTYPE} = virtual ]]
1444    then
1445     echo "virtual package detected; nothing will be build ..."
1446     # automatically set !pkgbuild here too
1447     msetfeature "!pkgbuild"
1448    else
1449     src_prepare | ${SMAGE_LOG_CMD}
1450     die_pipestatus 0 "src_prepare failed"
1451     step_by_step $_
1452    
1453     src_compile | ${SMAGE_LOG_CMD}
1454     die_pipestatus 0 "src_compile failed"
1455     step_by_step $_
1456    
1457     # only run checks if requested
1458     if mqueryfeature "!check"
1459     then
1460     echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD}
1461     step_by_step src_check
1462     else
1463     src_check | ${SMAGE_LOG_CMD}
1464     die_pipestatus 0 "src_check failed"
1465     step_by_step $_
1466     fi
1467    
1468     # build several subpackages
1469     if [[ -n ${SPLIT_PACKAGES} ]]
1470     then
1471     # save bindir & pname
1472     split_save_variables
1473     export SAVED_BINDIR="${BINDIR}"
1474     for subpackage in ${SPLIT_PACKAGES}
1475     do
1476     if typeset -f src_install_${subpackage} > /dev/null
1477     then
1478     # export subpackage bindir
1479     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1480     # export PNAME, several internal function and include
1481     # rely on this variable
1482     export PNAME="${subpackage}"
1483    
1484     echo
1485     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1486     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1487     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1488     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1489    
1490     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1491     die_pipestatus 0 "src_install_${subpackage} failed"
1492     step_by_step $_
1493     fi
1494     done
1495     # restore bindir & pname
1496     split_restore_variables
1497     # unset all saved smage variables
1498     split_unset_variables
1499     else
1500     src_install | ${SMAGE_LOG_CMD}
1501     die_pipestatus 0 "src_install failed"
1502     step_by_step $_
1503     fi
1504  fi  fi
1505    
1506  src_prepare || die "src_prepare failed"  # echo for sake of good-looking
1507  src_compile || die "src_compile failed"  echo
 src_install || die "src_install failed"  
1508    
1509    if mqueryfeature "!compressdoc"
1510    then
1511     echo -e "!compressdoc detected; documentation will not be compressed ..."
1512    else
1513     # compressing doc, info & man files
1514     if [[ -n ${SPLIT_PACKAGES} ]]
1515     then
1516     for subpackage in ${SPLIT_PACKAGES}
1517     do
1518     mcompressdocs ${BINDIR}_${subpackage}
1519     done
1520     else
1521     mcompressdocs ${BINDIR}
1522     fi
1523    fi
1524    
1525  # compressing doc, info & man files  if mqueryfeature "!libtool"
 echo -e "Compressing man-pages ..."  
 if [ -d ${BUILDDIR}/builded/usr/share/man ]  
1526  then  then
1527   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   if [[ -n ${SPLIT_PACKAGES} ]]
1528     then
1529     for subpackage in ${SPLIT_PACKAGES}
1530     do
1531     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives for '${subpackage}' ...${COLDEFAULT}"
1532     mstriplibtoolarchive ${BINDIR}_${subpackage}
1533     done
1534     else
1535     echo -e "${COLBLUE}===${COLGREEN} stripping libtool archives ...${COLDEFAULT}"
1536     mstriplibtoolarchive ${BINDIR}
1537     fi
1538  fi  fi
1539    
1540  echo -e "Compressing info-pages ..."  if mqueryfeature "purge"
 if [ -d ${BUILDDIR}/builded/usr/share/info ]  
1541  then  then
1542   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   if [[ -n ${SPLIT_PACKAGES} ]]
1543     then
1544     for subpackage in ${SPLIT_PACKAGES}
1545     do
1546     echo -e "${COLBLUE}===${COLGREEN} purging all purge targets in '${subpackage}' ...${COLDEFAULT}"
1547     mpurgetargets ${BINDIR}_${subpackage}
1548     done
1549     else
1550     echo -e "${COLBLUE}===${COLGREEN} purging all purge targets ...${COLDEFAULT}"
1551     mpurgetargets ${BINDIR}
1552     fi
1553  fi  fi
1554    
1555  # stripping all bins and libs  # stripping all bins and libs
1556  case ${NOSTRIP} in  if mqueryfeature "!strip"
1557   true|TRUE|yes|y)  then
1558   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "!strip detected; Package will not be stripped ..."
1559   ;;  else
1560   *)   if [[ -n ${SPLIT_PACKAGES} ]]
1561   echo -e "Stripping binaries ..."   then
1562   mstripbins ${BINDIR}   for subpackage in ${SPLIT_PACKAGES}
1563   echo -e "Stripping libraries ..."   do
1564   mstriplibs ${BINDIR}   echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1565   ;;   mstripbins ${BINDIR}_${subpackage}
1566  esac   echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1567     mstriplibs ${BINDIR}_${subpackage}
1568  # the new buildpkg command   echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1569  case ${NOPKGBUILD} in   mstripstatic ${BINDIR}_${subpackage}
1570   true|TRUE|yes|y)   done
1571   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   else
1572   ;;   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1573   *)   mstripbins ${BINDIR}
1574   # build serveral targets   echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1575   if [ -n "${MAGE_TARGETS}" ]   mstriplibs ${BINDIR}
1576     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1577     mstripstatic ${BINDIR}
1578     fi
1579    fi
1580    
1581    if mqueryfeature "!buildpkg"
1582    then
1583     echo -e "!buildpkg detected; Package will not be build ..."
1584    else
1585     # build several targets
1586     if [[ -n ${MAGE_TARGETS} ]]
1587   then   then
1588   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1589   do   do
1590   # check if an special target_pkgbuild exists   # check if a special target_pkgbuild exists
1591   if typeset -f ${target}_pkgbuild > /dev/null   if typeset -f ${target}_pkgbuild > /dev/null
1592   then   then
1593   # run it   # run it
# Line 944  case ${NOPKGBUILD} in Line 1595  case ${NOPKGBUILD} in
1595   fi   fi
1596   # now create the target package   # now create the target package
1597   ${MLIBDIR}/pkgbuild_dir.sh \   ${MLIBDIR}/pkgbuild_dir.sh \
1598   "${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \   "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \
1599   ${BINDIR} || die "target: ${target} package-build failed"   ${BINDIR} || die "target: ${target} package-build failed"
1600   echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n"  
1601     # build pkg-md5-sum if requested
1602     generate_package_md5sum \
1603     --pcat "${PCATEGORIE}" \
1604     --pname "${PNAME}" \
1605     --pver "${PVER}" \
1606     --pbuild "${PBUILD}" \
1607     --parch "${ARCH}" \
1608     --target "${target}"
1609    
1610     echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1611     done
1612    
1613     # build several subpackages
1614     elif [[ -n ${SPLIT_PACKAGES} ]]
1615     then
1616     split_save_variables
1617     for subpackage in ${SPLIT_PACKAGES}
1618     do
1619     # get the right variables for the split
1620     export PNAME="${subpackage}"
1621     split_info_${PNAME}
1622    
1623     # jump to next one if !buildpkg is set in split_info
1624     mqueryfeature "!buildpkg" && continue
1625    
1626     # check if an special subpackage_pkgbuild exists
1627     if typeset -f ${PNAME}_pkgbuild > /dev/null
1628     then
1629     # run it
1630     ${PNAME}_pkgbuild
1631     fi
1632     # now create the target package
1633     ${MLIBDIR}/pkgbuild_dir.sh \
1634     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1635     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1636    
1637     # build pkg-md5-sum if requested
1638     generate_package_md5sum \
1639     --pcat "${PCATEGORIE}" \
1640     --pname "${PNAME}" \
1641     --pver "${PVER}" \
1642     --pbuild "${PBUILD}" \
1643     --parch "${ARCH}"
1644    
1645     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1646    
1647     # restore smage environment
1648     split_restore_variables
1649   done   done
1650     # unset all saved smage variables
1651     split_unset_variables
1652    
1653   else   else
1654   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1655   echo -e "\nPackage ${PKGNAME} successfully builded.\n"  
1656     # build pkg-md5-sum if requested
1657     generate_package_md5sum \
1658     --pcat "${PCATEGORIE}" \
1659     --pname "${PNAME}" \
1660     --pver "${PVER}" \
1661     --pbuild "${PBUILD}" \
1662     --parch "${ARCH}"
1663    
1664     echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1665   fi   fi
  ;;  
 esac  
1666    
1667  # for sure   # build src-pkg-tarball if requested
1668  unset NOPKGBUILD   mqueryfeature "srcpkg" && source_pkg_build ${SMAGENAME}
1669  unset NOSTRIP  fi
1670    
1671    if mqueryfeature "buildlog"
1672    then
1673     bzip2 -9f /var/log/smage/${PKGNAME}.log
1674    else
1675     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1676    fi
1677    
1678  xtitleclean  xtitleclean
 #echo -e "\nPackage ${PKGNAME} successfully builded.\n"  

Legend:
Removed from v.204  
changed lines
  Added in v.1594