Magellan Linux

Diff of /branches/mage-0_3_7-r6/mage/usr/lib/mage/smage2.sh

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

trunk/mage/usr/lib/mage/smage2.sh revision 191 by niro, Fri Aug 19 02:24:12 2005 UTC branches/mage-0_3_7-r6/mage/usr/lib/mage/smage2.sh revision 398 by niro, Mon Nov 20 12:48:17 2006 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.22 2005-08-19 02:24:12 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.36.2.1 2006-11-20 12:48:17 niro Exp $
8    
9  #01.10.2004  #01.10.2004
10  # added ccache support  # added ccache support
# Line 24  SMAGEVERSION="$( < ${MLIBDIR}/version)" Line 24  SMAGEVERSION="$( < ${MLIBDIR}/version)"
24  export LC_ALL=C  export LC_ALL=C
25    
26  source /etc/mage.rc  source /etc/mage.rc
27    source ${MLIBDIR}/mage3.functions.sh
28    
29  showversion() {  showversion() {
30   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
# Line 230  src_install() { Line 231  src_install() {
231   return 0   return 0
232  }  }
233    
   
 build_mage_script() {  
  return 0  
 }  
   
234  mconfigure() {  mconfigure() {
235   if [ -x ./configure ]   if [ -x ./configure ]
236   then   then
# Line 411  setup_ccache_environment(){ Line 407  setup_ccache_environment(){
407   fi   fi
408  }  }
409    
410  # alx_create_mage_file: helper functions for regen_mage_tree()  
411    # fixes given dependencies to match a MAGE_TARGET
412    # fix_mage_deps -target s/depend # <-- note -target !
413    fix_mage_deps() {
414     local target="$1"
415     local depend="$2"
416     local NDEPEND
417     local sym dep cat pver pname
418    
419     # deps and provides are special
420     # they must be fixed to match the target
421    
422     # run this only if target and depend is not empty
423     if [ -n "${target}" ] && [ -n "${depend}" ]
424     then
425     # fix DEPEND
426     while read sym dep
427     do
428     cat="$(dirname ${dep})"
429     # change if not virtual
430     if [[ ${cat} = virtual ]]
431     then
432     pname="$(basename ${dep})"
433     else
434     # fix pver to target-pver
435     # to get pname-target-pver
436    
437     # doing it backwards !
438     pver="${dep##*-}"
439     # full pver
440     pname="$(basename ${dep/-${pver}/})${target}-${pver}"
441     fi
442    
443     # do not add empty lines
444     if [ -z "${NDEPEND}" ]
445     then
446     NDEPEND="${sym} ${cat}/${pname}"
447     else
448     NDEPEND="${NDEPEND}
449     ${sym} ${cat}/${pname}"
450     fi
451    
452     unset cat pname pver
453     done << EOF
454    ${depend}
455    EOF
456     # set NDEPEND to DEPEND
457     depend="${NDEPEND}"
458     fi
459    
460     echo "${depend}"
461    }
462    
463    # build_mage_script(): helper functions for regen_mage_tree()
464  # generates an mage file with given information in smage file  # generates an mage file with given information in smage file
465  # needs at least:  # needs at least:
466  #   PNAME                 name of pkg  #   PNAME                 name of pkg
# Line 433  setup_ccache_environment(){ Line 482  setup_ccache_environment(){
482  #  #
483  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
484  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
485  alx_create_mage_file()  #
486    # gets called with build_mage_script target
487    build_mage_script()
488  {  {
489   local magefile   local magefile
490   local dest   local dest
491   local suffix   local target
492   local sym   local sym
493   local depname   local depname
494    
# Line 445  alx_create_mage_file() Line 496  alx_create_mage_file()
496   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
497    
498   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
499   suffix="$1"   [ -n "$1" ] && target="-$1"
500    
501   # name of magefile   # name of magefile
502   magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
503    
504   # destination to magefile   # destination to magefile
505   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
506    
507   # show what we are doing   # show what we are doing
508   echo "Generating Mage file:"   echo "Generating Mage file:"
# Line 462  alx_create_mage_file() Line 513  alx_create_mage_file()
513   > ${dest}   > ${dest}
514    
515   # header   # header
516   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.22 2005-08-19 02:24:12 niro Exp $' >> ${dest}   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.36.2.1 2006-11-20 12:48:17 niro Exp $' >> ${dest}
517   echo  >> ${dest}   echo  >> ${dest}
518    
519   # pgkname and state   # pgkname and state
520   echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
521   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
522   echo >> ${dest}   echo >> ${dest}
523    
# Line 475  alx_create_mage_file() Line 526  alx_create_mage_file()
526   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
527   echo >> ${dest}   echo >> ${dest}
528    
529   # special tags   # special tags and vars
530   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
531    
532     # echo MAGE_TARGETS ## note -target is needed !
533     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
534     echo >> ${dest}
535    
536     # add special vars
537     if [ -n "${SPECIAL_VARS}" ]
538     then
539     local i
540     for i in ${SPECIAL_VARS}
541     do
542     # being tricky here :)
543     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
544     done
545     echo  >> ${dest}
546     fi
547    
548     # add at least all includes
549   if [ -n "${INHERITS}" ]   if [ -n "${INHERITS}" ]
550   then   then
551   echo -n "minclude"  >> ${dest}   echo -n "minclude"  >> ${dest}
# Line 490  alx_create_mage_file() Line 559  alx_create_mage_file()
559   echo >> ${dest}   echo >> ${dest}
560    
561   # deps and provides   # deps and provides
562   echo "DEPEND=\"${DEPEND}\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
563   echo "SDEPEND=\"${SDEPEND}\"" >> ${dest}   echo >> ${dest}
564     echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
565     echo >> ${dest}
566   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
567   echo >> ${dest}   echo >> ${dest}
568    
# Line 503  alx_create_mage_file() Line 574  alx_create_mage_file()
574   do   do
575   # add to mage (quotes needed !)   # add to mage (quotes needed !)
576   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
577     echo >> ${dest}
578   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
579   unset "${i}"   #unset "${i}" <-- later to get every target built
580   done   done
581     echo  >> ${dest}
582   fi   fi
583    
584   # pre|post-install|removes   # pre|post-install|removes
# Line 526  regen_mage_tree() Line 599  regen_mage_tree()
599   # build them only if requested   # build them only if requested
600   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
601   then   then
602   # build for each target an mage file   # run it without targets
603   for i in ${MAGE_TARGETS}   if [ -z "${MAGE_TARGETS}" ]
604   do   then
605   echo   echo
606   alx_create_mage_file "${i}"   build_mage_script
607   echo   echo
608   done   else
609    
610     # build for each target an mage file
611     # run it with several targets
612     for i in ${MAGE_TARGETS}
613     do
614     echo
615     build_mage_script "${i}"
616     echo
617     done
618     fi
619   fi   fi
620    
621   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
622   unset PKGNAME   # unset PKGNAME <-- don't do that; smage needs this var
623     # unset to be safe (quotes needed !)
624     for i in ${SPECIAL_FUNCTIONS}
625     do
626     unset "${i}"
627     done
628     unset SPECIAL_FUNCTIONS
629     for i in ${SPECIAL_VARS}
630     do
631     unset "${i}"
632     done
633     unset SPECIAL_VARS
634   unset STATE   unset STATE
635   unset DESCRIPTION   unset DESCRIPTION
636   unset HOMEPAGE   unset HOMEPAGE
# Line 545  regen_mage_tree() Line 639  regen_mage_tree()
639   unset DEPEND   unset DEPEND
640   unset SDEPEND   unset SDEPEND
641   unset PROVIDE   unset PROVIDE
  unset SPECIAL_FUNCTIONS  
642   unset preinstall   unset preinstall
643   unset postinstall   unset postinstall
644   unset preremove   unset preremove
# Line 563  then Line 656  then
656   exit 1   exit 1
657  fi  fi
658    
659  #updating smage2-scripts  # updating smage2-scripts
660  if [ "$1" == "update" ]  if [ "$1" == "update" ]
661  then  then
662   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
# Line 574  then Line 667  then
667   exit 0   exit 0
668  fi  fi
669    
670  #creates md5sums for smages to given dir  # creates md5sums for smages to given dir
671  if [ "$1" == "calcmd5" ]  if [ "$1" == "calcmd5" ]
672  then  then
673   if [ $# -ge 3 ]   if [ $# -ge 3 ]
# Line 644  then Line 737  then
737   exit 0   exit 0
738  fi  fi
739    
740  #download sources  # download sources
741  if [ "$1" == "download" -a -n "$2" ]  if [ "$1" == "download" -a -n "$2" ]
742  then  then
743   if [ ! -d ${SMAGESCRIPTSDIR} ]   if [ ! -d ${SMAGESCRIPTSDIR} ]
# Line 661  then Line 754  then
754   exit 0   exit 0
755  fi  fi
756    
757    # regen-mage-tree
758    if [ "$1" == "only-regen-tree" -a -n "$2" ]
759    then
760     # set correct SMAGENAME
761     SMAGENAME="$2"
762     MD5DIR="$(dirname ${SMAGENAME})/md5"
763     source ${SMAGENAME} || die "regen: smage2 not found"
764    
765     regen_mage_tree
766     exit 0
767    fi
768    
769  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]
770  then  then
771   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
# Line 718  echo "Compiling ${PKGNAME}" Line 823  echo "Compiling ${PKGNAME}"
823  # auto regen mage tree if requested  # auto regen mage tree if requested
824  regen_mage_tree  regen_mage_tree
825    
826  #download sources  # download sources
827  download_sources  download_sources
828    
829  #fixes some issues with these functions  # fixes some issues with these functions
830  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
831  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
832  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
833    
834  #fixes some compile issues  # fixes some compile issues
835  export CHOST="${CHOST}" || die "CHOST export failed"  export CHOST="${CHOST}" || die "CHOST export failed"
836  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
837  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
# Line 734  export BINDIR="${BINDIR}" || die "BINDIR Line 839  export BINDIR="${BINDIR}" || die "BINDIR
839  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
840    
841    
842  #setup distcc  # setup distcc
843  #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
844  if [ "${SMAGE_USE_DISTCC}" == "true" ]  if [ "${SMAGE_USE_DISTCC}" == "true" ]
845  then  then
846   setup_distcc_environment   setup_distcc_environment
847  fi  fi
848    
849  #setup ccache  # setup ccache
850  if [ "${SMAGE_USE_CCACHE}" == "true" ]  if [ "${SMAGE_USE_CCACHE}" == "true" ]
851  then  then
852   setup_ccache_environment   setup_ccache_environment
# Line 762  sleep 1 Line 867  sleep 1
867  #read  #read
868  #debug end  #debug end
869    
870  #cleans up build if a previously one exists  # cleans up build if a previously one exists
871  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
872  then  then
873   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
874  fi  fi
875  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
876    
877  #cleans up srcdir if a previously unpacked one exists  # cleans up srcdir if a previously unpacked one exists
878  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
879  then  then
880   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
881  fi  fi
882    
883  #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
884  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
885  then  then
886   rm -rf ${BINDIR}   rm -rf ${BINDIR}
887  fi  fi
888  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
889    
890  #cleans up package temp dir if a previous build exists  # cleans up package temp dir if a previous build exists
891  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
892  then  then
893   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
894  fi  fi
895    
896  #cleans up timestamp if one exists  # cleans up timestamp if one exists
897  if [ -f /var/tmp/timestamp ]  if [ -f /var/tmp/timestamp ]
898  then  then
899   mage rmstamp   mage rmstamp
# Line 799  src_compile || die "src_compile failed" Line 904  src_compile || die "src_compile failed"
904  src_install || die "src_install failed"  src_install || die "src_install failed"
905    
906    
907  #compressing doc, info & man files  # compressing doc, info & man files
908  echo -e "Compressing man-pages ..."  echo -e "Compressing man-pages ..."
909  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [ -d ${BUILDDIR}/builded/usr/share/man ]
910  then  then
# Line 825  case ${NOSTRIP} in Line 930  case ${NOSTRIP} in
930   ;;   ;;
931  esac  esac
932    
933  #the new buildpkg command  # the new buildpkg command
934  case ${NOPKGBUILD} in  case ${NOPKGBUILD} in
935   true|TRUE|yes|y)   true|TRUE|yes|y)
936   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "NOPGKBUILD=true detected; Package will not be build ..."
937   ;;   ;;
938   *)   *)
939   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   # build serveral targets
940   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   if [ -n "${MAGE_TARGETS}" ]
941     then
942     for target in ${MAGE_TARGETS}
943     do
944     # check if an special target_pkgbuild exists
945     if typeset -f ${target}_pkgbuild > /dev/null
946     then
947     # run it
948     ${target}_pkgbuild
949     fi
950     # now create the target package
951     ${MLIBDIR}/pkgbuild_dir.sh \
952     "${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \
953     ${BINDIR} || die "target: ${target} package-build failed"
954     echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n"
955     done
956     else
957     ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
958     echo -e "\nPackage ${PKGNAME} successfully builded.\n"
959     fi
960   ;;   ;;
961  esac  esac
962    
963  #for sure  # for sure
964  unset NOPKGBUILD  unset NOPKGBUILD
965  unset NOSTRIP  unset NOSTRIP
966    

Legend:
Removed from v.191  
changed lines
  Added in v.398