Magellan Linux

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

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

revision 253 by niro, Sun Oct 2 14:23:11 2005 UTC revision 945 by niro, Sat Nov 21 01:31:33 2009 UTC
# Line 4  Line 4 
4  # needs pkgbuild_dir (mage)  # needs pkgbuild_dir (mage)
5    
6  # SMAGE2  # SMAGE2
7  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.37 2005-10-02 14:23:11 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $
8    
9  #01.10.2004  #01.10.2004
10  # added ccache support  # added ccache support
11  # added distcc support  # added distcc support
12    
13    # set default user mage.rc
14    : ${MAGERC="/etc/mage.rc"}
15    
16  ## setup ##  ## setup ##
17  PKGSUFFIX="mpk"  PKGSUFFIX="mpk"
18    SRCPKGSUFFIX="mpks"
19  SMAGENAME="$1"  SMAGENAME="$1"
20  SMAGESUFFIX="smage2"  SMAGESUFFIX="smage2"
 #SOURCEDIR="/bootstrap/sources"  
 #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"  
 #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"  
21  MLIBDIR=/usr/lib/mage  MLIBDIR=/usr/lib/mage
22  SMAGEVERSION="$( < ${MLIBDIR}/version)"  SMAGEVERSION="$( < ${MLIBDIR}/version)"
23    
24    ## only for tests -> normally in /etc/rc.d/init.d/functions
25    COLRED="\033[1;6m\033[31m"
26    COLGREEN="\033[1;6m\033[32m"
27    COLYELLOW="\033[1;6m\033[33m"
28    COLBLUE="\033[1;6m\033[34m"
29    COLMAGENTA="\033[1;6m\033[35m"
30    COLWHITE="\033[1;6m\033[37m"
31    COLGRAY="\033[0;6m\033[37m"
32    COLBOLD="\033[1m"
33    COLDEFAULT="\033[0m"
34    
35    if [[ ${NOCOLORS} = true ]]
36    then
37     COLRED=""
38     COLGREEN=""
39     COLYELLOW=""
40     COLBLUE=""
41     COLMAGENTA=""
42     COLWHITE=""
43     COLGRAY=""
44     COLBOLD=""
45     COLDEFAULT=""
46    fi
47    
48  # export default C locale  # export default C locale
49  export LC_ALL=C  export LC_ALL=C
50    
51  source /etc/mage.rc  source /etc/mage.rc.global
52    source ${MAGERC}
53    
54    # set PKGDIR and BUILDDIR and BINDIR to MROOT
55    if [[ -n ${MROOT} ]]
56    then
57     export PKGDIR=${MROOT}/${PKGDIR}
58     export BUILDDIR=${MROOT}/${BUILDDIR}
59     export BINDIR=${MROOT}/${BINDIR}
60    fi
61    
62  showversion() {  showversion()
63    {
64   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
65   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"
66  }  }
67    
68  die() {  die()
69    {
70   xtitleclean   xtitleclean
71     echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}
72   echo "SMAGE failed: $@"   echo "SMAGE failed: $@"
73   exit 1   exit 1
74  }  }
75    
76  xtitle() {  die_pipestatus()
77   if [ ${TERM} == "xterm" ]  {
78     # the status change if we do any parameter declarations!!
79     # dont do this anymore, keep this in mind!
80     #
81     # local pos="$1"
82     # local comment="$2"
83     #
84     # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}"
85     #
86     [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2"
87    }
88    
89    xtitle()
90    {
91     if [[ ${TERM} = xterm ]]
92   then   then
93   echo -ne "\033]0;[sMage: $@]\007"   echo -ne "\033]0;[sMage: $@]\007"
94   fi   fi
95   return 0   return 0
96  }  }
97    
98  xtitleclean() {  xtitleclean()
99   if [ ${TERM} == "xterm" ]  {
100     if [[ ${TERM} = xterm ]]
101   then   then
102   echo -ne "\033]0;\007"   echo -ne "\033]0;\007"
103   fi   fi
104   return 0   return 0
105  }  }
106    
107  syncsmage2() {  syncsmage2()
108    {
109   xtitle "Updating smage2-script tree ..."   xtitle "Updating smage2-script tree ..."
110   local i   local i
111   for i in ${SMAGE2RSYNC}   for i in ${SMAGE2RSYNC}
112   do   do
113   rsync \   rsync ${RSYNC_FETCH_OPTIONS} ${i} ${SMAGESCRIPTSDIR}
114   --recursive \   if [[ $? = 0 ]]
  --links \  
  --perms \  
  --times \  
  --devices \  
  --timeout=600 \  
  --verbose \  
  --compress \  
  --progress \  
  --stats \  
  --delete \  
  --delete-after \  
  ${i} ${SMAGESCRIPTSDIR}  
   
  if [ "$?" == "0" ]  
115   then   then
116   break   break
117   else   else
118   continue   continue
119   fi   fi
   
120   done   done
121    
122   #clean up backup files (foo~)   # clean up backup files (foo~)
123   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'
124    
125   xtitleclean   xtitleclean
126  }  }
127    
128  # $1 filename  # $1 filename
129  get_db_md5_sum() {  get_db_md5_sum()
130    {
131   local DB_FILE   local DB_FILE
132   local MD5_FILE   local MD5_FILE
133   local i   local i
# Line 101  get_db_md5_sum() { Line 140  get_db_md5_sum() {
140   echo "${i}"   echo "${i}"
141  }  }
142    
143  download_sources() {  download_sources()
144    {
145    
146   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
147    
# Line 113  download_sources() { Line 153  download_sources() {
153   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
154   local FETCHING   local FETCHING
155   local i mirror   local i mirror
   
156    
157   #install SRCDIR/PNAME if not exist  
158     # 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 --check ${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
169   fi   fi
170    
171   for ((i=0; i < EOA; i++))   for ((i=0; i < EOA; i++))
172   do   do
173   # url to file   # url to file
# Line 144  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    
197   #echo "DEBUG: ${MY_SRC_URI}"   if [[ ${FETCHING} = true ]]
198   if [[ ${FETCHING} == true ]]   then
199     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
200     wget \
201     --passive-ftp \
202     --tries 3 \
203     --continue \
204     --progress bar \
205     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
206     "${my_SRC_URI_MIRROR}"
207     if [[ $? = 0 ]]
208     then
209     break
210     else
211     continue
212     fi
213     fi
214     done
215     elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]]
216     then
217     for mirror in ${SOURCEFORGE_MIRRORS}
218     do
219     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")"
220    
221     if [[ ${FETCHING} = true ]]
222     then
223     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
224     wget \
225     --passive-ftp \
226     --tries 3 \
227     --continue \
228     --progress bar \
229     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
230     "${my_SRC_URI_MIRROR}"
231     if [[ $? = 0 ]]
232     then
233     break
234     else
235     continue
236     fi
237     fi
238     done
239     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]]
240     then
241     for mirror in ${GNU_MIRRORS}
242     do
243     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")"
244    
245     if [[ ${FETCHING} = true ]]
246     then
247     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
248     wget \
249     --passive-ftp \
250     --tries 3 \
251     --continue \
252     --progress bar \
253     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
254     "${my_SRC_URI_MIRROR}"
255     if [[ $? = 0 ]]
256     then
257     break
258     else
259     continue
260     fi
261     fi
262     done
263     elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]
264     then
265     for mirror in ${KDE_MIRRORS}
266     do
267     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"
268    
269     if [[ ${FETCHING} = true ]]
270   then   then
271   echo "==> fetching ${my_SRC_URI_MIRROR}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
272   wget \   wget \
273   --passive-ftp \   --passive-ftp \
274   --tries 3 \   --tries 3 \
275   --continue \   --continue \
276   --progress bar \   --progress bar \
277   --directory-prefix="${my_SOURCEDIR}" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
278   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
279   if [ "$?" == "0" ]   if [[ $? = 0 ]]
280     then
281     break
282     else
283     continue
284     fi
285     fi
286     done
287     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]
288     then
289     for mirror in ${GNOME_MIRRORS}
290     do
291     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"
292    
293     if [[ ${FETCHING} = true ]]
294     then
295     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
296     wget \
297     --passive-ftp \
298     --tries 3 \
299     --continue \
300     --progress bar \
301     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
302     "${my_SRC_URI_MIRROR}"
303     if [[ $? = 0 ]]
304   then   then
305   break   break
306   else   else
# Line 171  download_sources() { Line 309  download_sources() {
309   fi   fi
310   done   done
311   else   else
312   #echo "DEBUG: ${SRC_URI[${i}]}"   if [[ ${FETCHING} = true ]]
  if [[ ${FETCHING} == true ]]  
313   then   then
314   echo "==> fetching ${my_SRC_URI}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
315   wget \   wget \
316   --passive-ftp \   --passive-ftp \
317   --tries 3 \   --tries 3 \
318   --continue \   --continue \
319   --progress bar \   --progress bar \
320   --directory-prefix="${my_SOURCEDIR}" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
321   "${my_SRC_URI}"   "${my_SRC_URI}"
 # only needed to run through a list of mirrors  
 # if [ "$?" == "0" ]  
 # then  
 # break  
 # else  
 # continue  
 # fi  
322   fi   fi
323   fi   fi
324    
325   # unset them to be shure   # unset them to be shure
326   unset my_SRC_URI   unset my_SRC_URI
327   unset my_SRC_URI_DEST   unset my_SRC_URI_DEST
# Line 201  download_sources() { Line 331  download_sources() {
331    
332   # recheck md5 sums   # recheck md5 sums
333   echo   echo
334   echo ">== Checking MD5 sums:"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
335   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"
336   echo   echo
337    
# Line 210  download_sources() { Line 340  download_sources() {
340  }  }
341    
342  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
343  src_prepare() {  src_prepare()
344    {
345   echo "no src_prepare defined"   echo "no src_prepare defined"
346   sleep 2   sleep 2
347   return 0   return 0
348  }  }
349    
350  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
351  src_compile() {  src_compile()
352    {
353   echo "no src_compile defined"   echo "no src_compile defined"
354   sleep 2   sleep 2
355   return 0   return 0
356  }  }
357    
358  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
359  src_install() {  src_install()
360    {
361   echo "no src_install defined"   echo "no src_install defined"
362   sleep 2   sleep 2
363   return 0   return 0
364  }  }
365    
366  mconfigure() {  mlibdir()
367    {
368     local libdir=lib
369     [[ ${ARCH} = x86_64 ]] && libdir=lib64
370    
371     echo "${libdir}"
372    }
373    
374    mconfigure()
375    {
376   if [ -x ./configure ]   if [ -x ./configure ]
377   then   then
378   ./configure \   ./configure \
379   --prefix=/usr \   --prefix=/usr \
380   --host=${CHOST} \   --host=${CHOST} \
381   --mandir=/usr/share/man \   --build=${CHOST} \
382   --infodir=/usr/share/info \   --mandir=/usr/share/man \
383   --datadir=/usr/share \   --infodir=/usr/share/info \
384   --sysconfdir=/etc \   --datadir=/usr/share \
385   --localstatedir=/var/lib \   --sysconfdir=/etc \
386   "$@" || die "mconfigure failed"   --localstatedir=/var/lib \
387     --libdir=/usr/$(mlibdir) \
388     "$@" || die "mconfigure failed"
389   else   else
390   echo "configure is not an executable ..."   echo "configure is not an executable ..."
391   exit 1   exit 1
392   fi   fi
393  }  }
394    
395  minstall() {  minstall()
396   if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then  {
397     if [ -f ./[mM]akefile -o -f ./GNUmakefile ]
398     then
399   make prefix=${BINDIR}/usr \   make prefix=${BINDIR}/usr \
400   datadir=${BINDIR}/usr/share \   datadir=${BINDIR}/usr/share \
401   infodir=${BINDIR}/usr/share/info \   infodir=${BINDIR}/usr/share/info \
402   localstatedir=${BINDIR}/var/lib \   localstatedir=${BINDIR}/var/lib \
403   mandir=${BINDIR}/usr/share/man \   mandir=${BINDIR}/usr/share/man \
404   sysconfdir=${BINDIR}/etc \   sysconfdir=${BINDIR}/etc \
405     libdir=${BINDIR}/usr/$(mlibdir) \
406   "$@" install || die "minstall failed"   "$@" install || die "minstall failed"
407          else          else
408                  die "no Makefile found"                  die "no Makefile found"
409          fi          fi
410  }  }
411    
412  mmake() {  mmake()
413    {
414   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
415  }  }
416    
417  munpack() {  munpack()
418    {
419   local SRCFILE   local SRCFILE
420   local IFTAR   local IFTAR
421   local DEST   local DEST
422    
423   SRCFILE=$1   SRCFILE=$1
424    
425   if [ -z "$2" ]   if [[ -z $2 ]]
426   then   then
427   DEST=${BUILDDIR}   DEST=${BUILDDIR}
428   else   else
429   DEST=$2   DEST=$2
430   fi   fi
431    
432     [[ ! -d ${DEST} ]] && install -d ${DEST}
433    
434   case "${SRCFILE##*.}" in   case "${SRCFILE##*.}" in
435   bz2)   bz2)
436   IFTAR="$(basename $SRCFILE .bz2)"   IFTAR="$(basename $SRCFILE .bz2)"
437   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
438   if [ "${IFTAR}" == "tar" ]   if [[ ${IFTAR} = tar ]]
439   then   then
440   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."
441     else
442     pushd ${DEST} > /dev/null
443     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
444     popd > /dev/null
445   fi   fi
446   ;;   ;;
447   gz)   gz)
448   IFTAR="$(basename $SRCFILE .gz)"   IFTAR="$(basename $SRCFILE .gz)"
449   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
450   if [ "${IFTAR}" == "tar" ]   if [[ ${IFTAR} = tar ]]
451   then   then
452   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."
453     else
454     pushd ${DEST} > /dev/null
455     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
456     popd > /dev/null
457   fi   fi
458   ;;   ;;
459   tbz2)   tbz2|mpks|mpk)
460   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
461   ;;   ;;
462   tgz)   tgz)
463   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
464     ;;
465     rar)
466     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
467     ;;
468     zip|xpi)
469     unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
470     ;;
471     rpm)
472     pushd ${DEST} > /dev/null
473     rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
474     tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
475     if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
476     then
477     rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
478     fi
479   ;;   ;;
480   *)   *)
481   die "munpack failed"   die "munpack failed"
# Line 309  munpack() { Line 483  munpack() {
483   esac   esac
484  }  }
485    
486  mpatch() {  mpatch()
487    {
488   local PATCHOPTS   local PATCHOPTS
489   local PATCHFILE   local PATCHFILE
490     local i
491    
492   PATCHOPTS=$1   PATCHOPTS=$1
493   PATCHFILE=$2   PATCHFILE=$2
494    
495     if [[ -z $2 ]]
496     then
497     PATCHFILE=$1
498    
499     ## patch level auto-detection, get patch level
500     for ((i=0; i < 10; i++))
501     do
502     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
503     if [[ $? = 0 ]]
504     then
505     PATCHOPTS="-Np${i}"
506     break
507     fi
508     done
509     fi
510    
511     echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
512   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
513  }  }
514    
515    mlibtoolize()
516    {
517     local opts="$@"
518     [[ -z ${opts} ]] && opts="--copy --force"
519    
520     libtoolize ${opts} || die "running: mlibtoolize ${opts}"
521    }
522    
523  minstalldocs() {  minstalldocs()
524    {
525   local docfiles   local docfiles
   
526   docfiles="$@"   docfiles="$@"
527    
528   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
529   then   then
530   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
531   fi   fi
532    
533   for i in ${docfiles}   for i in ${docfiles}
534   do   do
535   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
# Line 338  minstalldocs() { Line 538  minstalldocs() {
538   done   done
539  }  }
540    
541  mstriplibs() {  mstriplibs()
542    {
543   local stripdir="$@"   local stripdir="$@"
544    
545   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
546   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-unneeded 2> /dev/null
547  }  }
548    
549  mstripbins() {  mstripbins()
550    {
551   local stripdir="$@"   local stripdir="$@"
552    
553   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
554   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-unneeded 2> /dev/null
555  }  }
556    
557  sminclude() {  mcompressdocs()
558    {
559     local bindir="$@"
560    
561     if [ -d ${bindir}/usr/share/man ]
562     then
563     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
564     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
565     fi
566    
567     if [ -d ${bindir}/usr/share/info ]
568     then
569     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
570     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
571     fi
572    }
573    
574    sminclude()
575    {
576   local i   local i
577    
578   if [[ -n "$@" ]]   if [[ -n "$@" ]]
# Line 366  sminclude() { Line 586  sminclude() {
586   fi   fi
587  }  }
588    
589  setup_distcc_environment(){  setup_distcc_environment()
590    {
591   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
592   then   then
593   echo "Using DistCC for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
594   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  
595    
596   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
597    
598     # 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  
599   install -o distcc -g daemon -d ${DISTCC_DIR}   install -o distcc -g daemon -d ${DISTCC_DIR}
600   chmod 1777 ${DISTCC_DIR}   chmod 1777 ${DISTCC_DIR}
601   fi   fi
602  }  }
603    
604  setup_ccache_environment(){  setup_ccache_environment()
605    {
606   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
607   then   then
608   echo "Using CCache for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
609   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  
610   fi   fi
611  }  }
612    
613    
614  # fixes given dependencies to match a MAGE_TARGET  # fixes given dependencies to match a MAGE_TARGET
615  # fix_mage_deps -target s/depend # <-- note -target !  # fix_mage_deps -target s/depend # <-- note -target !
616  fix_mage_deps() {  fix_mage_deps()
617    {
618   local target="$1"   local target="$1"
619   local depend="$2"   local depend="$2"
620   local NDEPEND   local NDEPEND
# Line 424  fix_mage_deps() { Line 629  fix_mage_deps() {
629   # fix DEPEND   # fix DEPEND
630   while read sym dep   while read sym dep
631   do   do
632     # ignore empty lines
633     [[ -z ${dep} ]] && continue
634    
635   cat="$(dirname ${dep})"   cat="$(dirname ${dep})"
636   # change if not virtual   # change if not virtual
637   if [[ ${cat} = virtual ]]   if [[ ${cat} = virtual ]]
# Line 476  EOF Line 684  EOF
684  # special tags:  # special tags:
685  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
686  #   INHERITS              which functions get included  #   INHERITS              which functions get included
687  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
688  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
689    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
690    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
691    #                         (only in the resulting magefile}
692  #  #
693  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
694  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 488  build_mage_script() Line 699  build_mage_script()
699   local magefile   local magefile
700   local dest   local dest
701   local target   local target
702     local split_pkg_base
703   local sym   local sym
704   local depname   local depname
705    
# Line 495  build_mage_script() Line 707  build_mage_script()
707   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
708    
709   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
710   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
711    
712     # mark package as splitpackage
713     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
714    
715   # name of magefile   # name of magefile
716   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 504  build_mage_script() Line 719  build_mage_script()
719   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
720    
721   # show what we are doing   # show what we are doing
722   echo "Generating Mage file:"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
723   echo "  ${dest}"   echo "${dest}"
724    
725   install -d "$(dirname ${dest})"   install -d "$(dirname ${dest})"
726   # now build the mage file   # now build the mage file
727   > ${dest}   > ${dest}
728    
729   # header   # header
730   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.37 2005-10-02 14:23:11 niro Exp $' >> ${dest}   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest}
731   echo  >> ${dest}   echo  >> ${dest}
732    
733   # pgkname and state   # pgkname and state
# Line 532  build_mage_script() Line 747  build_mage_script()
747   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
748   echo >> ${dest}   echo >> ${dest}
749    
750     # split package base
751     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
752     echo >> ${dest}
753    
754   # add special vars   # add special vars
755   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
756   then   then
# Line 599  regen_mage_tree() Line 818  regen_mage_tree()
818   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
819   then   then
820   # run it without targets   # run it without targets
821   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
822   then   then
823     # build for each target a mage file
824     # run it with several targets
825   echo   echo
826   build_mage_script   for i in ${MAGE_TARGETS}
827     do
828     build_mage_script --target "${i}"
829     done
830   echo   echo
  else  
831    
832   # build for each target an mage file   # run it for splitpackages
833     elif [[ -n ${SPLIT_PACKAGES} ]]
834     then
835     local split_pkg_base="${PNAME}"
836     # save smage environment
837     split_save_variables
838     # build for each subpackage a mage file
839   # run it with several targets   # run it with several targets
840   for i in ${MAGE_TARGETS}   echo
841     for i in ${SPLIT_PACKAGES}
842   do   do
843   echo   # get the right variables for the split
844   build_mage_script "${i}"   export PNAME="${i}"
845   echo   split_info_${i}
846     build_mage_script --split-pkg-base "${split_pkg_base}"
847   done   done
848     echo
849     # restore smage environment
850     split_restore_variables
851    
852     else
853     echo
854     build_mage_script
855     echo
856   fi   fi
857   fi   fi
858    
859   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
860   # unset PKGNAME <-- don't do that; smage needs this var   # unset PKGNAME <-- don't do that; smage needs this var
861   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
862   for i in ${SPECIAL_FUNCTIONS}  # for i in ${SPECIAL_FUNCTIONS}
863   do  # do
864   unset "${i}"  # unset "${i}"
865   done  # done
866   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
867   for i in ${SPECIAL_VARS}  # for i in ${SPECIAL_VARS}
868   do  # do
869   unset "${i}"  # unset "${i}"
870   done  # done
871   unset SPECIAL_VARS   unset SPECIAL_VARS
872   unset STATE   unset STATE
873   unset DESCRIPTION   unset DESCRIPTION
# Line 644  regen_mage_tree() Line 883  regen_mage_tree()
883   unset postremove   unset postremove
884  }  }
885    
886    split_save_variables()
887    {
888     export SAVED_PNAME="${PNAME}"
889     export SAVED_PVER="${PVER}"
890     export SAVED_PBUILD="${PBUILD}"
891     export SAVED_PCATEGORIE="${PCATEGORIE}"
892     export SAVED_DESCRIPTION="${DESCRIPTION}"
893     export SAVED_HOMEPAGE="${HOMEPAGE}"
894     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
895     export SAVED_STATE="${STATE}"
896     export SAVED_PKGTYPE="${PKGTYPE}"
897     export SAVED_INHERITS="${INHERITS}"
898     export SAVED_DEPEND="${DEPEND}"
899     export SAVED_SDEPEND="${SDEPEND}"
900     export SAVED_PROVIDE="${PROVIDE}"
901     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
902    
903     # bindir too
904     export SAVED_BINDIR="${BINDIR}"
905    
906     # export the SPLIT_PACKAGE_BASE
907     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
908    
909     # functions
910     if [[ ! -z $(typeset -f preinstall) ]]
911     then
912     # rename the old one
913     local saved_preinstall
914     saved_preinstall=SAVED_$(typeset -f preinstall)
915     eval "${saved_preinstall}"
916     export -f SAVED_preinstall
917     fi
918    
919     if [[ ! -z $(typeset -f postinstall) ]]
920     then
921     # rename the old one
922     local saved_postinstall
923     saved_postinstall=SAVED_$(typeset -f postinstall)
924     eval "${saved_postinstall}"
925     export -f SAVED_postinstall
926     fi
927    
928     if [[ ! -z $(typeset -f preremove) ]]
929     then
930     # rename the old one
931     local saved_preremove
932     saved_preremove=SAVED_$(typeset -f preremove)
933     eval "${saved_preremove}"
934     export -f SAVED_preremove
935     fi
936    
937     if [[ ! -z $(typeset -f postremove) ]]
938     then
939     # rename the old one
940     local saved_postremove
941     saved_postremove=SAVED_$(typeset -f postremove)
942     eval "${saved_postremove}"
943     export -f SAVED_postremove
944     fi
945    }
946    
947    split_restore_variables()
948    {
949     export PNAME="${SAVED_PNAME}"
950     export PVER="${SAVED_PVER}"
951     export PBUILD="${SAVED_PBUILD}"
952     export PCATEGORIE="${SAVED_PCATEGORIE}"
953     export DESCRIPTION="${SAVED_DESCRIPTION}"
954     export HOMEPAGE="${SAVED_HOMEPAGE}"
955     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
956     export STATE="${SAVED_STATE}"
957     export PKGTYPE="${SAVED_PKGTYPE}"
958     export INHERITS="${SAVED_INHERITS}"
959     export DEPEND="${SAVED_DEPEND}"
960     export SDEPEND="${SAVED_SDEPEND}"
961     export PROVIDE="${SAVED_PROVIDE}"
962     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
963    
964     # bindir too
965     export BINDIR="${SAVED_BINDIR}"
966    
967     # functions
968     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
969     then
970     # rename the old one
971     local saved_preinstall
972     saved_preinstall=$(typeset -f SAVED_preinstall)
973     eval "${saved_preinstall/SAVED_/}"
974     export -f preinstall
975     fi
976    
977     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
978     then
979     # rename the old one
980     local saved_postinstall
981     saved_postinstall=$(typeset -f SAVED_postinstall)
982     eval "${saved_postinstall/SAVED_/}"
983     export -f postinstall
984     fi
985    
986     if [[ ! -z $(typeset -f SAVED_preremove) ]]
987     then
988     # rename the old one
989     local saved_preremove
990     saved_preremove=$(typeset -f SAVED_preremove)
991     eval "${saved_preremove/SAVED_/}"
992     export -f preremove
993     fi
994    
995     if [[ ! -z $(typeset -f SAVED_postremove) ]]
996     then
997     # rename the old one
998     local saved_postremove
999     saved_postremove=$(typeset -f SAVED_postremove)
1000     eval "${saved_postremove/SAVED_/}"
1001     export -f postremove
1002     fi
1003    
1004     # unset saved vars; not needed anymore
1005     unset SAVED_PNAME
1006     unset SAVED_PVER
1007     unset SAVED_PBUILD
1008     unset SAVED_PCATEGORIE
1009     unset SAVED_DESCRIPTION
1010     unset SAVED_HOMEPAGE
1011     unset SAVED_SPECIAL_VARS
1012     unset SAVED_STATE
1013     unset SAVED_PKGTYPE
1014     unset SAVED_INHERITS
1015     unset SAVED_DEPEND
1016     unset SAVED_SDEPEND
1017     unset SAVED_PROVIDE
1018     unset SAVED_BINDIR
1019     unset SAVED_NOPKGBUILD
1020     unset SPLIT_PACKAGE_BASE
1021     unset -f SAVED_preinstall
1022     unset -f SAVED_postinstall
1023     unset -f SAVED_preremove
1024     unset -f SAVED_postremove
1025    }
1026    
1027  export_inherits()  export_inherits()
1028  {  {
1029   local include="$1"   local include="$1"
# Line 666  export_inherits() Line 1046  export_inherits()
1046   done   done
1047  }  }
1048    
1049    generate_package_md5sum()
1050    {
1051     local dest
1052     local pcat
1053     local pname
1054     local pver
1055     local pbuild
1056     local parch
1057     local target
1058     local pkgname
1059    
1060     # very basic getops
1061     for i in $*
1062     do
1063     case $1 in
1064     --pcat|-c) shift; pcat="$1" ;;
1065     --pname|-n) shift; pname="$1" ;;
1066     --pver|-v) shift; pver="$1" ;;
1067     --pbuild|-b) shift; pbuild="$1" ;;
1068     --parch|a) shift; parch="$1" ;;
1069     --target|t) shift; target="$1" ;;
1070     esac
1071     shift
1072     done
1073    
1074     # sanity checks; abort if not given
1075     [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given."
1076     [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given."
1077     [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given."
1078     [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given."
1079     [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given."
1080    
1081     # check needed global vars
1082     [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
1083     [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
1084    
1085     # fix target as it may be empty !
1086     [ -n "${target}" ] && target="-${target}"
1087    
1088    
1089     # build pkgname
1090     pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1091    
1092     # build pkg-md5-sum only if requested
1093     if [[ ${REGEN_MAGE_TREE} = true ]]
1094     then
1095     echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
1096    
1097     # abort if not exist
1098     if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
1099     then
1100     echo -e "${COLRED}! exists${COLDEFAULT}"
1101     return 0
1102     fi
1103    
1104     # if MAGE_TREE_DEST not set use BUILDDIR
1105     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1106    
1107     # setup md5 dir
1108     dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1109     install -d ${dest}
1110    
1111     # gen md5sum
1112     ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
1113     > ${dest}/${pkgname}.md5
1114     echo -e "${COLGREEN}done${COLDEFAULT}"
1115     fi
1116    }
1117    
1118    source_pkg_build()
1119    {
1120     if [[ ${PKGTYPE} = virtual ]]
1121     then
1122     echo "Virtual package detected; src-pkg-tarball not necessary ..."
1123     return 0
1124     fi
1125    
1126     if [[ ! -d ${SOURCEDIR}/${PNAME} ]]
1127     then
1128     echo "No SRC_URI defined; src-pkg-tarball not necessary ..."
1129     return 0
1130     fi
1131    
1132     [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."
1133    
1134     echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}"
1135    
1136     # include the smage2 file
1137     cp ${SMAGENAME} ${SOURCEDIR}/${PNAME}
1138    
1139     ( cd ${SOURCEDIR}; tar cvjf ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${PNAME}; )
1140     [[ ! -d ${SRCPKGDIR} ]] && install -d ${SRCPKGDIR}
1141     mv ${BUILDDIR}/${PNAME}-${PVER}-${PBUILD}.tar.bz2 ${SRCPKGDIR}/${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX}
1142    
1143     echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
1144    }
1145    
1146    step_by_step()
1147    {
1148     if [[ ${STEP_BY_STEP} = true ]]
1149     then
1150     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1151     echo "Press [enter] to continue"
1152     read
1153     fi
1154    }
1155    
1156    
1157  # print out our version  # print out our version
1158  showversion  showversion
1159  echo  echo
# Line 678  then Line 1166  then
1166  fi  fi
1167    
1168  # updating smage2-scripts  # updating smage2-scripts
1169  if [ "$1" == "update" ]  if [[ $1 = update ]]
1170  then  then
1171   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
1172   then   then
# Line 689  then Line 1177  then
1177  fi  fi
1178    
1179  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1180  if [ "$1" == "calcmd5" ]  if [[ $1 = calcmd5 ]]
1181  then  then
1182   if [ $# -ge 3 ]   if [ $# -ge 3 ]
1183   then   then
# Line 741  then Line 1229  then
1229   unset my_SRC_URI_MIRROR   unset my_SRC_URI_MIRROR
1230   unset my_SOURCEDIR   unset my_SOURCEDIR
1231   done   done
1232    
1233   echo   echo
1234   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
1235   echo   echo
# Line 754  then Line 1242  then
1242   echo   echo
1243   exit 1   exit 1
1244   fi   fi
1245    
1246   exit 0   exit 0
1247  fi  fi
1248    
# Line 784  then Line 1272  then
1272   source ${SMAGENAME} || die "regen: smage2 not found"   source ${SMAGENAME} || die "regen: smage2 not found"
1273    
1274   regen_mage_tree   regen_mage_tree
1275    
1276     # build several targets
1277     if [[ -n ${MAGE_TARGETS} ]]
1278     then
1279     for target in ${MAGE_TARGETS}
1280     do
1281     # build md5sum for existing packages
1282     generate_package_md5sum \
1283     --pcat "${PCATEGORIE}" \
1284     --pname "${PNAME}" \
1285     --pver "${PVER}" \
1286     --pbuild "${PBUILD}" \
1287     --parch "${ARCH}" \
1288     --target "${target}"
1289     done
1290    
1291     # build several subpackages
1292     elif [[ -n ${SPLIT_PACKAGES} ]]
1293     then
1294     split_save_variables
1295     for subpackage in ${SPLIT_PACKAGE}
1296     do
1297     # get the right variables for the split
1298     export PNAME="${subpackage}"
1299     split_info_${subpackage}
1300     # build md5sum for existing packages
1301     generate_package_md5sum \
1302     --pcat "${PCATEGORIE}" \
1303     --pname "${PNAME}" \
1304     --pver "${PVER}" \
1305     --pbuild "${PBUILD}" \
1306     --parch "${ARCH}"
1307     done
1308     split_restore_variables
1309    
1310     else
1311     # build md5sum for existing packages
1312     generate_package_md5sum \
1313     --pcat "${PCATEGORIE}" \
1314     --pname "${PNAME}" \
1315     --pver "${PVER}" \
1316     --pbuild "${PBUILD}" \
1317     --parch "${ARCH}"
1318     fi
1319    
1320   exit 0   exit 0
1321  fi  fi
1322    
1323  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  if [ "$1" == "--create-src-tarball" -a -n "$2" ]
1324  then  then
1325   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."   # set correct SMAGENAME
1326  fi   SMAGENAME="$2"
1327     MD5DIR="$(dirname ${SMAGENAME})/md5"
1328    
1329  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  
1330    
1331  if [ -z "${SOURCEDIR}" ]   source ${SMAGENAME} || die "regen: smage2 not found"
 then  
  die "\$SOURCEDIR not found. Please setup your mage.rc correctly."  
 fi  
1332    
1333  if [ -z "${SMAGESCRIPTSDIR}" ]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1334  then   then
1335   die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."   echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1336  fi   rm -rf ${SOURCEDIR}/${PKGNAME}
1337     fi
1338    
1339  if [ -z "${SMAGE2RSYNC}" ]   download_sources
1340  then   source_pkg_build ${SMAGENAME}
1341   echo "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."   exit 0
  exit 1  
1342  fi  fi
1343    
1344  if [ -z "${BINDIR}" ]  if [ "$1" == "--src-tarball" -a -n "$2" ] || [ "$1" == "-st" -a -n "$2" ]
1345  then  then
1346   die "no BINDIR variable found in /etc/mage.rc"   SRCPKGTARBALL="${2}"
1347  fi   USE_SRC_PKG_TARBALL=true
1348    
1349  if [ -z "${CHOST}" ]   # abort if given file is not a source pkg
1350  then   [[ ${SRCPKGTARBALL##*.} != ${SRCPKGSUFFIX} ]] && die "${SRCPKGTARBALL} is not a valid src-pkg file."
  die "no CHOST variable found in /etc/mage.rc"  
 fi  
1351    
1352  if [ -z "${CFLAGS}" ]   # set correct SMAGENAME; use the one that the src_pkg provide
1353  then   # /path/to/SOURCEDIR/PNAME/SMAGENAME
1354   die "no CFLAGS variable found in /etc/mage.rc"   SMAGENAME="${SOURCEDIR}/$(basename ${SRCPKGTARBALL%-*-*})/$(basename ${SRCPKGTARBALL} .${SRCPKGSUFFIX}).${SMAGESUFFIX}"
 fi  
1355    
1356  if [ -z "${CXXFLAGS}" ]   echo -e "${COLGREEN}Using src-tarball ${COLBLUE}${SRCPKGTARBALL}${COLGREEN} ...${COLDEFAULT}"
1357  then  
1358   die "no CXXFLAGS variable found in /etc/mage.rc"   [[ ! -d ${SOURCEDIR} ]] && install -d ${SOURCEDIR}
1359    
1360     # unpack srctarball
1361     [[ ! -f ${SRCPKGTARBALL} ]] && die "Error: ${SRCPKGTARBALL} does not exist. Aborting."
1362    
1363     tar xvjf ${SRCPKGTARBALL} -C ${SOURCEDIR} || die  "Error unpackung src-tarball ${SRCPKGTARBALL}"
1364    
1365     [[ ! -f ${SMAGENAME} ]] && die "Included smage2 file in src-tarball not found: ${SMAGENAME}"
1366  fi  fi
1367    
1368    
1369    [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
1370    [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
1371     die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
1372    [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
1373    [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly."
1374    [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly."
1375    [ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}"
1376    [ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}"
1377    [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1378    [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1379    
1380  source ${SMAGENAME} || die "source failed"  source ${SMAGENAME} || die "source failed"
1381  PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1382  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1383    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1384    
1385  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1386  echo "Compiling ${PKGNAME}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1387    
1388  # auto regen mage tree if requested  # auto regen mage tree if requested
1389  regen_mage_tree  regen_mage_tree
1390    
1391    if [[ ${CREATE_SRC_PKG_TARBALL} = true ]]
1392    then
1393     if [[ -d ${SOURCEDIR}/${PNAME} ]]
1394     then
1395     echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1396     rm -rf ${SOURCEDIR}/${PNAME}
1397     fi
1398    fi
1399    
1400  # download sources  # download sources
1401  download_sources  [[ ${USE_SRC_PKG_TARBALL} != true ]] && download_sources
1402    
1403  # fixes some issues with these functions  # fixes some issues with these functions
1404  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
# Line 861  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 1414  export MAKEOPTS="${MAKEOPTS}" || die "MA
1414    
1415    
1416  # setup distcc  # setup distcc
1417  # 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
1418  if [ "${SMAGE_USE_DISTCC}" == "true" ]  [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment
 then  
  setup_distcc_environment  
 fi  
1419    
1420  # setup ccache  # setup ccache
1421  if [ "${SMAGE_USE_CCACHE}" == "true" ]  [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
 then  
  setup_ccache_environment  
 fi  
   
1422    
1423  # small sleep to show our settings  # small sleep to show our settings
1424  sleep 1  sleep 1
1425    
 #debug  
 #echo "CC=${CC}"  
 #echo "CXX=${CXX}"  
 #echo "DISTCC_DIR=${DISTCC_DIR}"  
 #echo "PATH: ${PATH}"  
 #echo "--------------------------------------"  
 #env  
 #echo "--------------------------------------"  
 #read  
 #debug end  
   
1426  # cleans up build if a previously one exists  # cleans up build if a previously one exists
1427  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
1428  then  then
# Line 920  then Line 1455  then
1455   mage rmstamp   mage rmstamp
1456  fi  fi
1457    
1458  src_prepare || die "src_prepare failed"  # setup build loggins
1459  src_compile || die "src_compile failed"  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1460  src_install || die "src_install failed"  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1461    
1462    src_prepare | ${SMAGE_LOG_CMD}
1463    die_pipestatus 0 "src_prepare failed"
1464    step_by_step $_
1465    
1466    src_compile | ${SMAGE_LOG_CMD}
1467    die_pipestatus 0 "src_compile failed"
1468    step_by_step $_
1469    
1470    # build several subpackages
1471    if [[ -n ${SPLIT_PACKAGES} ]]
1472    then
1473     # save bindir & pname
1474     split_save_variables
1475     export SAVED_BINDIR="${BINDIR}"
1476     for subpackage in ${SPLIT_PACKAGES}
1477     do
1478     if typeset -f src_install_${subpackage} > /dev/null
1479     then
1480     # export subpackage bindir
1481     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1482     # export PNAME, several internal function and include
1483     # rely on this variable
1484     export PNAME="${subpackage}"
1485    
1486     echo
1487     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1488     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1489     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1490     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1491    
1492     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1493     die_pipestatus 0 "src_install_${subpackage} failed"
1494     step_by_step $_
1495     fi
1496     done
1497     # restore bindir & pname
1498     split_restore_variables
1499    else
1500     src_install | ${SMAGE_LOG_CMD}
1501     die_pipestatus 0 "src_install failed"
1502     step_by_step $_
1503    fi
1504    
1505  # compressing doc, info & man files  # compressing doc, info & man files
1506  echo -e "Compressing man-pages ..."  if [[ -n ${SPLIT_PACKAGES} ]]
 if [ -d ${BUILDDIR}/builded/usr/share/man ]  
1507  then  then
1508   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   for subpackage in ${SPLIT_PACKAGE}
1509     do
1510     mcompressdocs ${BINDIR}_${subpackage}
1511     done
1512    else
1513     mcompressdocs ${BINDIR}
1514  fi  fi
1515    
 echo -e "Compressing info-pages ..."  
 if [ -d ${BUILDDIR}/builded/usr/share/info ]  
 then  
  ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info  
 fi  
1516    
1517  # stripping all bins and libs  # stripping all bins and libs
1518  case ${NOSTRIP} in  case ${NOSTRIP} in
# Line 944  case ${NOSTRIP} in Line 1520  case ${NOSTRIP} in
1520   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1521   ;;   ;;
1522   *)   *)
1523   echo -e "Stripping binaries ..."   if [[ -n ${SPLIT_PACKAGES} ]]
1524   mstripbins ${BINDIR}   then
1525   echo -e "Stripping libraries ..."   for subpackage in ${SPLIT_PACKAGE}
1526   mstriplibs ${BINDIR}   do
1527     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1528     mstripbins ${BINDIR}_${subpackage}
1529     echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1530     mstriplibs ${BINDIR}_${subpackage}
1531     done
1532     else
1533     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1534     mstripbins ${BINDIR}
1535     echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1536     mstriplibs ${BINDIR}
1537     fi
1538   ;;   ;;
1539  esac  esac
1540    
# Line 957  case ${NOPKGBUILD} in Line 1544  case ${NOPKGBUILD} in
1544   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "NOPGKBUILD=true detected; Package will not be build ..."
1545   ;;   ;;
1546   *)   *)
1547   # build serveral targets   # build several targets
1548   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1549   then   then
1550   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1551   do   do
# Line 970  case ${NOPKGBUILD} in Line 1557  case ${NOPKGBUILD} in
1557   fi   fi
1558   # now create the target package   # now create the target package
1559   ${MLIBDIR}/pkgbuild_dir.sh \   ${MLIBDIR}/pkgbuild_dir.sh \
1560   "${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \   "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \
1561   ${BINDIR} || die "target: ${target} package-build failed"   ${BINDIR} || die "target: ${target} package-build failed"
1562   echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n"  
1563     # build pkg-md5-sum if requested
1564     generate_package_md5sum \
1565     --pcat "${PCATEGORIE}" \
1566     --pname "${PNAME}" \
1567     --pver "${PVER}" \
1568     --pbuild "${PBUILD}" \
1569     --parch "${ARCH}" \
1570     --target "${target}"
1571    
1572     echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1573   done   done
1574    
1575     # build several subpackages
1576     elif [[ -n ${SPLIT_PACKAGES} ]]
1577     then
1578     split_save_variables
1579     for subpackage in ${SPLIT_PACKAGES}
1580     do
1581     # get the right variables for the split
1582     export PNAME="${subpackage}"
1583     split_info_${PNAME}
1584    
1585     # check if an special subpackage_pkgbuild exists
1586     if typeset -f ${PNAME}_pkgbuild > /dev/null
1587     then
1588     # run it
1589     ${PNAME}_pkgbuild
1590     fi
1591     # now create the target package
1592     ${MLIBDIR}/pkgbuild_dir.sh \
1593     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1594     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1595    
1596     # build pkg-md5-sum if requested
1597     generate_package_md5sum \
1598     --pcat "${PCATEGORIE}" \
1599     --pname "${PNAME}" \
1600     --pver "${PVER}" \
1601     --pbuild "${PBUILD}" \
1602     --parch "${ARCH}"
1603    
1604     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1605     done
1606     split_restore_variables
1607    
1608   else   else
1609   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1610   echo -e "\nPackage ${PKGNAME} successfully builded.\n"  
1611     # build pkg-md5-sum if requested
1612     generate_package_md5sum \
1613     --pcat "${PCATEGORIE}" \
1614     --pname "${PNAME}" \
1615     --pver "${PVER}" \
1616     --pbuild "${PBUILD}" \
1617     --parch "${ARCH}"
1618    
1619     echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1620   fi   fi
1621    
1622     # build src-pkg-tarball if requested
1623     [[ ${CREATE_SRC_PKG_TARBALL} = true ]] && source_pkg_build ${SMAGENAME}
1624   ;;   ;;
1625  esac  esac
1626    
1627    if [[ ${SMAGE_BUILD_LOGGING} != false ]]
1628    then
1629     bzip2 -9f /var/log/smage/${PKGNAME}.log
1630    else
1631     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1632    fi
1633    
1634  # for sure  # for sure
1635  unset NOPKGBUILD  unset NOPKGBUILD
1636  unset NOSTRIP  unset NOSTRIP
1637    
1638  xtitleclean  xtitleclean
 #echo -e "\nPackage ${PKGNAME} successfully builded.\n"  

Legend:
Removed from v.253  
changed lines
  Added in v.945