Magellan Linux

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

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

revision 90 by niro, Tue Jun 28 20:39:35 2005 UTC revision 192 by niro, Fri Aug 19 03:43:56 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.13 2005-06-28 20:39:35 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.23 2005-08-19 03:43:56 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-r17  
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
24    export LC_ALL=C
25    
26  source /etc/mage.rc  source /etc/mage.rc
27    
# Line 227  src_install() { Line 230  src_install() {
230   return 0   return 0
231  }  }
232    
   
 build_mage_script() {  
  return 0  
 }  
   
233  mconfigure() {  mconfigure() {
234   if [ -x ./configure ]   if [ -x ./configure ]
235   then   then
# Line 354  mstripbins() { Line 352  mstripbins() {
352   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
353  }  }
354    
355    sminclude() {
356     local i
357    
358     if [[ -n "$@" ]]
359     then
360     for i in $@
361     do
362     echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
363     source ${SMAGESCRIPTSDIR}/include/${i}.sminc
364     done
365     echo
366     fi
367    }
368    
369  setup_distcc_environment(){  setup_distcc_environment(){
370   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
371   then   then
# Line 394  setup_ccache_environment(){ Line 406  setup_ccache_environment(){
406   fi   fi
407  }  }
408    
409    # build_mage_script(): helper functions for regen_mage_tree()
410    # generates an mage file with given information in smage file
411    # needs at least:
412    #   PNAME                 name of pkg
413    #   PVER                  version
414    #   PBUILD                revision
415    #   PCATEGORIE            categorie of the pkg
416    #   STATE                 state of pkg stable|unstable|old
417    #   DESCRIPTION           va short description (opt)
418    #   HOMEPAGE              homepage (opt)
419    #   DEPEND                runtime dependencies (opt)
420    #   SDEPEND               add. needed deps to build the pkg (opt)
421    #   PROVIDE               provides a virtual (opt)
422    #
423    # special tags:
424    #   PKGTYPE               type of pkg
425    #   INHERITS              which functions get included
426    #   SPECIAL_FUNCTIONS     special functions wich should also be added
427    #                         warning: they get killed before the build starts !
428    #
429    #   MAGE_TREE_DEST        target destination of the generated tree
430    #   REGEN_MAGE_TREE       set to 'true' to enable this
431    build_mage_script()
432    {
433     local magefile
434     local dest
435     local suffix
436     local sym
437     local depname
438    
439     # if MAGE_TREE_DEST not set use BUILDDIR
440     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
441    
442     # determinate which suffix this mage file should get, if any
443     suffix="$1"
444    
445     # name of magefile
446     magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage"
447    
448     # destination to magefile
449     dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}"
450    
451     # show what we are doing
452     echo "Generating Mage file:"
453     echo "  ${dest}"
454    
455     install -d "$(dirname ${dest})"
456     # now build the mage file
457     > ${dest}
458    
459     # header
460     echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.23 2005-08-19 03:43:56 niro Exp $' >> ${dest}
461     echo  >> ${dest}
462    
463     # pgkname and state
464     echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
465     echo "STATE=\"${STATE}\"" >> ${dest}
466     echo >> ${dest}
467    
468     # description and homepage
469     echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
470     echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
471     echo >> ${dest}
472    
473     # special tags
474     echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
475     if [ -n "${INHERITS}" ]
476     then
477     echo -n "minclude"  >> ${dest}
478     local i
479     for i in ${INHERITS}
480     do
481     echo -n " ${i}"  >> ${dest}
482     done
483     echo  >> ${dest}
484     fi
485     echo >> ${dest}
486    
487     # deps and provides
488     echo "DEPEND=\"${DEPEND}\"" >> ${dest}
489     echo "SDEPEND=\"${SDEPEND}\"" >> ${dest}
490     echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
491     echo >> ${dest}
492    
493     # add special functions
494     if [ -n "${SPECIAL_FUNCTIONS}" ]
495     then
496     local i
497     for i in ${SPECIAL_FUNCTIONS}
498     do
499     # add to mage (quotes needed !)
500     typeset -f "${i}" >> ${dest}
501     # unset to be safe (quotes needed !)
502     #unset "${i}" <-- later to get every target built
503     done
504     fi
505    
506     # pre|post-install|removes
507     typeset -f preinstall >> ${dest}
508     echo  >> ${dest}
509     typeset -f postinstall >> ${dest}
510     echo  >> ${dest}
511     typeset -f preremove >> ${dest}
512     echo  >> ${dest}
513     typeset -f postremove >> ${dest}
514     echo  >> ${dest}
515    }
516    
517    regen_mage_tree()
518    {
519     local i
520    
521     # build them only if requested
522     if [[ ${REGEN_MAGE_TREE} = true ]]
523     then
524     # build for each target an mage file
525     for i in ${MAGE_TARGETS}
526     do
527     echo
528     build_mage_script "${i}"
529     echo
530     done
531     fi
532    
533     # now unset all uneeded vars to be safe
534     # unset PKGNAME <-- don't do that; smage needs this var
535     # unset to be safe (quotes needed !)
536     for i in ${SPECIAL_FUNCTIONS}
537     do
538     unset "${i}"
539     done
540     unset SPECIAL_FUNCTIONS
541     unset STATE
542     unset DESCRIPTION
543     unset HOMEPAGE
544     unset PKGTYPE
545     unset INHERITS
546     unset DEPEND
547     unset SDEPEND
548     unset PROVIDE
549     unset preinstall
550     unset postinstall
551     unset preremove
552     unset postremove
553    }
554    
555  # print out our version  # print out our version
556  showversion  showversion
557  echo  echo
# Line 405  then Line 563  then
563   exit 1   exit 1
564  fi  fi
565    
566  #updating smage2-scripts  # updating smage2-scripts
567  if [ "$1" == "update" ]  if [ "$1" == "update" ]
568  then  then
569   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
# Line 416  then Line 574  then
574   exit 0   exit 0
575  fi  fi
576    
577  #creates md5sums for smages to given dir  # creates md5sums for smages to given dir
578  if [ "$1" == "calcmd5" ]  if [ "$1" == "calcmd5" ]
579  then  then
580   if [ $# -ge 3 ]   if [ $# -ge 3 ]
# Line 486  then Line 644  then
644   exit 0   exit 0
645  fi  fi
646    
647  #download sources  # download sources
648  if [ "$1" == "download" -a -n "$2" ]  if [ "$1" == "download" -a -n "$2" ]
649  then  then
  showversion  
650   if [ ! -d ${SMAGESCRIPTSDIR} ]   if [ ! -d ${SMAGESCRIPTSDIR} ]
651   then   then
652   install -d ${SMAGESCRIPTSDIR}   install -d ${SMAGESCRIPTSDIR}
# Line 558  MD5DIR="$(dirname ${SMAGENAME})/md5" Line 715  MD5DIR="$(dirname ${SMAGENAME})/md5"
715  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
716  echo "Compiling ${PKGNAME}"  echo "Compiling ${PKGNAME}"
717    
718  #download sources  # auto regen mage tree if requested
719    regen_mage_tree
720    
721    # download sources
722  download_sources  download_sources
723    
724  #fixes some issues with these functions  # fixes some issues with these functions
725  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
726  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
727  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
728    
729  #fixes some compile issues  # fixes some compile issues
730  export CHOST="${CHOST}" || die "CHOST export failed"  export CHOST="${CHOST}" || die "CHOST export failed"
731  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
732  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
# Line 574  export BINDIR="${BINDIR}" || die "BINDIR Line 734  export BINDIR="${BINDIR}" || die "BINDIR
734  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
735    
736    
737  #setup distcc  # setup distcc
738  #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
739  if [ "${SMAGE_USE_DISTCC}" == "true" ]  if [ "${SMAGE_USE_DISTCC}" == "true" ]
740  then  then
741   setup_distcc_environment   setup_distcc_environment
742  fi  fi
743    
744  #setup ccache  # setup ccache
745  if [ "${SMAGE_USE_CCACHE}" == "true" ]  if [ "${SMAGE_USE_CCACHE}" == "true" ]
746  then  then
747   setup_ccache_environment   setup_ccache_environment
# Line 602  sleep 1 Line 762  sleep 1
762  #read  #read
763  #debug end  #debug end
764    
765  #cleans up build if a previously one exists  # cleans up build if a previously one exists
766  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
767  then  then
768   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
769  fi  fi
770  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
771    
772  #cleans up srcdir if a previously unpacked one exists  # cleans up srcdir if a previously unpacked one exists
773  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
774  then  then
775   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
776  fi  fi
777    
778  #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
779  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
780  then  then
781   rm -rf ${BINDIR}   rm -rf ${BINDIR}
782  fi  fi
783  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
784    
785  #cleans up package temp dir if a previous build exists  # cleans up package temp dir if a previous build exists
786  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
787  then  then
788   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
789  fi  fi
790    
791  #cleans up timestamp if one exists  # cleans up timestamp if one exists
792  if [ -f /var/tmp/timestamp ]  if [ -f /var/tmp/timestamp ]
793  then  then
794   mage rmstamp   mage rmstamp
# Line 639  src_compile || die "src_compile failed" Line 799  src_compile || die "src_compile failed"
799  src_install || die "src_install failed"  src_install || die "src_install failed"
800    
801    
802  #compressing doc, info & man files  # compressing doc, info & man files
803  echo -e "Compressing man-pages ..."  echo -e "Compressing man-pages ..."
804  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [ -d ${BUILDDIR}/builded/usr/share/man ]
805  then  then
# Line 665  case ${NOSTRIP} in Line 825  case ${NOSTRIP} in
825   ;;   ;;
826  esac  esac
827    
828  #the new buildpkg command  # the new buildpkg command
829  case ${NOPKGBUILD} in  case ${NOPKGBUILD} in
830   true|TRUE|yes|y)   true|TRUE|yes|y)
831   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "NOPGKBUILD=true detected; Package will not be build ..."
832   ;;   ;;
833   *)   *)
834   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   # build serveral targets
835   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   if [ -n "${MAGE_TARGETS}" ]
836     then
837     for target in ${MAGE_TARGETS}
838     do
839     # check if an special target_pkgbuild exists
840     if typeset -f ${target}_pkgbuild > /dev/null
841     then
842     # run it
843     ${target}_pkgbuild
844     fi
845     # now create the target package
846     ${MLIBDIR}/pkgbuild_dir.sh \
847     "${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \
848     ${BINDIR} || die "target: ${target} package-build failed"
849     echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n"
850     done
851     else
852     ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
853     echo -e "\nPackage ${PKGNAME} successfully builded.\n"
854     fi
855   ;;   ;;
856  esac  esac
857    
858  #for sure  # for sure
859  unset NOPKGBUILD  unset NOPKGBUILD
860  unset NOSTRIP  unset NOSTRIP
861    

Legend:
Removed from v.90  
changed lines
  Added in v.192