Magellan Linux

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

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

revision 600 by niro, Mon Nov 5 17:08:33 2007 UTC revision 1436 by niro, Mon Jul 25 11:59:49 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.60 2007-11-05 17:08:33 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    
75     # do not overide if local state was broken or disabled!
76     case ${STATE} in
77     broken) return ;;
78     disabled) return ;;
79     esac
80    
81     if [ -f ${SMAGESCRIPTSDIR}/distribution ]
82     then
83     source ${SMAGESCRIPTSDIR}/distribution
84     [[ -n ${STATE} ]] && mystate="${STATE}"
85     fi
86     # now switch state and export it
87     STATE="${mystate}"
88    }
89    
90  showversion()  showversion()
91  {  {
92   echo -en "Magellan Source Install v${SMAGEVERSION} "   echo -en "Magellan Source Install v${SMAGEVERSION} "
# Line 73  die() Line 101  die()
101   exit 1   exit 1
102  }  }
103    
104    die_pipestatus()
105    {
106     # the status change if we do any parameter declarations!!
107     # dont do this anymore, keep this in mind!
108     #
109     # local pos="$1"
110     # local comment="$2"
111     #
112     # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}"
113     #
114     [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2"
115    }
116    
117  xtitle()  xtitle()
118  {  {
119   if [[ ${TERM} = xterm ]]   if [[ ${TERM} = xterm ]]
# Line 140  download_sources() Line 181  download_sources()
181   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"   local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5"
182   local FETCHING   local FETCHING
183   local i mirror   local i mirror
184     local wget_opts
185    
186     # filter wget command if busybox was found
187     wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})"
188    
189   # install SRCDIR/PNAME if not exist   # install SRCDIR/PNAME if not exist
190   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}   [ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME}
191    
192   # check if FETCHING is needed   # check if FETCHING is needed
193   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null )
194   if [[ $? = 0 ]]   if [[ $? = 0 ]]
195   then   then
196   # md5's ok, no fetching needed   # md5's ok, no fetching needed
# Line 171  download_sources() Line 215  download_sources()
215   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"   my_SOURCEDIR="${SOURCEDIR}/${PNAME}"
216   fi   fi
217    
218     # create the SOURCEDIR
219     install -d ${my_SOURCEDIR}
220    
221   # if an mirrored file than replace first the mirror uri   # if an mirrored file than replace first the mirror uri
222   if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]   if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]
223   then   then
# Line 182  download_sources() Line 229  download_sources()
229   then   then
230   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
231   wget \   wget \
232   --passive-ftp \   ${wget_opts} \
233   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
234   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
235   if [[ $? = 0 ]]   if [[ $? = 0 ]]
236   then   then
# Line 206  download_sources() Line 250  download_sources()
250   then   then
251   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
252   wget \   wget \
253   --passive-ftp \   ${wget_opts} \
254   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
255   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
256   if [[ $? = 0 ]]   if [[ $? = 0 ]]
257   then   then
# Line 230  download_sources() Line 271  download_sources()
271   then   then
272   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
273   wget \   wget \
274   --passive-ftp \   ${wget_opts} \
275   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
276   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
277   if [[ $? = 0 ]]   if [[ $? = 0 ]]
278   then   then
# Line 254  download_sources() Line 292  download_sources()
292   then   then
293   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
294   wget \   wget \
295   --passive-ftp \   ${wget_opts} \
296   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
297   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
298   if [[ $? = 0 ]]   if [[ $? = 0 ]]
299   then   then
# Line 278  download_sources() Line 313  download_sources()
313   then   then
314   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
315   wget \   wget \
316   --passive-ftp \   ${wget_opts} \
317   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
318   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
319   if [[ $? = 0 ]]   if [[ $? = 0 ]]
320   then   then
# Line 297  download_sources() Line 329  download_sources()
329   then   then
330   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
331   wget \   wget \
332   --passive-ftp \   ${wget_opts} \
333   --tries 3 \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
  --continue \  
  --progress bar \  
  --directory-prefix="${my_SOURCEDIR}" \  
334   "${my_SRC_URI}"   "${my_SRC_URI}"
335   fi   fi
336   fi   fi
# Line 316  download_sources() Line 345  download_sources()
345   # recheck md5 sums   # recheck md5 sums
346   echo   echo
347   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
348   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   ( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed"
349   echo   echo
350    
351   # not needed anymore   # not needed anymore
# Line 362  mconfigure() Line 391  mconfigure()
391   ./configure \   ./configure \
392   --prefix=/usr \   --prefix=/usr \
393   --host=${CHOST} \   --host=${CHOST} \
394     --build=${CHOST} \
395   --mandir=/usr/share/man \   --mandir=/usr/share/man \
396   --infodir=/usr/share/info \   --infodir=/usr/share/info \
397   --datadir=/usr/share \   --datadir=/usr/share \
# Line 439  munpack() Line 469  munpack()
469   popd > /dev/null   popd > /dev/null
470   fi   fi
471   ;;   ;;
472     xz)
473     IFTAR="$(basename $SRCFILE .xz)"
474     IFTAR="${IFTAR##*.}"
475     if [[ ${IFTAR} = tar ]]
476     then
477     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed."
478     else
479     pushd ${DEST} > /dev/null
480     xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed."
481     popd > /dev/null
482     fi
483     ;;
484   tbz2|mpks|mpk)   tbz2|mpks|mpk)
485   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
486   ;;   ;;
487   tgz)   tgz)
488   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
489   ;;   ;;
490     txz|mpkzs|mpkz)
491     tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed."
492     ;;
493   rar)   rar)
494   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."   unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
495   ;;   ;;
# Line 452  munpack() Line 497  munpack()
497   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."   unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
498   ;;   ;;
499   rpm)   rpm)
500   pushd ${BUILDDIR} > /dev/null   pushd ${DEST} > /dev/null
501   rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."   rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
502   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."
503   [[ -f ${BUILDDIR}/${SRCFILE/.rpm/.tar.gz/} ]] && rm ${BUILDDIR}/${SRCFILE/.rpm/.tar.gz/}   if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
504     then
505     rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
506     fi
507   ;;   ;;
508   *)   *)
509   die "munpack failed"   die "munpack failed"
# Line 495  mpatch() Line 543  mpatch()
543  mlibtoolize()  mlibtoolize()
544  {  {
545   local opts="$@"   local opts="$@"
546   [[ -z ${opts} ]] && opts="--copy --force"   [[ -z ${opts} ]] && opts="--verbose --install --force"
547    
548   libtoolize ${opts} || die "running: mlibtoolize ${opts}"   libtoolize ${opts} || die "running: mlibtoolize ${opts}"
549  }  }
550    
551    mautoreconf()
552    {
553     local opts="$@"
554     [[ -z ${opts} ]] && opts="--verbose --install --force"
555    
556     autoreconf ${opts} || die "running: mautoreconf ${opts}"
557    }
558    
559  minstalldocs()  minstalldocs()
560  {  {
561   local docfiles   local docfiles
# Line 510  minstalldocs() Line 566  minstalldocs()
566   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs."
567   fi   fi
568    
569     local i
570   for i in ${docfiles}   for i in ${docfiles}
571   do   do
572   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."   if [ -f ${i} ]
573   install -m 0644 ${SRCDIR}/${i}.gz \   then
574   ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."   cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs."
575     install -m 0644 ${SRCDIR}/${i}.gz \
576     ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs."
577     fi
578   done   done
579  }  }
580    
# Line 534  mstripbins() Line 594  mstripbins()
594   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
595  }  }
596    
597    mcompressdocs()
598    {
599     local bindir="$@"
600    
601     if [ -d ${bindir}/usr/share/man ]
602     then
603     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
604     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
605     fi
606    
607     if [ -d ${bindir}/usr/share/info ]
608     then
609     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
610     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
611     fi
612    }
613    
614  sminclude()  sminclude()
615  {  {
616   local i   local i
# Line 647  EOF Line 724  EOF
724  # special tags:  # special tags:
725  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
726  #   INHERITS              which functions get included  #   INHERITS              which functions get included
727  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
728  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
729    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
730    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
731    #                         (only in the resulting magefile}
732  #  #
733  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
734  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 659  build_mage_script() Line 739  build_mage_script()
739   local magefile   local magefile
740   local dest   local dest
741   local target   local target
742     local split_pkg_base
743   local sym   local sym
744   local depname   local depname
745    
# Line 666  build_mage_script() Line 747  build_mage_script()
747   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
748    
749   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
750   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
751    
752     # mark package as splitpackage
753     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
754    
755   # name of magefile   # name of magefile
756   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 682  build_mage_script() Line 766  build_mage_script()
766   # now build the mage file   # now build the mage file
767   > ${dest}   > ${dest}
768    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.60 2007-11-05 17:08:33 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
769   # pgkname and state   # pgkname and state
770   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
771   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
772    
773   # description and homepage   # description and homepage
774   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
775   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
776    
777   # special tags and vars   # special tags and vars
778   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
779    
780   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
781   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
782   echo >> ${dest}  
783     # split package base
784     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
785    
786   # add special vars   # add special vars
787   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 712  build_mage_script() Line 792  build_mage_script()
792   # being tricky here :)   # being tricky here :)
793   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
794   done   done
  echo  >> ${dest}  
795   fi   fi
796    
797   # add at least all includes   # add at least all includes
# Line 724  build_mage_script() Line 803  build_mage_script()
803   do   do
804   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
805   done   done
806   echo  >> ${dest}   # a CRLF is needed here!
807     echo >> ${dest}
808   fi   fi
  echo >> ${dest}  
809    
810   # deps and provides   # deps and provides
811   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
812   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
813   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
814    
815   # add special functions   # add special functions
816   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 744  build_mage_script() Line 820  build_mage_script()
820   do   do
821   # add to mage (quotes needed !)   # add to mage (quotes needed !)
822   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
823   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
824   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
825   done   done
  echo  >> ${dest}  
826   fi   fi
827    
828   # pre|post-install|removes   # pre|post-install|removes
829   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
830   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
831   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
832   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
833  }  }
834    
835  regen_mage_tree()  regen_mage_tree()
836  {  {
837   local i   local subpackage
838    
839   # build them only if requested   # build them only if requested
840   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
841   then   then
842   # run it without targets   # run it without targets
843   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
844   then   then
845     # build for each target a mage file
846     # run it with several targets
847   echo   echo
848   build_mage_script   for subpackage in ${MAGE_TARGETS}
849     do
850     build_mage_script --target "${subpackage}"
851     done
852   echo   echo
  else  
853    
854   # build for each target an mage file   # run it for splitpackages
855     elif [[ -n ${SPLIT_PACKAGES} ]]
856     then
857     local split_pkg_base="${PNAME}"
858     # save smage environment
859     split_save_variables
860     # build for each subpackage a mage file
861   # run it with several targets   # run it with several targets
862   for i in ${MAGE_TARGETS}   echo
863     for subpackage in ${SPLIT_PACKAGES}
864   do   do
865   echo   # get the right variables for the split
866   build_mage_script "${i}"   export PNAME="${subpackage}"
867   echo   split_info_${subpackage}
868     # get the preinstall etc
869     split_export_inherits ${subpackage}
870     build_mage_script --split-pkg-base "${split_pkg_base}"
871     # delete split preinstall etc
872     split_delete_inherits ${subpackage}
873     # restore smage environment
874     split_restore_variables
875   done   done
876     echo
877     # unset all saved smage variables
878     split_unset_variables
879    
880     else
881     echo
882     build_mage_script
883     echo
884   fi   fi
885   fi   fi
886    
# Line 815  regen_mage_tree() Line 911  regen_mage_tree()
911   unset postremove   unset postremove
912  }  }
913    
914    split_save_variables()
915    {
916     export SAVED_PNAME="${PNAME}"
917     export SAVED_PVER="${PVER}"
918     export SAVED_PBUILD="${PBUILD}"
919     export SAVED_PCATEGORIE="${PCATEGORIE}"
920     export SAVED_DESCRIPTION="${DESCRIPTION}"
921     export SAVED_HOMEPAGE="${HOMEPAGE}"
922     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
923     export SAVED_STATE="${STATE}"
924     export SAVED_PKGTYPE="${PKGTYPE}"
925     export SAVED_INHERITS="${INHERITS}"
926     export SAVED_DEPEND="${DEPEND}"
927     export SAVED_SDEPEND="${SDEPEND}"
928     export SAVED_PROVIDE="${PROVIDE}"
929     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
930    
931     # bindir too
932     export SAVED_BINDIR="${BINDIR}"
933    
934     # export the SPLIT_PACKAGE_BASE
935     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
936    
937     # functions
938     if [[ ! -z $(typeset -f preinstall) ]]
939     then
940     # rename the old one
941     local saved_preinstall
942     saved_preinstall=SAVED_$(typeset -f preinstall)
943     eval "${saved_preinstall}"
944     export -f SAVED_preinstall
945     fi
946    
947     if [[ ! -z $(typeset -f postinstall) ]]
948     then
949     # rename the old one
950     local saved_postinstall
951     saved_postinstall=SAVED_$(typeset -f postinstall)
952     eval "${saved_postinstall}"
953     export -f SAVED_postinstall
954     fi
955    
956     if [[ ! -z $(typeset -f preremove) ]]
957     then
958     # rename the old one
959     local saved_preremove
960     saved_preremove=SAVED_$(typeset -f preremove)
961     eval "${saved_preremove}"
962     export -f SAVED_preremove
963     fi
964    
965     if [[ ! -z $(typeset -f postremove) ]]
966     then
967     # rename the old one
968     local saved_postremove
969     saved_postremove=SAVED_$(typeset -f postremove)
970     eval "${saved_postremove}"
971     export -f SAVED_postremove
972     fi
973    }
974    
975    split_restore_variables()
976    {
977     export PNAME="${SAVED_PNAME}"
978     export PVER="${SAVED_PVER}"
979     export PBUILD="${SAVED_PBUILD}"
980     export PCATEGORIE="${SAVED_PCATEGORIE}"
981     export DESCRIPTION="${SAVED_DESCRIPTION}"
982     export HOMEPAGE="${SAVED_HOMEPAGE}"
983     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
984     export STATE="${SAVED_STATE}"
985     export PKGTYPE="${SAVED_PKGTYPE}"
986     export INHERITS="${SAVED_INHERITS}"
987     export DEPEND="${SAVED_DEPEND}"
988     export SDEPEND="${SAVED_SDEPEND}"
989     export PROVIDE="${SAVED_PROVIDE}"
990     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
991    
992     # bindir too
993     export BINDIR="${SAVED_BINDIR}"
994    
995     # functions
996     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
997     then
998     # rename the old one
999     local saved_preinstall
1000     saved_preinstall=$(typeset -f SAVED_preinstall)
1001     eval "${saved_preinstall/SAVED_/}"
1002     export -f preinstall
1003     fi
1004    
1005     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
1006     then
1007     # rename the old one
1008     local saved_postinstall
1009     saved_postinstall=$(typeset -f SAVED_postinstall)
1010     eval "${saved_postinstall/SAVED_/}"
1011     export -f postinstall
1012     fi
1013    
1014     if [[ ! -z $(typeset -f SAVED_preremove) ]]
1015     then
1016     # rename the old one
1017     local saved_preremove
1018     saved_preremove=$(typeset -f SAVED_preremove)
1019     eval "${saved_preremove/SAVED_/}"
1020     export -f preremove
1021     fi
1022    
1023     if [[ ! -z $(typeset -f SAVED_postremove) ]]
1024     then
1025     # rename the old one
1026     local saved_postremove
1027     saved_postremove=$(typeset -f SAVED_postremove)
1028     eval "${saved_postremove/SAVED_/}"
1029     export -f postremove
1030     fi
1031    }
1032    
1033    split_unset_variables()
1034    {
1035     # unset saved vars; not needed anymore
1036     unset SAVED_PNAME
1037     unset SAVED_PVER
1038     unset SAVED_PBUILD
1039     unset SAVED_PCATEGORIE
1040     unset SAVED_DESCRIPTION
1041     unset SAVED_HOMEPAGE
1042     unset SAVED_SPECIAL_VARS
1043     unset SAVED_STATE
1044     unset SAVED_PKGTYPE
1045     unset SAVED_INHERITS
1046     unset SAVED_DEPEND
1047     unset SAVED_SDEPEND
1048     unset SAVED_PROVIDE
1049     unset SAVED_BINDIR
1050     unset SAVED_NOPKGBUILD
1051     unset SPLIT_PACKAGE_BASE
1052     unset -f SAVED_preinstall
1053     unset -f SAVED_postinstall
1054     unset -f SAVED_preremove
1055     unset -f SAVED_postremove
1056    }
1057    
1058    split_export_inherits()
1059    {
1060     local subpackage="$1"
1061     local func
1062     local newfunc
1063    
1064     for func in preinstall postinstall preremove postremove
1065     do
1066     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1067     then
1068     newfunc=$(typeset -f ${func}_${subpackage})
1069     newfunc="${newfunc/_${subpackage} (/ (}"
1070     eval "${newfunc}"
1071     fi
1072     done
1073    }
1074    
1075    split_delete_inherits()
1076    {
1077     local subpackage="$1"
1078     local func
1079    
1080     for func in preinstall postinstall preremove postremove
1081     do
1082     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1083     then
1084     unset -f ${func}
1085     fi
1086     done
1087     }
1088    
1089  export_inherits()  export_inherits()
1090  {  {
1091   local include="$1"   local include="$1"
# Line 876  generate_package_md5sum() Line 1147  generate_package_md5sum()
1147   # fix target as it may be empty !   # fix target as it may be empty !
1148   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1149    
1150    
1151   # build pkgname   # build pkgname
1152   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1153    
# Line 895  generate_package_md5sum() Line 1167  generate_package_md5sum()
1167   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1168    
1169   # setup md5 dir   # setup md5 dir
1170   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1171   install -d ${dest}   install -d ${dest}
1172    
1173   # gen md5sum   # gen md5sum
# Line 933  source_pkg_build() Line 1205  source_pkg_build()
1205   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}"
1206  }  }
1207    
1208    step_by_step()
1209    {
1210     if [[ ${STEP_BY_STEP} = true ]]
1211     then
1212     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1213     echo "Press [enter] to continue"
1214     read
1215     fi
1216    }
1217    
1218    
1219  # print out our version  # print out our version
1220  showversion  showversion
# Line 959  fi Line 1241  fi
1241  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1242  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1243  then  then
1244   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1245   then   then
1246   SMAGENAME="$2"   SMAGENAME="$2"
1247   MD5DIR="$3"   MD5DIR="$3"
1248   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1249    
1250     smagesource ${SMAGENAME} || die "download source failed"
1251    
1252   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1253   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1015  then Line 1299  then
1299   echo   echo
1300   else   else
1301   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1302   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1303   echo   echo
1304   echo   echo
1305   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1037  then Line 1321  then
1321   # get smage   # get smage
1322   SMAGENAME="$2"   SMAGENAME="$2"
1323   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1324   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1325    
1326   download_sources   download_sources
1327   exit 0   exit 0
# Line 1049  then Line 1333  then
1333   # set correct SMAGENAME   # set correct SMAGENAME
1334   SMAGENAME="$2"   SMAGENAME="$2"
1335   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1336   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1337    
1338   regen_mage_tree   regen_mage_tree
1339    
1340   # build md5sum for existing packages   # build several targets
1341   generate_package_md5sum \   if [[ -n ${MAGE_TARGETS} ]]
1342   --pcat "${PCATEGORIE}" \   then
1343   --pname "${PNAME}" \   for target in ${MAGE_TARGETS}
1344   --pver "${PVER}" \   do
1345   --pbuild "${PBUILD}" \   # build md5sum for existing packages
1346   --parch "${ARCH}" \   generate_package_md5sum \
1347   --target "${target}"   --pcat "${PCATEGORIE}" \
1348     --pname "${PNAME}" \
1349     --pver "${PVER}" \
1350     --pbuild "${PBUILD}" \
1351     --parch "${ARCH}" \
1352     --target "${target}"
1353     done
1354    
1355     # build several subpackages
1356     elif [[ -n ${SPLIT_PACKAGES} ]]
1357     then
1358     split_save_variables
1359     for subpackage in ${SPLIT_PACKAGES}
1360     do
1361     # get the right variables for the split
1362     export PNAME="${subpackage}"
1363     split_info_${subpackage}
1364     # build md5sum for existing packages
1365     generate_package_md5sum \
1366     --pcat "${PCATEGORIE}" \
1367     --pname "${PNAME}" \
1368     --pver "${PVER}" \
1369     --pbuild "${PBUILD}" \
1370     --parch "${ARCH}"
1371     # restore smage environment
1372     split_restore_variables
1373     done
1374     # unset all saved smage variables
1375     split_unset_variables
1376    
1377     else
1378     # build md5sum for existing packages
1379     generate_package_md5sum \
1380     --pcat "${PCATEGORIE}" \
1381     --pname "${PNAME}" \
1382     --pver "${PVER}" \
1383     --pbuild "${PBUILD}" \
1384     --parch "${ARCH}"
1385     fi
1386    
1387   exit 0   exit 0
1388  fi  fi
# Line 1073  then Line 1395  then
1395    
1396   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1397    
1398   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1399    
1400   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1401   then   then
# Line 1122  fi Line 1444  fi
1444  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1445  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1446    
1447  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1448  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1449  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1450    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1451    
1452  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1453  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
# Line 1199  then Line 1522  then
1522   mage rmstamp   mage rmstamp
1523  fi  fi
1524    
1525  src_prepare || die "src_prepare failed"  # setup build loggins
1526  src_compile || die "src_compile failed"  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1527  src_install || die "src_install failed"  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1528    
1529    src_prepare | ${SMAGE_LOG_CMD}
1530    die_pipestatus 0 "src_prepare failed"
1531    step_by_step $_
1532    
1533    src_compile | ${SMAGE_LOG_CMD}
1534    die_pipestatus 0 "src_compile failed"
1535    step_by_step $_
1536    
1537    # build several subpackages
1538  # compressing doc, info & man files  if [[ -n ${SPLIT_PACKAGES} ]]
 if [ -d ${BUILDDIR}/builded/usr/share/man ]  
1539  then  then
1540   echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"   # save bindir & pname
1541   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   split_save_variables
1542     export SAVED_BINDIR="${BINDIR}"
1543     for subpackage in ${SPLIT_PACKAGES}
1544     do
1545     if typeset -f src_install_${subpackage} > /dev/null
1546     then
1547     # export subpackage bindir
1548     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1549     # export PNAME, several internal function and include
1550     # rely on this variable
1551     export PNAME="${subpackage}"
1552    
1553     echo
1554     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1555     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1556     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1557     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1558    
1559     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1560     die_pipestatus 0 "src_install_${subpackage} failed"
1561     step_by_step $_
1562     fi
1563     done
1564     # restore bindir & pname
1565     split_restore_variables
1566     # unset all saved smage variables
1567     split_unset_variables
1568    else
1569     src_install | ${SMAGE_LOG_CMD}
1570     die_pipestatus 0 "src_install failed"
1571     step_by_step $_
1572  fi  fi
1573    
1574  if [ -d ${BUILDDIR}/builded/usr/share/info ]  # compressing doc, info & man files
1575    if [[ -n ${SPLIT_PACKAGES} ]]
1576  then  then
1577   echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1578   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   do
1579     mcompressdocs ${BINDIR}_${subpackage}
1580     done
1581    else
1582     mcompressdocs ${BINDIR}
1583  fi  fi
1584    
1585    
1586  # stripping all bins and libs  # stripping all bins and libs
1587  case ${NOSTRIP} in  case ${NOSTRIP} in
1588   true|TRUE|yes|y)   true|TRUE|yes|y)
1589   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1590   ;;   ;;
1591   *)   *)
1592   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   if [[ -n ${SPLIT_PACKAGES} ]]
1593   mstripbins ${BINDIR}   then
1594   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1595   mstriplibs ${BINDIR}   do
1596     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1597     mstripbins ${BINDIR}_${subpackage}
1598     echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}"
1599     mstriplibs ${BINDIR}_${subpackage}
1600     done
1601     else
1602     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1603     mstripbins ${BINDIR}
1604     echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1605     mstriplibs ${BINDIR}
1606     fi
1607   ;;   ;;
1608  esac  esac
1609    
# Line 1237  case ${NOPKGBUILD} in Line 1614  case ${NOPKGBUILD} in
1614   ;;   ;;
1615   *)   *)
1616   # build several targets   # build several targets
1617   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1618   then   then
1619   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1620   do   do
# Line 1263  case ${NOPKGBUILD} in Line 1640  case ${NOPKGBUILD} in
1640    
1641   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}"
1642   done   done
1643    
1644     # build several subpackages
1645     elif [[ -n ${SPLIT_PACKAGES} ]]
1646     then
1647     split_save_variables
1648     for subpackage in ${SPLIT_PACKAGES}
1649     do
1650     # get the right variables for the split
1651     export PNAME="${subpackage}"
1652     split_info_${PNAME}
1653    
1654     # jump to next one if NOPKGBUILD is set in split_info
1655     case ${NOPKGBUILD} in
1656     true|TRUE|yes|y) continue ;;
1657     esac
1658    
1659     # check if an special subpackage_pkgbuild exists
1660     if typeset -f ${PNAME}_pkgbuild > /dev/null
1661     then
1662     # run it
1663     ${PNAME}_pkgbuild
1664     fi
1665     # now create the target package
1666     ${MLIBDIR}/pkgbuild_dir.sh \
1667     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1668     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1669    
1670     # build pkg-md5-sum if requested
1671     generate_package_md5sum \
1672     --pcat "${PCATEGORIE}" \
1673     --pname "${PNAME}" \
1674     --pver "${PVER}" \
1675     --pbuild "${PBUILD}" \
1676     --parch "${ARCH}"
1677    
1678     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1679    
1680     # restore smage environment
1681     split_restore_variables
1682     done
1683     # unset all saved smage variables
1684     split_unset_variables
1685    
1686   else   else
1687   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1688    
# Line 1282  case ${NOPKGBUILD} in Line 1702  case ${NOPKGBUILD} in
1702   ;;   ;;
1703  esac  esac
1704    
1705    if [[ ${SMAGE_BUILD_LOGGING} != false ]]
1706    then
1707     bzip2 -9f /var/log/smage/${PKGNAME}.log
1708    else
1709     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1710    fi
1711    
1712  # for sure  # for sure
1713  unset NOPKGBUILD  unset NOPKGBUILD
1714  unset NOSTRIP  unset NOSTRIP

Legend:
Removed from v.600  
changed lines
  Added in v.1436