Magellan Linux

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

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

revision 172 by niro, Sun Jul 31 14:16:19 2005 UTC revision 306 by niro, Mon Dec 26 23:16:38 2005 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.17 2005-07-31 14:16:19 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.40 2005-12-26 23:16:38 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  ## setup ##  ## setup ##
 SMAGEVERSION=0.3.6-r19  
14  PKGSUFFIX="mpk"  PKGSUFFIX="mpk"
15  SMAGENAME="$1"  SMAGENAME="$1"
16  SMAGESUFFIX="smage2"  SMAGESUFFIX="smage2"
# Line 19  SMAGESUFFIX="smage2" Line 18  SMAGESUFFIX="smage2"
18  #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"  #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"
19  #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"  #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"
20  MLIBDIR=/usr/lib/mage  MLIBDIR=/usr/lib/mage
21    SMAGEVERSION="$( < ${MLIBDIR}/version)"
22    
23  # export default C locale  # export default C locale
24  export LC_ALL=C  export LC_ALL=C
25    
26  source /etc/mage.rc  source /etc/mage.rc
27    
28  showversion() {  showversion()
29    {
30   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
31   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"   echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"
32  }  }
33    
34  die() {  die()
35    {
36   xtitleclean   xtitleclean
37   echo "SMAGE failed: $@"   echo "SMAGE failed: $@"
38   exit 1   exit 1
39  }  }
40    
41  xtitle() {  xtitle()
42   if [ ${TERM} == "xterm" ]  {
43     if [[ ${TERM} = xterm ]]
44   then   then
45   echo -ne "\033]0;[sMage: $@]\007"   echo -ne "\033]0;[sMage: $@]\007"
46   fi   fi
47   return 0   return 0
48  }  }
49    
50  xtitleclean() {  xtitleclean()
51   if [ ${TERM} == "xterm" ]  {
52     if [[ ${TERM} = xterm ]]
53   then   then
54   echo -ne "\033]0;\007"   echo -ne "\033]0;\007"
55   fi   fi
56   return 0   return 0
57  }  }
58    
59  syncsmage2() {  syncsmage2()
60    {
61   xtitle "Updating smage2-script tree ..."   xtitle "Updating smage2-script tree ..."
62   local i   local i
63   for i in ${SMAGE2RSYNC}   for i in ${SMAGE2RSYNC}
# Line 71  syncsmage2() { Line 76  syncsmage2() {
76   --delete \   --delete \
77   --delete-after \   --delete-after \
78   ${i} ${SMAGESCRIPTSDIR}   ${i} ${SMAGESCRIPTSDIR}
79    
80   if [ "$?" == "0" ]   if [[ $? = 0 ]]
81   then   then
82   break   break
83   else   else
84   continue   continue
85   fi   fi
86    
87   done   done
88    
89   #clean up backup files (foo~)   # clean up backup files (foo~)
90   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'   find ${SMAGESCRIPTSDIR} -name *~ -exec rm '{}' ';'
91    
92   xtitleclean   xtitleclean
93  }  }
94    
95  # $1 filename  # $1 filename
96  get_db_md5_sum() {  get_db_md5_sum()
97    {
98   local DB_FILE   local DB_FILE
99   local MD5_FILE   local MD5_FILE
100   local i   local i
# Line 101  get_db_md5_sum() { Line 107  get_db_md5_sum() {
107   echo "${i}"   echo "${i}"
108  }  }
109    
110  download_sources() {  download_sources()
111    {
112    
113   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0   [ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0
114    
# Line 113  download_sources() { Line 120  download_sources() {
120   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
121   local FETCHING   local FETCHING
122   local i mirror   local i mirror
   
123    
124   #install SRCDIR/PNAME if not exist  
125     # install SRCDIR/PNAME if not exist
126   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
127    
128   # check if FETCHING is needed   # check if FETCHING is needed
129   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )
130   if [[ $? == 0 ]]   if [[ $? = 0 ]]
131   then   then
132   # md5's ok, not fetching needed   # md5's ok, not fetching needed
133   FETCHING=false   FETCHING=false
134   else   else
135   FETCHING=true   FETCHING=true
136   fi   fi
137    
138   for ((i=0; i < EOA; i++))   for ((i=0; i < EOA; i++))
139   do   do
140   # url to file   # url to file
# Line 152  download_sources() { Line 159  download_sources() {
159   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")"
160    
161   #echo "DEBUG: ${MY_SRC_URI}"   #echo "DEBUG: ${MY_SRC_URI}"
162   if [[ ${FETCHING} == true ]]   if [[ ${FETCHING} = true ]]
163   then   then
164   echo "==> fetching ${my_SRC_URI_MIRROR}"   echo "==> fetching ${my_SRC_URI_MIRROR}"
165   wget \   wget \
# Line 162  download_sources() { Line 169  download_sources() {
169   --progress bar \   --progress bar \
170   --directory-prefix="${my_SOURCEDIR}" \   --directory-prefix="${my_SOURCEDIR}" \
171   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
172   if [ "$?" == "0" ]   if [[ $? = 0 ]]
173   then   then
174   break   break
175   else   else
# Line 172  download_sources() { Line 179  download_sources() {
179   done   done
180   else   else
181   #echo "DEBUG: ${SRC_URI[${i}]}"   #echo "DEBUG: ${SRC_URI[${i}]}"
182   if [[ ${FETCHING} == true ]]   if [[ ${FETCHING} = true ]]
183   then   then
184   echo "==> fetching ${my_SRC_URI}"   echo "==> fetching ${my_SRC_URI}"
185   wget \   wget \
# Line 191  download_sources() { Line 198  download_sources() {
198  # fi  # fi
199   fi   fi
200   fi   fi
201    
202   # unset them to be shure   # unset them to be shure
203   unset my_SRC_URI   unset my_SRC_URI
204   unset my_SRC_URI_DEST   unset my_SRC_URI_DEST
# Line 210  download_sources() { Line 217  download_sources() {
217  }  }
218    
219  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
220  src_prepare() {  src_prepare()
221    {
222   echo "no src_prepare defined"   echo "no src_prepare defined"
223   sleep 2   sleep 2
224   return 0   return 0
225  }  }
226    
227  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
228  src_compile() {  src_compile()
229    {
230   echo "no src_compile defined"   echo "no src_compile defined"
231   sleep 2   sleep 2
232   return 0   return 0
233  }  }
234    
235  # dummy function, used if that not exist in smage file  # dummy function, used if that not exist in smage file
236  src_install() {  src_install()
237    {
238   echo "no src_install defined"   echo "no src_install defined"
239   sleep 2   sleep 2
240   return 0   return 0
241  }  }
242    
243    mconfigure()
244  build_mage_script() {  {
  return 0  
 }  
   
 mconfigure() {  
245   if [ -x ./configure ]   if [ -x ./configure ]
246   then   then
247   ./configure \   ./configure \
248   --prefix=/usr \   --prefix=/usr \
249   --host=${CHOST} \   --host=${CHOST} \
250   --mandir=/usr/share/man \   --mandir=/usr/share/man \
251   --infodir=/usr/share/info \   --infodir=/usr/share/info \
252   --datadir=/usr/share \   --datadir=/usr/share \
253   --sysconfdir=/etc \   --sysconfdir=/etc \
254   --localstatedir=/var/lib \   --localstatedir=/var/lib \
255   "$@" || die "mconfigure failed"   "$@" || die "mconfigure failed"
256   else   else
257   echo "configure is not an executable ..."   echo "configure is not an executable ..."
258   exit 1   exit 1
259   fi   fi
260  }  }
261    
262  minstall() {  minstall()
263   if [ -f ./[mM]akefile -o -f ./GNUmakefile ] ; then  {
264     if [ -f ./[mM]akefile -o -f ./GNUmakefile ]
265     then
266   make prefix=${BINDIR}/usr \   make prefix=${BINDIR}/usr \
267   datadir=${BINDIR}/usr/share \   datadir=${BINDIR}/usr/share \
268   infodir=${BINDIR}/usr/share/info \   infodir=${BINDIR}/usr/share/info \
# Line 267  minstall() { Line 275  minstall() {
275          fi          fi
276  }  }
277    
278  mmake() {  mmake()
279    {
280   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"   make ${MAKEOPTS} ${EXTRA_EMAKE} "$@"
281  }  }
282    
283  munpack() {  munpack()
284    {
285   local SRCFILE   local SRCFILE
286   local IFTAR   local IFTAR
287   local DEST   local DEST
288    
289   SRCFILE=$1   SRCFILE=$1
290    
291   if [ -z "$2" ]   if [ -z "$2" ]
292   then   then
293   DEST=${BUILDDIR}   DEST=${BUILDDIR}
294   else   else
295   DEST=$2   DEST=$2
296   fi   fi
297    
298   case "${SRCFILE##*.}" in   case "${SRCFILE##*.}" in
299   bz2)   bz2)
300   IFTAR="$(basename $SRCFILE .bz2)"   IFTAR="$(basename $SRCFILE .bz2)"
301   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
302   if [ "${IFTAR}" == "tar" ]   if [[ ${IFTAR} = tar ]]
303   then   then
304   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
305   fi   fi
# Line 297  munpack() { Line 307  munpack() {
307   gz)   gz)
308   IFTAR="$(basename $SRCFILE .gz)"   IFTAR="$(basename $SRCFILE .gz)"
309   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
310   if [ "${IFTAR}" == "tar" ]   if [[ ${IFTAR} = tar ]]
311   then   then
312   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}
313   fi   fi
# Line 314  munpack() { Line 324  munpack() {
324   esac   esac
325  }  }
326    
327  mpatch() {  mpatch()
328    {
329   local PATCHOPTS   local PATCHOPTS
330   local PATCHFILE   local PATCHFILE
331    
# Line 325  mpatch() { Line 336  mpatch() {
336  }  }
337    
338    
339  minstalldocs() {  minstalldocs()
340    {
341   local docfiles   local docfiles
   
342   docfiles="$@"   docfiles="$@"
343    
344   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]   if [ ! -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} ]
345   then   then
346   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
347   fi   fi
348    
349   for i in ${docfiles}   for i in ${docfiles}
350   do   do
351   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
# Line 343  minstalldocs() { Line 354  minstalldocs() {
354   done   done
355  }  }
356    
357  mstriplibs() {  mstriplibs()
358    {
359   local stripdir="$@"   local stripdir="$@"
360    
361   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
362   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
363  }  }
364    
365  mstripbins() {  mstripbins()
366    {
367   local stripdir="$@"   local stripdir="$@"
368    
369   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
370   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
371  }  }
372    
373  sminclude() {  sminclude()
374    {
375   local i   local i
376    
377   if [ -n "$@" ]   if [[ -n "$@" ]]
378   then   then
379   for i in $@   for i in $@
380   do   do
381   echo "--- including ${SMAGESCRIPTSDIR}/include/${i}.incl"   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
382   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
383   done   done
384     echo
385   fi   fi
386  }  }
387    
388  setup_distcc_environment(){  setup_distcc_environment()
389    {
390   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
391   then   then
392   echo "Using DistCC for compilation ..."   echo "Using DistCC for compilation ..."
393   export PATH=/usr/lib/distcc/bin:${PATH} || die "distcc: could not export new $PATH"   export PATH=/usr/lib/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
394    
395   #export distcc as compiler   # export distcc as compiler
396  # export CC="distcc"  # export CC="distcc"
397  # export CXX=distcc  # export CXX=distcc
398    
399   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
400    
401     # ccache + distcc together
402   #ccache + distcc together   if [[ ${SMAGE_USE_CCACHE} = true ]]
  if [ "${SMAGE_USE_CCACHE}" == "true" ]  
403   then   then
404   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
405   then   then
# Line 395  setup_distcc_environment(){ Line 410  setup_distcc_environment(){
410   fi   fi
411   fi   fi
412    
413   #creating distcc tempdir   # creating distcc tempdir
414   install -o distcc -g daemon -d ${DISTCC_DIR}   install -o distcc -g daemon -d ${DISTCC_DIR}
415   chmod 1777 ${DISTCC_DIR}   chmod 1777 ${DISTCC_DIR}
416   fi   fi
417  }  }
418    
419  setup_ccache_environment(){  setup_ccache_environment()
420    {
421   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
422   then   then
423   echo "Using CCache for compilation ..."   echo "Using CCache for compilation ..."
# Line 410  setup_ccache_environment(){ Line 426  setup_ccache_environment(){
426   fi   fi
427  }  }
428    
429    
430    # fixes given dependencies to match a MAGE_TARGET
431    # fix_mage_deps -target s/depend # <-- note -target !
432    fix_mage_deps()
433    {
434     local target="$1"
435     local depend="$2"
436     local NDEPEND
437     local sym dep cat pver pname
438    
439     # deps and provides are special
440     # they must be fixed to match the target
441    
442     # run this only if target and depend is not empty
443     if [ -n "${target}" ] && [ -n "${depend}" ]
444     then
445     # fix DEPEND
446     while read sym dep
447     do
448     cat="$(dirname ${dep})"
449     # change if not virtual
450     if [[ ${cat} = virtual ]]
451     then
452     pname="$(basename ${dep})"
453     else
454     # fix pver to target-pver
455     # to get pname-target-pver
456    
457     # doing it backwards !
458     pver="${dep##*-}"
459     # full pver
460     pname="$(basename ${dep/-${pver}/})${target}-${pver}"
461     fi
462    
463     # do not add empty lines
464     if [ -z "${NDEPEND}" ]
465     then
466     NDEPEND="${sym} ${cat}/${pname}"
467     else
468     NDEPEND="${NDEPEND}
469     ${sym} ${cat}/${pname}"
470     fi
471    
472     unset cat pname pver
473     done << EOF
474    ${depend}
475    EOF
476     # set NDEPEND to DEPEND
477     depend="${NDEPEND}"
478     fi
479    
480     echo "${depend}"
481    }
482    
483    # build_mage_script(): helper functions for regen_mage_tree()
484    # generates an mage file with given information in smage file
485    # needs at least:
486    #   PNAME                 name of pkg
487    #   PVER                  version
488    #   PBUILD                revision
489    #   PCATEGORIE            categorie of the pkg
490    #   STATE                 state of pkg stable|unstable|old
491    #   DESCRIPTION           va short description (opt)
492    #   HOMEPAGE              homepage (opt)
493    #   DEPEND                runtime dependencies (opt)
494    #   SDEPEND               add. needed deps to build the pkg (opt)
495    #   PROVIDE               provides a virtual (opt)
496    #
497    # special tags:
498    #   PKGTYPE               type of pkg
499    #   INHERITS              which functions get included
500    #   SPECIAL_FUNCTIONS     special functions wich should also be added
501    #                         warning: they get killed before the build starts !
502    #
503    #   MAGE_TREE_DEST        target destination of the generated tree
504    #   REGEN_MAGE_TREE       set to 'true' to enable this
505    #
506    # gets called with build_mage_script target
507    build_mage_script()
508    {
509     local magefile
510     local dest
511     local target
512     local sym
513     local depname
514    
515     # if MAGE_TREE_DEST not set use BUILDDIR
516     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
517    
518     # determinate which suffix this mage file should get, if any
519     [ -n "$1" ] && target="-$1"
520    
521     # name of magefile
522     magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
523    
524     # destination to magefile
525     dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
526    
527     # show what we are doing
528     echo "Generating Mage file:"
529     echo "  ${dest}"
530    
531     install -d "$(dirname ${dest})"
532     # now build the mage file
533     > ${dest}
534    
535     # header
536     echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.40 2005-12-26 23:16:38 niro Exp $' >> ${dest}
537     echo  >> ${dest}
538    
539     # pgkname and state
540     echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
541     echo "STATE=\"${STATE}\"" >> ${dest}
542     echo >> ${dest}
543    
544     # description and homepage
545     echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
546     echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
547     echo >> ${dest}
548    
549     # special tags and vars
550     echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
551    
552     # echo MAGE_TARGETS ## note -target is needed !
553     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
554     echo >> ${dest}
555    
556     # add special vars
557     if [ -n "${SPECIAL_VARS}" ]
558     then
559     local i
560     for i in ${SPECIAL_VARS}
561     do
562     # being tricky here :)
563     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
564     done
565     echo  >> ${dest}
566     fi
567    
568     # add at least all includes
569     if [ -n "${INHERITS}" ]
570     then
571     echo -n "minclude"  >> ${dest}
572     local i
573     for i in ${INHERITS}
574     do
575     echo -n " ${i}"  >> ${dest}
576     done
577     echo  >> ${dest}
578     fi
579     echo >> ${dest}
580    
581     # deps and provides
582     echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
583     echo >> ${dest}
584     echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
585     echo >> ${dest}
586     echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
587     echo >> ${dest}
588    
589     # add special functions
590     if [ -n "${SPECIAL_FUNCTIONS}" ]
591     then
592     local i
593     for i in ${SPECIAL_FUNCTIONS}
594     do
595     # add to mage (quotes needed !)
596     typeset -f "${i}" >> ${dest}
597     echo >> ${dest}
598     # unset to be safe (quotes needed !)
599     #unset "${i}" <-- later to get every target built
600     done
601     echo  >> ${dest}
602     fi
603    
604     # pre|post-install|removes
605     typeset -f preinstall >> ${dest}
606     echo  >> ${dest}
607     typeset -f postinstall >> ${dest}
608     echo  >> ${dest}
609     typeset -f preremove >> ${dest}
610     echo  >> ${dest}
611     typeset -f postremove >> ${dest}
612     echo  >> ${dest}
613    }
614    
615    regen_mage_tree()
616    {
617     local i
618    
619     # build them only if requested
620     if [[ ${REGEN_MAGE_TREE} = true ]]
621     then
622     # run it without targets
623     if [ -z "${MAGE_TARGETS}" ]
624     then
625     echo
626     build_mage_script
627     echo
628     else
629    
630     # build for each target an mage file
631     # run it with several targets
632     for i in ${MAGE_TARGETS}
633     do
634     echo
635     build_mage_script "${i}"
636     echo
637     done
638     fi
639     fi
640    
641     # now unset all uneeded vars to be safe
642     # unset PKGNAME <-- don't do that; smage needs this var
643     # unset to be safe (quotes needed !)
644     for i in ${SPECIAL_FUNCTIONS}
645     do
646     unset "${i}"
647     done
648     unset SPECIAL_FUNCTIONS
649     for i in ${SPECIAL_VARS}
650     do
651     unset "${i}"
652     done
653     unset SPECIAL_VARS
654     unset STATE
655     unset DESCRIPTION
656     unset HOMEPAGE
657     unset PKGTYPE
658     unset INHERITS
659     unset DEPEND
660     unset SDEPEND
661     unset PROVIDE
662     unset preinstall
663     unset postinstall
664     unset preremove
665     unset postremove
666    }
667    
668    export_inherits()
669    {
670     local include="$1"
671     shift
672    
673     while [ "$1" ]
674     do
675     local functions="$1"
676    
677     # sanity checks
678     [ -z "${include}" ] && die "export_inherits(): \$include not given."
679     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
680    
681     eval "${functions}() { ${include}_${functions} ; }"
682    
683     # debug
684     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
685    
686     shift
687     done
688    }
689    
690    generate_package_md5sum()
691    {
692     local dest
693     local pcat
694     local pname
695     local pver
696     local pbuild
697     local parch
698     local target
699     local pkgname
700    
701     # very basic getops
702     for i in $*
703     do
704     case $1 in
705     --pcat|-c) shift; pcat="$1" ;;
706     --pname|-n) shift; pname="$1" ;;
707     --pver|-v) shift; pver="$1" ;;
708     --pbuild|-b) shift; pbuild="$1" ;;
709     --parch|a) shift; parch="$1" ;;
710     --target|t) shift; target="$1" ;;
711     esac
712     shift
713     done
714    
715     # sanity checks; abort if not given
716     [ -z "${pcat}" ] && die "generate_package_md5sum() \$pcat not given."
717     [ -z "${pname}" ] && die "generate_package_md5sum() \$pname not given."
718     [ -z "${pver}" ] && die "generate_package_md5sum() \$pver not given."
719     [ -z "${pbuild}" ] && die "generate_package_md5sum() \$pbuild not given."
720     [ -z "${parch}" ] && die "generate_package_md5sum() \$parch not given."
721    
722     # check needed global vars
723     [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
724     [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
725    
726     # fix target as it may be empty !
727     [ -n "${target}" ] && target="-${target}"
728    
729     # build pkgname
730     pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
731    
732     # build pkg-md5-sum only if requested
733     if [[ ${REGEN_MAGE_TREE} = true ]]
734     then
735     echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... "
736    
737     # abort if not exist
738     if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
739     then
740     echo "! exists"
741     return 0
742     fi
743    
744     # if MAGE_TREE_DEST not set use BUILDDIR
745     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
746    
747     # setup md5 dir
748     dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"
749     install -d ${dest}
750    
751     # gen md5sum
752     ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
753     > ${dest}/${pkgname}.md5
754     echo "done"
755     fi
756    }
757    
758  # print out our version  # print out our version
759  showversion  showversion
760  echo  echo
# Line 421  then Line 766  then
766   exit 1   exit 1
767  fi  fi
768    
769  #updating smage2-scripts  # updating smage2-scripts
770  if [ "$1" == "update" ]  if [[ $1 = update ]]
771  then  then
772   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
773   then   then
# Line 432  then Line 777  then
777   exit 0   exit 0
778  fi  fi
779    
780  #creates md5sums for smages to given dir  # creates md5sums for smages to given dir
781  if [ "$1" == "calcmd5" ]  if [[ $1 = calcmd5 ]]
782  then  then
783   if [ $# -ge 3 ]   if [ $# -ge 3 ]
784   then   then
# Line 485  then Line 830  then
830   unset my_SRC_URI_MIRROR   unset my_SRC_URI_MIRROR
831   unset my_SOURCEDIR   unset my_SOURCEDIR
832   done   done
833    
834   echo   echo
835   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."   echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done."
836   echo   echo
# Line 498  then Line 843  then
843   echo   echo
844   exit 1   exit 1
845   fi   fi
846    
847   exit 0   exit 0
848  fi  fi
849    
850  #download sources  # download sources
851  if [ "$1" == "download" -a -n "$2" ]  if [ "$1" == "download" -a -n "$2" ]
852  then  then
  showversion  
853   if [ ! -d ${SMAGESCRIPTSDIR} ]   if [ ! -d ${SMAGESCRIPTSDIR} ]
854   then   then
855   install -d ${SMAGESCRIPTSDIR}   install -d ${SMAGESCRIPTSDIR}
# Line 520  then Line 864  then
864   exit 0   exit 0
865  fi  fi
866    
867  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  # regen-mage-tree
868  then  if [ "$1" == "only-regen-tree" -a -n "$2" ]
  die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."  
 fi  
   
 if [ -z "`basename ${SMAGENAME}|grep .${SMAGESUFFIX}`" ]  
 then  
  die "File '`basename ${SMAGENAME}`' is not a sMage v${SMAGEVERSION} file. Aborting."  
 fi  
   
 if [ -z "${SOURCEDIR}" ]  
 then  
  die "\$SOURCEDIR not found. Please setup your mage.rc correctly."  
 fi  
   
 if [ -z "${SMAGESCRIPTSDIR}" ]  
869  then  then
870   die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."   # set correct SMAGENAME
871  fi   SMAGENAME="$2"
872     MD5DIR="$(dirname ${SMAGENAME})/md5"
873  if [ -z "${SMAGE2RSYNC}" ]   source ${SMAGENAME} || die "regen: smage2 not found"
 then  
  echo "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."  
  exit 1  
 fi  
874    
875  if [ -z "${BINDIR}" ]   regen_mage_tree
 then  
  die "no BINDIR variable found in /etc/mage.rc"  
 fi  
876    
877  if [ -z "${CHOST}" ]   # build md5sum for existing packages
878  then   generate_package_md5sum \
879   die "no CHOST variable found in /etc/mage.rc"   --pcat "${PCATEGORIE}" \
880  fi   --pname "${PNAME}" \
881     --pver "${PVER}" \
882  if [ -z "${CFLAGS}" ]   --pbuild "${PBUILD}" \
883  then   --parch "${ARCH}" \
884   die "no CFLAGS variable found in /etc/mage.rc"   --target "${target}"
 fi  
885    
886  if [ -z "${CXXFLAGS}" ]   exit 0
 then  
  die "no CXXFLAGS variable found in /etc/mage.rc"  
887  fi  fi
888    
889    [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
890    [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
891     die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
892    [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your mage.rc correctly."
893    [ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly."
894    [ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly."
895    [ -z "${BINDIR}" ] && die "no BINDIR variable found in /etc/mage.rc"
896    [ -z "${CHOST}" ] && die "no CHOST variable found in /etc/mage.rc"
897    [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in /etc/mage.rc"
898    [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in /etc/mage.rc"
899    
900  source ${SMAGENAME} || die "source failed"  source ${SMAGENAME} || die "source failed"
901  PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
902  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
903    
904  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
905  echo "Compiling ${PKGNAME}"  echo "Compiling ${PKGNAME}"
906    
907  #download sources  # auto regen mage tree if requested
908    regen_mage_tree
909    
910    # download sources
911  download_sources  download_sources
912    
913  #fixes some issues with these functions  # fixes some issues with these functions
914  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
915  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
916  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
917    
918  #fixes some compile issues  # fixes some compile issues
919  export CHOST="${CHOST}" || die "CHOST export failed"  export CHOST="${CHOST}" || die "CHOST export failed"
920  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
921  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
# Line 590  export BINDIR="${BINDIR}" || die "BINDIR Line 923  export BINDIR="${BINDIR}" || die "BINDIR
923  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
924    
925    
926  #setup distcc  # setup distcc
927  #distcc mus be setup *before* ccache, as ccache need to be before distcc in path  # distcc mus be setup *before* ccache, as ccache need to be before distcc in path
928  if [ "${SMAGE_USE_DISTCC}" == "true" ]  [[ ${SMAGE_USE_DISTCC} = true ]] && setup_distcc_environment
 then  
  setup_distcc_environment  
 fi  
   
 #setup ccache  
 if [ "${SMAGE_USE_CCACHE}" == "true" ]  
 then  
  setup_ccache_environment  
 fi  
929    
930    # setup ccache
931    [[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment
932    
933  # small sleep to show our settings  # small sleep to show our settings
934  sleep 1  sleep 1
# Line 618  sleep 1 Line 944  sleep 1
944  #read  #read
945  #debug end  #debug end
946    
947  #cleans up build if a previously one exists  # cleans up build if a previously one exists
948  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
949  then  then
950   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
951  fi  fi
952  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
953    
954  #cleans up srcdir if a previously unpacked one exists  # cleans up srcdir if a previously unpacked one exists
955  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
956  then  then
957   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
958  fi  fi
959    
960  #cleans up bindir if a previous build exists or creates a new one  # cleans up bindir if a previous build exists or creates a new one
961  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
962  then  then
963   rm -rf ${BINDIR}   rm -rf ${BINDIR}
964  fi  fi
965  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
966    
967  #cleans up package temp dir if a previous build exists  # cleans up package temp dir if a previous build exists
968  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
969  then  then
970   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
971  fi  fi
972    
973  #cleans up timestamp if one exists  # cleans up timestamp if one exists
974  if [ -f /var/tmp/timestamp ]  if [ -f /var/tmp/timestamp ]
975  then  then
976   mage rmstamp   mage rmstamp
# Line 655  src_compile || die "src_compile failed" Line 981  src_compile || die "src_compile failed"
981  src_install || die "src_install failed"  src_install || die "src_install failed"
982    
983    
984  #compressing doc, info & man files  # compressing doc, info & man files
985  echo -e "Compressing man-pages ..."  echo -e "Compressing man-pages ..."
986  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [ -d ${BUILDDIR}/builded/usr/share/man ]
987  then  then
# Line 681  case ${NOSTRIP} in Line 1007  case ${NOSTRIP} in
1007   ;;   ;;
1008  esac  esac
1009    
1010  #the new buildpkg command  # the new buildpkg command
1011  case ${NOPKGBUILD} in  case ${NOPKGBUILD} in
1012   true|TRUE|yes|y)   true|TRUE|yes|y)
1013   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "NOPGKBUILD=true detected; Package will not be build ..."
1014   ;;   ;;
1015   *)   *)
1016   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   # build several targets
1017   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   if [ -n "${MAGE_TARGETS}" ]
1018     then
1019     for target in ${MAGE_TARGETS}
1020     do
1021     # check if an special target_pkgbuild exists
1022     if typeset -f ${target}_pkgbuild > /dev/null
1023     then
1024     # run it
1025     ${target}_pkgbuild
1026     fi
1027     # now create the target package
1028     ${MLIBDIR}/pkgbuild_dir.sh \
1029     "${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD}" \
1030     ${BINDIR} || die "target: ${target} package-build failed"
1031    
1032     # build pkg-md5-sum if requested
1033     generate_package_md5sum \
1034     --pcat "${PCATEGORIE}" \
1035     --pname "${PNAME}" \
1036     --pver "${PVER}" \
1037     --pbuild "${PBUILD}" \
1038     --parch "${ARCH}" \
1039     --target "${target}"
1040    
1041     echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n"
1042     done
1043     else
1044     ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1045    
1046     # build pkg-md5-sum if requested
1047     generate_package_md5sum \
1048     --pcat "${PCATEGORIE}" \
1049     --pname "${PNAME}" \
1050     --pver "${PVER}" \
1051     --pbuild "${PBUILD}" \
1052     --parch "${ARCH}"
1053    
1054     echo -e "\nPackage ${PKGNAME} successfully builded.\n"
1055     fi
1056   ;;   ;;
1057  esac  esac
1058    
1059  #for sure  # for sure
1060  unset NOPKGBUILD  unset NOPKGBUILD
1061  unset NOSTRIP  unset NOSTRIP
1062    

Legend:
Removed from v.172  
changed lines
  Added in v.306