Magellan Linux

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

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

revision 602 by niro, Mon Nov 5 19:05:22 2007 UTC revision 1346 by niro, Sat Jun 4 09:20:09 2011 UTC
# Line 4  Line 4 
4  # needs pkgbuild_dir (mage)  # needs pkgbuild_dir (mage)
5    
6  # SMAGE2  # SMAGE2
7  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.61 2007-11-05 19:05:22 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $
8    
9  #01.10.2004  #01.10.2004
10  # added ccache support  # added ccache support
# Line 50  export LC_ALL=C Line 50  export LC_ALL=C
50    
51  source /etc/mage.rc.global  source /etc/mage.rc.global
52  source ${MAGERC}  source ${MAGERC}
53    source ${MLIBDIR}/mage4.functions.sh
54    
55  # set PKGDIR and BUILDDIR and BINDIR to MROOT  # set PKGDIR and BUILDDIR and BINDIR to MROOT
56  if [[ -n ${MROOT} ]]  if [[ -n ${MROOT} ]]
# Line 59  then Line 60  then
60   export BINDIR=${MROOT}/${BINDIR}   export BINDIR=${MROOT}/${BINDIR}
61  fi  fi
62    
63    # sources the smage file and uses state from distribution file if exist
64    # may helpful for repository support later on
65    smagesource()
66    {
67     local file="$1"
68     local mystate
69     local mycodename
70    
71     source ${file}
72    
73     [[ -n ${STATE} ]] && mystate="${STATE}"
74     if [ -f ${SMAGESCRIPTSDIR}/distribution ]
75     then
76     source ${SMAGESCRIPTSDIR}/distribution
77     [[ -n ${STATE} ]] && mystate="${STATE}"
78     fi
79     # now switch state and export it
80     STATE="${mystate}"
81    }
82    
83  showversion()  showversion()
84  {  {
85   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
# Line 73  die() Line 94  die()
94   exit 1   exit 1
95  }  }
96    
97    die_pipestatus()
98    {
99     # the status change if we do any parameter declarations!!
100     # dont do this anymore, keep this in mind!
101     #
102     # local pos="$1"
103     # local comment="$2"
104     #
105     # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}"
106     #
107     [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2"
108    }
109    
110  xtitle()  xtitle()
111  {  {
112   if [[ ${TERM} = xterm ]]   if [[ ${TERM} = xterm ]]
# Line 140  download_sources() Line 174  download_sources()
174   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
175   local FETCHING   local FETCHING
176   local i mirror   local i mirror
177     local wget_opts
178    
179     # filter wget command if busybox was found
180     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
181    
182   # install SRCDIR/PNAME if not exist   # install SRCDIR/PNAME if not exist
183   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
184    
185   # check if FETCHING is needed   # check if FETCHING is needed
186   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null )
187   if [[ $? = 0 ]]   if [[ $? = 0 ]]
188   then   then
189   # md5's ok, no fetching needed   # md5's ok, no fetching needed
# Line 171  download_sources() Line 208  download_sources()
208   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"
209   fi   fi
210    
211     # create the SOURCEDIR
212     install -d ${my_SOURCEDIR}
213    
214   # if an mirrored file than replace first the mirror uri   # if an mirrored file than replace first the mirror uri
215   if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]   if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]
216   then   then
# Line 182  download_sources() Line 222  download_sources()
222   then   then
223   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
224   wget \   wget \
225   --passive-ftp \   ${wget_opts} \
226   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
227   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
228   if [[ $? = 0 ]]   if [[ $? = 0 ]]
229   then   then
# Line 206  download_sources() Line 243  download_sources()
243   then   then
244   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
245   wget \   wget \
246   --passive-ftp \   ${wget_opts} \
247   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
248   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
249   if [[ $? = 0 ]]   if [[ $? = 0 ]]
250   then   then
# Line 230  download_sources() Line 264  download_sources()
264   then   then
265   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
266   wget \   wget \
267   --passive-ftp \   ${wget_opts} \
268   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
269   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
270   if [[ $? = 0 ]]   if [[ $? = 0 ]]
271   then   then
# Line 254  download_sources() Line 285  download_sources()
285   then   then
286   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
287   wget \   wget \
288   --passive-ftp \   ${wget_opts} \
289   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
290   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
291   if [[ $? = 0 ]]   if [[ $? = 0 ]]
292   then   then
# Line 278  download_sources() Line 306  download_sources()
306   then   then
307   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
308   wget \   wget \
309   --passive-ftp \   ${wget_opts} \
310   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
311   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
312   if [[ $? = 0 ]]   if [[ $? = 0 ]]
313   then   then
# Line 297  download_sources() Line 322  download_sources()
322   then   then
323   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
324   wget \   wget \
325   --passive-ftp \   ${wget_opts} \
326   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
327   "${my_SRC_URI}"   "${my_SRC_URI}"
328   fi   fi
329   fi   fi
# Line 316  download_sources() Line 338  download_sources()
338   # recheck md5 sums   # recheck md5 sums
339   echo   echo
340   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
341   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed"
342   echo   echo
343    
344   # not needed anymore   # not needed anymore
# Line 362  mconfigure() Line 384  mconfigure()
384   ./configure \   ./configure \
385   --prefix=/usr \   --prefix=/usr \
386   --host=${CHOST} \   --host=${CHOST} \
387     --build=${CHOST} \
388   --mandir=/usr/share/man \   --mandir=/usr/share/man \
389   --infodir=/usr/share/info \   --infodir=/usr/share/info \
390   --datadir=/usr/share \   --datadir=/usr/share \
# Line 452  munpack() Line 475  munpack()
475   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
476   ;;   ;;
477   rpm)   rpm)
478   pushd ${BUILDDIR} > /dev/null   pushd ${DEST} > /dev/null
479   rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."   rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
480   tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."   tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
481   if [[ -f ${BUILDDIR}/${SRCFILE/.rpm/.tar.gz} ]]   if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
482   then   then
483   rm ${BUILDDIR}/${SRCFILE/.rpm/.tar.gz}   rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
484   fi   fi
485   ;;   ;;
486   *)   *)
# Line 503  mlibtoolize() Line 526  mlibtoolize()
526   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
527  }  }
528    
529    mautoreconf()
530    {
531     local opts="$@"
532     [[ -z ${opts} ]] && opts="--verbose --install --force"
533    
534     autoreconf ${opts} || die "running: mautoreconf ${opts}"
535    }
536    
537  minstalldocs()  minstalldocs()
538  {  {
539   local docfiles   local docfiles
# Line 513  minstalldocs() Line 544  minstalldocs()
544   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
545   fi   fi
546    
547     local i
548   for i in ${docfiles}   for i in ${docfiles}
549   do   do
550   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${i} ]
551   install -m 0644 ${SRCDIR}/${i}.gz \   then
552   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
553     install -m 0644 ${SRCDIR}/${i}.gz \
554     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
555     fi
556   done   done
557  }  }
558    
# Line 537  mstripbins() Line 572  mstripbins()
572   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
573  }  }
574    
575    mcompressdocs()
576    {
577     local bindir="$@"
578    
579     if [ -d ${bindir}/usr/share/man ]
580     then
581     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
582     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
583     fi
584    
585     if [ -d ${bindir}/usr/share/info ]
586     then
587     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
588     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
589     fi
590    }
591    
592  sminclude()  sminclude()
593  {  {
594   local i   local i
# Line 650  EOF Line 702  EOF
702  # special tags:  # special tags:
703  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
704  #   INHERITS              which functions get included  #   INHERITS              which functions get included
705  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
706  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
707    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
708    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
709    #                         (only in the resulting magefile}
710  #  #
711  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
712  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 662  build_mage_script() Line 717  build_mage_script()
717   local magefile   local magefile
718   local dest   local dest
719   local target   local target
720     local split_pkg_base
721   local sym   local sym
722   local depname   local depname
723    
# Line 669  build_mage_script() Line 725  build_mage_script()
725   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
726    
727   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
728   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
729    
730     # mark package as splitpackage
731     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
732    
733   # name of magefile   # name of magefile
734   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 686  build_mage_script() Line 745  build_mage_script()
745   > ${dest}   > ${dest}
746    
747   # header   # header
748   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.61 2007-11-05 19:05:22 niro Exp $' >> ${dest}   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest}
749   echo  >> ${dest}   echo  >> ${dest}
750    
751   # pgkname and state   # pgkname and state
# Line 706  build_mage_script() Line 765  build_mage_script()
765   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
766   echo >> ${dest}   echo >> ${dest}
767    
768     # split package base
769     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
770     echo >> ${dest}
771    
772   # add special vars   # add special vars
773   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
774   then   then
# Line 773  regen_mage_tree() Line 836  regen_mage_tree()
836   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
837   then   then
838   # run it without targets   # run it without targets
839   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
840   then   then
841     # build for each target a mage file
842     # run it with several targets
843   echo   echo
844   build_mage_script   for i in ${MAGE_TARGETS}
845     do
846     build_mage_script --target "${i}"
847     done
848   echo   echo
  else  
849    
850   # build for each target an mage file   # run it for splitpackages
851     elif [[ -n ${SPLIT_PACKAGES} ]]
852     then
853     local split_pkg_base="${PNAME}"
854     # save smage environment
855     split_save_variables
856     # build for each subpackage a mage file
857   # run it with several targets   # run it with several targets
858   for i in ${MAGE_TARGETS}   echo
859     for i in ${SPLIT_PACKAGES}
860   do   do
861   echo   # get the right variables for the split
862   build_mage_script "${i}"   export PNAME="${i}"
863   echo   split_info_${i}
864     build_mage_script --split-pkg-base "${split_pkg_base}"
865     # restore smage environment
866     split_restore_variables
867   done   done
868     echo
869     # unset all saved smage variables
870     split_unset_variables
871    
872     else
873     echo
874     build_mage_script
875     echo
876   fi   fi
877   fi   fi
878    
# Line 818  regen_mage_tree() Line 903  regen_mage_tree()
903   unset postremove   unset postremove
904  }  }
905    
906    split_save_variables()
907    {
908     export SAVED_PNAME="${PNAME}"
909     export SAVED_PVER="${PVER}"
910     export SAVED_PBUILD="${PBUILD}"
911     export SAVED_PCATEGORIE="${PCATEGORIE}"
912     export SAVED_DESCRIPTION="${DESCRIPTION}"
913     export SAVED_HOMEPAGE="${HOMEPAGE}"
914     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
915     export SAVED_STATE="${STATE}"
916     export SAVED_PKGTYPE="${PKGTYPE}"
917     export SAVED_INHERITS="${INHERITS}"
918     export SAVED_DEPEND="${DEPEND}"
919     export SAVED_SDEPEND="${SDEPEND}"
920     export SAVED_PROVIDE="${PROVIDE}"
921     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
922    
923     # bindir too
924     export SAVED_BINDIR="${BINDIR}"
925    
926     # export the SPLIT_PACKAGE_BASE
927     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
928    
929     # functions
930     if [[ ! -z $(typeset -f preinstall) ]]
931     then
932     # rename the old one
933     local saved_preinstall
934     saved_preinstall=SAVED_$(typeset -f preinstall)
935     eval "${saved_preinstall}"
936     export -f SAVED_preinstall
937     fi
938    
939     if [[ ! -z $(typeset -f postinstall) ]]
940     then
941     # rename the old one
942     local saved_postinstall
943     saved_postinstall=SAVED_$(typeset -f postinstall)
944     eval "${saved_postinstall}"
945     export -f SAVED_postinstall
946     fi
947    
948     if [[ ! -z $(typeset -f preremove) ]]
949     then
950     # rename the old one
951     local saved_preremove
952     saved_preremove=SAVED_$(typeset -f preremove)
953     eval "${saved_preremove}"
954     export -f SAVED_preremove
955     fi
956    
957     if [[ ! -z $(typeset -f postremove) ]]
958     then
959     # rename the old one
960     local saved_postremove
961     saved_postremove=SAVED_$(typeset -f postremove)
962     eval "${saved_postremove}"
963     export -f SAVED_postremove
964     fi
965    }
966    
967    split_restore_variables()
968    {
969     export PNAME="${SAVED_PNAME}"
970     export PVER="${SAVED_PVER}"
971     export PBUILD="${SAVED_PBUILD}"
972     export PCATEGORIE="${SAVED_PCATEGORIE}"
973     export DESCRIPTION="${SAVED_DESCRIPTION}"
974     export HOMEPAGE="${SAVED_HOMEPAGE}"
975     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
976     export STATE="${SAVED_STATE}"
977     export PKGTYPE="${SAVED_PKGTYPE}"
978     export INHERITS="${SAVED_INHERITS}"
979     export DEPEND="${SAVED_DEPEND}"
980     export SDEPEND="${SAVED_SDEPEND}"
981     export PROVIDE="${SAVED_PROVIDE}"
982     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
983    
984     # bindir too
985     export BINDIR="${SAVED_BINDIR}"
986    
987     # functions
988     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
989     then
990     # rename the old one
991     local saved_preinstall
992     saved_preinstall=$(typeset -f SAVED_preinstall)
993     eval "${saved_preinstall/SAVED_/}"
994     export -f preinstall
995     fi
996    
997     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
998     then
999     # rename the old one
1000     local saved_postinstall
1001     saved_postinstall=$(typeset -f SAVED_postinstall)
1002     eval "${saved_postinstall/SAVED_/}"
1003     export -f postinstall
1004     fi
1005    
1006     if [[ ! -z $(typeset -f SAVED_preremove) ]]
1007     then
1008     # rename the old one
1009     local saved_preremove
1010     saved_preremove=$(typeset -f SAVED_preremove)
1011     eval "${saved_preremove/SAVED_/}"
1012     export -f preremove
1013     fi
1014    
1015     if [[ ! -z $(typeset -f SAVED_postremove) ]]
1016     then
1017     # rename the old one
1018     local saved_postremove
1019     saved_postremove=$(typeset -f SAVED_postremove)
1020     eval "${saved_postremove/SAVED_/}"
1021     export -f postremove
1022     fi
1023    }
1024    
1025    split_unset_variables()
1026    {
1027     # unset saved vars; not needed anymore
1028     unset SAVED_PNAME
1029     unset SAVED_PVER
1030     unset SAVED_PBUILD
1031     unset SAVED_PCATEGORIE
1032     unset SAVED_DESCRIPTION
1033     unset SAVED_HOMEPAGE
1034     unset SAVED_SPECIAL_VARS
1035     unset SAVED_STATE
1036     unset SAVED_PKGTYPE
1037     unset SAVED_INHERITS
1038     unset SAVED_DEPEND
1039     unset SAVED_SDEPEND
1040     unset SAVED_PROVIDE
1041     unset SAVED_BINDIR
1042     unset SAVED_NOPKGBUILD
1043     unset SPLIT_PACKAGE_BASE
1044     unset -f SAVED_preinstall
1045     unset -f SAVED_postinstall
1046     unset -f SAVED_preremove
1047     unset -f SAVED_postremove
1048    }
1049    
1050  export_inherits()  export_inherits()
1051  {  {
1052   local include="$1"   local include="$1"
# Line 879  generate_package_md5sum() Line 1108  generate_package_md5sum()
1108   # fix target as it may be empty !   # fix target as it may be empty !
1109   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1110    
1111    
1112   # build pkgname   # build pkgname
1113   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1114    
# Line 898  generate_package_md5sum() Line 1128  generate_package_md5sum()
1128   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1129    
1130   # setup md5 dir   # setup md5 dir
1131   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1132   install -d ${dest}   install -d ${dest}
1133    
1134   # gen md5sum   # gen md5sum
# Line 936  source_pkg_build() Line 1166  source_pkg_build()
1166   echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"   echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}"
1167  }  }
1168    
1169    step_by_step()
1170    {
1171     if [[ ${STEP_BY_STEP} = true ]]
1172     then
1173     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1174     echo "Press [enter] to continue"
1175     read
1176     fi
1177    }
1178    
1179    
1180  # print out our version  # print out our version
1181  showversion  showversion
# Line 962  fi Line 1202  fi
1202  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1203  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1204  then  then
1205   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1206   then   then
1207   SMAGENAME="$2"   SMAGENAME="$2"
1208   MD5DIR="$3"   MD5DIR="$3"
1209   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1210    
1211     smagesource ${SMAGENAME} || die "download source failed"
1212    
1213   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1214   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1018  then Line 1260  then
1260   echo   echo
1261   else   else
1262   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1263   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1264   echo   echo
1265   echo   echo
1266   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1040  then Line 1282  then
1282   # get smage   # get smage
1283   SMAGENAME="$2"   SMAGENAME="$2"
1284   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1285   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1286    
1287   download_sources   download_sources
1288   exit 0   exit 0
# Line 1052  then Line 1294  then
1294   # set correct SMAGENAME   # set correct SMAGENAME
1295   SMAGENAME="$2"   SMAGENAME="$2"
1296   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1297   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1298    
1299   regen_mage_tree   regen_mage_tree
1300    
1301   # build md5sum for existing packages   # build several targets
1302   generate_package_md5sum \   if [[ -n ${MAGE_TARGETS} ]]
1303   --pcat "${PCATEGORIE}" \   then
1304   --pname "${PNAME}" \   for target in ${MAGE_TARGETS}
1305   --pver "${PVER}" \   do
1306   --pbuild "${PBUILD}" \   # build md5sum for existing packages
1307   --parch "${ARCH}" \   generate_package_md5sum \
1308   --target "${target}"   --pcat "${PCATEGORIE}" \
1309     --pname "${PNAME}" \
1310     --pver "${PVER}" \
1311     --pbuild "${PBUILD}" \
1312     --parch "${ARCH}" \
1313     --target "${target}"
1314     done
1315    
1316     # build several subpackages
1317     elif [[ -n ${SPLIT_PACKAGES} ]]
1318     then
1319     split_save_variables
1320     for subpackage in ${SPLIT_PACKAGES}
1321     do
1322     # get the right variables for the split
1323     export PNAME="${subpackage}"
1324     split_info_${subpackage}
1325     # build md5sum for existing packages
1326     generate_package_md5sum \
1327     --pcat "${PCATEGORIE}" \
1328     --pname "${PNAME}" \
1329     --pver "${PVER}" \
1330     --pbuild "${PBUILD}" \
1331     --parch "${ARCH}"
1332     # restore smage environment
1333     split_restore_variables
1334     done
1335     # unset all saved smage variables
1336     split_unset_variables
1337    
1338     else
1339     # build md5sum for existing packages
1340     generate_package_md5sum \
1341     --pcat "${PCATEGORIE}" \
1342     --pname "${PNAME}" \
1343     --pver "${PVER}" \
1344     --pbuild "${PBUILD}" \
1345     --parch "${ARCH}"
1346     fi
1347    
1348   exit 0   exit 0
1349  fi  fi
# Line 1076  then Line 1356  then
1356    
1357   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1358    
1359   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1360    
1361   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1362   then   then
# Line 1125  fi Line 1405  fi
1405  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1406  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1407    
1408  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1409  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1410  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1411    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1412    
1413  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1414  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
# Line 1202  then Line 1483  then
1483   mage rmstamp   mage rmstamp
1484  fi  fi
1485    
1486  src_prepare || die "src_prepare failed"  # setup build loggins
1487  src_compile || die "src_compile failed"  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1488  src_install || die "src_install failed"  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1489    
1490    src_prepare | ${SMAGE_LOG_CMD}
1491    die_pipestatus 0 "src_prepare failed"
1492    step_by_step $_
1493    
1494    src_compile | ${SMAGE_LOG_CMD}
1495    die_pipestatus 0 "src_compile failed"
1496    step_by_step $_
1497    
1498  # compressing doc, info & man files  # build several subpackages
1499  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [[ -n ${SPLIT_PACKAGES} ]]
1500  then  then
1501   echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"   # save bindir & pname
1502   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   split_save_variables
1503     export SAVED_BINDIR="${BINDIR}"
1504     for subpackage in ${SPLIT_PACKAGES}
1505     do
1506     if typeset -f src_install_${subpackage} > /dev/null
1507     then
1508     # export subpackage bindir
1509     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1510     # export PNAME, several internal function and include
1511     # rely on this variable
1512     export PNAME="${subpackage}"
1513    
1514     echo
1515     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1516     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1517     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1518     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1519    
1520     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1521     die_pipestatus 0 "src_install_${subpackage} failed"
1522     step_by_step $_
1523     fi
1524     done
1525     # restore bindir & pname
1526     split_restore_variables
1527     # unset all saved smage variables
1528     split_unset_variables
1529    else
1530     src_install | ${SMAGE_LOG_CMD}
1531     die_pipestatus 0 "src_install failed"
1532     step_by_step $_
1533  fi  fi
1534    
1535  if [ -d ${BUILDDIR}/builded/usr/share/info ]  # compressing doc, info & man files
1536    if [[ -n ${SPLIT_PACKAGES} ]]
1537  then  then
1538   echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1539   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   do
1540     mcompressdocs ${BINDIR}_${subpackage}
1541     done
1542    else
1543     mcompressdocs ${BINDIR}
1544  fi  fi
1545    
1546    
1547  # stripping all bins and libs  # stripping all bins and libs
1548  case ${NOSTRIP} in  case ${NOSTRIP} in
1549   true|TRUE|yes|y)   true|TRUE|yes|y)
1550   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1551   ;;   ;;
1552   *)   *)
1553   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   if [[ -n ${SPLIT_PACKAGES} ]]
1554   mstripbins ${BINDIR}   then
1555   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1556   mstriplibs ${BINDIR}   do
1557     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1558     mstripbins ${BINDIR}_${subpackage}
1559     echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}"
1560     mstriplibs ${BINDIR}_${subpackage}
1561     done
1562     else
1563     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1564     mstripbins ${BINDIR}
1565     echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1566     mstriplibs ${BINDIR}
1567     fi
1568   ;;   ;;
1569  esac  esac
1570    
# Line 1240  case ${NOPKGBUILD} in Line 1575  case ${NOPKGBUILD} in
1575   ;;   ;;
1576   *)   *)
1577   # build several targets   # build several targets
1578   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1579   then   then
1580   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1581   do   do
# Line 1266  case ${NOPKGBUILD} in Line 1601  case ${NOPKGBUILD} in
1601    
1602   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1603   done   done
1604    
1605     # build several subpackages
1606     elif [[ -n ${SPLIT_PACKAGES} ]]
1607     then
1608     split_save_variables
1609     for subpackage in ${SPLIT_PACKAGES}
1610     do
1611     # get the right variables for the split
1612     export PNAME="${subpackage}"
1613     split_info_${PNAME}
1614    
1615     # jump to next one if NOPKGBUILD is set in split_info
1616     case ${NOPKGBUILD} in
1617     true|TRUE|yes|y) continue ;;
1618     esac
1619    
1620     # check if an special subpackage_pkgbuild exists
1621     if typeset -f ${PNAME}_pkgbuild > /dev/null
1622     then
1623     # run it
1624     ${PNAME}_pkgbuild
1625     fi
1626     # now create the target package
1627     ${MLIBDIR}/pkgbuild_dir.sh \
1628     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1629     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1630    
1631     # build pkg-md5-sum if requested
1632     generate_package_md5sum \
1633     --pcat "${PCATEGORIE}" \
1634     --pname "${PNAME}" \
1635     --pver "${PVER}" \
1636     --pbuild "${PBUILD}" \
1637     --parch "${ARCH}"
1638    
1639     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1640    
1641     # restore smage environment
1642     split_restore_variables
1643     done
1644     # unset all saved smage variables
1645     split_unset_variables
1646    
1647   else   else
1648   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1649    
# Line 1285  case ${NOPKGBUILD} in Line 1663  case ${NOPKGBUILD} in
1663   ;;   ;;
1664  esac  esac
1665    
1666    if [[ ${SMAGE_BUILD_LOGGING} != false ]]
1667    then
1668     bzip2 -9f /var/log/smage/${PKGNAME}.log
1669    else
1670     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1671    fi
1672    
1673  # for sure  # for sure
1674  unset NOPKGBUILD  unset NOPKGBUILD
1675  unset NOSTRIP  unset NOSTRIP

Legend:
Removed from v.602  
changed lines
  Added in v.1346