Magellan Linux

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

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

revision 347 by niro, Sat Mar 4 23:29:45 2006 UTC revision 1573 by niro, Wed Dec 28 10:41:44 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.41 2006-03-04 23:29:45 niro Exp $  
8    
9  #01.10.2004  
10  # added ccache support  # set default user mage.rc
11  # added distcc support  : ${MAGERC="/etc/mage.rc"}
12    
13  ## setup ##  ## setup ##
 PKGSUFFIX="mpk"  
14  SMAGENAME="$1"  SMAGENAME="$1"
 SMAGESUFFIX="smage2"  
 #SOURCEDIR="/bootstrap/sources"  
 #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"  
 #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"  
 MLIBDIR=/usr/lib/mage  
15  SMAGEVERSION="$( < ${MLIBDIR}/version)"  SMAGEVERSION="$( < ${MLIBDIR}/version)"
16    
17  # export default C locale  # export default C locale
18  export LC_ALL=C  export LC_ALL=C
19    
20  source /etc/mage.rc  source /etc/mage.rc.global
21    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 33  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 42  showversion() Line 65  showversion()
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    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 70  syncsmage2() Line 107  syncsmage2()
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}
  --recursive \  
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${SMAGESCRIPTSDIR}  
   
111   if [[ $? = 0 ]]   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~)
# Line 128  download_sources() Line 150  download_sources()
150   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
151   local FETCHING   local FETCHING
152   local i mirror   local i mirror
153     local wget_opts
154    
155     # filter wget command if busybox was found
156     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
157    
158   # install SRCDIR/PNAME if not exist   # install SRCDIR/PNAME if not exist
159   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
160    
161   # check if FETCHING is needed   # check if FETCHING is needed
162   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null )
163   if [[ $? = 0 ]]   if [[ $? = 0 ]]
164   then   then
165   # md5's ok, not fetching needed   # md5's ok, no fetching needed
166   FETCHING=false   FETCHING=false
167   else   else
168   FETCHING=true   FETCHING=true
# Line 159  download_sources() Line 184  download_sources()
184   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"
185   fi   fi
186    
187     # create the SOURCEDIR
188     install -d ${my_SOURCEDIR}
189    
190   # if an mirrored file than replace first the mirror uri   # if an mirrored file than replace first the mirror uri
191   if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ]   if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]
192   then   then
193   for mirror in ${MIRRORS}   for mirror in ${MIRRORS}
194   do   do
195   my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"   my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")"
196    
  #echo "DEBUG: ${MY_SRC_URI}"  
197   if [[ ${FETCHING} = true ]]   if [[ ${FETCHING} = true ]]
198   then   then
199   echo "==> fetching ${my_SRC_URI_MIRROR}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
200     wget \
201     ${wget_opts} \
202     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
203     "${my_SRC_URI_MIRROR}"
204     if [[ $? = 0 ]]
205     then
206     break
207     else
208     continue
209     fi
210     fi
211     done
212     elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]]
213     then
214     for mirror in ${SOURCEFORGE_MIRRORS}
215     do
216     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")"
217    
218     if [[ ${FETCHING} = true ]]
219     then
220     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
221     wget \
222     ${wget_opts} \
223     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
224     "${my_SRC_URI_MIRROR}"
225     if [[ $? = 0 ]]
226     then
227     break
228     else
229     continue
230     fi
231     fi
232     done
233     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]]
234     then
235     for mirror in ${GNU_MIRRORS}
236     do
237     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")"
238    
239     if [[ ${FETCHING} = true ]]
240     then
241     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
242     wget \
243     ${wget_opts} \
244     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
245     "${my_SRC_URI_MIRROR}"
246     if [[ $? = 0 ]]
247     then
248     break
249     else
250     continue
251     fi
252     fi
253     done
254     elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]
255     then
256     for mirror in ${KDE_MIRRORS}
257     do
258     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"
259    
260     if [[ ${FETCHING} = true ]]
261     then
262     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
263     wget \
264     ${wget_opts} \
265     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
266     "${my_SRC_URI_MIRROR}"
267     if [[ $? = 0 ]]
268     then
269     break
270     else
271     continue
272     fi
273     fi
274     done
275     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]
276     then
277     for mirror in ${GNOME_MIRRORS}
278     do
279     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"
280    
281     if [[ ${FETCHING} = true ]]
282     then
283     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
284   wget \   wget \
285   --passive-ftp \   ${wget_opts} \
286   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
287   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
288   if [[ $? = 0 ]]   if [[ $? = 0 ]]
289   then   then
# Line 186  download_sources() Line 294  download_sources()
294   fi   fi
295   done   done
296   else   else
  #echo "DEBUG: ${SRC_URI[${i}]}"  
297   if [[ ${FETCHING} = true ]]   if [[ ${FETCHING} = true ]]
298   then   then
299   echo "==> fetching ${my_SRC_URI}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
300   wget \   wget \
301   --passive-ftp \   ${wget_opts} \
302   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
303   "${my_SRC_URI}"   "${my_SRC_URI}"
 # only needed to run through a list of mirrors  
 # if [ "$?" == "0" ]  
 # then  
 # break  
 # else  
 # continue  
 # fi  
304   fi   fi
305   fi   fi
306    
# Line 216  download_sources() Line 313  download_sources()
313    
314   # recheck md5 sums   # recheck md5 sums
315   echo   echo
316   echo ">== Checking MD5 sums:"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
317   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed"
318   echo   echo
319    
320   # not needed anymore   # not needed anymore
321   unset SRC_URI   unset SRC_URI
322  }  }
323    
324  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
325  src_prepare()  src_prepare()
326  {  {
327   echo "no src_prepare defined"   echo "no src_prepare defined"
# Line 232  src_prepare() Line 329  src_prepare()
329   return 0   return 0
330  }  }
331    
332  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
333  src_compile()  src_compile()
334  {  {
335   echo "no src_compile defined"   echo "no src_compile defined"
# Line 240  src_compile() Line 337  src_compile()
337   return 0   return 0
338  }  }
339    
340  # dummy function, used if that not exist in smage file  # dummy function, used if that does not exist in smage file
341  src_install()  src_install()
342  {  {
343   echo "no src_install defined"   echo "no src_install defined"
# Line 248  src_install() Line 345  src_install()
345   return 0   return 0
346  }  }
347    
348    mlibdir()
349    {
350     local libdir=lib
351     [[ ${ARCH} = x86_64 ]] && libdir=lib64
352    
353     echo "${libdir}"
354    }
355    
356  mconfigure()  mconfigure()
357  {  {
358   if [ -x ./configure ]   if [ -x ./configure ]
# Line 255  mconfigure() Line 360  mconfigure()
360   ./configure \   ./configure \
361   --prefix=/usr \   --prefix=/usr \
362   --host=${CHOST} \   --host=${CHOST} \
363     --build=${CHOST} \
364   --mandir=/usr/share/man \   --mandir=/usr/share/man \
365   --infodir=/usr/share/info \   --infodir=/usr/share/info \
366   --datadir=/usr/share \   --datadir=/usr/share \
367   --sysconfdir=/etc \   --sysconfdir=/etc \
368   --localstatedir=/var/lib \   --localstatedir=/var/lib \
369     --libdir=/usr/$(mlibdir) \
370   "$@" || die "mconfigure failed"   "$@" || die "mconfigure failed"
371   else   else
372   echo "configure is not an executable ..."   echo "configure is not an executable ..."
# Line 277  minstall() Line 384  minstall()
384   localstatedir=${BINDIR}/var/lib \   localstatedir=${BINDIR}/var/lib \
385   mandir=${BINDIR}/usr/share/man \   mandir=${BINDIR}/usr/share/man \
386   sysconfdir=${BINDIR}/etc \   sysconfdir=${BINDIR}/etc \
387     libdir=${BINDIR}/usr/$(mlibdir) \
388   "$@" install || die "minstall failed"   "$@" install || die "minstall failed"
389          else          else
390                  die "no Makefile found"                  die "no Makefile found"
# Line 296  munpack() Line 404  munpack()
404    
405   SRCFILE=$1   SRCFILE=$1
406    
407   if [ -z "$2" ]   if [[ -z $2 ]]
408   then   then
409   DEST=${BUILDDIR}   DEST=${BUILDDIR}
410   else   else
411   DEST=$2   DEST=$2
412   fi   fi
413    
414     [[ ! -d ${DEST} ]] && install -d ${DEST}
415    
416   case "${SRCFILE##*.}" in   case "${SRCFILE##*.}" in
417   bz2)   bz2)
418   IFTAR="$(basename $SRCFILE .bz2)"   IFTAR="$(basename $SRCFILE .bz2)"
419   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
420   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
421   then   then
422   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."
423     else
424     pushd ${DEST} > /dev/null
425     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
426     popd > /dev/null
427   fi   fi
428   ;;   ;;
429   gz)   gz)
# Line 317  munpack() Line 431  munpack()
431   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
432   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
433   then   then
434   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."
435     else
436     pushd ${DEST} > /dev/null
437     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
438     popd > /dev/null
439   fi   fi
440   ;;   ;;
441   tbz2)   xz)
442   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   IFTAR="$(basename $SRCFILE .xz)"
443     IFTAR="${IFTAR##*.}"
444     if [[ ${IFTAR} = tar ]]
445     then
446     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
447     else
448     pushd ${DEST} > /dev/null
449     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
450     popd > /dev/null
451     fi
452     ;;
453     tbz2|mpks|mpk)
454     tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
455   ;;   ;;
456   tgz)   tgz)
457   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
458     ;;
459     txz|mpkzs|mpkz)
460     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
461     ;;
462     rar)
463     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
464     ;;
465     zip|xpi)
466     unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
467     ;;
468     rpm)
469     pushd ${DEST} > /dev/null
470     rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
471     tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
472     if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
473     then
474     rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
475     fi
476   ;;   ;;
477   *)   *)
478   die "munpack failed"   die "munpack failed"
# Line 336  mpatch() Line 484  mpatch()
484  {  {
485   local PATCHOPTS   local PATCHOPTS
486   local PATCHFILE   local PATCHFILE
487     local i
488    
489   PATCHOPTS=$1   PATCHOPTS=$1
490   PATCHFILE=$2   PATCHFILE=$2
491    
492     if [[ -z $2 ]]
493     then
494     PATCHFILE=$1
495    
496     ## patch level auto-detection, get patch level
497     for ((i=0; i < 10; i++))
498     do
499     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
500     if [[ $? = 0 ]]
501     then
502     PATCHOPTS="-Np${i}"
503     break
504     fi
505     done
506     fi
507    
508     echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
509   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
510  }  }
511    
512    mlibtoolize()
513    {
514     local opts="$@"
515     [[ -z ${opts} ]] && opts="--verbose --install --force"
516    
517     libtoolize ${opts} || die "running: mlibtoolize ${opts}"
518    }
519    
520    mautoreconf()
521    {
522     local opts="$@"
523     [[ -z ${opts} ]] && opts="--verbose --install --force"
524    
525     autoreconf ${opts} || die "running: mautoreconf ${opts}"
526    }
527    
528  minstalldocs()  minstalldocs()
529  {  {
# Line 354  minstalldocs() Line 535  minstalldocs()
535   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
536   fi   fi
537    
538     local i
539   for i in ${docfiles}   for i in ${docfiles}
540   do   do
541   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${i} ]
542   install -m 0644 ${SRCDIR}/${i}.gz \   then
543   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
544     install -m 0644 ${SRCDIR}/${i}.gz \
545     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
546     fi
547   done   done
548  }  }
549    
# Line 367  mstriplibs() Line 552  mstriplibs()
552   local stripdir="$@"   local stripdir="$@"
553    
554   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
555   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_LIB} 2> /dev/null
556  }  }
557    
558  mstripbins()  mstripbins()
# Line 375  mstripbins() Line 560  mstripbins()
560   local stripdir="$@"   local stripdir="$@"
561    
562   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
563   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_BIN} 2> /dev/null
564    }
565    
566    mstripstatic()
567    {
568     local stripdir="$@"
569    
570     [ -z "${stripdir}" ] && stripdir=${BINDIR}
571     find ${stripdir} | xargs file | grep "ar archive" | cut -f 1 -d : | xargs strip ${STRIP_STATIC_LIB} 2> /dev/null
572    }
573    
574    mcompressdocs()
575    {
576     local bindir="$@"
577    
578     if [ -d ${bindir}/usr/share/man ]
579     then
580     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
581     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
582     fi
583    
584     if [ -d ${bindir}/usr/share/info ]
585     then
586     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
587     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
588     fi
589  }  }
590    
591  sminclude()  sminclude()
# Line 397  setup_distcc_environment() Line 607  setup_distcc_environment()
607  {  {
608   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
609   then   then
610   echo "Using DistCC for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
611   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  
612    
613   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
614    
  # 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  
   
615   # creating distcc tempdir   # creating distcc tempdir
616   install -o distcc -g daemon -d ${DISTCC_DIR}   install -o distcc -g daemon -d ${DISTCC_DIR}
617   chmod 1777 ${DISTCC_DIR}   chmod 1777 ${DISTCC_DIR}
# Line 428  setup_ccache_environment() Line 622  setup_ccache_environment()
622  {  {
623   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
624   then   then
625   echo "Using CCache for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
626   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  
627   fi   fi
628  }  }
629    
# Line 453  fix_mage_deps() Line 646  fix_mage_deps()
646   # fix DEPEND   # fix DEPEND
647   while read sym dep   while read sym dep
648   do   do
649     # ignore empty lines
650     [[ -z ${dep} ]] && continue
651    
652   cat="$(dirname ${dep})"   cat="$(dirname ${dep})"
653   # change if not virtual   # change if not virtual
654   if [[ ${cat} = virtual ]]   if [[ ${cat} = virtual ]]
# Line 505  EOF Line 701  EOF
701  # special tags:  # special tags:
702  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
703  #   INHERITS              which functions get included  #   INHERITS              which functions get included
704  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
705  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
706    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
707    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
708    #                         (only in the resulting magefile}
709  #  #
710  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
711  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 517  build_mage_script() Line 716  build_mage_script()
716   local magefile   local magefile
717   local dest   local dest
718   local target   local target
719     local split_pkg_base
720   local sym   local sym
721   local depname   local depname
722    
# Line 524  build_mage_script() Line 724  build_mage_script()
724   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
725    
726   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
727   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
728    
729     # mark package as splitpackage
730     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
731    
732   # name of magefile   # name of magefile
733   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 533  build_mage_script() Line 736  build_mage_script()
736   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
737    
738   # show what we are doing   # show what we are doing
739   echo "Generating Mage file:"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
740   echo "  ${dest}"   echo "${dest}"
741    
742   install -d "$(dirname ${dest})"   install -d "$(dirname ${dest})"
743   # now build the mage file   # now build the mage file
744   > ${dest}   > ${dest}
745    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.41 2006-03-04 23:29:45 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
746   # pgkname and state   # pgkname and state
747   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
748   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
749    
750   # description and homepage   # description and homepage
751   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
752   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
753    
754   # special tags and vars   # special tags and vars
755   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
756    
757   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
758   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
759   echo >> ${dest}  
760     # split package base
761     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
762    
763   # add special vars   # add special vars
764   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 570  build_mage_script() Line 769  build_mage_script()
769   # being tricky here :)   # being tricky here :)
770   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
771   done   done
  echo  >> ${dest}  
772   fi   fi
773    
774   # add at least all includes   # add at least all includes
# Line 582  build_mage_script() Line 780  build_mage_script()
780   do   do
781   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
782   done   done
783   echo  >> ${dest}   # a CRLF is needed here!
784     echo >> ${dest}
785   fi   fi
  echo >> ${dest}  
786    
787   # deps and provides   # deps and provides
788   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
789   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
790   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
791    
792   # add special functions   # add special functions
793   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 602  build_mage_script() Line 797  build_mage_script()
797   do   do
798   # add to mage (quotes needed !)   # add to mage (quotes needed !)
799   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
800   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
801   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
802   done   done
  echo  >> ${dest}  
803   fi   fi
804    
805   # pre|post-install|removes   # pre|post-install|removes
806   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
807   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
808   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
809   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
810  }  }
811    
812  regen_mage_tree()  regen_mage_tree()
813  {  {
814   local i   local subpackage
815    
816   # build them only if requested   # build them only if requested
817   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
818   then   then
819   # run it without targets   # run it without targets
820   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
821   then   then
822     # build for each target a mage file
823     # run it with several targets
824   echo   echo
825   build_mage_script   for subpackage in ${MAGE_TARGETS}
826     do
827     build_mage_script --target "${subpackage}"
828     done
829   echo   echo
  else  
830    
831   # build for each target an mage file   # run it for splitpackages
832     elif [[ -n ${SPLIT_PACKAGES} ]]
833     then
834     local split_pkg_base="${PNAME}"
835     # save smage environment
836     split_save_variables
837     # build for each subpackage a mage file
838   # run it with several targets   # run it with several targets
839   for i in ${MAGE_TARGETS}   echo
840     for subpackage in ${SPLIT_PACKAGES}
841   do   do
842   echo   # get the right variables for the split
843   build_mage_script "${i}"   export PNAME="${subpackage}"
844   echo   split_info_${subpackage}
845     # get the preinstall etc
846     split_export_inherits ${subpackage}
847     build_mage_script --split-pkg-base "${split_pkg_base}"
848     # delete split preinstall etc
849     split_delete_inherits ${subpackage}
850     # restore smage environment
851     split_restore_variables
852   done   done
853     echo
854     # unset all saved smage variables
855     split_unset_variables
856    
857     else
858     echo
859     build_mage_script
860     echo
861   fi   fi
862   fi   fi
863    
864   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
865   # unset PKGNAME <-- don't do that; smage needs this var   # unset PKGNAME <-- don't do that; smage needs this var
866   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
867   for i in ${SPECIAL_FUNCTIONS}  # for i in ${SPECIAL_FUNCTIONS}
868   do  # do
869   unset "${i}"  # unset "${i}"
870   done  # done
871   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
872   for i in ${SPECIAL_VARS}  # for i in ${SPECIAL_VARS}
873   do  # do
874   unset "${i}"  # unset "${i}"
875   done  # done
876   unset SPECIAL_VARS   unset SPECIAL_VARS
877   unset STATE   unset STATE
878   unset DESCRIPTION   unset DESCRIPTION
# Line 673  regen_mage_tree() Line 888  regen_mage_tree()
888   unset postremove   unset postremove
889  }  }
890    
891    split_save_variables()
892    {
893     export SAVED_PNAME="${PNAME}"
894     export SAVED_PVER="${PVER}"
895     export SAVED_PBUILD="${PBUILD}"
896     export SAVED_PCATEGORIE="${PCATEGORIE}"
897     export SAVED_DESCRIPTION="${DESCRIPTION}"
898     export SAVED_HOMEPAGE="${HOMEPAGE}"
899     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
900     export SAVED_STATE="${STATE}"
901     export SAVED_PKGTYPE="${PKGTYPE}"
902     export SAVED_INHERITS="${INHERITS}"
903     export SAVED_DEPEND="${DEPEND}"
904     export SAVED_SDEPEND="${SDEPEND}"
905     export SAVED_PROVIDE="${PROVIDE}"
906     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
907    
908     # bindir too
909     export SAVED_BINDIR="${BINDIR}"
910    
911     # export the SPLIT_PACKAGE_BASE
912     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
913    
914     # functions
915     if [[ ! -z $(typeset -f preinstall) ]]
916     then
917     # rename the old one
918     local saved_preinstall
919     saved_preinstall=SAVED_$(typeset -f preinstall)
920     eval "${saved_preinstall}"
921     export -f SAVED_preinstall
922     fi
923    
924     if [[ ! -z $(typeset -f postinstall) ]]
925     then
926     # rename the old one
927     local saved_postinstall
928     saved_postinstall=SAVED_$(typeset -f postinstall)
929     eval "${saved_postinstall}"
930     export -f SAVED_postinstall
931     fi
932    
933     if [[ ! -z $(typeset -f preremove) ]]
934     then
935     # rename the old one
936     local saved_preremove
937     saved_preremove=SAVED_$(typeset -f preremove)
938     eval "${saved_preremove}"
939     export -f SAVED_preremove
940     fi
941    
942     if [[ ! -z $(typeset -f postremove) ]]
943     then
944     # rename the old one
945     local saved_postremove
946     saved_postremove=SAVED_$(typeset -f postremove)
947     eval "${saved_postremove}"
948     export -f SAVED_postremove
949     fi
950    }
951    
952    split_restore_variables()
953    {
954     export PNAME="${SAVED_PNAME}"
955     export PVER="${SAVED_PVER}"
956     export PBUILD="${SAVED_PBUILD}"
957     export PCATEGORIE="${SAVED_PCATEGORIE}"
958     export DESCRIPTION="${SAVED_DESCRIPTION}"
959     export HOMEPAGE="${SAVED_HOMEPAGE}"
960     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
961     export STATE="${SAVED_STATE}"
962     export PKGTYPE="${SAVED_PKGTYPE}"
963     export INHERITS="${SAVED_INHERITS}"
964     export DEPEND="${SAVED_DEPEND}"
965     export SDEPEND="${SAVED_SDEPEND}"
966     export PROVIDE="${SAVED_PROVIDE}"
967     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
968    
969     # bindir too
970     export BINDIR="${SAVED_BINDIR}"
971    
972     # functions
973     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
974     then
975     # rename the old one
976     local saved_preinstall
977     saved_preinstall=$(typeset -f SAVED_preinstall)
978     eval "${saved_preinstall/SAVED_/}"
979     export -f preinstall
980     fi
981    
982     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
983     then
984     # rename the old one
985     local saved_postinstall
986     saved_postinstall=$(typeset -f SAVED_postinstall)
987     eval "${saved_postinstall/SAVED_/}"
988     export -f postinstall
989     fi
990    
991     if [[ ! -z $(typeset -f SAVED_preremove) ]]
992     then
993     # rename the old one
994     local saved_preremove
995     saved_preremove=$(typeset -f SAVED_preremove)
996     eval "${saved_preremove/SAVED_/}"
997     export -f preremove
998     fi
999    
1000     if [[ ! -z $(typeset -f SAVED_postremove) ]]
1001     then
1002     # rename the old one
1003     local saved_postremove
1004     saved_postremove=$(typeset -f SAVED_postremove)
1005     eval "${saved_postremove/SAVED_/}"
1006     export -f postremove
1007     fi
1008    }
1009    
1010    split_unset_variables()
1011    {
1012     # unset saved vars; not needed anymore
1013     unset SAVED_PNAME
1014     unset SAVED_PVER
1015     unset SAVED_PBUILD
1016     unset SAVED_PCATEGORIE
1017     unset SAVED_DESCRIPTION
1018     unset SAVED_HOMEPAGE
1019     unset SAVED_SPECIAL_VARS
1020     unset SAVED_STATE
1021     unset SAVED_PKGTYPE
1022     unset SAVED_INHERITS
1023     unset SAVED_DEPEND
1024     unset SAVED_SDEPEND
1025     unset SAVED_PROVIDE
1026     unset SAVED_BINDIR
1027     unset SAVED_NOPKGBUILD
1028     unset SPLIT_PACKAGE_BASE
1029     unset -f SAVED_preinstall
1030     unset -f SAVED_postinstall
1031     unset -f SAVED_preremove
1032     unset -f SAVED_postremove
1033    }
1034    
1035    split_export_inherits()
1036    {
1037     local subpackage="$1"
1038     local func
1039     local newfunc
1040    
1041     for func in preinstall postinstall preremove postremove
1042     do
1043     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1044     then
1045     newfunc=$(typeset -f ${func}_${subpackage})
1046     newfunc="${newfunc/_${subpackage} (/ (}"
1047     eval "${newfunc}"
1048     fi
1049     done
1050    }
1051    
1052    split_delete_inherits()
1053    {
1054     local subpackage="$1"
1055     local func
1056    
1057     for func in preinstall postinstall preremove postremove
1058     do
1059     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1060     then
1061     unset -f ${func}
1062     fi
1063     done
1064     }
1065    
1066  export_inherits()  export_inherits()
1067  {  {
1068   local include="$1"   local include="$1"
# Line 734  generate_package_md5sum() Line 1124  generate_package_md5sum()
1124   # fix target as it may be empty !   # fix target as it may be empty !
1125   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1126    
1127    
1128   # build pkgname   # build pkgname
1129   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1130    
1131   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
1132   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
1133   then   then
1134   echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... "   echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
1135    
1136   # abort if not exist   # abort if not exist
1137   if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]   if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
1138   then   then
1139   echo "! exists"   echo -e "${COLRED}! exists${COLDEFAULT}"
1140   return 0   return 0
1141   fi   fi
1142    
# Line 753  generate_package_md5sum() Line 1144  generate_package_md5sum()
1144   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1145    
1146   # setup md5 dir   # setup md5 dir
1147   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1148   install -d ${dest}   install -d ${dest}
1149    
1150   # gen md5sum   # gen md5sum
1151   ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \   ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
1152   > ${dest}/${pkgname}.md5   > ${dest}/${pkgname}.md5
1153   echo "done"   echo -e "${COLGREEN}done${COLDEFAULT}"
1154     fi
1155    }
1156    
1157    source_pkg_build()
1158    {
1159     if [[ ${PKGTYPE} = virtual ]]
1160     then
1161     echo "Virtual package detected; src-pkg-tarball not necessary ..."
1162     return 0
1163     fi
1164    
1165     if [[ ! -d ${SOURCEDIR}/${PNAME} ]]
1166     then
1167     echo "No SRC_URI defined; src-pkg-tarball not necessary ..."
1168     return 0
1169   fi   fi
1170    
1171     [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."
1172    
1173     echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"
1174    
1175     # include the smage2 file
1176     cp ${SMAGENAME} ${SOURCEDIR}/${PNAME}
1177    
1178     ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; )
1179     [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR}
1180     mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}
1181    
1182     echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
1183  }  }
1184    
1185    step_by_step()
1186    {
1187     if [[ ${STEP_BY_STEP} = true ]]
1188     then
1189     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1190     echo "Press [enter] to continue"
1191     read
1192     fi
1193    }
1194    
1195    
1196  # print out our version  # print out our version
1197  showversion  showversion
1198  echo  echo
# Line 788  fi Line 1218  fi
1218  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1219  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1220  then  then
1221   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1222   then   then
1223   SMAGENAME="$2"   SMAGENAME="$2"
1224   MD5DIR="$3"   MD5DIR="$3"
1225   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1226    
1227     smagesource ${SMAGENAME} || die "download source failed"
1228    
1229   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1230   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 844  then Line 1276  then
1276   echo   echo
1277   else   else
1278   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1279   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1280   echo   echo
1281   echo   echo
1282   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 866  then Line 1298  then
1298   # get smage   # get smage
1299   SMAGENAME="$2"   SMAGENAME="$2"
1300   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1301   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1302    
1303   download_sources   download_sources
1304   exit 0   exit 0
# Line 878  then Line 1310  then
1310   # set correct SMAGENAME   # set correct SMAGENAME
1311   SMAGENAME="$2"   SMAGENAME="$2"
1312   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1313   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1314    
1315   regen_mage_tree   regen_mage_tree
1316    
1317   # build md5sum for existing packages   # build several targets
1318   generate_package_md5sum \   if [[ -n ${MAGE_TARGETS} ]]
1319   --pcat "${PCATEGORIE}" \   then
1320   --pname "${PNAME}" \   for target in ${MAGE_TARGETS}
1321   --pver "${PVER}" \   do
1322   --pbuild "${PBUILD}" \   # build md5sum for existing packages
1323   --parch "${ARCH}" \   generate_package_md5sum \
1324   --target "${target}"   --pcat "${PCATEGORIE}" \
1325     --pname "${PNAME}" \
1326     --pver "${PVER}" \
1327     --pbuild "${PBUILD}" \
1328     --parch "${ARCH}" \
1329     --target "${target}"
1330     done
1331    
1332     # build several subpackages
1333     elif [[ -n ${SPLIT_PACKAGES} ]]
1334     then
1335     split_save_variables
1336     for subpackage in ${SPLIT_PACKAGES}
1337     do
1338     # get the right variables for the split
1339     export PNAME="${subpackage}"
1340     split_info_${subpackage}
1341     # build md5sum for existing packages
1342     generate_package_md5sum \
1343     --pcat "${PCATEGORIE}" \
1344     --pname "${PNAME}" \
1345     --pver "${PVER}" \
1346     --pbuild "${PBUILD}" \
1347     --parch "${ARCH}"
1348     # restore smage environment
1349     split_restore_variables
1350     done
1351     # unset all saved smage variables
1352     split_unset_variables
1353    
1354     else
1355     # build md5sum for existing packages
1356     generate_package_md5sum \
1357     --pcat "${PCATEGORIE}" \
1358     --pname "${PNAME}" \
1359     --pver "${PVER}" \
1360     --pbuild "${PBUILD}" \
1361     --parch "${ARCH}"
1362     fi
1363    
1364     exit 0
1365    fi
1366    
1367    if [ "$1" == "--create-src-tarball" -a -n "$2" ]
1368    then
1369     # set correct SMAGENAME
1370     SMAGENAME="$2"
1371     MD5DIR="$(dirname ${SMAGENAME})/md5"
1372    
1373     echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1374    
1375     smagesource ${SMAGENAME} || die "regen: smage2 not found"
1376    
1377     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1378     then
1379     echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1380     rm -rf ${SOURCEDIR}/${PKGNAME}
1381     fi
1382    
1383     download_sources
1384     source_pkg_build ${SMAGENAME}
1385   exit 0   exit 0
1386  fi  fi
1387    
1388    if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1389    then
1390     SRCPKGTARBALL="${2}"
1391     USE_SRC_PKG_TARBALL=true
1392    
1393     # abort if given file is not a source pkg
1394     [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
1395    
1396     # set correct SMAGENAME; use the one that the src_pkg provide
1397     # /path/to/SOURCEDIR/PNAME/SMAGENAME
1398     SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}"
1399    
1400     echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}"
1401    
1402     [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR}
1403    
1404     # unpack srctarball
1405     [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting."
1406    
1407     tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die  "Error unpackung src-tarball ${SRCPKGTARBALL}"
1408    
1409     [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"
1410    fi
1411    
1412    
1413  [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."  [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
1414  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
1415   die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."   die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
1416  [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your mage.rc correctly."  [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
1417  [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."  [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly."
1418  [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."  [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly."
1419  [ -z "${BINDIR}" ] && die "no BINDIR variable found in /etc/mage.rc"  [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}"
1420  [ -z "${CHOST}" ] && die "no CHOST variable found in /etc/mage.rc"  [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}"
1421  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in /etc/mage.rc"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1422  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in /etc/mage.rc"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1423    
1424  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1425  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1426  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1427    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1428    
1429  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1430  echo "Compiling ${PKGNAME}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1431    
1432  # auto regen mage tree if requested  # auto regen mage tree if requested
1433  regen_mage_tree  regen_mage_tree
1434    
1435    if [[ ${CREATE_SRC_PKG_TARBALL} = true ]]
1436    then
1437     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1438     then
1439     echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1440     rm -rf ${SOURCEDIR}/${PNAME}
1441     fi
1442    fi
1443    
1444  # download sources  # download sources
1445  download_sources  [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources
1446    
1447  # fixes some issues with these functions  # fixes some issues with these functions
1448  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
# Line 932  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 1458  export MAKEOPTS="${MAKEOPTS}" || die "MA
1458    
1459    
1460  # setup distcc  # setup distcc
1461  # 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
1462  [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment  [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment
1463    
1464  # setup ccache  # setup ccache
# Line 941  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 1467  export MAKEOPTS="${MAKEOPTS}" || die "MA
1467  # small sleep to show our settings  # small sleep to show our settings
1468  sleep 1  sleep 1
1469    
1470  #debug  # clean up builddir if a previously one exist
 #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  
1471  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
1472  then  then
1473   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
1474  fi  fi
1475  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
1476    
1477  # cleans up srcdir if a previously unpacked one exists  # clean up srcdir if a previously unpacked one exist
1478  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
1479  then  then
1480   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
1481  fi  fi
1482    
1483  # 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
1484  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
1485  then  then
1486   rm -rf ${BINDIR}   rm -rf ${BINDIR}
# Line 984  then Line 1499  then
1499   mage rmstamp   mage rmstamp
1500  fi  fi
1501    
1502  src_prepare || die "src_prepare failed"  # setup build logging
1503  src_compile || die "src_compile failed"  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1504  src_install || die "src_install failed"  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1505    
1506    src_prepare | ${SMAGE_LOG_CMD}
1507    die_pipestatus 0 "src_prepare failed"
1508    step_by_step $_
1509    
1510    src_compile | ${SMAGE_LOG_CMD}
1511    die_pipestatus 0 "src_compile failed"
1512    step_by_step $_
1513    
1514  # compressing doc, info & man files  # build several subpackages
1515  echo -e "Compressing man-pages ..."  if [[ -n ${SPLIT_PACKAGES} ]]
 if [ -d ${BUILDDIR}/builded/usr/share/man ]  
1516  then  then
1517   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   # save bindir & pname
1518     split_save_variables
1519     export SAVED_BINDIR="${BINDIR}"
1520     for subpackage in ${SPLIT_PACKAGES}
1521     do
1522     if typeset -f src_install_${subpackage} > /dev/null
1523     then
1524     # export subpackage bindir
1525     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1526     # export PNAME, several internal function and include
1527     # rely on this variable
1528     export PNAME="${subpackage}"
1529    
1530     echo
1531     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1532     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1533     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1534     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1535    
1536     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1537     die_pipestatus 0 "src_install_${subpackage} failed"
1538     step_by_step $_
1539     fi
1540     done
1541     # restore bindir & pname
1542     split_restore_variables
1543     # unset all saved smage variables
1544     split_unset_variables
1545    else
1546     src_install | ${SMAGE_LOG_CMD}
1547     die_pipestatus 0 "src_install failed"
1548     step_by_step $_
1549  fi  fi
1550    
1551  echo -e "Compressing info-pages ..."  # compressing doc, info & man files
1552  if [ -d ${BUILDDIR}/builded/usr/share/info ]  if [[ -n ${SPLIT_PACKAGES} ]]
1553  then  then
1554   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   for subpackage in ${SPLIT_PACKAGES}
1555     do
1556     mcompressdocs ${BINDIR}_${subpackage}
1557     done
1558    else
1559     mcompressdocs ${BINDIR}
1560  fi  fi
1561    
1562    
1563  # stripping all bins and libs  # stripping all bins and libs
1564  case ${NOSTRIP} in  case ${NOSTRIP} in
1565   true|TRUE|yes|y)   true|TRUE|yes|y)
1566   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1567   ;;   ;;
1568   *)   *)
1569   echo -e "Stripping binaries ..."   if [[ -n ${SPLIT_PACKAGES} ]]
1570   mstripbins ${BINDIR}   then
1571   echo -e "Stripping libraries ..."   for subpackage in ${SPLIT_PACKAGES}
1572   mstriplibs ${BINDIR}   do
1573     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1574     mstripbins ${BINDIR}_${subpackage}
1575     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1576     mstriplibs ${BINDIR}_${subpackage}
1577     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1578     mstripstatic ${BINDIR}_${subpackage}
1579     done
1580     else
1581     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1582     mstripbins ${BINDIR}
1583     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1584     mstriplibs ${BINDIR}
1585     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1586     mstripstatic ${BINDIR}
1587     fi
1588   ;;   ;;
1589  esac  esac
1590    
# Line 1022  case ${NOPKGBUILD} in Line 1595  case ${NOPKGBUILD} in
1595   ;;   ;;
1596   *)   *)
1597   # build several targets   # build several targets
1598   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1599   then   then
1600   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1601   do   do
1602   # check if an special target_pkgbuild exists   # check if a special target_pkgbuild exists
1603   if typeset -f ${target}_pkgbuild > /dev/null   if typeset -f ${target}_pkgbuild > /dev/null
1604   then   then
1605   # run it   # run it
# Line 1046  case ${NOPKGBUILD} in Line 1619  case ${NOPKGBUILD} in
1619   --parch "${ARCH}" \   --parch "${ARCH}" \
1620   --target "${target}"   --target "${target}"
1621    
1622   echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n"   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1623   done   done
1624    
1625     # build several subpackages
1626     elif [[ -n ${SPLIT_PACKAGES} ]]
1627     then
1628     split_save_variables
1629     for subpackage in ${SPLIT_PACKAGES}
1630     do
1631     # get the right variables for the split
1632     export PNAME="${subpackage}"
1633     split_info_${PNAME}
1634    
1635     # jump to next one if NOPKGBUILD is set in split_info
1636     case ${NOPKGBUILD} in
1637     true|TRUE|yes|y) continue ;;
1638     esac
1639    
1640     # check if an special subpackage_pkgbuild exists
1641     if typeset -f ${PNAME}_pkgbuild > /dev/null
1642     then
1643     # run it
1644     ${PNAME}_pkgbuild
1645     fi
1646     # now create the target package
1647     ${MLIBDIR}/pkgbuild_dir.sh \
1648     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1649     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1650    
1651     # build pkg-md5-sum if requested
1652     generate_package_md5sum \
1653     --pcat "${PCATEGORIE}" \
1654     --pname "${PNAME}" \
1655     --pver "${PVER}" \
1656     --pbuild "${PBUILD}" \
1657     --parch "${ARCH}"
1658    
1659     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1660    
1661     # restore smage environment
1662     split_restore_variables
1663     done
1664     # unset all saved smage variables
1665     split_unset_variables
1666    
1667   else   else
1668   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1669    
# Line 1059  case ${NOPKGBUILD} in Line 1675  case ${NOPKGBUILD} in
1675   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1676   --parch "${ARCH}"   --parch "${ARCH}"
1677    
1678   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1679   fi   fi
1680    
1681     # build src-pkg-tarball if requested
1682     [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME}
1683   ;;   ;;
1684  esac  esac
1685    
1686    if [[ ${SMAGE_BUILD_LOGGING} != false ]]
1687    then
1688     bzip2 -9f /var/log/smage/${PKGNAME}.log
1689    else
1690     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1691    fi
1692    
1693  # for sure  # for sure
1694  unset NOPKGBUILD  unset NOPKGBUILD
1695  unset NOSTRIP  unset NOSTRIP
1696    
1697  xtitleclean  xtitleclean
 #echo -e "\nPackage ${PKGNAME} successfully builded.\n"  

Legend:
Removed from v.347  
changed lines
  Added in v.1573