Magellan Linux

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

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

revision 2158 by niro, Wed Aug 14 07:46:36 2013 UTC revision 2742 by niro, Tue Aug 12 21:53:03 2014 UTC
# Line 225  download_sources() Line 225  download_sources()
225  }  }
226    
227  # dummy function, used if that does not exist in smage file  # dummy function, used if that does not exist in smage file
228    src_setup()
229    {
230     echo "no src_setup defined; doing nothing ..."
231     return 0
232    }
233    
234    # dummy function, used if that does not exist in smage file
235  src_prepare()  src_prepare()
236  {  {
237   echo "no src_prepare defined; doing nothing ..."   echo "no src_prepare defined; doing nothing ..."
# Line 318  minstall() Line 325  minstall()
325   sysconfdir=${BINDIR}/etc \   sysconfdir=${BINDIR}/etc \
326   libdir=${BINDIR}/usr/$(mlibdir) \   libdir=${BINDIR}/usr/$(mlibdir) \
327   "$@" install || die "minstall failed"   "$@" install || die "minstall failed"
328          else   else
329                  die "no Makefile found"   die "no Makefile found"
330          fi   fi
331  }  }
332    
333  mmake()  mmake()
# Line 566  sminclude() Line 573  sminclude()
573   then   then
574   for i in $@   for i in $@
575   do   do
576   echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"   [[ ${SILENT} = 1 ]] || echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
577   source ${SMAGESCRIPTSDIR}/include/${i}.sminc   source ${SMAGESCRIPTSDIR}/include/${i}.sminc
578   done   done
579   echo   [[ ${SILENT} = 1 ]] || echo
580   fi   fi
581  }  }
582    
# Line 609  marchsrcfile() Line 616  marchsrcfile()
616  marchsrcdir()  marchsrcdir()
617  {  {
618   local retval   local retval
619   if [[ ! -z $(eval echo \$SRCDIR_${ARCH/i*86/x86}) ]]   local var="$1"
620    
621     [[ -z ${var} ]] && var="SRCDIR"
622    
623     if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
624   then   then
625   eval echo \$SRCDIR_${ARCH/i*86/x86} | tr ';' '\n'   eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n'
626   retval=0   retval=0
627   else   else
628   retval=1   retval=1
# Line 623  marchsrcdir() Line 634  marchsrcdir()
634  marchdepend()  marchdepend()
635  {  {
636   local retval   local retval
637     local var="$1"
638    
639     [[ -z ${var} ]] && var="DEPEND"
640    
641   if [[ ! -z $(eval echo \$DEPEND_${ARCH/i*86/x86}) ]]   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
642   then   then
643   echo "\$(eval echo \\\$DEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"   echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"
644   retval=0   retval=0
645   else   else
646   retval=1   retval=1
# Line 638  marchdepend() Line 652  marchdepend()
652  marchsdepend()  marchsdepend()
653  {  {
654   local retval   local retval
655   if [[ ! -z $(eval echo \$SDEPEND_${ARCH/i*86/x86}) ]]   local var="$1"
656    
657     [[ -z ${var} ]] && var="SDEPEND"
658    
659     if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
660   then   then
661   echo "\$(eval echo \\\$SDEPEND_\${ARCH/i*86/x86} | tr ';' '\n')"   echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"
662   retval=0   retval=0
663   else   else
664   retval=1   retval=1
# Line 664  setup_distcc_environment() Line 682  setup_distcc_environment()
682   fi   fi
683  }  }
684    
685  setup_ccache_environment()  setup_icecc_environment()
686  {  {
687   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/icecc ]
688   then   then
689   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"   echo -e "${COLBLUE}---${COLGREEN} Using IceCC for compilation ...${COLDEFAULT}"
690   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"
691   fi   fi
692  }  }
693    
694  # fixes given dependencies to match a MAGE_TARGET  setup_ccache_environment()
 # fix_mage_deps -target s/depend # <-- note -target !  
 fix_mage_deps()  
695  {  {
696   local target="$1"   if [ -x /usr/bin/ccache ]
  local depend="$2"  
  local NDEPEND  
  local sym dep cat pver pname  
   
  # first of all remove all tabs and duplicate lines  
  if [ -n "${depend}" ]  
  then  
  depend=$(echo "${depend}" | sed 's:\t::g' | sort -u)  
  fi  
   
  # 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}" ]  
697   then   then
698   # 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  
   
  # doing it backwards !  
  pver="${dep##*-}"  
  # full pver  
  pname="$(basename ${dep/-${pver}/})${target}-${pver}"  
  fi  
699    
700   # do not add empty lines   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
701   if [ -z "${NDEPEND}" ]   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
  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}"  
702   fi   fi
   
  echo "${depend}"  
703  }  }
704    
705  # build_mage_script(): helper functions for regen_mage_tree()  # build_mage_script(): helper functions for regen_mage_tree()
# Line 768  build_mage_script() Line 735  build_mage_script()
735  {  {
736   local magefile   local magefile
737   local dest   local dest
  local target  
738   local split_pkg_base   local split_pkg_base
739   local sym   local sym
740   local depname   local depname
# Line 776  build_mage_script() Line 742  build_mage_script()
742   # if MAGE_TREE_DEST not set use BUILDDIR   # if MAGE_TREE_DEST not set use BUILDDIR
743   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
744    
  # determinate which suffix this mage file should get, if any  
  [[ $1 = --target ]] && shift && target="-$1"  
   
745   # mark package as splitpackage   # mark package as splitpackage
746   [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"   [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
747    
748   # name of magefile   # name of magefile
749   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}-${PVER}-${PBUILD}.mage"
750    
751   # destination to magefile   # destination to magefile
752   dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}/${magefile}"
753    
754   # show what we are doing   # show what we are doing
755   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
# Line 797  build_mage_script() Line 760  build_mage_script()
760   > ${dest}   > ${dest}
761    
762   # pgkname and state   # pgkname and state
763   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest}
764   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
765    
766   # description and homepage   # description and homepage
# Line 810  build_mage_script() Line 773  build_mage_script()
773   # special tags and vars   # special tags and vars
774   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
775    
  # echo MAGE_TARGETS ## note -target is needed !  
  echo "MAGE_TARGETS=\"${target}\"" >> ${dest}  
   
776   # split package base   # split package base
777   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
778    
# Line 841  build_mage_script() Line 801  build_mage_script()
801   fi   fi
802    
803   # deps and provides   # deps and provides
804   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"${DEPEND}\"" >> ${dest}
805   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"${SDEPEND}\"" >> ${dest}
806   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
807    
808   # add special functions   # add special functions
# Line 853  build_mage_script() Line 813  build_mage_script()
813   do   do
814   # add to mage (quotes needed !)   # add to mage (quotes needed !)
815   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  # unset to be safe (quotes needed !)  
  #unset "${i}" <-- later to get every target built  
816   done   done
817   fi   fi
818    
# Line 872  regen_mage_tree() Line 830  regen_mage_tree()
830   # build them only if requested   # build them only if requested
831   if mqueryfeature regentree   if mqueryfeature regentree
832   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  
   
833   # run it for splitpackages   # run it for splitpackages
834   elif [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
835   then   then
836   local split_pkg_base="${PNAME}"   local split_pkg_base="${PNAME}"
837   # save smage environment   # save smage environment
# Line 925  regen_mage_tree() Line 871  regen_mage_tree()
871    
872   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
873   # 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  
874   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
 # for i in ${SPECIAL_VARS}  
 # do  
 # unset "${i}"  
 # done  
875   unset SPECIAL_VARS   unset SPECIAL_VARS
876   unset STATE   unset STATE
877   unset DESCRIPTION   unset DESCRIPTION
# Line 1034  split_restore_variables() Line 971  split_restore_variables()
971   export DESCRIPTION="${SAVED_DESCRIPTION}"   export DESCRIPTION="${SAVED_DESCRIPTION}"
972   export HOMEPAGE="${SAVED_HOMEPAGE}"   export HOMEPAGE="${SAVED_HOMEPAGE}"
973   export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"   export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
974   export SPECIAL_VARS="${SAVED_SPECIAL_FUNCTIONS}"   export SPECIAL_FUNCTIONS="${SAVED_SPECIAL_FUNCTIONS}"
975   export STATE="${SAVED_STATE}"   export STATE="${SAVED_STATE}"
976   export INHERITS="${SAVED_INHERITS}"   export INHERITS="${SAVED_INHERITS}"
977   export DEPEND="${SAVED_DEPEND}"   export DEPEND="${SAVED_DEPEND}"
# Line 1184  generate_package_md5sum() Line 1121  generate_package_md5sum()
1121   local pver   local pver
1122   local pbuild   local pbuild
1123   local parch   local parch
  local target  
1124   local pkgname   local pkgname
1125    
1126   # very basic getops   # very basic getops
# Line 1196  generate_package_md5sum() Line 1132  generate_package_md5sum()
1132   --pver|-v) shift; pver="$1" ;;   --pver|-v) shift; pver="$1" ;;
1133   --pbuild|-b) shift; pbuild="$1" ;;   --pbuild|-b) shift; pbuild="$1" ;;
1134   --parch|a) shift; parch="$1" ;;   --parch|a) shift; parch="$1" ;;
  --target|t) shift; target="$1" ;;  
1135   esac   esac
1136   shift   shift
1137   done   done
# Line 1212  generate_package_md5sum() Line 1147  generate_package_md5sum()
1147   [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."   [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
1148   [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."   [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
1149    
  # fix target as it may be empty !  
  [ -n "${target}" ] && target="-${target}"  
   
1150   # build pkgname   # build pkgname
1151   pkgname="${pname}${target}-${pver}-${parch}$(print_distrotag)-${pbuild}"   pkgname="${pname}-${pver}-${parch}$(print_distrotag)-${pbuild}"
1152    
1153   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
1154   if mqueryfeature regentree   if mqueryfeature regentree
# Line 1234  generate_package_md5sum() Line 1166  generate_package_md5sum()
1166   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1167    
1168   # setup md5 dir   # setup md5 dir
1169   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"
1170   install -d ${dest}   install -d ${dest}
1171    
1172   # gen md5sum   # gen md5sum

Legend:
Removed from v.2158  
changed lines
  Added in v.2742