Magellan Linux

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

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

revision 89 by niro, Tue Jun 28 20:34:48 2005 UTC revision 195 by niro, Sat Aug 20 15:51:14 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.12 2005-06-28 20:34:48 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.26 2005-08-20 15:51:14 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-r16  
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    
410    # fixes given dependencies to match a MAGE_TARGET
411    # fix_mage_deps target s/depend
412    fix_mage_deps() {
413     local target="$1"
414     local depend="$2"
415     local NDEPEND
416     local sym dep cat pver pname
417    
418     # deps and provides are special
419     # they must be fixed to match the target
420    
421     # run this only if target and depend is not empty
422     if [ -n "${target}" ] && [ -n "${depend}" ]
423     then
424     # fix DEPEND
425     while read sym dep
426     do
427     cat="$(dirname ${dep})"
428     # abort on virtual
429     [[ ${cat} = virtual ]] && continue
430    
431     # fix pver to target-pver
432     # to get pname-target-pver
433    
434     # doing it backwards !
435     pver="${dep##*-}"
436     pname=$(basename ${dep/-${pver}/})
437    
438     # do not add empty lines
439     if [ -z "${NDEPEND}" ]
440     then
441     NDEPEND="${sym} ${cat}/${pname}-${target}-${pver}"
442     else
443     NDEPEND="${NDEPEND}
444     ${sym} ${cat}/${pname}-${target}-${pver}"
445     fi
446    
447     unset cat pname pver
448     done << EOF
449    ${depend}
450    EOF
451     # set NDEPEND to DEPEND
452     depend="${NDEPEND}"
453     fi
454    
455     echo "${depend}"
456    }
457    
458    # build_mage_script(): helper functions for regen_mage_tree()
459    # generates an mage file with given information in smage file
460    # needs at least:
461    #   PNAME                 name of pkg
462    #   PVER                  version
463    #   PBUILD                revision
464    #   PCATEGORIE            categorie of the pkg
465    #   STATE                 state of pkg stable|unstable|old
466    #   DESCRIPTION           va short description (opt)
467    #   HOMEPAGE              homepage (opt)
468    #   DEPEND                runtime dependencies (opt)
469    #   SDEPEND               add. needed deps to build the pkg (opt)
470    #   PROVIDE               provides a virtual (opt)
471    #
472    # special tags:
473    #   PKGTYPE               type of pkg
474    #   INHERITS              which functions get included
475    #   SPECIAL_FUNCTIONS     special functions wich should also be added
476    #                         warning: they get killed before the build starts !
477    #
478    #   MAGE_TREE_DEST        target destination of the generated tree
479    #   REGEN_MAGE_TREE       set to 'true' to enable this
480    #
481    # gets called with build_mage_script target
482    build_mage_script()
483    {
484     local magefile
485     local dest
486     local target
487     local sym
488     local depname
489    
490     # if MAGE_TREE_DEST not set use BUILDDIR
491     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
492    
493     # determinate which suffix this mage file should get, if any
494     [ -n "$1" ] && target="-$1"
495    
496     # name of magefile
497     magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
498    
499     # destination to magefile
500     dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
501    
502     # show what we are doing
503     echo "Generating Mage file:"
504     echo "  ${dest}"
505    
506     install -d "$(dirname ${dest})"
507     # now build the mage file
508     > ${dest}
509    
510     # header
511     echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.26 2005-08-20 15:51:14 niro Exp $' >> ${dest}
512     echo  >> ${dest}
513    
514     # pgkname and state
515     echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
516     echo "STATE=\"${STATE}\"" >> ${dest}
517     echo >> ${dest}
518    
519     # description and homepage
520     echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
521     echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
522     echo >> ${dest}
523    
524     # special tags
525     echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
526     if [ -n "${INHERITS}" ]
527     then
528     echo -n "minclude"  >> ${dest}
529     local i
530     for i in ${INHERITS}
531     do
532     echo -n " ${i}"  >> ${dest}
533     done
534     echo  >> ${dest}
535     fi
536     echo >> ${dest}
537    
538     # deps and provides
539     echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
540     echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
541     echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
542     echo >> ${dest}
543    
544     # add special functions
545     if [ -n "${SPECIAL_FUNCTIONS}" ]
546     then
547     local i
548     for i in ${SPECIAL_FUNCTIONS}
549     do
550     # add to mage (quotes needed !)
551     typeset -f "${i}" >> ${dest}
552     # unset to be safe (quotes needed !)
553     #unset "${i}" <-- later to get every target built
554     done
555     fi
556    
557     # add special vars
558     if [ -n "${SPECIAL_VARS}" ]
559     then
560     local i
561     for i in ${SPECIAL_VARS}
562     do
563     # being tricky here :)
564     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
565     done
566     fi
567    
568     # pre|post-install|removes
569     typeset -f preinstall >> ${dest}
570     echo  >> ${dest}
571     typeset -f postinstall >> ${dest}
572     echo  >> ${dest}
573     typeset -f preremove >> ${dest}
574     echo  >> ${dest}
575     typeset -f postremove >> ${dest}
576     echo  >> ${dest}
577    }
578    
579    regen_mage_tree()
580    {
581     local i
582    
583     # build them only if requested
584     if [[ ${REGEN_MAGE_TREE} = true ]]
585     then
586     # run it without targets
587     if [ -z "${MAGE_TARGETS}" ]
588     then
589     echo
590     build_mage_script
591     echo
592     else
593    
594     # build for each target an mage file
595     # run it with several targets
596     for i in ${MAGE_TARGETS}
597     do
598     echo
599     build_mage_script "${i}"
600     echo
601     done
602     fi
603     fi
604    
605     # now unset all uneeded vars to be safe
606     # unset PKGNAME <-- don't do that; smage needs this var
607     # unset to be safe (quotes needed !)
608     for i in ${SPECIAL_FUNCTIONS}
609     do
610     unset "${i}"
611     done
612     unset SPECIAL_FUNCTIONS
613     for i in ${SPECIAL_VARS}
614     do
615     unset "${i}"
616     done
617     unset SPECIAL_VARS
618     unset STATE
619     unset DESCRIPTION
620     unset HOMEPAGE
621     unset PKGTYPE
622     unset INHERITS
623     unset DEPEND
624     unset SDEPEND
625     unset PROVIDE
626     unset preinstall
627     unset postinstall
628     unset preremove
629     unset postremove
630    }
631    
632  # print out our version  # print out our version
633  showversion  showversion
634  echo  echo
# Line 405  then Line 640  then
640   exit 1   exit 1
641  fi  fi
642    
643  #updating smage2-scripts  # updating smage2-scripts
644  if [ "$1" == "update" ]  if [ "$1" == "update" ]
645  then  then
646   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
# Line 416  then Line 651  then
651   exit 0   exit 0
652  fi  fi
653    
654  #creates md5sums for smages to given dir  # creates md5sums for smages to given dir
655  if [ "$1" == "calcmd5" ]  if [ "$1" == "calcmd5" ]
656  then  then
657   if [ $# -ge 3 ]   if [ $# -ge 3 ]
# Line 486  then Line 721  then
721   exit 0   exit 0
722  fi  fi
723    
724  #download sources  # download sources
725  if [ "$1" == "download" -a -n "$2" ]  if [ "$1" == "download" -a -n "$2" ]
726  then  then
  showversion  
727   if [ ! -d ${SMAGESCRIPTSDIR} ]   if [ ! -d ${SMAGESCRIPTSDIR} ]
728   then   then
729   install -d ${SMAGESCRIPTSDIR}   install -d ${SMAGESCRIPTSDIR}
# Line 558  MD5DIR="$(dirname ${SMAGENAME})/md5" Line 792  MD5DIR="$(dirname ${SMAGENAME})/md5"
792  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
793  echo "Compiling ${PKGNAME}"  echo "Compiling ${PKGNAME}"
794    
795  #download sources  # auto regen mage tree if requested
796    regen_mage_tree
797    
798    # download sources
799  download_sources  download_sources
800    
801  #fixes some issues with these functions  # fixes some issues with these functions
802  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
803  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
804  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
805    
806  #fixes some compile issues  # fixes some compile issues
807  export CHOST="${CHOST}" || die "CHOST export failed"  export CHOST="${CHOST}" || die "CHOST export failed"
808  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
809  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
# Line 574  export BINDIR="${BINDIR}" || die "BINDIR Line 811  export BINDIR="${BINDIR}" || die "BINDIR
811  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
812    
813    
814  #setup distcc  # setup distcc
815  #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
816  if [ "${SMAGE_USE_DISTCC}" == "true" ]  if [ "${SMAGE_USE_DISTCC}" == "true" ]
817  then  then
818   setup_distcc_environment   setup_distcc_environment
819  fi  fi
820    
821  #setup ccache  # setup ccache
822  if [ "${SMAGE_USE_CCACHE}" == "true" ]  if [ "${SMAGE_USE_CCACHE}" == "true" ]
823  then  then
824   setup_ccache_environment   setup_ccache_environment
# Line 602  sleep 1 Line 839  sleep 1
839  #read  #read
840  #debug end  #debug end
841    
842  #cleans up build if a previously one exists  # cleans up build if a previously one exists
843  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
844  then  then
845   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
846  fi  fi
847  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
848    
849  #cleans up srcdir if a previously unpacked one exists  # cleans up srcdir if a previously unpacked one exists
850  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
851  then  then
852   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
853  fi  fi
854    
855  #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
856  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
857  then  then
858   rm -rf ${BINDIR}   rm -rf ${BINDIR}
859  fi  fi
860  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
861    
862  #cleans up package temp dir if a previous build exists  # cleans up package temp dir if a previous build exists
863  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
864  then  then
865   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
866  fi  fi
867    
868  #cleans up timestamp if one exists  # cleans up timestamp if one exists
869  if [ -f /var/tmp/timestamp ]  if [ -f /var/tmp/timestamp ]
870  then  then
871   mage rmstamp   mage rmstamp
# Line 639  src_compile || die "src_compile failed" Line 876  src_compile || die "src_compile failed"
876  src_install || die "src_install failed"  src_install || die "src_install failed"
877    
878    
879  #compressing doc, info & man files  # compressing doc, info & man files
880  echo -e "Compressing man-pages ..."  echo -e "Compressing man-pages ..."
881  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [ -d ${BUILDDIR}/builded/usr/share/man ]
882  then  then
# Line 665  case ${NOSTRIP} in Line 902  case ${NOSTRIP} in
902   ;;   ;;
903  esac  esac
904    
905  #the new buildpkg command  # the new buildpkg command
906  case ${NOPKGBUILD} in  case ${NOPKGBUILD} in
907   true|TRUE|yes|y)   true|TRUE|yes|y)
908   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "NOPGKBUILD=true detected; Package will not be build ..."
909   ;;   ;;
910   *)   *)
911   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   # build serveral targets
912   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   if [ -n "${MAGE_TARGETS}" ]
913     then
914     for target in ${MAGE_TARGETS}
915     do
916     # check if an special target_pkgbuild exists
917     if typeset -f ${target}_pkgbuild > /dev/null
918     then
919     # run it
920     ${target}_pkgbuild
921     fi
922     # now create the target package
923     ${MLIBDIR}/pkgbuild_dir.sh \
924     "${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \
925     ${BINDIR} || die "target: ${target} package-build failed"
926     echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n"
927     done
928     else
929     ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
930     echo -e "\nPackage ${PKGNAME} successfully builded.\n"
931     fi
932   ;;   ;;
933  esac  esac
934    
935  #for sure  # for sure
936  unset NOPKGBUILD  unset NOPKGBUILD
937  unset NOSTRIP  unset NOSTRIP
938    

Legend:
Removed from v.89  
changed lines
  Added in v.195