Magellan Linux

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

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

revision 891 by niro, Tue Aug 4 19:51:42 2009 UTC revision 1543 by niro, Tue Dec 20 16:06:13 2011 UTC
# Line 20  SMAGENAME="$1" Line 20  SMAGENAME="$1"
20  SMAGESUFFIX="smage2"  SMAGESUFFIX="smage2"
21  MLIBDIR=/usr/lib/mage  MLIBDIR=/usr/lib/mage
22  SMAGEVERSION="$( < ${MLIBDIR}/version)"  SMAGEVERSION="$( < ${MLIBDIR}/version)"
 SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"  
   
23    
24  ## only for tests -> normally in /etc/rc.d/init.d/functions  ## only for tests -> normally in /etc/rc.d/init.d/functions
25  COLRED="\033[1;6m\033[31m"  COLRED="\033[1;6m\033[31m"
# Line 52  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 61  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 75  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 142  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 187  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} \
  --tries 3 \  
  --continue \  
  --progress bar \  
233   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
234   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
235   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 211  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} \
  --tries 3 \  
  --continue \  
  --progress bar \  
254   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
255   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
256   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 235  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} \
  --tries 3 \  
  --continue \  
  --progress bar \  
275   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
276   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
277   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 259  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} \
  --tries 3 \  
  --continue \  
  --progress bar \  
296   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
297   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
298   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 283  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} \
  --tries 3 \  
  --continue \  
  --progress bar \  
317   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \
318   "${my_SRC_URI_MIRROR}"   "${my_SRC_URI_MIRROR}"
319   if [[ $? = 0 ]]   if [[ $? = 0 ]]
# Line 302  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} \
  --tries 3 \  
  --continue \  
  --progress bar \  
333   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \   --output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \
334   "${my_SRC_URI}"   "${my_SRC_URI}"
335   fi   fi
# Line 321  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 445  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 504  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 519  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 532  mstriplibs() Line 583  mstriplibs()
583   local stripdir="$@"   local stripdir="$@"
584    
585   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
586   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null   find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_LIB} 2> /dev/null
587  }  }
588    
589  mstripbins()  mstripbins()
# Line 540  mstripbins() Line 591  mstripbins()
591   local stripdir="$@"   local stripdir="$@"
592    
593   [ -z "${stripdir}" ] && stripdir=${BINDIR}   [ -z "${stripdir}" ] && stripdir=${BINDIR}
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_DYN_BIN} 2> /dev/null
595    }
596    
597    mstripstatic()
598    {
599     local stripdir="$@"
600    
601     [ -z "${stripdir}" ] && stripdir=${BINDIR}
602     find ${stripdir} | xargs file | grep "ar archive" | cut -f 1 -d : | xargs strip ${STRIP_STATIC_LIB} 2> /dev/null
603    }
604    
605    mcompressdocs()
606    {
607     local bindir="$@"
608    
609     if [ -d ${bindir}/usr/share/man ]
610     then
611     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
612     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
613     fi
614    
615     if [ -d ${bindir}/usr/share/info ]
616     then
617     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
618     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
619     fi
620  }  }
621    
622  sminclude()  sminclude()
# Line 658  EOF Line 734  EOF
734  #   INHERITS              which functions get included  #   INHERITS              which functions get included
735  #   SPECIAL_FUNCTIONS     special functions which should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
736  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
737    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
738    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
739    #                         (only in the resulting magefile}
740  #  #
741  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
742  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 668  build_mage_script() Line 747  build_mage_script()
747   local magefile   local magefile
748   local dest   local dest
749   local target   local target
750     local split_pkg_base
751   local sym   local sym
752   local depname   local depname
753    
# Line 675  build_mage_script() Line 755  build_mage_script()
755   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
756    
757   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
758   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
759    
760     # mark package as splitpackage
761     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
762    
763   # name of magefile   # name of magefile
764   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 691  build_mage_script() Line 774  build_mage_script()
774   # now build the mage file   # now build the mage file
775   > ${dest}   > ${dest}
776    
  # header  
  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}  
  echo  >> ${dest}  
   
777   # pgkname and state   # pgkname and state
778   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}   echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
779   echo "STATE=\"${STATE}\"" >> ${dest}   echo "STATE=\"${STATE}\"" >> ${dest}
  echo >> ${dest}  
780    
781   # description and homepage   # description and homepage
782   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}   echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
783   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}   echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
  echo >> ${dest}  
784    
785   # special tags and vars   # special tags and vars
786   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}   echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
787    
788   # echo MAGE_TARGETS ## note -target is needed !   # echo MAGE_TARGETS ## note -target is needed !
789   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
790   echo >> ${dest}  
791     # split package base
792     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
793    
794   # add special vars   # add special vars
795   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
# Line 721  build_mage_script() Line 800  build_mage_script()
800   # being tricky here :)   # being tricky here :)
801   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}   echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
802   done   done
  echo  >> ${dest}  
803   fi   fi
804    
805   # add at least all includes   # add at least all includes
# Line 733  build_mage_script() Line 811  build_mage_script()
811   do   do
812   echo -n " ${i}"  >> ${dest}   echo -n " ${i}"  >> ${dest}
813   done   done
814   echo  >> ${dest}   # a CRLF is needed here!
815     echo >> ${dest}
816   fi   fi
  echo >> ${dest}  
817    
818   # deps and provides   # deps and provides
819   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}   echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
  echo >> ${dest}  
820   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}   echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
  echo >> ${dest}  
821   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}   echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
  echo >> ${dest}  
822    
823   # add special functions   # add special functions
824   if [ -n "${SPECIAL_FUNCTIONS}" ]   if [ -n "${SPECIAL_FUNCTIONS}" ]
# Line 753  build_mage_script() Line 828  build_mage_script()
828   do   do
829   # add to mage (quotes needed !)   # add to mage (quotes needed !)
830   typeset -f "${i}" >> ${dest}   typeset -f "${i}" >> ${dest}
  echo >> ${dest}  
831   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
832   #unset "${i}" <-- later to get every target built   #unset "${i}" <-- later to get every target built
833   done   done
  echo  >> ${dest}  
834   fi   fi
835    
836   # pre|post-install|removes   # pre|post-install|removes
837   typeset -f preinstall >> ${dest}   typeset -f preinstall >> ${dest}
  echo  >> ${dest}  
838   typeset -f postinstall >> ${dest}   typeset -f postinstall >> ${dest}
  echo  >> ${dest}  
839   typeset -f preremove >> ${dest}   typeset -f preremove >> ${dest}
  echo  >> ${dest}  
840   typeset -f postremove >> ${dest}   typeset -f postremove >> ${dest}
  echo  >> ${dest}  
841  }  }
842    
843  regen_mage_tree()  regen_mage_tree()
844  {  {
845   local i   local subpackage
846    
847   # build them only if requested   # build them only if requested
848   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
849   then   then
850   # run it without targets   # run it without targets
851   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
852   then   then
853     # build for each target a mage file
854     # run it with several targets
855   echo   echo
856   build_mage_script   for subpackage in ${MAGE_TARGETS}
857     do
858     build_mage_script --target "${subpackage}"
859     done
860   echo   echo
  else  
861    
862   # build for each target an mage file   # run it for splitpackages
863     elif [[ -n ${SPLIT_PACKAGES} ]]
864     then
865     local split_pkg_base="${PNAME}"
866     # save smage environment
867     split_save_variables
868     # build for each subpackage a mage file
869   # run it with several targets   # run it with several targets
870   for i in ${MAGE_TARGETS}   echo
871     for subpackage in ${SPLIT_PACKAGES}
872   do   do
873   echo   # get the right variables for the split
874   build_mage_script "${i}"   export PNAME="${subpackage}"
875   echo   split_info_${subpackage}
876     # get the preinstall etc
877     split_export_inherits ${subpackage}
878     build_mage_script --split-pkg-base "${split_pkg_base}"
879     # delete split preinstall etc
880     split_delete_inherits ${subpackage}
881     # restore smage environment
882     split_restore_variables
883   done   done
884     echo
885     # unset all saved smage variables
886     split_unset_variables
887    
888     else
889     echo
890     build_mage_script
891     echo
892   fi   fi
893   fi   fi
894    
# Line 824  regen_mage_tree() Line 919  regen_mage_tree()
919   unset postremove   unset postremove
920  }  }
921    
922    split_save_variables()
923    {
924     export SAVED_PNAME="${PNAME}"
925     export SAVED_PVER="${PVER}"
926     export SAVED_PBUILD="${PBUILD}"
927     export SAVED_PCATEGORIE="${PCATEGORIE}"
928     export SAVED_DESCRIPTION="${DESCRIPTION}"
929     export SAVED_HOMEPAGE="${HOMEPAGE}"
930     export SAVED_SPECIAL_VARS="${SPECIAL_VARS}"
931     export SAVED_STATE="${STATE}"
932     export SAVED_PKGTYPE="${PKGTYPE}"
933     export SAVED_INHERITS="${INHERITS}"
934     export SAVED_DEPEND="${DEPEND}"
935     export SAVED_SDEPEND="${SDEPEND}"
936     export SAVED_PROVIDE="${PROVIDE}"
937     export SAVED_NOPKGBUILD="${NOPKGBUILD}"
938    
939     # bindir too
940     export SAVED_BINDIR="${BINDIR}"
941    
942     # export the SPLIT_PACKAGE_BASE
943     export SPLIT_PACKAGE_BASE="${SAVED_PNAME}"
944    
945     # functions
946     if [[ ! -z $(typeset -f preinstall) ]]
947     then
948     # rename the old one
949     local saved_preinstall
950     saved_preinstall=SAVED_$(typeset -f preinstall)
951     eval "${saved_preinstall}"
952     export -f SAVED_preinstall
953     fi
954    
955     if [[ ! -z $(typeset -f postinstall) ]]
956     then
957     # rename the old one
958     local saved_postinstall
959     saved_postinstall=SAVED_$(typeset -f postinstall)
960     eval "${saved_postinstall}"
961     export -f SAVED_postinstall
962     fi
963    
964     if [[ ! -z $(typeset -f preremove) ]]
965     then
966     # rename the old one
967     local saved_preremove
968     saved_preremove=SAVED_$(typeset -f preremove)
969     eval "${saved_preremove}"
970     export -f SAVED_preremove
971     fi
972    
973     if [[ ! -z $(typeset -f postremove) ]]
974     then
975     # rename the old one
976     local saved_postremove
977     saved_postremove=SAVED_$(typeset -f postremove)
978     eval "${saved_postremove}"
979     export -f SAVED_postremove
980     fi
981    }
982    
983    split_restore_variables()
984    {
985     export PNAME="${SAVED_PNAME}"
986     export PVER="${SAVED_PVER}"
987     export PBUILD="${SAVED_PBUILD}"
988     export PCATEGORIE="${SAVED_PCATEGORIE}"
989     export DESCRIPTION="${SAVED_DESCRIPTION}"
990     export HOMEPAGE="${SAVED_HOMEPAGE}"
991     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
992     export STATE="${SAVED_STATE}"
993     export PKGTYPE="${SAVED_PKGTYPE}"
994     export INHERITS="${SAVED_INHERITS}"
995     export DEPEND="${SAVED_DEPEND}"
996     export SDEPEND="${SAVED_SDEPEND}"
997     export PROVIDE="${SAVED_PROVIDE}"
998     export NOPKGBUILD="${SAVED_NOPKGBUILD}"
999    
1000     # bindir too
1001     export BINDIR="${SAVED_BINDIR}"
1002    
1003     # functions
1004     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
1005     then
1006     # rename the old one
1007     local saved_preinstall
1008     saved_preinstall=$(typeset -f SAVED_preinstall)
1009     eval "${saved_preinstall/SAVED_/}"
1010     export -f preinstall
1011     fi
1012    
1013     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
1014     then
1015     # rename the old one
1016     local saved_postinstall
1017     saved_postinstall=$(typeset -f SAVED_postinstall)
1018     eval "${saved_postinstall/SAVED_/}"
1019     export -f postinstall
1020     fi
1021    
1022     if [[ ! -z $(typeset -f SAVED_preremove) ]]
1023     then
1024     # rename the old one
1025     local saved_preremove
1026     saved_preremove=$(typeset -f SAVED_preremove)
1027     eval "${saved_preremove/SAVED_/}"
1028     export -f preremove
1029     fi
1030    
1031     if [[ ! -z $(typeset -f SAVED_postremove) ]]
1032     then
1033     # rename the old one
1034     local saved_postremove
1035     saved_postremove=$(typeset -f SAVED_postremove)
1036     eval "${saved_postremove/SAVED_/}"
1037     export -f postremove
1038     fi
1039    }
1040    
1041    split_unset_variables()
1042    {
1043     # unset saved vars; not needed anymore
1044     unset SAVED_PNAME
1045     unset SAVED_PVER
1046     unset SAVED_PBUILD
1047     unset SAVED_PCATEGORIE
1048     unset SAVED_DESCRIPTION
1049     unset SAVED_HOMEPAGE
1050     unset SAVED_SPECIAL_VARS
1051     unset SAVED_STATE
1052     unset SAVED_PKGTYPE
1053     unset SAVED_INHERITS
1054     unset SAVED_DEPEND
1055     unset SAVED_SDEPEND
1056     unset SAVED_PROVIDE
1057     unset SAVED_BINDIR
1058     unset SAVED_NOPKGBUILD
1059     unset SPLIT_PACKAGE_BASE
1060     unset -f SAVED_preinstall
1061     unset -f SAVED_postinstall
1062     unset -f SAVED_preremove
1063     unset -f SAVED_postremove
1064    }
1065    
1066    split_export_inherits()
1067    {
1068     local subpackage="$1"
1069     local func
1070     local newfunc
1071    
1072     for func in preinstall postinstall preremove postremove
1073     do
1074     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1075     then
1076     newfunc=$(typeset -f ${func}_${subpackage})
1077     newfunc="${newfunc/_${subpackage} (/ (}"
1078     eval "${newfunc}"
1079     fi
1080     done
1081    }
1082    
1083    split_delete_inherits()
1084    {
1085     local subpackage="$1"
1086     local func
1087    
1088     for func in preinstall postinstall preremove postremove
1089     do
1090     if [[ ! -z $(typeset -f ${func}_${subpackage}) ]]
1091     then
1092     unset -f ${func}
1093     fi
1094     done
1095     }
1096    
1097  export_inherits()  export_inherits()
1098  {  {
1099   local include="$1"   local include="$1"
# Line 947  step_by_step() Line 1217  step_by_step()
1217  {  {
1218   if [[ ${STEP_BY_STEP} = true ]]   if [[ ${STEP_BY_STEP} = true ]]
1219   then   then
1220   echo "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"   echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}"
1221   echo "Press [enter] to continue"   echo "Press [enter] to continue"
1222   read   read
1223   fi   fi
# Line 979  fi Line 1249  fi
1249  # creates md5sums for smages to given dir  # creates md5sums for smages to given dir
1250  if [[ $1 = calcmd5 ]]  if [[ $1 = calcmd5 ]]
1251  then  then
1252   if [ $# -ge 3 ]   if [ $# -ge 2 ]
1253   then   then
1254   SMAGENAME="$2"   SMAGENAME="$2"
1255   MD5DIR="$3"   MD5DIR="$3"
1256   source ${SMAGENAME} || die "download source failed"   [[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5"
1257    
1258     smagesource ${SMAGENAME} || die "download source failed"
1259    
1260   # overridable sourcedir; must be declared after source of the smage2   # overridable sourcedir; must be declared after source of the smage2
1261   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"   CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}"
# Line 1035  then Line 1307  then
1307   echo   echo
1308   else   else
1309   echo "Usage: Calculating MD5 Sums:"   echo "Usage: Calculating MD5 Sums:"
1310   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR"   echo "    $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]"
1311   echo   echo
1312   echo   echo
1313   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."   echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs."
# Line 1057  then Line 1329  then
1329   # get smage   # get smage
1330   SMAGENAME="$2"   SMAGENAME="$2"
1331   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1332   source ${SMAGENAME} || die "download source failed"   smagesource ${SMAGENAME} || die "download source failed"
1333    
1334   download_sources   download_sources
1335   exit 0   exit 0
# Line 1069  then Line 1341  then
1341   # set correct SMAGENAME   # set correct SMAGENAME
1342   SMAGENAME="$2"   SMAGENAME="$2"
1343   MD5DIR="$(dirname ${SMAGENAME})/md5"   MD5DIR="$(dirname ${SMAGENAME})/md5"
1344   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1345    
1346   regen_mage_tree   regen_mage_tree
1347    
1348   # build several targets   # build several targets
1349   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1350   then   then
1351   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1352   do   do
# Line 1087  then Line 1359  then
1359   --parch "${ARCH}" \   --parch "${ARCH}" \
1360   --target "${target}"   --target "${target}"
1361   done   done
1362    
1363     # build several subpackages
1364     elif [[ -n ${SPLIT_PACKAGES} ]]
1365     then
1366     split_save_variables
1367     for subpackage in ${SPLIT_PACKAGES}
1368     do
1369     # get the right variables for the split
1370     export PNAME="${subpackage}"
1371     split_info_${subpackage}
1372     # build md5sum for existing packages
1373     generate_package_md5sum \
1374     --pcat "${PCATEGORIE}" \
1375     --pname "${PNAME}" \
1376     --pver "${PVER}" \
1377     --pbuild "${PBUILD}" \
1378     --parch "${ARCH}"
1379     # restore smage environment
1380     split_restore_variables
1381     done
1382     # unset all saved smage variables
1383     split_unset_variables
1384    
1385   else   else
1386   # build md5sum for existing packages   # build md5sum for existing packages
1387   generate_package_md5sum \   generate_package_md5sum \
# Line 1094  then Line 1389  then
1389   --pname "${PNAME}" \   --pname "${PNAME}" \
1390   --pver "${PVER}" \   --pver "${PVER}" \
1391   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1392   --parch "${ARCH}" \   --parch "${ARCH}"
  --target "${target}"  
1393   fi   fi
1394    
1395   exit 0   exit 0
# Line 1109  then Line 1403  then
1403    
1404   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}"
1405    
1406   source ${SMAGENAME} || die "regen: smage2 not found"   smagesource ${SMAGENAME} || die "regen: smage2 not found"
1407    
1408   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1409   then   then
# Line 1158  fi Line 1452  fi
1452  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"  [ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}"
1453  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"  [ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}"
1454    
1455  source ${SMAGENAME} || die "source failed"  smagesource ${SMAGENAME} || die "source failed"
1456  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}"
1457  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1458    SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log"
1459    
1460  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1461  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
# Line 1239  fi Line 1534  fi
1534  [[ ! -d /var/log/smage ]] && install -d /var/log/smage  [[ ! -d /var/log/smage ]] && install -d /var/log/smage
1535  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log  echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log
1536    
1537  src_prepare || die "src_prepare failed" | ${SMAGE_LOG_CMD}  src_prepare | ${SMAGE_LOG_CMD}
1538  step_by_step $_  die_pipestatus 0 "src_prepare failed"
 src_compile || die "src_compile failed" | ${SMAGE_LOG_CMD}  
 step_by_step $_  
 src_install || die "src_install failed" | ${SMAGE_LOG_CMD}  
1539  step_by_step $_  step_by_step $_
1540    
1541    src_compile | ${SMAGE_LOG_CMD}
1542    die_pipestatus 0 "src_compile failed"
1543    step_by_step $_
1544    
1545  # compressing doc, info & man files  # build several subpackages
1546  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [[ -n ${SPLIT_PACKAGES} ]]
1547  then  then
1548   echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"   # save bindir & pname
1549   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   split_save_variables
1550     export SAVED_BINDIR="${BINDIR}"
1551     for subpackage in ${SPLIT_PACKAGES}
1552     do
1553     if typeset -f src_install_${subpackage} > /dev/null
1554     then
1555     # export subpackage bindir
1556     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1557     # export PNAME, several internal function and include
1558     # rely on this variable
1559     export PNAME="${subpackage}"
1560    
1561     echo
1562     echo -en "${COLBLUE}*** ${COLDEFAULT}"
1563     echo -en "  Running ${COLGREEN}split src_install()${COLDEFAULT}"
1564     echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}"
1565     echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..."
1566    
1567     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1568     die_pipestatus 0 "src_install_${subpackage} failed"
1569     step_by_step $_
1570     fi
1571     done
1572     # restore bindir & pname
1573     split_restore_variables
1574     # unset all saved smage variables
1575     split_unset_variables
1576    else
1577     src_install | ${SMAGE_LOG_CMD}
1578     die_pipestatus 0 "src_install failed"
1579     step_by_step $_
1580  fi  fi
1581    
1582  if [ -d ${BUILDDIR}/builded/usr/share/info ]  # compressing doc, info & man files
1583    if [[ -n ${SPLIT_PACKAGES} ]]
1584  then  then
1585   echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1586   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   do
1587     mcompressdocs ${BINDIR}_${subpackage}
1588     done
1589    else
1590     mcompressdocs ${BINDIR}
1591  fi  fi
1592    
1593    
1594  # stripping all bins and libs  # stripping all bins and libs
1595  case ${NOSTRIP} in  case ${NOSTRIP} in
1596   true|TRUE|yes|y)   true|TRUE|yes|y)
1597   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1598   ;;   ;;
1599   *)   *)
1600   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   if [[ -n ${SPLIT_PACKAGES} ]]
1601   mstripbins ${BINDIR}   then
1602   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGES}
1603   mstriplibs ${BINDIR}   do
1604     echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}"
1605     mstripbins ${BINDIR}_${subpackage}
1606     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}"
1607     mstriplibs ${BINDIR}_${subpackage}
1608     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}"
1609     mstripstatic ${BINDIR}_${subpackage}
1610     done
1611     else
1612     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1613     mstripbins ${BINDIR}
1614     echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}"
1615     mstriplibs ${BINDIR}
1616     echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}"
1617     mstripstatic ${BINDIR}
1618     fi
1619   ;;   ;;
1620  esac  esac
1621    
# Line 1280  case ${NOPKGBUILD} in Line 1626  case ${NOPKGBUILD} in
1626   ;;   ;;
1627   *)   *)
1628   # build several targets   # build several targets
1629   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1630   then   then
1631   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1632   do   do
# Line 1306  case ${NOPKGBUILD} in Line 1652  case ${NOPKGBUILD} in
1652    
1653   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}"
1654   done   done
1655    
1656     # build several subpackages
1657     elif [[ -n ${SPLIT_PACKAGES} ]]
1658     then
1659     split_save_variables
1660     for subpackage in ${SPLIT_PACKAGES}
1661     do
1662     # get the right variables for the split
1663     export PNAME="${subpackage}"
1664     split_info_${PNAME}
1665    
1666     # jump to next one if NOPKGBUILD is set in split_info
1667     case ${NOPKGBUILD} in
1668     true|TRUE|yes|y) continue ;;
1669     esac
1670    
1671     # check if an special subpackage_pkgbuild exists
1672     if typeset -f ${PNAME}_pkgbuild > /dev/null
1673     then
1674     # run it
1675     ${PNAME}_pkgbuild
1676     fi
1677     # now create the target package
1678     ${MLIBDIR}/pkgbuild_dir.sh \
1679     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1680     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1681    
1682     # build pkg-md5-sum if requested
1683     generate_package_md5sum \
1684     --pcat "${PCATEGORIE}" \
1685     --pname "${PNAME}" \
1686     --pver "${PVER}" \
1687     --pbuild "${PBUILD}" \
1688     --parch "${ARCH}"
1689    
1690     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1691    
1692     # restore smage environment
1693     split_restore_variables
1694     done
1695     # unset all saved smage variables
1696     split_unset_variables
1697    
1698   else   else
1699   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1700    

Legend:
Removed from v.891  
changed lines
  Added in v.1543