Magellan Linux

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

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

trunk/mage/usr/lib/mage/smage2.sh revision 2157 by niro, Wed Aug 14 07:38:37 2013 UTC branches/mage-next/src/smage2.in revision 3035 by niro, Fri Jun 30 12:11:53 2017 UTC
# Line 7  Line 7 
7  # TODO: record dynlib, gz | xz database  # TODO: record dynlib, gz | xz database
8    
9    
10  # set default user mage.rc  # set default variables
11  : ${MAGERC="/etc/mage.rc"}  : ${MAGERC="@@SYSCONFDIR@@/mage.rc"}
12    : ${MLIBDIR="@@MAGELIBDIR@@"}
13    
14  # export default C locale  # export default C locale
15  export LC_ALL=C  export LC_ALL=C
16    
17  source /etc/mage.rc.global  # first of all include common functions
18  source ${MAGERC}  source ${MLIBDIR}/common.functions.sh || exit 1
19  source ${MLIBDIR}/mage4.functions.sh  source @@SYSCONFDIR@@/mage.rc.global || die "@@SYSCONFDIR@@/mage.rc.global missing."
20  source ${MLIBDIR}/smage2.functions.sh  source ${MAGERC} || die "${MAGERC} missing."
21    source ${MLIBDIR}/mage4.functions.sh || die "${MLIBDIR}/mage4.functions.sh missing."
22    source ${MLIBDIR}/smage2.functions.sh || die "${MLIBDIR}/smage2.functions.sh missing."
23    
24    # export default path
25    export PATH="${PATH}:${MLIBDIR}"
26    
27    print_usage()
28    {
29     echo "Usage: $(basename $0) [option] pkgname ..."
30     echo "Options:"
31     echo "--smage"
32     echo "--src-tarball"
33     echo "--calc"
34     echo "--update"
35     echo "--download"
36     echo "--regen"
37     echo "--create-src-tarball"
38     echo "--resume"
39     echo
40     echo "Environment variables::"
41     echo " NOCOLORS=true $(basename $0) [src]install PACKAGE"
42     echo " Disables all colors in the messages."
43     echo
44    }
45    
46    # very basic getops
47    for i in $*
48    do
49     case $1 in
50     --smage|*.${SMAGESUFFIX}) shift; SMAGENAME="$1" ;;
51     --src-tarball) shift; SRCPKGTARBALL="$1" ;;
52     --calc) shift; SMAGENAME="$1" ;;
53     --update) ;;
54     --download) shift; SMAGENAME="$1" ;;
55     --regen) shift; SMAGENAME="$1" ;;
56     --create-src-tarball) shift; SMAGENAME="$1" ;;
57     --resume) ;;
58     esac
59     shift
60    done
61    
62  ## setup ##  ## setup ##
63  SMAGENAME="$1"  SMAGENAME="$1"
 SMAGEVERSION="$(< ${MLIBDIR}/version)"  
64    
65  # expand PKGDIR, BUILDDIR and BINDIR with MROOT  # expand PKGDIR, BUILDDIR and BINDIR with MROOT
66  if [[ -n ${MROOT} ]]  if [[ -n ${MROOT} ]]
# Line 154  then Line 194  then
194    
195   regen_mage_tree   regen_mage_tree
196    
  # build several targets  
  if [[ -n ${MAGE_TARGETS} ]]  
  then  
  for target in ${MAGE_TARGETS}  
  do  
  # build md5sum for existing packages  
  generate_package_md5sum \  
  --pcat "${PCAT}" \  
  --pname "${PNAME}" \  
  --pver "${PVER}" \  
  --pbuild "${PBUILD}" \  
  --parch "${ARCH}" \  
  --target "${target}"  
  done  
   
197   # build several subpackages   # build several subpackages
198   elif [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
199   then   then
200   split_save_variables   split_save_variables
201   for subpackage in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
# Line 261  then Line 286  then
286   SMAGENAME="$2"   SMAGENAME="$2"
287  fi  fi
288    
289  [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."  [ ! -e ${MLIBDIR}/pkgbuild_dir ] && die "Error: ${MLIBDIR}/pkgbuild_dir not found. Aborting."
290  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&  [ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] &&
291   die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."   die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting."
292  [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."  [ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly."
# Line 275  fi Line 300  fi
300  smagesource ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
301  PKGNAME="${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}"
302  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
303  SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"  SMAGE_LOG_CMD="tee -a ${SMAGELOGDIR}/${PKGNAME}.log"
304    
305  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
306  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
307    
 # auto regen mage tree if requested  
 regen_mage_tree  
   
308  if mqueryfeature "srcpkgbuild"  if mqueryfeature "srcpkgbuild"
309  then  then
310   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
# Line 296  fi Line 318  fi
318  mqueryfeature "srcpkgtarball" || download_sources  mqueryfeature "srcpkgtarball" || download_sources
319    
320  # fixes some issues with these functions  # fixes some issues with these functions
321    export -f pkg_setup || die "pkg_setup export failed"
322  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
323  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
324  export -f src_check || die "src_check export failed"  export -f src_check || die "src_check export failed"
# Line 303  export -f src_install || die "src_instal Line 326  export -f src_install || die "src_instal
326    
327  # fixes some compile issues  # fixes some compile issues
328  export CHOST="${CHOST}" || die "CHOST export failed"  export CHOST="${CHOST}" || die "CHOST export failed"
329    export CPPFLAGS="${CPPFLAGS}" || die "CPPFLAGS export failed"
330  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
331  if [[ -z ${CXXFLAGS} ]]  if [[ -z ${CXXFLAGS} ]]
332  then  then
# Line 318  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 342  export MAKEOPTS="${MAKEOPTS}" || die "MA
342  # setup for distcc goes *before* ccache, so ccache comes before distcc in path  # setup for distcc goes *before* ccache, so ccache comes before distcc in path
343  mqueryfeature "distcc" && setup_distcc_environment  mqueryfeature "distcc" && setup_distcc_environment
344    
345    # setup icecc
346    # setup for icecc goes *before* ccache, so ccache comes before icecc in path
347    mqueryfeature "icecc" && setup_icecc_environment
348    
349  # setup ccache  # setup ccache
350  mqueryfeature "ccache" && setup_ccache_environment  mqueryfeature "ccache" && setup_ccache_environment
351    
# Line 326  then Line 354  then
354   echo -e "${COLMAGENTA}Resume requested; continuing previous build${COLDEFAULT}"   echo -e "${COLMAGENTA}Resume requested; continuing previous build${COLDEFAULT}"
355    
356   # setup build logging   # setup build logging
357   [[ ! -d /var/log/smage ]] && install -d /var/log/smage   [[ ! -d ${SMAGELOGDIR} ]] && install -d ${SMAGELOGDIR}
358   if [[ -f /var/log/smage/${PKGNAME}.log.bz2 ]]   if [[ -f ${SMAGELOGDIR}/${PKGNAME}.log.bz2 ]]
359   then   then
360   bunzip2 -f /var/log/smage/${PKGNAME}.log.bz2   bunzip2 -f ${SMAGELOGDIR}/${PKGNAME}.log.bz2
361   fi   fi
362   echo -e "### Resume started on $(date) ###\n" >> /var/log/smage/${PKGNAME}.log   echo -e "### Resume started on $(date) ###\n" >> ${SMAGELOGDIR}/${PKGNAME}.log
363    
364  else  else
365   # clean up builddir if a previously one exist   # clean up builddir if a previously one exist
# Line 367  else Line 395  else
395   fi   fi
396    
397   # setup build logging   # setup build logging
398   [[ ! -d /var/log/smage ]] && install -d /var/log/smage   [[ ! -d ${SMAGELOGDIR} ]] && install -d ${SMAGELOGDIR}
399   echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log   echo -e "### Build started on $(date) ###\n" > ${SMAGELOGDIR}/${PKGNAME}.log
400  fi  fi
401    
402  if [[ ${PKGTYPE} = virtual ]]  if [[ ${PKGTYPE} = virtual ]]
# Line 377  then Line 405  then
405   # automatically set !pkgbuild here too   # automatically set !pkgbuild here too
406   msetfeature "!pkgbuild"   msetfeature "!pkgbuild"
407  else  else
408   ( run_resume src_prepare || src_prepare ) | ${SMAGE_LOG_CMD}   ( run_resume pkg_setup || pkg_setup ) |& ${SMAGE_LOG_CMD}
409     die_pipestatus 0 "pkg_setup failed"
410     resume_stamp pkg_setup
411     step_by_step pkg_setup
412    
413     ( run_resume src_prepare || src_prepare ) |& ${SMAGE_LOG_CMD}
414   die_pipestatus 0 "src_prepare failed"   die_pipestatus 0 "src_prepare failed"
415   resume_stamp src_prepare   resume_stamp src_prepare
416   step_by_step src_prepare   step_by_step src_prepare
417    
418   ( run_resume src_compile || src_compile ) | ${SMAGE_LOG_CMD}   ( run_resume src_compile || src_compile ) |& ${SMAGE_LOG_CMD}
419   die_pipestatus 0 "src_compile failed"   die_pipestatus 0 "src_compile failed"
420   resume_stamp src_compile   resume_stamp src_compile
421   step_by_step src_compile   step_by_step src_compile
# Line 390  else Line 423  else
423   # only run checks if requested   # only run checks if requested
424   if mqueryfeature "!check"   if mqueryfeature "!check"
425   then   then
426   echo "!check detected; src_check() will not be run!" | ${SMAGE_LOG_CMD}   echo "!check detected; src_check() will not be run!" |& ${SMAGE_LOG_CMD}
427   else   else
428   ( run_resume src_check || src_check ) | ${SMAGE_LOG_CMD}   ( run_resume src_check || src_check ) |& ${SMAGE_LOG_CMD}
429   die_pipestatus 0 "src_check failed"   die_pipestatus 0 "src_check failed"
430   resume_stamp src_check   resume_stamp src_check
431   fi   fi
# Line 433  else Line 466  else
466   echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"   echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
467   echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."   echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
468    
469   ( run_resume src_install_${subpackage} || src_install_${subpackage} ) | ${SMAGE_LOG_CMD}   ( run_resume src_install_${subpackage} || src_install_${subpackage} ) |& ${SMAGE_LOG_CMD}
470   die_pipestatus 0 "src_install_${subpackage} failed"   die_pipestatus 0 "src_install_${subpackage} failed"
471   resume_stamp src_install_${subpackage}   resume_stamp src_install_${subpackage}
472   step_by_step src_install_${subpackage}   step_by_step src_install_${subpackage}
# Line 445  else Line 478  else
478   # unset all saved smage variables   # unset all saved smage variables
479   split_unset_variables   split_unset_variables
480   else   else
481   ( run_resume src_install || src_install ) | ${SMAGE_LOG_CMD}   ( run_resume src_install || src_install ) |& ${SMAGE_LOG_CMD}
482   die_pipestatus 0 "src_install failed"   die_pipestatus 0 "src_install failed"
483   resume_stamp src_install   resume_stamp src_install
484   step_by_step src_install   step_by_step src_install
# Line 482  else Line 515  else
515   echo -e "!compressdoc detected; documentation of '${subpackage}' will not be compressed ..."   echo -e "!compressdoc detected; documentation of '${subpackage}' will not be compressed ..."
516   elif mqueryfeature "!pkgbuild"   elif mqueryfeature "!pkgbuild"
517   then   then
518   echo "!pkgbuild detected; skipping documentation compression for '${subpackage}' ..."   echo "!pkgbuild detected; skipping documentation compression for '${subpackage}' ..."
519   else   else
520   run_resume post-mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage}   run_resume post-mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage}
521   resume_stamp post-mcompressdoc_${subpackage}   resume_stamp post-mcompressdoc_${subpackage}
522   fi   fi
523   # restore smage environment   # restore smage environment
524   split_restore_variables   split_restore_variables
# Line 693  if mqueryfeature "!pkgbuild" Line 726  if mqueryfeature "!pkgbuild"
726  then  then
727   echo -e "!pkgbuild detected; Package will not be build ..."   echo -e "!pkgbuild detected; Package will not be build ..."
728  else  else
  # build several targets  
  if [[ -n ${MAGE_TARGETS} ]]  
  then  
  for target in ${MAGE_TARGETS}  
  do  
  # check if a special target_pkgbuild exists  
  if typeset -f ${target}_pkgbuild > /dev/null  
  then  
  # run it  
  run_resume post-${target}_pkgbuild || ${target}_pkgbuild  
  resume_stamp post-${target}_pkgbuild  
  fi  
  # now create the target package  
  run_resume post-pkg_builddir_${target} || ${MLIBDIR}/pkgbuild_dir.sh \  
  "${PNAME}-${target}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" \  
  ${BINDIR} || die "target: ${target} package-build failed"  
  resume_stamp post-pkg_builddir_${target}  
   
  # build pkg-md5-sum if requested  
  run_resume post-md5sum_${target} || generate_package_md5sum \  
  --pcat "${PCAT}" \  
  --pname "${PNAME}" \  
  --pver "${PVER}" \  
  --pbuild "${PBUILD}" \  
  --parch "${ARCH}" \  
  --target "${target}"  
  resume_stamp post-md5sum_${target}  
   
  echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD} successfully builded.\n${COLDEFAULT}"  
  done  
   
729   # build several subpackages   # build several subpackages
730   elif [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
731   then   then
732   split_save_variables   split_save_variables
733   for subpackage in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
# Line 761  else Line 763  else
763   resume_stamp post-${PNAME}_pkgbuild   resume_stamp post-${PNAME}_pkgbuild
764   fi   fi
765   # now create the target package   # now create the target package
766   run_resume post-pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir.sh \   run_resume post-pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir \
767   "${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" \   "${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" \
768   "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"   "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
769   resume_stamp post-pkg_builddir_${PNAME}   resume_stamp post-pkg_builddir_${PNAME}
# Line 784  else Line 786  else
786   split_unset_variables   split_unset_variables
787    
788   else   else
789   run_resume post-pkg_builddir || ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   run_resume post-pkg_builddir || ${MLIBDIR}/pkgbuild_dir ${PKGNAME} ${BINDIR} || die "package-build failed"
790   resume_stamp post-pkg_builddir   resume_stamp post-pkg_builddir
791    
792   # build pkg-md5-sum if requested   # build pkg-md5-sum if requested
# Line 807  else Line 809  else
809   fi   fi
810  fi  fi
811    
812    # auto regen mage tree if requested
813    regen_mage_tree
814    
815  if mqueryfeature "buildlog"  if mqueryfeature "buildlog"
816  then  then
817   bzip2 -9f /var/log/smage/${PKGNAME}.log   bzip2 -9f ${SMAGELOGDIR}/${PKGNAME}.log
818  else  else
819   [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log   [[ -f ${SMAGELOGDIR}/${PKGNAME}.log ]] && rm ${SMAGELOGDIR}/${PKGNAME}.log
820  fi  fi
821    
822  xtitleclean  xtitleclean

Legend:
Removed from v.2157  
changed lines
  Added in v.3035