Magellan Linux

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

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

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

Legend:
Removed from v.186  
changed lines
  Added in v.200