Magellan Linux

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

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

revision 193 by niro, Fri Aug 19 14:14:59 2005 UTC revision 253 by niro, Sun Oct 2 14:23:11 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.24 2005-08-19 14:14:59 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.37 2005-10-02 14:23:11 niro Exp $
8    
9  #01.10.2004  #01.10.2004
10  # added ccache support  # added ccache support
# Line 408  setup_ccache_environment(){ Line 408  setup_ccache_environment(){
408    
409    
410  # fixes given dependencies to match a MAGE_TARGET  # fixes given dependencies to match a MAGE_TARGET
411  # fix_mage_deps -target s/depend # <-- '-' is essential ! (build_mage_script needs this)  # fix_mage_deps -target s/depend # <-- note -target !
412  fix_mage_deps() {  fix_mage_deps() {
413   local target="$1"   local target="$1"
414   local depend="$2"   local depend="$2"
# Line 425  fix_mage_deps() { Line 425  fix_mage_deps() {
425   while read sym dep   while read sym dep
426   do   do
427   cat="$(dirname ${dep})"   cat="$(dirname ${dep})"
428   # abort on virtual   # change if not virtual
429   [[ ${cat} = virtual ]] && continue   if [[ ${cat} = virtual ]]
430     then
431   # fix pver to target-pver   pname="$(basename ${dep})"
432   # to get pname-target-pver   else
433     # fix pver to target-pver
434     # to get pname-target-pver
435    
436   # doing it backwards !   # doing it backwards !
437   pver="${dep##*-}"   pver="${dep##*-}"
438   pname=$(basename ${dep/-${pver}/})   # full pver
439     pname="$(basename ${dep/-${pver}/})${target}-${pver}"
440     fi
441    
442   # do not add empty lines   # do not add empty lines
443   if [ -z "${NDEPEND}" ]   if [ -z "${NDEPEND}" ]
444   then   then
445   NDEPEND="${sym} ${cat}/${pname}${target}-${pver}"   NDEPEND="${sym} ${cat}/${pname}"
446   else   else
447   NDEPEND="${NDEPEND}   NDEPEND="${NDEPEND}
448   ${sym} ${cat}/${pname}${target}-${pver}"   ${sym} ${cat}/${pname}"
449   fi   fi
450    
451   unset cat pname pver   unset cat pname pver
# Line 478  EOF Line 482  EOF
482  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
483  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
484  #  #
485  # gets called with build_mage_script target # <-- '-' is essential !  # gets called with build_mage_script target
486  build_mage_script()  build_mage_script()
487  {  {
488   local magefile   local magefile
# Line 491  build_mage_script() Line 495  build_mage_script()
495   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
496    
497   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
498   target="$1"   [ -n "$1" ] && target="-$1"
499    
500   # name of magefile   # name of magefile
501   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 508  build_mage_script() Line 512  build_mage_script()
512   > ${dest}   > ${dest}
513    
514   # header   # header
515   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.24 2005-08-19 14:14:59 niro Exp $' >> ${dest}   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.37 2005-10-02 14:23:11 niro Exp $' >> ${dest}
516   echo  >> ${dest}   echo  >> ${dest}
517    
518   # pgkname and state   # pgkname and state
# Line 521  build_mage_script() Line 525  build_mage_script()
525   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
526   echo >> ${dest}   echo >> ${dest}
527    
528   # special tags   # special tags and vars
529   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
530    
531     # echo MAGE_TARGETS ## note -target is needed !
532     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
533     echo >> ${dest}
534    
535     # add special vars
536     if [ -n "${SPECIAL_VARS}" ]
537     then
538     local i
539     for i in ${SPECIAL_VARS}
540     do
541     # being tricky here :)
542     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
543     done
544     echo  >> ${dest}
545     fi
546    
547     # add at least all includes
548   if [ -n "${INHERITS}" ]   if [ -n "${INHERITS}" ]
549   then   then
550   echo -n "minclude"  >> ${dest}   echo -n "minclude"  >> ${dest}
# Line 537  build_mage_script() Line 559  build_mage_script()
559    
560   # deps and provides   # deps and provides
561   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
562     echo >> ${dest}
563   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
564     echo >> ${dest}
565   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
566   echo >> ${dest}   echo >> ${dest}
567    
# Line 549  build_mage_script() Line 573  build_mage_script()
573   do   do
574   # add to mage (quotes needed !)   # add to mage (quotes needed !)
575   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
576     echo >> ${dest}
577   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
578   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
579   done   done
580     echo  >> ${dest}
581   fi   fi
582    
583   # pre|post-install|removes   # pre|post-install|removes
# Line 572  regen_mage_tree() Line 598  regen_mage_tree()
598   # build them only if requested   # build them only if requested
599   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
600   then   then
601   # build for each target an mage file   # run it without targets
602   for i in ${MAGE_TARGETS}   if [ -z "${MAGE_TARGETS}" ]
603   do   then
604   echo   echo
605   build_mage_script "-${i}"   build_mage_script
606   echo   echo
607   done   else
608    
609     # build for each target an mage file
610     # run it with several targets
611     for i in ${MAGE_TARGETS}
612     do
613     echo
614     build_mage_script "${i}"
615     echo
616     done
617     fi
618   fi   fi
619    
620   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
# Line 589  regen_mage_tree() Line 625  regen_mage_tree()
625   unset "${i}"   unset "${i}"
626   done   done
627   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
628     for i in ${SPECIAL_VARS}
629     do
630     unset "${i}"
631     done
632     unset SPECIAL_VARS
633   unset STATE   unset STATE
634   unset DESCRIPTION   unset DESCRIPTION
635   unset HOMEPAGE   unset HOMEPAGE
# Line 603  regen_mage_tree() Line 644  regen_mage_tree()
644   unset postremove   unset postremove
645  }  }
646    
647    export_inherits()
648    {
649     local include="$1"
650     shift
651    
652     while [ "$1" ]
653     do
654     local functions="$1"
655    
656     # sanity checks
657     [ -z "${include}" ] && die "export_inherits(): \$include not given."
658     [ -z "${functions}" ] && die "export_inherits(): \$functions not given."
659    
660     eval "${functions}() { ${include}_${functions} ; }"
661    
662     # debug
663     [[ ${MAGEDEBUG} = on ]] && typeset -f "${functions}"
664    
665     shift
666     done
667    }
668    
669  # print out our version  # print out our version
670  showversion  showversion
671  echo  echo
# Line 712  then Line 775  then
775   exit 0   exit 0
776  fi  fi
777    
778    # regen-mage-tree
779    if [ "$1" == "only-regen-tree" -a -n "$2" ]
780    then
781     # set correct SMAGENAME
782     SMAGENAME="$2"
783     MD5DIR="$(dirname ${SMAGENAME})/md5"
784     source ${SMAGENAME} || die "regen: smage2 not found"
785    
786     regen_mage_tree
787     exit 0
788    fi
789    
790  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]
791  then  then
792   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."

Legend:
Removed from v.193  
changed lines
  Added in v.253