Magellan Linux

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

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

revision 2363 by niro, Mon Jan 6 12:49:32 2014 UTC revision 3081 by niro, Tue May 22 14:09:28 2018 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    pkg_setup()
229    {
230     echo "no pkg_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 491  mstriplibs() Line 498  mstriplibs()
498    
499   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
500   [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug"   [[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug"
501   find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null   find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "[shared object|pie executable]" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null
502  }  }
503    
504  mstripbins()  mstripbins()
# Line 500  mstripbins() Line 507  mstripbins()
507    
508   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"   [[ -z ${stripdir} ]] && stripdir="${BINDIR}"
509   [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug"   [[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug"
510   find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null   find ${stripdir} ! -type d | xargs --no-run-if-empty file | grep -v "pie executable" | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null
511  }  }
512    
513  mstripstatic()  mstripstatic()
# Line 588  march() Line 595  march()
595   return "${retval}"   return "${retval}"
596  }  }
597    
598  marchsrcfile()  marchvariable()
599  {  {
600   local retval   local retval
601   local var="$1"   local var="$1"
602    
603   [[ -z ${var} ]] && var="SRCFILE"   [[ -n ${var} ]] || die "marchvariable(): missing variable"
604    
605   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
606   then   then
# Line 606  marchsrcfile() Line 613  marchsrcfile()
613   return "${retval}"   return "${retval}"
614  }  }
615    
616    marchsrcfile()
617    {
618     local retval
619     local var="$1"
620    
621     [[ -z ${var} ]] && var="SRCFILE"
622    
623     marchvariable "${var}" || die
624    }
625    
626  marchsrcdir()  marchsrcdir()
627  {  {
628   local retval   local retval
# Line 613  marchsrcdir() Line 630  marchsrcdir()
630    
631   [[ -z ${var} ]] && var="SRCDIR"   [[ -z ${var} ]] && var="SRCDIR"
632    
633   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]   marchvariable "${var}" || die
  then  
  eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n'  
  retval=0  
  else  
  retval=1  
  fi  
   
  return "${retval}"  
634  }  }
635    
636  marchdepend()  marchdepend()
# Line 633  marchdepend() Line 642  marchdepend()
642    
643   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
644   then   then
645   echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"   # evaluate with escape strings for the magefile if called by smage
646     # but do not escape if the smagefile was called by depwalker directly
647     if [[ ${SMAGE_DEPEND} = 1 ]]
648     then
649     eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n'
650     else
651     echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"
652     fi
653   retval=0   retval=0
654   else   else
655   retval=1   retval=1
# Line 651  marchsdepend() Line 667  marchsdepend()
667    
668   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]   if [[ ! -z $(eval echo \$${var}_${ARCH/i*86/x86}) ]]
669   then   then
670   echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"   # evaluate with escape strings for the magefile if called by smage
671     # but do not escape if the smagefile was called by depwalker directly
672     if [[ ${SMAGE_DEPEND} = 1 ]]
673     then
674     eval echo \$${var}_${ARCH/i*86/x86} | tr ';' '\n'
675     else
676     echo "\$(eval echo \\\$${var}_\${ARCH/i*86/x86} | tr ';' '\n')"
677     fi
678   retval=0   retval=0
679   else   else
680   retval=1   retval=1
# Line 695  setup_ccache_environment() Line 718  setup_ccache_environment()
718   fi   fi
719  }  }
720    
 # fixes given dependencies to match a MAGE_TARGET  
 # fix_mage_deps -target s/depend # <-- note -target !  
 fix_mage_deps()  
 {  
  local target="$1"  
  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}" ]  
  then  
  # fix DEPEND  
  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  
   
  # 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}"  
  fi  
   
  echo "${depend}"  
 }  
   
721  # build_mage_script(): helper functions for regen_mage_tree()  # build_mage_script(): helper functions for regen_mage_tree()
722  # generates an mage file with given information in smage file  # generates an mage file with given information in smage file
723  # needs at least:  # needs at least:
# Line 790  build_mage_script() Line 751  build_mage_script()
751  {  {
752   local magefile   local magefile
753   local dest   local dest
  local target  
754   local split_pkg_base   local split_pkg_base
755   local sym   local sym
756   local depname   local depname
# Line 798  build_mage_script() Line 758  build_mage_script()
758   # if MAGE_TREE_DEST not set use BUILDDIR   # if MAGE_TREE_DEST not set use BUILDDIR
759   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
760    
  # determinate which suffix this mage file should get, if any  
  [[ $1 = --target ]] && shift && target="-$1"  
   
761   # mark package as splitpackage   # mark package as splitpackage
762   [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"   [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
763    
764   # name of magefile   # name of magefile
765   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}-${PVER}-${PBUILD}.mage"
766    
767   # destination to magefile   # destination to magefile
768   dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCAT}/${PNAME}/${magefile}"
769    
770   # show what we are doing   # show what we are doing
771   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
# Line 819  build_mage_script() Line 776  build_mage_script()
776   > ${dest}   > ${dest}
777    
778   # pgkname and state   # pgkname and state
779   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}-${PVER}-\${ARCH}$(print_distrotag)-${PBUILD}\"" >> ${dest}
780   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
781    
782   # description and homepage   # description and homepage
# Line 832  build_mage_script() Line 789  build_mage_script()
789   # special tags and vars   # special tags and vars
790   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
791    
  # echo MAGE_TARGETS ## note -target is needed !  
  echo "MAGE_TARGETS=\"${target}\"" >> ${dest}  
   
792   # split package base   # split package base
793   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}   echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
794    
# Line 863  build_mage_script() Line 817  build_mage_script()
817   fi   fi
818    
819   # deps and provides   # deps and provides
820   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"${DEPEND}\"" >> ${dest}
821   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"${SDEPEND}\"" >> ${dest}
822   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
823    
824   # add special functions   # add special functions
# Line 875  build_mage_script() Line 829  build_mage_script()
829   do   do
830   # add to mage (quotes needed !)   # add to mage (quotes needed !)
831   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  # unset to be safe (quotes needed !)  
  #unset "${i}" <-- later to get every target built  
832   done   done
833   fi   fi
834    
# Line 894  regen_mage_tree() Line 846  regen_mage_tree()
846   # build them only if requested   # build them only if requested
847   if mqueryfeature regentree   if mqueryfeature regentree
848   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  
   
849   # run it for splitpackages   # run it for splitpackages
850   elif [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
851   then   then
852   local split_pkg_base="${PNAME}"   local split_pkg_base="${PNAME}"
853   # save smage environment   # save smage environment
# Line 947  regen_mage_tree() Line 887  regen_mage_tree()
887    
888   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
889   # 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  
890   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
 # for i in ${SPECIAL_VARS}  
 # do  
 # unset "${i}"  
 # done  
891   unset SPECIAL_VARS   unset SPECIAL_VARS
892   unset STATE   unset STATE
893   unset DESCRIPTION   unset DESCRIPTION
# Line 1206  generate_package_md5sum() Line 1137  generate_package_md5sum()
1137   local pver   local pver
1138   local pbuild   local pbuild
1139   local parch   local parch
  local target  
1140   local pkgname   local pkgname
1141    
1142   # very basic getops   # very basic getops
# Line 1218  generate_package_md5sum() Line 1148  generate_package_md5sum()
1148   --pver|-v) shift; pver="$1" ;;   --pver|-v) shift; pver="$1" ;;
1149   --pbuild|-b) shift; pbuild="$1" ;;   --pbuild|-b) shift; pbuild="$1" ;;
1150   --parch|a) shift; parch="$1" ;;   --parch|a) shift; parch="$1" ;;
  --target|t) shift; target="$1" ;;  
1151   esac   esac
1152   shift   shift
1153   done   done
# Line 1234  generate_package_md5sum() Line 1163  generate_package_md5sum()
1163   [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."   [ -z "${PKGDIR}" ] && die "generate_package_md5sum() \$PKGDIR not set."
1164   [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."   [ -z "${PKGSUFFIX}" ] && die "generate_package_md5sum() \$PKGSUFFIX not set."
1165    
  # fix target as it may be empty !  
  [ -n "${target}" ] && target="-${target}"  
   
1166   # build pkgname   # build pkgname
1167   pkgname="${pname}${target}-${pver}-${parch}$(print_distrotag)-${pbuild}"   pkgname="${pname}-${pver}-${parch}$(print_distrotag)-${pbuild}"
1168    
1169   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
1170   if mqueryfeature regentree   if mqueryfeature regentree
# Line 1256  generate_package_md5sum() Line 1182  generate_package_md5sum()
1182   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1183    
1184   # setup md5 dir   # setup md5 dir
1185   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"
1186   install -d ${dest}   install -d ${dest}
1187    
1188   # gen md5sum   # gen md5sum
# Line 1268  generate_package_md5sum() Line 1194  generate_package_md5sum()
1194    
1195  source_pkg_build()  source_pkg_build()
1196  {  {
  if [[ ${PKGTYPE} = virtual ]]  
  then  
  echo "Virtual package detected; src-pkg-tarball not necessary ..."  
  return 0  
  fi  
   
1197   if [[ ! -d ${SOURCEDIR}/${PNAME} ]]   if [[ ! -d ${SOURCEDIR}/${PNAME} ]]
1198   then   then
1199   echo "No SRC_URI defined; src-pkg-tarball not necessary ..."   install -d ${SOURCEDIR}/${PNAME}
  return 0  
1200   fi   fi
1201    
1202   [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."   [ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly."

Legend:
Removed from v.2363  
changed lines
  Added in v.3081