Magellan Linux

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

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

revision 447 by niro, Tue Mar 20 01:15:31 2007 UTC revision 1347 by niro, Sat Jun 4 09:25:44 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.55 2007-03-20 01:15:31 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})" \
269   --continue \   "${my_SRC_URI_MIRROR}"
270   --progress bar \   if [[ $? = 0 ]]
271   --directory-prefix="${my_SOURCEDIR}" \   then
272     break
273     else
274     continue
275     fi
276     fi
277     done
278     elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]
279     then
280     for mirror in ${KDE_MIRRORS}
281     do
282     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"
283    
284     if [[ ${FETCHING} = true ]]
285     then
286     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
287     wget \
288     ${wget_opts} \
289     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
290     "${my_SRC_URI_MIRROR}"
291     if [[ $? = 0 ]]
292     then
293     break
294     else
295     continue
296     fi
297     fi
298     done
299     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]
300     then
301     for mirror in ${GNOME_MIRRORS}
302     do
303     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"
304    
305     if [[ ${FETCHING} = true ]]
306     then
307     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
308     wget \
309     ${wget_opts} \
310     --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
311   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
312   if [[ $? = 0 ]]   if [[ $? = 0 ]]
313   then   then
# Line 249  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 268  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 314  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 357  munpack() Line 428  munpack()
428    
429   SRCFILE=$1   SRCFILE=$1
430    
431   if [ -z "$2" ]   if [[ -z $2 ]]
432   then   then
433   DEST=${BUILDDIR}   DEST=${BUILDDIR}
434   else   else
# Line 372  munpack() Line 443  munpack()
443   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
444   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
445   then   then
446   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed."
447     else
448     pushd ${DEST} > /dev/null
449     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
450     popd > /dev/null
451   fi   fi
452   ;;   ;;
453   gz)   gz)
# Line 380  munpack() Line 455  munpack()
455   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
456   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
457   then   then
458   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed."
459     else
460     pushd ${DEST} > /dev/null
461     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
462     popd > /dev/null
463   fi   fi
464   ;;   ;;
465   tbz2)   tbz2|mpks|mpk)
466   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
467   ;;   ;;
468   tgz)   tgz)
469   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
470     ;;
471     rar)
472     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
473     ;;
474     zip|xpi)
475     unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
476     ;;
477     rpm)
478     pushd ${DEST} > /dev/null
479     rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
480     tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
481     if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
482     then
483     rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
484     fi
485   ;;   ;;
486   *)   *)
487   die "munpack failed"   die "munpack failed"
# Line 424  mpatch() Line 518  mpatch()
518   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
519  }  }
520    
521    mlibtoolize()
522    {
523     local opts="$@"
524     [[ -z ${opts} ]] && opts="--copy --force"
525    
526     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  {  {
# Line 435  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 459  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 572  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 584  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 591  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 607  build_mage_script() Line 744  build_mage_script()
744   # now build the mage file   # now build the mage file
745   > ${dest}   > ${dest}
746    
  # header  
  echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.55 2007-03-20 01:15:31 niro Exp $' >> ${dest}  
  echo  >> ${dest}  
   
747   # pgkname and state   # pgkname and state
748   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
749   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
750    
751   # description and homepage   # description and homepage
752   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
753   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
754    
755   # special tags and vars   # special tags and vars
756   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
757    
758   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
759   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
760   echo >> ${dest}  
761     # split package base
762     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
763    
764   # add special vars   # add special vars
765   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 637  build_mage_script() Line 770  build_mage_script()
770   # being tricky here :)   # being tricky here :)
771   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
772   done   done
  echo  >> ${dest}  
773   fi   fi
774    
775   # add at least all includes   # add at least all includes
# Line 649  build_mage_script() Line 781  build_mage_script()
781   do   do
782   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
783   done   done
  echo  >> ${dest}  
784   fi   fi
  echo >> ${dest}  
785    
786   # deps and provides   # deps and provides
787   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
788   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
789   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
790    
791   # add special functions   # add special functions
792   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 669  build_mage_script() Line 796  build_mage_script()
796   do   do
797   # add to mage (quotes needed !)   # add to mage (quotes needed !)
798   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
799   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
800   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
801   done   done
  echo  >> ${dest}  
802   fi   fi
803    
804   # pre|post-install|removes   # pre|post-install|removes
805   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
806   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
807   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
808   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
809  }  }
810    
811  regen_mage_tree()  regen_mage_tree()
# Line 695  regen_mage_tree() Line 816  regen_mage_tree()
816   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
817   then   then
818   # run it without targets   # run it without targets
819   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
820   then   then
821     # build for each target a mage file
822     # run it with several targets
823   echo   echo
824   build_mage_script   for i in ${MAGE_TARGETS}
825     do
826     build_mage_script --target "${i}"
827     done
828   echo   echo
  else  
829    
830   # build for each target an mage file   # run it for splitpackages
831     elif [[ -n ${SPLIT_PACKAGES} ]]
832     then
833     local split_pkg_base="${PNAME}"
834     # save smage environment
835     split_save_variables
836     # build for each subpackage a mage file
837   # run it with several targets   # run it with several targets
838   for i in ${MAGE_TARGETS}   echo
839     for i in ${SPLIT_PACKAGES}
840   do   do
841   echo   # get the right variables for the split
842   build_mage_script "${i}"   export PNAME="${i}"
843   echo   split_info_${i}
844     build_mage_script --split-pkg-base "${split_pkg_base}"
845     # restore smage environment
846     split_restore_variables
847   done   done
848     echo
849     # unset all saved smage variables
850     split_unset_variables
851    
852     else
853     echo
854     build_mage_script
855     echo
856   fi   fi
857   fi   fi
858    
859   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
860   # unset PKGNAME <-- don't do that; smage needs this var   # unset PKGNAME <-- don't do that; smage needs this var
861   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
862   for i in ${SPECIAL_FUNCTIONS}  # for i in ${SPECIAL_FUNCTIONS}
863   do  # do
864   unset "${i}"  # unset "${i}"
865   done  # done
866   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
867   for i in ${SPECIAL_VARS}  # for i in ${SPECIAL_VARS}
868   do  # do
869   unset "${i}"  # unset "${i}"
870   done  # done
871   unset SPECIAL_VARS   unset SPECIAL_VARS
872   unset STATE   unset STATE
873   unset DESCRIPTION   unset DESCRIPTION
# Line 740  regen_mage_tree() Line 883  regen_mage_tree()
883   unset postremove   unset postremove
884  }  }
885    
886    split_save_variables()
887    {
888     export SAVED_PNAME="${PNAME}"
889     export SAVED_PVER="${PVER}"
890     export SAVED_PBUILD="${PBUILD}"
891     export SAVED_PCATEGORIE="${PCATEGORIE}"
892     export SAVED_DESCRIPTION="${DESCRIPTION}"
893     export SAVED_HOMEPAGE="${HOMEPAGE}"
894     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
895     export SAVED_STATE="${STATE}"
896     export SAVED_PKGTYPE="${PKGTYPE}"
897     export SAVED_INHERITS="${INHERITS}"
898     export SAVED_DEPEND="${DEPEND}"
899     export SAVED_SDEPEND="${SDEPEND}"
900     export SAVED_PROVIDE="${PROVIDE}"
901     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
902    
903     # bindir too
904     export SAVED_BINDIR="${BINDIR}"
905    
906     # export the SPLIT_PACKAGE_BASE
907     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
908    
909     # functions
910     if [[ ! -z $(typeset -f preinstall) ]]
911     then
912     # rename the old one
913     local saved_preinstall
914     saved_preinstall=SAVED_$(typeset -f preinstall)
915     eval "${saved_preinstall}"
916     export -f SAVED_preinstall
917     fi
918    
919     if [[ ! -z $(typeset -f postinstall) ]]
920     then
921     # rename the old one
922     local saved_postinstall
923     saved_postinstall=SAVED_$(typeset -f postinstall)
924     eval "${saved_postinstall}"
925     export -f SAVED_postinstall
926     fi
927    
928     if [[ ! -z $(typeset -f preremove) ]]
929     then
930     # rename the old one
931     local saved_preremove
932     saved_preremove=SAVED_$(typeset -f preremove)
933     eval "${saved_preremove}"
934     export -f SAVED_preremove
935     fi
936    
937     if [[ ! -z $(typeset -f postremove) ]]
938     then
939     # rename the old one
940     local saved_postremove
941     saved_postremove=SAVED_$(typeset -f postremove)
942     eval "${saved_postremove}"
943     export -f SAVED_postremove
944     fi
945    }
946    
947    split_restore_variables()
948    {
949     export PNAME="${SAVED_PNAME}"
950     export PVER="${SAVED_PVER}"
951     export PBUILD="${SAVED_PBUILD}"
952     export PCATEGORIE="${SAVED_PCATEGORIE}"
953     export DESCRIPTION="${SAVED_DESCRIPTION}"
954     export HOMEPAGE="${SAVED_HOMEPAGE}"
955     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
956     export STATE="${SAVED_STATE}"
957     export PKGTYPE="${SAVED_PKGTYPE}"
958     export INHERITS="${SAVED_INHERITS}"
959     export DEPEND="${SAVED_DEPEND}"
960     export SDEPEND="${SAVED_SDEPEND}"
961     export PROVIDE="${SAVED_PROVIDE}"
962     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
963    
964     # bindir too
965     export BINDIR="${SAVED_BINDIR}"
966    
967     # functions
968     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
969     then
970     # rename the old one
971     local saved_preinstall
972     saved_preinstall=$(typeset -f SAVED_preinstall)
973     eval "${saved_preinstall/SAVED_/}"
974     export -f preinstall
975     fi
976    
977     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
978     then
979     # rename the old one
980     local saved_postinstall
981     saved_postinstall=$(typeset -f SAVED_postinstall)
982     eval "${saved_postinstall/SAVED_/}"
983     export -f postinstall
984     fi
985    
986     if [[ ! -z $(typeset -f SAVED_preremove) ]]
987     then
988     # rename the old one
989     local saved_preremove
990     saved_preremove=$(typeset -f SAVED_preremove)
991     eval "${saved_preremove/SAVED_/}"
992     export -f preremove
993     fi
994    
995     if [[ ! -z $(typeset -f SAVED_postremove) ]]
996     then
997     # rename the old one
998     local saved_postremove
999     saved_postremove=$(typeset -f SAVED_postremove)
1000     eval "${saved_postremove/SAVED_/}"
1001     export -f postremove
1002     fi
1003    }
1004    
1005    split_unset_variables()
1006    {
1007     # unset saved vars; not needed anymore
1008     unset SAVED_PNAME
1009     unset SAVED_PVER
1010     unset SAVED_PBUILD
1011     unset SAVED_PCATEGORIE
1012     unset SAVED_DESCRIPTION
1013     unset SAVED_HOMEPAGE
1014     unset SAVED_SPECIAL_VARS
1015     unset SAVED_STATE
1016     unset SAVED_PKGTYPE
1017     unset SAVED_INHERITS
1018     unset SAVED_DEPEND
1019     unset SAVED_SDEPEND
1020     unset SAVED_PROVIDE
1021     unset SAVED_BINDIR
1022     unset SAVED_NOPKGBUILD
1023     unset SPLIT_PACKAGE_BASE
1024     unset -f SAVED_preinstall
1025     unset -f SAVED_postinstall
1026     unset -f SAVED_preremove
1027     unset -f SAVED_postremove
1028    }
1029    
1030  export_inherits()  export_inherits()
1031  {  {
1032   local include="$1"   local include="$1"
# Line 801  generate_package_md5sum() Line 1088  generate_package_md5sum()
1088   # fix target as it may be empty !   # fix target as it may be empty !
1089   [ -n "${target}" ] && target="-${target}"   [ -n "${target}" ] && target="-${target}"
1090    
1091    
1092   # build pkgname   # build pkgname
1093   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"   pkgname="${pname}${target}-${pver}-${parch}-${pbuild}"
1094    
# Line 820  generate_package_md5sum() Line 1108  generate_package_md5sum()
1108   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
1109    
1110   # setup md5 dir   # setup md5 dir
1111   dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5"   dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5"
1112   install -d ${dest}   install -d ${dest}
1113    
1114   # gen md5sum   # gen md5sum
# Line 858  source_pkg_build() Line 1146  source_pkg_build()
1146   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}"
1147  }  }
1148    
1149    step_by_step()
1150    {
1151     if [[ ${STEP_BY_STEP} = true ]]
1152     then
1153     echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1154     echo "Press [enter] to continue"
1155     read
1156     fi
1157    }
1158    
1159    
1160  # print out our version  # print out our version
1161  showversion  showversion
# Line 884  fi Line 1182  fi
1182  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1183  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1184  then  then
1185   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1186   then   then
1187   SMAGENAME="$2"   SMAGENAME="$2"
1188   MD5DIR="$3"   MD5DIR="$3"
1189   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1190    
1191     smagesource ${SMAGENAME} || die "download source failed"
1192    
1193   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1194   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 940  then Line 1240  then
1240   echo   echo
1241   else   else
1242   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1243   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1244   echo   echo
1245   echo   echo
1246   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 962  then Line 1262  then
1262   # get smage   # get smage
1263   SMAGENAME="$2"   SMAGENAME="$2"
1264   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1265   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1266    
1267   download_sources   download_sources
1268   exit 0   exit 0
# Line 974  then Line 1274  then
1274   # set correct SMAGENAME   # set correct SMAGENAME
1275   SMAGENAME="$2"   SMAGENAME="$2"
1276   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1277   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1278    
1279   regen_mage_tree   regen_mage_tree
1280    
1281   # build md5sum for existing packages   # build several targets
1282   generate_package_md5sum \   if [[ -n ${MAGE_TARGETS} ]]
1283   --pcat "${PCATEGORIE}" \   then
1284   --pname "${PNAME}" \   for target in ${MAGE_TARGETS}
1285   --pver "${PVER}" \   do
1286   --pbuild "${PBUILD}" \   # build md5sum for existing packages
1287   --parch "${ARCH}" \   generate_package_md5sum \
1288   --target "${target}"   --pcat "${PCATEGORIE}" \
1289     --pname "${PNAME}" \
1290     --pver "${PVER}" \
1291     --pbuild "${PBUILD}" \
1292     --parch "${ARCH}" \
1293     --target "${target}"
1294     done
1295    
1296     # build several subpackages
1297     elif [[ -n ${SPLIT_PACKAGES} ]]
1298     then
1299     split_save_variables
1300     for subpackage in ${SPLIT_PACKAGES}
1301     do
1302     # get the right variables for the split
1303     export PNAME="${subpackage}"
1304     split_info_${subpackage}
1305     # build md5sum for existing packages
1306     generate_package_md5sum \
1307     --pcat "${PCATEGORIE}" \
1308     --pname "${PNAME}" \
1309     --pver "${PVER}" \
1310     --pbuild "${PBUILD}" \
1311     --parch "${ARCH}"
1312     # restore smage environment
1313     split_restore_variables
1314     done
1315     # unset all saved smage variables
1316     split_unset_variables
1317    
1318     else
1319     # build md5sum for existing packages
1320     generate_package_md5sum \
1321     --pcat "${PCATEGORIE}" \
1322     --pname "${PNAME}" \
1323     --pver "${PVER}" \
1324     --pbuild "${PBUILD}" \
1325     --parch "${ARCH}"
1326     fi
1327    
1328   exit 0   exit 0
1329  fi  fi
# Line 998  then Line 1336  then
1336    
1337   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1338    
1339   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1340    
1341   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1342   then   then
# Line 1047  fi Line 1385  fi
1385  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1386  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1387    
1388  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1389  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1390  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1391    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1392    
1393  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1394  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
# Line 1124  then Line 1463  then
1463   mage rmstamp   mage rmstamp
1464  fi  fi
1465    
1466  src_prepare || die "src_prepare failed"  # setup build loggins
1467  src_compile || die "src_compile failed"  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1468  src_install || die "src_install failed"  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1469    
1470    src_prepare | ${SMAGE_LOG_CMD}
1471    die_pipestatus 0 "src_prepare failed"
1472    step_by_step $_
1473    
1474    src_compile | ${SMAGE_LOG_CMD}
1475    die_pipestatus 0 "src_compile failed"
1476    step_by_step $_
1477    
1478    # build several subpackages
1479  # compressing doc, info & man files  if [[ -n ${SPLIT_PACKAGES} ]]
 if [ -d ${BUILDDIR}/builded/usr/share/man ]  
1480  then  then
1481   echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"   # save bindir & pname
1482   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   split_save_variables
1483     export SAVED_BINDIR="${BINDIR}"
1484     for subpackage in ${SPLIT_PACKAGES}
1485     do
1486     if typeset -f src_install_${subpackage} > /dev/null
1487     then
1488     # export subpackage bindir
1489     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1490     # export PNAME, several internal function and include
1491     # rely on this variable
1492     export PNAME="${subpackage}"
1493    
1494     echo
1495     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1496     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1497     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1498     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1499    
1500     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1501     die_pipestatus 0 "src_install_${subpackage} failed"
1502     step_by_step $_
1503     fi
1504     done
1505     # restore bindir & pname
1506     split_restore_variables
1507     # unset all saved smage variables
1508     split_unset_variables
1509    else
1510     src_install | ${SMAGE_LOG_CMD}
1511     die_pipestatus 0 "src_install failed"
1512     step_by_step $_
1513  fi  fi
1514    
1515  if [ -d ${BUILDDIR}/builded/usr/share/info ]  # compressing doc, info & man files
1516    if [[ -n ${SPLIT_PACKAGES} ]]
1517  then  then
1518   echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1519   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   do
1520     mcompressdocs ${BINDIR}_${subpackage}
1521     done
1522    else
1523     mcompressdocs ${BINDIR}
1524  fi  fi
1525    
1526    
1527  # stripping all bins and libs  # stripping all bins and libs
1528  case ${NOSTRIP} in  case ${NOSTRIP} in
1529   true|TRUE|yes|y)   true|TRUE|yes|y)
1530   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1531   ;;   ;;
1532   *)   *)
1533   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   if [[ -n ${SPLIT_PACKAGES} ]]
1534   mstripbins ${BINDIR}   then
1535   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1536   mstriplibs ${BINDIR}   do
1537     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1538     mstripbins ${BINDIR}_${subpackage}
1539     echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}"
1540     mstriplibs ${BINDIR}_${subpackage}
1541     done
1542     else
1543     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1544     mstripbins ${BINDIR}
1545     echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1546     mstriplibs ${BINDIR}
1547     fi
1548   ;;   ;;
1549  esac  esac
1550    
# Line 1162  case ${NOPKGBUILD} in Line 1555  case ${NOPKGBUILD} in
1555   ;;   ;;
1556   *)   *)
1557   # build several targets   # build several targets
1558   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1559   then   then
1560   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1561   do   do
# Line 1188  case ${NOPKGBUILD} in Line 1581  case ${NOPKGBUILD} in
1581    
1582   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}"
1583   done   done
1584    
1585     # build several subpackages
1586     elif [[ -n ${SPLIT_PACKAGES} ]]
1587     then
1588     split_save_variables
1589     for subpackage in ${SPLIT_PACKAGES}
1590     do
1591     # get the right variables for the split
1592     export PNAME="${subpackage}"
1593     split_info_${PNAME}
1594    
1595     # jump to next one if NOPKGBUILD is set in split_info
1596     case ${NOPKGBUILD} in
1597     true|TRUE|yes|y) continue ;;
1598     esac
1599    
1600     # check if an special subpackage_pkgbuild exists
1601     if typeset -f ${PNAME}_pkgbuild > /dev/null
1602     then
1603     # run it
1604     ${PNAME}_pkgbuild
1605     fi
1606     # now create the target package
1607     ${MLIBDIR}/pkgbuild_dir.sh \
1608     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1609     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1610    
1611     # build pkg-md5-sum if requested
1612     generate_package_md5sum \
1613     --pcat "${PCATEGORIE}" \
1614     --pname "${PNAME}" \
1615     --pver "${PVER}" \
1616     --pbuild "${PBUILD}" \
1617     --parch "${ARCH}"
1618    
1619     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1620    
1621     # restore smage environment
1622     split_restore_variables
1623     done
1624     # unset all saved smage variables
1625     split_unset_variables
1626    
1627   else   else
1628   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1629    
# Line 1207  case ${NOPKGBUILD} in Line 1643  case ${NOPKGBUILD} in
1643   ;;   ;;
1644  esac  esac
1645    
1646    if [[ ${SMAGE_BUILD_LOGGING} != false ]]
1647    then
1648     bzip2 -9f /var/log/smage/${PKGNAME}.log
1649    else
1650     [[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log
1651    fi
1652    
1653  # for sure  # for sure
1654  unset NOPKGBUILD  unset NOPKGBUILD
1655  unset NOSTRIP  unset NOSTRIP

Legend:
Removed from v.447  
changed lines
  Added in v.1347