Magellan Linux

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

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

revision 1273 by niro, Wed Apr 27 09:45:07 2011 UTC revision 1436 by niro, Mon Jul 25 11:59:49 2011 UTC
# Line 60  then Line 60  then
60   export BINDIR=${MROOT}/${BINDIR}   export BINDIR=${MROOT}/${BINDIR}
61  fi  fi
62    
63    # sources the smage file and uses state from distribution file if exist
64    # may helpful for repository support later on
65    smagesource()
66    {
67     local file="$1"
68     local mystate
69     local mycodename
70    
71     source ${file}
72    
73     [[ -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 ]
82     then
83     source ${SMAGESCRIPTSDIR}/distribution
84     [[ -n ${STATE} ]] && mystate="${STATE}"
85     fi
86     # now switch state and export it
87     STATE="${mystate}"
88    }
89    
90  showversion()  showversion()
91  {  {
92   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
# Line 442  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 501  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  }  }
550    
551    mautoreconf()
552    {
553     local opts="$@"
554     [[ -z ${opts} ]] && opts="--verbose --install --force"
555    
556     autoreconf ${opts} || die "running: mautoreconf ${opts}"
557    }
558    
559  minstalldocs()  minstalldocs()
560  {  {
561   local docfiles   local docfiles
# Line 716  build_mage_script() Line 766  build_mage_script()
766   # now build the mage file   # now build the mage file
767   > ${dest}   > ${dest}
768    
  # 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}  
   
769   # pgkname and state   # pgkname and state
770   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
771   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
772    
773   # description and homepage   # description and homepage
774   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
775   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
776    
777   # special tags and vars   # special tags and vars
778   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
779    
780   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
781   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
  echo >> ${dest}  
782    
783   # split package base   # split package base
784   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
  echo >> ${dest}  
785    
786   # add special vars   # add special vars
787   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 750  build_mage_script() Line 792  build_mage_script()
792   # being tricky here :)   # being tricky here :)
793   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
794   done   done
  echo  >> ${dest}  
795   fi   fi
796    
797   # add at least all includes   # add at least all includes
# Line 762  build_mage_script() Line 803  build_mage_script()
803   do   do
804   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
805   done   done
806   echo  >> ${dest}   # a CRLF is needed here!
807     echo >> ${dest}
808   fi   fi
  echo >> ${dest}  
809    
810   # deps and provides   # deps and provides
811   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
812   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
813   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
814    
815   # add special functions   # add special functions
816   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 782  build_mage_script() Line 820  build_mage_script()
820   do   do
821   # add to mage (quotes needed !)   # add to mage (quotes needed !)
822   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
823   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
824   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
825   done   done
  echo  >> ${dest}  
826   fi   fi
827    
828   # pre|post-install|removes   # pre|post-install|removes
829   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
830   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
831   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
832   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
833  }  }
834    
835  regen_mage_tree()  regen_mage_tree()
836  {  {
837   local i   local subpackage
838    
839   # build them only if requested   # build them only if requested
840   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
# Line 813  regen_mage_tree() Line 845  regen_mage_tree()
845   # build for each target a mage file   # build for each target a mage file
846   # run it with several targets   # run it with several targets
847   echo   echo
848   for i in ${MAGE_TARGETS}   for subpackage in ${MAGE_TARGETS}
849   do   do
850   build_mage_script --target "${i}"   build_mage_script --target "${subpackage}"
851   done   done
852   echo   echo
853    
# Line 828  regen_mage_tree() Line 860  regen_mage_tree()
860   # build for each subpackage a mage file   # build for each subpackage a mage file
861   # run it with several targets   # run it with several targets
862   echo   echo
863   for i in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
864   do   do
865   # get the right variables for the split   # get the right variables for the split
866   export PNAME="${i}"   export PNAME="${subpackage}"
867   split_info_${i}   split_info_${subpackage}
868     # get the preinstall etc
869     split_export_inherits ${subpackage}
870   build_mage_script --split-pkg-base "${split_pkg_base}"   build_mage_script --split-pkg-base "${split_pkg_base}"
871     # delete split preinstall etc
872     split_delete_inherits ${subpackage}
873   # restore smage environment   # restore smage environment
874   split_restore_variables   split_restore_variables
875   done   done
# Line 1019  split_unset_variables() Line 1055  split_unset_variables()
1055   unset -f SAVED_postremove   unset -f SAVED_postremove
1056  }  }
1057    
1058    split_export_inherits()
1059    {
1060     local subpackage="$1"
1061     local func
1062     local newfunc
1063    
1064     for func in preinstall postinstall preremove postremove
1065     do
1066     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1067     then
1068     newfunc=$(typeset -f ${func}_${subpackage})
1069     newfunc="${newfunc/_${subpackage} (/ (}"
1070     eval "${newfunc}"
1071     fi
1072     done
1073    }
1074    
1075    split_delete_inherits()
1076    {
1077     local subpackage="$1"
1078     local func
1079    
1080     for func in preinstall postinstall preremove postremove
1081     do
1082     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1083     then
1084     unset -f ${func}
1085     fi
1086     done
1087     }
1088    
1089  export_inherits()  export_inherits()
1090  {  {
1091   local include="$1"   local include="$1"
# Line 1180  then Line 1247  then
1247   MD5DIR="$3"   MD5DIR="$3"
1248   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1249    
1250   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1251    
1252   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1253   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1254  then Line 1321  then
1321   # get smage   # get smage
1322   SMAGENAME="$2"   SMAGENAME="$2"
1323   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1324   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1325    
1326   download_sources   download_sources
1327   exit 0   exit 0
# Line 1266  then Line 1333  then
1333   # set correct SMAGENAME   # set correct SMAGENAME
1334   SMAGENAME="$2"   SMAGENAME="$2"
1335   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1336   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1337    
1338   regen_mage_tree   regen_mage_tree
1339    
# Line 1328  then Line 1395  then
1395    
1396   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1397    
1398   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1399    
1400   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1401   then   then
# Line 1377  fi Line 1444  fi
1444  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1445  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1446    
1447  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1448  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1449  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1450  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"

Legend:
Removed from v.1273  
changed lines
  Added in v.1436