Magellan Linux

Diff of /branches/mage-next/src/smage2.functions.sh.in

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

trunk/mage/usr/lib/mage/smage2.functions.sh revision 1689 by niro, Thu Feb 16 11:58:12 2012 UTC branches/mage-next/src/smage2.functions.sh.in revision 2613 by niro, Tue Mar 4 15:26:05 2014 UTC
# Line 79  print_distrotag() Line 79  print_distrotag()
79   fi   fi
80  }  }
81    
 showversion()  
 {  
  echo -en "Magellan Source Install v${SMAGEVERSION} "  
  echo -e  "-- Niels Rogalla (niro@magellan-linux.de)"  
 }  
   
 die()  
 {  
  xtitleclean  
  echo -e ${COLRED}"Exited ${BASH_SOURCE} at line no ${BASH_LINENO}."${COLDEFAULT}  
  echo "SMAGE failed: $@"  
  exit 1  
 }  
   
 die_pipestatus()  
 {  
  # the status change if we do any parameter declarations!!  
  # dont do this anymore, keep this in mind!  
  #  
  # local pos="$1"  
  # local comment="$2"  
  #  
  # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}"  
  #  
  [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2"  
 }  
   
 xtitle()  
 {  
  if [[ ${TERM} = xterm ]]  
  then  
  echo -ne "\033]0;[sMage: $@]\007"  
  fi  
  return 0  
 }  
   
 xtitleclean()  
 {  
  if [[ ${TERM} = xterm ]]  
  then  
  echo -ne "\033]0;\007"  
  fi  
  return 0  
 }  
   
82  syncsmage2()  syncsmage2()
83  {  {
84   xtitle "Updating smage2-script tree ..."   xtitle "Updating smage2-script tree ..."
# Line 318  minstall() Line 273  minstall()
273   sysconfdir=${BINDIR}/etc \   sysconfdir=${BINDIR}/etc \
274   libdir=${BINDIR}/usr/$(mlibdir) \   libdir=${BINDIR}/usr/$(mlibdir) \
275   "$@" install || die "minstall failed"   "$@" install || die "minstall failed"
276          else   else
277                  die "no Makefile found"   die "no Makefile found"
278          fi   fi
279  }  }
280    
281  mmake()  mmake()
# Line 343  munpack() Line 298  munpack()
298   DEST=$2   DEST=$2
299   fi   fi
300    
301     echo -e "${COLBLUE}>>>${COLGREEN} Unpacking ${SOURCEDIR}/${PNAME}/${SRCFILE}${COLDEFAULT}"
302    
303   [[ ! -d ${DEST} ]] && install -d ${DEST}   [[ ! -d ${DEST} ]] && install -d ${DEST}
304    
305   case "${SRCFILE##*.}" in   case "${SRCFILE##*.}" in
# Line 392  munpack() Line 349  munpack()
349   tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."   tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
350   ;;   ;;
351   rar)   rar)
352   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed."
353   ;;   ;;
354   zip|xpi|jar)   zip|xpi|jar)
355   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
# Line 564  sminclude() Line 521  sminclude()
521   then   then
522   for i in $@   for i in $@
523   do   do
524   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
525   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
526   done   done
527   echo   [[ ${SILENT} = 1 ]] || echo
528   fi   fi
529  }  }
530    
# Line 589  march() Line 546  march()
546  marchsrcfile()  marchsrcfile()
547  {  {
548   local retval   local retval
549   if [[ ! -z $(eval echo \$SRCFILE_${ARCH/i*86/x86}) ]]   local var="$1"
550    
551     [[ -z ${var} ]] && var="SRCFILE"
552    
553     if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
554   then   then
555   eval echo \$SRCFILE_${ARCH/i*86/x86} | tr ';' '\n'   eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n'
556   retval=0   retval=0
557   else   else
558   retval=1   retval=1
# Line 603  marchsrcfile() Line 564  marchsrcfile()
564  marchsrcdir()  marchsrcdir()
565  {  {
566   local retval   local retval
567   if [[ ! -z $(eval echo \$SRCDIR_${ARCH/i*86/x86}) ]]   local var="$1"
568    
569     [[ -z ${var} ]] && var="SRCDIR"
570    
571     if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
572   then   then
573   eval echo \$SRCDIR_${ARCH/i*86/x86} | tr ';' '\n'   eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n'
574   retval=0   retval=0
575   else   else
576   retval=1   retval=1
# Line 617  marchsrcdir() Line 582  marchsrcdir()
582  marchdepend()  marchdepend()
583  {  {
584   local retval   local retval
585     local var="$1"
586    
587     [[ -z ${var} ]] && var="DEPEND"
588    
589   if [[ ! -z $(eval echo \$DEPEND_${ARCH/i*86/x86}) ]]   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
590   then   then
591   echo "\$(eval echo \\\$DEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"   echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"
592   retval=0   retval=0
593   else   else
594   retval=1   retval=1
# Line 632  marchdepend() Line 600  marchdepend()
600  marchsdepend()  marchsdepend()
601  {  {
602   local retval   local retval
603   if [[ ! -z $(eval echo \$SDEPEND_${ARCH/i*86/x86}) ]]   local var="$1"
604    
605     [[ -z ${var} ]] && var="SDEPEND"
606    
607     if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
608   then   then
609   echo "\$(eval echo \\\$SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"   echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"
610   retval=0   retval=0
611   else   else
612   retval=1   retval=1
# Line 658  setup_distcc_environment() Line 630  setup_distcc_environment()
630   fi   fi
631  }  }
632    
633  setup_ccache_environment()  setup_icecc_environment()
634  {  {
635   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/icecc ]
636   then   then
637   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"   echo -e "${COLBLUE}---${COLGREEN} Using IceCC for compilation ...${COLDEFAULT}"
638   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"   export PATH=/usr/$(mlibdir)/icecc/bin:${PATH} || die "icecc: could not export new $PATH"
639   fi   fi
640  }  }
641    
642  # fixes given dependencies to match a MAGE_TARGET  setup_ccache_environment()
643  # fix_mage_deps -target s/depend # <-- note -target !  {
644  fix_mage_deps()   if [ -x /usr/bin/ccache ]
 {  
  local target="$1"  
  local depend="$2"  
  local NDEPEND  
  local sym dep cat pver pname  
   
  # deps and provides are special  
  # they must be fixed to match the target  
   
  # run this only if target and depend is not empty  
  if [ -n "${target}" ] && [ -n "${depend}" ]  
645   then   then
646   # fix DEPEND   mqueryfeature "icecc" && export CCACHE_PREFIX=icecc
  while read sym dep  
  do  
  # ignore empty lines  
  [[ -z ${dep} ]] && continue  
   
  cat="$(dirname ${dep})"  
  # change if not virtual  
  if [[ ${cat} = virtual ]]  
  then  
  pname="$(basename ${dep})"  
  else  
  # fix pver to target-pver  
  # to get pname-target-pver  
647    
648   # doing it backwards !   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
649   pver="${dep##*-}"   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
  # full pver  
  pname="$(basename ${dep/-${pver}/})${target}-${pver}"  
  fi  
   
  # do not add empty lines  
  if [ -z "${NDEPEND}" ]  
  then  
  NDEPEND="${sym} ${cat}/${pname}"  
  else  
  NDEPEND="${NDEPEND}  
  ${sym} ${cat}/${pname}"  
  fi  
   
  unset cat pname pver  
  done << EOF  
 ${depend}  
 EOF  
  # set NDEPEND to DEPEND  
  depend="${NDEPEND}"  
650   fi   fi
   
  echo "${depend}"  
651  }  }
652    
653  # build_mage_script(): helper functions for regen_mage_tree()  # build_mage_script(): helper functions for regen_mage_tree()
# Line 756  build_mage_script() Line 683  build_mage_script()
683  {  {
684   local magefile   local magefile
685   local dest   local dest
  local target  
686   local split_pkg_base   local split_pkg_base
687   local sym   local sym
688   local depname   local depname
# Line 764  build_mage_script() Line 690  build_mage_script()
690   # if MAGE_TREE_DEST not set use BUILDDIR   # if MAGE_TREE_DEST not set use BUILDDIR
691   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
692    
  # determinate which suffix this mage file should get, if any  
  [[ $1 = --target ]] && shift && target="-$1"  
   
693   # mark package as splitpackage   # mark package as splitpackage
694   [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"   [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
695    
696   # name of magefile   # name of magefile
697   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}-${PVER}-${PBUILD}.mage"
698    
699   # destination to magefile   # destination to magefile
700   dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}/${magefile}"
701    
702   # show what we are doing   # show what we are doing
703   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
# Line 785  build_mage_script() Line 708  build_mage_script()
708   > ${dest}   > ${dest}
709    
710   # pgkname and state   # pgkname and state
711   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest}
712   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
713    
714   # description and homepage   # description and homepage
# Line 798  build_mage_script() Line 721  build_mage_script()
721   # special tags and vars   # special tags and vars
722   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
723    
  # echo MAGE_TARGETS ## note -target is needed !  
  echo "MAGE_TARGETS=\"${target}\"" >> ${dest}  
   
724   # split package base   # split package base
725   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
726    
# Line 829  build_mage_script() Line 749  build_mage_script()
749   fi   fi
750    
751   # deps and provides   # deps and provides
752   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"${DEPEND}\"" >> ${dest}
753   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"${SDEPEND}\"" >> ${dest}
754   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
755    
756   # add special functions   # add special functions
# Line 841  build_mage_script() Line 761  build_mage_script()
761   do   do
762   # add to mage (quotes needed !)   # add to mage (quotes needed !)
763   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  # unset to be safe (quotes needed !)  
  #unset "${i}" <-- later to get every target built  
764   done   done
765   fi   fi
766    
# Line 860  regen_mage_tree() Line 778  regen_mage_tree()
778   # build them only if requested   # build them only if requested
779   if mqueryfeature regentree   if mqueryfeature regentree
780   then   then
  # run it without targets  
  if [[ -n ${MAGE_TARGETS} ]]  
  then  
  # build for each target a mage file  
  # run it with several targets  
  echo  
  for subpackage in ${MAGE_TARGETS}  
  do  
  build_mage_script --target "${subpackage}"  
  done  
  echo  
   
781   # run it for splitpackages   # run it for splitpackages
782   elif [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
783   then   then
784   local split_pkg_base="${PNAME}"   local split_pkg_base="${PNAME}"
785   # save smage environment   # save smage environment
# Line 913  regen_mage_tree() Line 819  regen_mage_tree()
819    
820   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
821   # unset PKGNAME <-- don't do that; smage needs this var   # unset PKGNAME <-- don't do that; smage needs this var
  # unset to be safe (quotes needed !)  
 # for i in ${SPECIAL_FUNCTIONS}  
 # do  
 # unset "${i}"  
 # done  
822   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
 # for i in ${SPECIAL_VARS}  
 # do  
 # unset "${i}"  
 # done  
823   unset SPECIAL_VARS   unset SPECIAL_VARS
824   unset STATE   unset STATE
825   unset DESCRIPTION   unset DESCRIPTION
# Line 947  split_save_variables() Line 844  split_save_variables()
844   export SAVED_DESCRIPTION="${DESCRIPTION}"   export SAVED_DESCRIPTION="${DESCRIPTION}"
845   export SAVED_HOMEPAGE="${HOMEPAGE}"   export SAVED_HOMEPAGE="${HOMEPAGE}"
846   export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"   export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
847     export SAVED_SPECIAL_FUNCTIONS="${SPECIAL_FUNCTIONS}"
848   export SAVED_STATE="${STATE}"   export SAVED_STATE="${STATE}"
  export SAVED_PKGTYPE="${PKGTYPE}"  
849   export SAVED_INHERITS="${INHERITS}"   export SAVED_INHERITS="${INHERITS}"
850   export SAVED_DEPEND="${DEPEND}"   export SAVED_DEPEND="${DEPEND}"
851   export SAVED_SDEPEND="${SDEPEND}"   export SAVED_SDEPEND="${SDEPEND}"
# Line 1022  split_restore_variables() Line 919  split_restore_variables()
919   export DESCRIPTION="${SAVED_DESCRIPTION}"   export DESCRIPTION="${SAVED_DESCRIPTION}"
920   export HOMEPAGE="${SAVED_HOMEPAGE}"   export HOMEPAGE="${SAVED_HOMEPAGE}"
921   export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"   export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
922     export SPECIAL_FUNCTIONS="${SAVED_SPECIAL_FUNCTIONS}"
923   export STATE="${SAVED_STATE}"   export STATE="${SAVED_STATE}"
  export PKGTYPE="${SAVED_PKGTYPE}"  
924   export INHERITS="${SAVED_INHERITS}"   export INHERITS="${SAVED_INHERITS}"
925   export DEPEND="${SAVED_DEPEND}"   export DEPEND="${SAVED_DEPEND}"
926   export SDEPEND="${SAVED_SDEPEND}"   export SDEPEND="${SAVED_SDEPEND}"
# Line 1091  split_unset_variables() Line 988  split_unset_variables()
988   unset SAVED_DESCRIPTION   unset SAVED_DESCRIPTION
989   unset SAVED_HOMEPAGE   unset SAVED_HOMEPAGE
990   unset SAVED_SPECIAL_VARS   unset SAVED_SPECIAL_VARS
991     unset SAVED_SPECIAL_FUNCTIONS
992   unset SAVED_STATE   unset SAVED_STATE
993   unset SAVED_PKGTYPE   unset SAVED_PKGTYPE
994   unset SAVED_INHERITS   unset SAVED_INHERITS
# Line 1171  generate_package_md5sum() Line 1069  generate_package_md5sum()
1069   local pver   local pver
1070   local pbuild   local pbuild
1071   local parch   local parch
  local target  
1072   local pkgname   local pkgname
1073    
1074   # very basic getops   # very basic getops
# Line 1183  generate_package_md5sum() Line 1080  generate_package_md5sum()
1080   --pver|-v) shift; pver="$1" ;;   --pver|-v) shift; pver="$1" ;;
1081   --pbuild|-b) shift; pbuild="$1" ;;   --pbuild|-b) shift; pbuild="$1" ;;
1082   --parch|a) shift; parch="$1" ;;   --parch|a) shift; parch="$1" ;;
  --target|t) shift; target="$1" ;;  
1083   esac   esac
1084   shift   shift
1085   done   done
# Line 1199  generate_package_md5sum() Line 1095  generate_package_md5sum()
1095   [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."   [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
1096   [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."   [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
1097    
  # fix target as it may be empty !  
  [ -n "${target}" ] && target="-${target}"  
   
1098   # build pkgname   # build pkgname
1099   pkgname="${pname}${target}-${pver}-${parch}$(print_distrotag)-${pbuild}"   pkgname="${pname}-${pver}-${parch}$(print_distrotag)-${pbuild}"
1100    
1101   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
1102   if mqueryfeature regentree   if mqueryfeature regentree
# Line 1221  generate_package_md5sum() Line 1114  generate_package_md5sum()
1114   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1115    
1116   # setup md5 dir   # setup md5 dir
1117   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"
1118   install -d ${dest}   install -d ${dest}
1119    
1120   # gen md5sum   # gen md5sum
# Line 1288  run_resume() Line 1181  run_resume()
1181   return 1   return 1
1182   fi   fi
1183  }  }
1184    
1185    mqalint()
1186    {
1187     return 0
1188    }

Legend:
Removed from v.1689  
changed lines
  Added in v.2613