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 2042 by niro, Fri Feb 1 09:50:07 2013 UTC branches/mage-next/src/smage2.in revision 2631 by niro, Mon Mar 10 12:15:30 2014 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 280  SMAGE_LOG_CMD="tee -a /var/log/smage/${P Line 305  SMAGE_LOG_CMD="tee -a /var/log/smage/${P
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 318  export MAKEOPTS="${MAKEOPTS}" || die "MA Line 340  export MAKEOPTS="${MAKEOPTS}" || die "MA
340  # 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
341  mqueryfeature "distcc" && setup_distcc_environment  mqueryfeature "distcc" && setup_distcc_environment
342    
343    # setup icecc
344    # setup for icecc goes *before* ccache, so ccache comes before icecc in path
345    mqueryfeature "icecc" && setup_icecc_environment
346    
347  # setup ccache  # setup ccache
348  mqueryfeature "ccache" && setup_ccache_environment  mqueryfeature "ccache" && setup_ccache_environment
349    
# Line 471  else Line 497  else
497   do   do
498   # honor split_info   # honor split_info
499   split_info_${subpackage}   split_info_${subpackage}
500     if [[ ${PKGTYPE} = virtual ]]
501     then
502     # automatically set !pkgbuild here too
503     msetfeature "!pkgbuild"
504     fi
505    
506   if mqueryfeature "!compressdoc"   if mqueryfeature "!compressdoc"
507   then   then
508   echo -e "!compressdoc detected; documentation of '${subpackage}' will not be compressed ..."   echo -e "!compressdoc detected; documentation of '${subpackage}' will not be compressed ..."
509   elif mqueryfeature "!pkgbuild"   elif mqueryfeature "!pkgbuild"
510   then   then
511   echo "!pkgbuild detected; skipping documentation compression for '${subpackage}' ..."   echo "!pkgbuild detected; skipping documentation compression for '${subpackage}' ..."
512   else   else
513   run_resume post-mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage}   run_resume post-mcompressdoc_${subpackage} || mcompressdocs ${BINDIR}_${subpackage}
514   resume_stamp post-mcompressdoc_${subpackage}   resume_stamp post-mcompressdoc_${subpackage}
515   fi   fi
516   # restore smage environment   # restore smage environment
517   split_restore_variables   split_restore_variables
# Line 507  then Line 538  then
538   do   do
539   # honor split_info   # honor split_info
540   split_info_${subpackage}   split_info_${subpackage}
541     if [[ ${PKGTYPE} = virtual ]]
542     then
543     # automatically set !pkgbuild here too
544     msetfeature "!pkgbuild"
545     fi
546    
547   if mqueryfeature "!libtool"   if mqueryfeature "!libtool"
548   then   then
# Line 547  then Line 583  then
583   do   do
584   # honor split_info   # honor split_info
585   split_info_${subpackage}   split_info_${subpackage}
586     if [[ ${PKGTYPE} = virtual ]]
587     then
588     # automatically set !pkgbuild here too
589     msetfeature "!pkgbuild"
590     fi
591    
592   if mqueryfeature "purge"   if mqueryfeature "purge"
593   then   then
# Line 589  else Line 630  else
630   do   do
631   # honor split_info   # honor split_info
632   split_info_${subpackage}   split_info_${subpackage}
633     if [[ ${PKGTYPE} = virtual ]]
634     then
635     # automatically set !pkgbuild here too
636     msetfeature "!pkgbuild"
637     fi
638    
639   if mqueryfeature "!strip"   if mqueryfeature "!strip"
640   then   then
# Line 626  else Line 672  else
672   fi   fi
673  fi  fi
674    
675  if mqueryfeature "!pkgbuild"  if mqueryfeature "qalint"
676  then  then
677   echo -e "!pkgbuild detected; Package will not be build ..."   if mqueryfeature "!pkgbuild"
678  else   then
679   # build several targets   echo "!pkgbuild detected; skipping QA lint checks ..."
680   if [[ -n ${MAGE_TARGETS} ]]   else
681     if [[ -n ${SPLIT_PACKAGES} ]]
682   then   then
683   for target in ${MAGE_TARGETS}   # save smage environment
684     split_save_variables
685     for subpackage in ${SPLIT_PACKAGES}
686   do   do
687   # check if a special target_pkgbuild exists   # honor split_info
688   if typeset -f ${target}_pkgbuild > /dev/null   split_info_${subpackage}
689     if [[ ${PKGTYPE} = virtual ]]
690   then   then
691   # run it   # automatically set !pkgbuild here too
692   run_resume post-${target}_pkgbuild || ${target}_pkgbuild   msetfeature "!pkgbuild"
  resume_stamp post-${target}_pkgbuild  
693   fi   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}  
694    
695   # build pkg-md5-sum if requested   if mqueryfeature "qalint"
696   run_resume post-md5sum_${target} || generate_package_md5sum \   then
697   --pcat "${PCAT}" \   if mqueryfeature "!pkgbuild"
698   --pname "${PNAME}" \   then
699   --pver "${PVER}" \   echo "!pkgbuild detected; skipping QA lint checks for '${subpackage}' ..."
700   --pbuild "${PBUILD}" \   else
701   --parch "${ARCH}" \   echo -e "${COLBLUE}===${COLGREEN} running QA lint checks for '${subpackage}' ...${COLDEFAULT}"
702   --target "${target}"   mqalint ${BINDIR}_${subpackage}
703   resume_stamp post-md5sum_${target}   fi
704     fi
705    
706   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD} successfully builded.\n${COLDEFAULT}"   # restore smage environment
707     split_restore_variables
708   done   done
709     # unset saved variables
710     split_unset_variables
711     else
712     echo -e "${COLBLUE}===${COLGREEN} running QA lint checks ...${COLDEFAULT}"
713     mqalint ${BINDIR}
714     fi
715     fi
716    fi
717    
718    if mqueryfeature "!pkgbuild"
719    then
720     echo -e "!pkgbuild detected; Package will not be build ..."
721    else
722   # build several subpackages   # build several subpackages
723   elif [[ -n ${SPLIT_PACKAGES} ]]   if [[ -n ${SPLIT_PACKAGES} ]]
724   then   then
725   split_save_variables   split_save_variables
726   for subpackage in ${SPLIT_PACKAGES}   for subpackage in ${SPLIT_PACKAGES}
# Line 676  else Line 734  else
734   PCAT="${PCATEGORIE}"   PCAT="${PCATEGORIE}"
735   unset PCATEGORIE   unset PCATEGORIE
736   fi   fi
737     if [[ ${PKGTYPE} = virtual ]]
738     then
739     # automatically set !pkgbuild here too
740     msetfeature "!pkgbuild"
741     fi
742    
743   # jump to next one if !pkgbuild is set in split_info   # jump to next one if !pkgbuild is set in split_info
744   if mqueryfeature "!pkgbuild"   if mqueryfeature "!pkgbuild"
# Line 693  else Line 756  else
756   resume_stamp post-${PNAME}_pkgbuild   resume_stamp post-${PNAME}_pkgbuild
757   fi   fi
758   # now create the target package   # now create the target package
759   run_resume post-pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir.sh \   run_resume post-pkg_builddir_${PNAME} || ${MLIBDIR}/pkgbuild_dir \
760   "${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" \   "${PNAME}-${PVER}-${ARCH}$(print_distrotag)-${PBUILD}" \
761   "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"   "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
762   resume_stamp post-pkg_builddir_${PNAME}   resume_stamp post-pkg_builddir_${PNAME}
# Line 716  else Line 779  else
779   split_unset_variables   split_unset_variables
780    
781   else   else
782   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"
783   resume_stamp post-pkg_builddir   resume_stamp post-pkg_builddir
784    
785   # build pkg-md5-sum if requested   # build pkg-md5-sum if requested
# Line 739  else Line 802  else
802   fi   fi
803  fi  fi
804    
805    # auto regen mage tree if requested
806    regen_mage_tree
807    
808  if mqueryfeature "buildlog"  if mqueryfeature "buildlog"
809  then  then
810   bzip2 -9f /var/log/smage/${PKGNAME}.log   bzip2 -9f /var/log/smage/${PKGNAME}.log

Legend:
Removed from v.2042  
changed lines
  Added in v.2631