Magellan Linux

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

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

revision 1346 by niro, Sat Jun 4 09:20:09 2011 UTC revision 1543 by niro, Tue Dec 20 16:06:13 2011 UTC
# Line 71  smagesource() Line 71  smagesource()
71   source ${file}   source ${file}
72    
73   [[ -n ${STATE} ]] && mystate="${STATE}"   [[ -n ${STATE} ]] && mystate="${STATE}"
74    
75     # do not overide if local state was broken or disabled!
76     case ${STATE} in
77     broken) return ;;
78     disabled) return ;;
79     esac
80    
81   if [ -f ${SMAGESCRIPTSDIR}/distribution ]   if [ -f ${SMAGESCRIPTSDIR}/distribution ]
82   then   then
83   source ${SMAGESCRIPTSDIR}/distribution   source ${SMAGESCRIPTSDIR}/distribution
# Line 462  munpack() Line 469  munpack()
469   popd > /dev/null   popd > /dev/null
470   fi   fi
471   ;;   ;;
472     xz)
473     IFTAR="$(basename $SRCFILE .xz)"
474     IFTAR="${IFTAR##*.}"
475     if [[ ${IFTAR} = tar ]]
476     then
477     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
478     else
479     pushd ${DEST} > /dev/null
480     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
481     popd > /dev/null
482     fi
483     ;;
484   tbz2|mpks|mpk)   tbz2|mpks|mpk)
485   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
486   ;;   ;;
487   tgz)   tgz)
488   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
489   ;;   ;;
490     txz|mpkzs|mpkz)
491     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
492     ;;
493   rar)   rar)
494   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
495   ;;   ;;
# Line 521  mpatch() Line 543  mpatch()
543  mlibtoolize()  mlibtoolize()
544  {  {
545   local opts="$@"   local opts="$@"
546   [[ -z ${opts} ]] && opts="--copy --force"   [[ -z ${opts} ]] && opts="--verbose --install --force"
547    
548   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
549  }  }
# Line 561  mstriplibs() Line 583  mstriplibs()
583   local stripdir="$@"   local stripdir="$@"
584    
585   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
586   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_LIB} 2> /dev/null
587  }  }
588    
589  mstripbins()  mstripbins()
# Line 569  mstripbins() Line 591  mstripbins()
591   local stripdir="$@"   local stripdir="$@"
592    
593   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
594   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_DYN_BIN} 2> /dev/null
595    }
596    
597    mstripstatic()
598    {
599     local stripdir="$@"
600    
601     [ -z "${stripdir}" ] && stripdir=${BINDIR}
602     find ${stripdir} | xargs file | grep "ar archive" | cut -f 1 -d : | xargs strip ${STRIP_STATIC_LIB} 2> /dev/null
603  }  }
604    
605  mcompressdocs()  mcompressdocs()
# Line 744  build_mage_script() Line 774  build_mage_script()
774   # now build the mage file   # now build the mage file
775   > ${dest}   > ${dest}
776    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
777   # pgkname and state   # pgkname and state
778   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
779   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
780    
781   # description and homepage   # description and homepage
782   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
783   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
784    
785   # special tags and vars   # special tags and vars
786   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
787    
788   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
789   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
  echo >> ${dest}  
790    
791   # split package base   # split package base
792   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
  echo >> ${dest}  
793    
794   # add special vars   # add special vars
795   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 778  build_mage_script() Line 800  build_mage_script()
800   # being tricky here :)   # being tricky here :)
801   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
802   done   done
  echo  >> ${dest}  
803   fi   fi
804    
805   # add at least all includes   # add at least all includes
# Line 790  build_mage_script() Line 811  build_mage_script()
811   do   do
812   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
813   done   done
814   echo  >> ${dest}   # a CRLF is needed here!
815     echo >> ${dest}
816   fi   fi
  echo >> ${dest}  
817    
818   # deps and provides   # deps and provides
819   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
820   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
821   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
822    
823   # add special functions   # add special functions
824   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 810  build_mage_script() Line 828  build_mage_script()
828   do   do
829   # add to mage (quotes needed !)   # add to mage (quotes needed !)
830   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
831   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
832   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
833   done   done
  echo  >> ${dest}  
834   fi   fi
835    
836   # pre|post-install|removes   # pre|post-install|removes
837   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
838   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
839   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
840   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
841  }  }
842    
843  regen_mage_tree()  regen_mage_tree()
844  {  {
845   local i   local subpackage
846    
847   # build them only if requested   # build them only if requested
848   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
# Line 841  regen_mage_tree() Line 853  regen_mage_tree()
853   # build for each target a mage file   # build for each target a mage file
854   # run it with several targets   # run it with several targets
855   echo   echo
856   for i in ${MAGE_TARGETS}   for subpackage in ${MAGE_TARGETS}
857   do   do
858   build_mage_script --target "${i}"   build_mage_script --target "${subpackage}"
859   done   done
860   echo   echo
861    
# Line 856  regen_mage_tree() Line 868  regen_mage_tree()
868   # build for each subpackage a mage file   # build for each subpackage a mage file
869   # run it with several targets   # run it with several targets
870   echo   echo
871   for i in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
872   do   do
873   # get the right variables for the split   # get the right variables for the split
874   export PNAME="${i}"   export PNAME="${subpackage}"
875   split_info_${i}   split_info_${subpackage}
876     # get the preinstall etc
877     split_export_inherits ${subpackage}
878   build_mage_script --split-pkg-base "${split_pkg_base}"   build_mage_script --split-pkg-base "${split_pkg_base}"
879     # delete split preinstall etc
880     split_delete_inherits ${subpackage}
881   # restore smage environment   # restore smage environment
882   split_restore_variables   split_restore_variables
883   done   done
# Line 1047  split_unset_variables() Line 1063  split_unset_variables()
1063   unset -f SAVED_postremove   unset -f SAVED_postremove
1064  }  }
1065    
1066    split_export_inherits()
1067    {
1068     local subpackage="$1"
1069     local func
1070     local newfunc
1071    
1072     for func in preinstall postinstall preremove postremove
1073     do
1074     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1075     then
1076     newfunc=$(typeset -f ${func}_${subpackage})
1077     newfunc="${newfunc/_${subpackage} (/ (}"
1078     eval "${newfunc}"
1079     fi
1080     done
1081    }
1082    
1083    split_delete_inherits()
1084    {
1085     local subpackage="$1"
1086     local func
1087    
1088     for func in preinstall postinstall preremove postremove
1089     do
1090     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1091     then
1092     unset -f ${func}
1093     fi
1094     done
1095     }
1096    
1097  export_inherits()  export_inherits()
1098  {  {
1099   local include="$1"   local include="$1"
# Line 1556  case ${NOSTRIP} in Line 1603  case ${NOSTRIP} in
1603   do   do
1604   echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1605   mstripbins ${BINDIR}_${subpackage}   mstripbins ${BINDIR}_${subpackage}
1606   echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1607   mstriplibs ${BINDIR}_${subpackage}   mstriplibs ${BINDIR}_${subpackage}
1608     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1609     mstripstatic ${BINDIR}_${subpackage}
1610   done   done
1611   else   else
1612   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1613   mstripbins ${BINDIR}   mstripbins ${BINDIR}
1614   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1615   mstriplibs ${BINDIR}   mstriplibs ${BINDIR}
1616     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1617     mstripstatic ${BINDIR}
1618   fi   fi
1619   ;;   ;;
1620  esac  esac

Legend:
Removed from v.1346  
changed lines
  Added in v.1543