Magellan Linux

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

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

revision 192 by niro, Fri Aug 19 03:43:56 2005 UTC revision 196 by niro, Sat Aug 20 15:55:19 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.23 2005-08-19 03:43:56 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.27 2005-08-20 15:55:19 niro Exp $
8    
9  #01.10.2004  #01.10.2004
10  # added ccache support  # added ccache support
# Line 406  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()  # build_mage_script(): helper functions for regen_mage_tree()
459  # generates an mage file with given information in smage file  # generates an mage file with given information in smage file
460  # needs at least:  # needs at least:
# Line 428  setup_ccache_environment(){ Line 477  setup_ccache_environment(){
477  #  #
478  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
479  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
480    #
481    # gets called with build_mage_script target
482  build_mage_script()  build_mage_script()
483  {  {
484   local magefile   local magefile
485   local dest   local dest
486   local suffix   local target
487   local sym   local sym
488   local depname   local depname
489    
# Line 440  build_mage_script() Line 491  build_mage_script()
491   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
492    
493   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
494   suffix="$1"   [ -n "$1" ] && target="-$1"
495    
496   # name of magefile   # name of magefile
497   magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
498    
499   # destination to magefile   # destination to magefile
500   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
501    
502   # show what we are doing   # show what we are doing
503   echo "Generating Mage file:"   echo "Generating Mage file:"
# Line 457  build_mage_script() Line 508  build_mage_script()
508   > ${dest}   > ${dest}
509    
510   # header   # header
511   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}   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.27 2005-08-20 15:55:19 niro Exp $' >> ${dest}
512   echo  >> ${dest}   echo  >> ${dest}
513    
514   # pgkname and state   # pgkname and state
515   echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
516   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
517   echo >> ${dest}   echo >> ${dest}
518    
# Line 470  build_mage_script() Line 521  build_mage_script()
521   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
522   echo >> ${dest}   echo >> ${dest}
523    
524   # special tags   # special tags and vars
525   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
526   if [ -n "${INHERITS}" ]   if [ -n "${INHERITS}" ]
527   then   then
# Line 484  build_mage_script() Line 535  build_mage_script()
535   fi   fi
536   echo >> ${dest}   echo >> ${dest}
537    
538     # add special vars
539     if [ -n "${SPECIAL_VARS}" ]
540     then
541     local i
542     for i in ${SPECIAL_VARS}
543     do
544     # being tricky here :)
545     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
546     done
547     echo  >> ${dest}
548     fi
549    
550   # deps and provides   # deps and provides
551   echo "DEPEND=\"${DEPEND}\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
552   echo "SDEPEND=\"${SDEPEND}\"" >> ${dest}   echo >> ${dest}
553     echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
554     echo >> ${dest}
555   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
556   echo >> ${dest}   echo >> ${dest}
557    
# Line 501  build_mage_script() Line 566  build_mage_script()
566   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
567   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
568   done   done
569     echo  >> ${dest}
570   fi   fi
571    
572   # pre|post-install|removes   # pre|post-install|removes
# Line 521  regen_mage_tree() Line 587  regen_mage_tree()
587   # build them only if requested   # build them only if requested
588   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
589   then   then
590   # build for each target an mage file   # run it without targets
591   for i in ${MAGE_TARGETS}   if [ -z "${MAGE_TARGETS}" ]
592   do   then
593   echo   echo
594   build_mage_script "${i}"   build_mage_script
595   echo   echo
596   done   else
597    
598     # build for each target an mage file
599     # run it with several targets
600     for i in ${MAGE_TARGETS}
601     do
602     echo
603     build_mage_script "${i}"
604     echo
605     done
606     fi
607   fi   fi
608    
609   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
# Line 538  regen_mage_tree() Line 614  regen_mage_tree()
614   unset "${i}"   unset "${i}"
615   done   done
616   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
617     for i in ${SPECIAL_VARS}
618     do
619     unset "${i}"
620     done
621     unset SPECIAL_VARS
622   unset STATE   unset STATE
623   unset DESCRIPTION   unset DESCRIPTION
624   unset HOMEPAGE   unset HOMEPAGE

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