Magellan Linux

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

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

revision 419 by niro, Mon Jan 22 00:24:14 2007 UTC revision 833 by niro, Wed Apr 29 20:20:46 2009 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.51 2007-01-22 00:24:14 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 48  fi Line 48  fi
48  # export default C locale  # export default C locale
49  export LC_ALL=C  export LC_ALL=C
50    
51    source /etc/mage.rc.global
52  source ${MAGERC}  source ${MAGERC}
53    
54  # set PKGDIR and BUILDDIR and BINDIR to MROOT  # set PKGDIR and BUILDDIR and BINDIR to MROOT
# Line 148  download_sources() Line 149  download_sources()
149   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null )
150   if [[ $? = 0 ]]   if [[ $? = 0 ]]
151   then   then
152   # md5's ok, not fetching needed   # md5's ok, no fetching needed
153   FETCHING=false   FETCHING=false
154   else   else
155   FETCHING=true   FETCHING=true
# Line 171  download_sources() Line 172  download_sources()
172   fi   fi
173    
174   # if an mirrored file than replace first the mirror uri   # if an mirrored file than replace first the mirror uri
175   if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ]   if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]]
176   then   then
177   for mirror in ${MIRRORS}   for mirror in ${MIRRORS}
178   do   do
# Line 179  download_sources() Line 180  download_sources()
180    
181   if [[ ${FETCHING} = true ]]   if [[ ${FETCHING} = true ]]
182   then   then
183   echo "==> fetching ${my_SRC_URI_MIRROR}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
184     wget \
185     --passive-ftp \
186     --tries 3 \
187     --continue \
188     --progress bar \
189     --directory-prefix="${my_SOURCEDIR}" \
190     "${my_SRC_URI_MIRROR}"
191     if [[ $? = 0 ]]
192     then
193     break
194     else
195     continue
196     fi
197     fi
198     done
199     elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]]
200     then
201     for mirror in ${SOURCEFORGE_MIRRORS}
202     do
203     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")"
204    
205     if [[ ${FETCHING} = true ]]
206     then
207     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
208     wget \
209     --passive-ftp \
210     --tries 3 \
211     --continue \
212     --progress bar \
213     --directory-prefix="${my_SOURCEDIR}" \
214     "${my_SRC_URI_MIRROR}"
215     if [[ $? = 0 ]]
216     then
217     break
218     else
219     continue
220     fi
221     fi
222     done
223     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]]
224     then
225     for mirror in ${GNU_MIRRORS}
226     do
227     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")"
228    
229     if [[ ${FETCHING} = true ]]
230     then
231     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
232     wget \
233     --passive-ftp \
234     --tries 3 \
235     --continue \
236     --progress bar \
237     --directory-prefix="${my_SOURCEDIR}" \
238     "${my_SRC_URI_MIRROR}"
239     if [[ $? = 0 ]]
240     then
241     break
242     else
243     continue
244     fi
245     fi
246     done
247     elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]]
248     then
249     for mirror in ${KDE_MIRRORS}
250     do
251     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")"
252    
253     if [[ ${FETCHING} = true ]]
254     then
255     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
256     wget \
257     --passive-ftp \
258     --tries 3 \
259     --continue \
260     --progress bar \
261     --directory-prefix="${my_SOURCEDIR}" \
262     "${my_SRC_URI_MIRROR}"
263     if [[ $? = 0 ]]
264     then
265     break
266     else
267     continue
268     fi
269     fi
270     done
271     elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]]
272     then
273     for mirror in ${GNOME_MIRRORS}
274     do
275     my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")"
276    
277     if [[ ${FETCHING} = true ]]
278     then
279     echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}"
280   wget \   wget \
281   --passive-ftp \   --passive-ftp \
282   --tries 3 \   --tries 3 \
# Line 198  download_sources() Line 295  download_sources()
295   else   else
296   if [[ ${FETCHING} = true ]]   if [[ ${FETCHING} = true ]]
297   then   then
298   echo "==> fetching ${my_SRC_URI}"   echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}"
299   wget \   wget \
300   --passive-ftp \   --passive-ftp \
301   --tries 3 \   --tries 3 \
# Line 218  download_sources() Line 315  download_sources()
315    
316   # recheck md5 sums   # recheck md5 sums
317   echo   echo
318   echo ">== Checking MD5 sums:"   echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}"
319   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"   ( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed"
320   echo   echo
321    
# Line 265  mconfigure() Line 362  mconfigure()
362   ./configure \   ./configure \
363   --prefix=/usr \   --prefix=/usr \
364   --host=${CHOST} \   --host=${CHOST} \
365     --build=${CHOST} \
366   --mandir=/usr/share/man \   --mandir=/usr/share/man \
367   --infodir=/usr/share/info \   --infodir=/usr/share/info \
368   --datadir=/usr/share \   --datadir=/usr/share \
# Line 308  munpack() Line 406  munpack()
406    
407   SRCFILE=$1   SRCFILE=$1
408    
409   if [ -z "$2" ]   if [[ -z $2 ]]
410   then   then
411   DEST=${BUILDDIR}   DEST=${BUILDDIR}
412   else   else
# Line 323  munpack() Line 421  munpack()
421   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
422   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
423   then   then
424   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."
425     else
426     pushd ${DEST} > /dev/null
427     bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed."
428     popd > /dev/null
429   fi   fi
430   ;;   ;;
431   gz)   gz)
# Line 331  munpack() Line 433  munpack()
433   IFTAR="${IFTAR##*.}"   IFTAR="${IFTAR##*.}"
434   if [[ ${IFTAR} = tar ]]   if [[ ${IFTAR} = tar ]]
435   then   then
436   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."
437     else
438     pushd ${DEST} > /dev/null
439     zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed."
440     popd > /dev/null
441   fi   fi
442   ;;   ;;
443   tbz2)   tbz2|mpks|mpk)
444   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed."
445   ;;   ;;
446   tgz)   tgz)
447   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST}   tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed."
448     ;;
449     rar)
450     unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST}  || die ".rar unpack failed."
451     ;;
452     zip|xpi)
453     unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed."
454     ;;
455     rpm)
456     pushd ${DEST} > /dev/null
457     rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed."
458     tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed."
459     if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]]
460     then
461     rm ${DEST}/${SRCFILE/.rpm/.tar.gz}
462     fi
463   ;;   ;;
464   *)   *)
465   die "munpack failed"   die "munpack failed"
# Line 350  mpatch() Line 471  mpatch()
471  {  {
472   local PATCHOPTS   local PATCHOPTS
473   local PATCHFILE   local PATCHFILE
474     local i
475    
476   PATCHOPTS=$1   PATCHOPTS=$1
477   PATCHFILE=$2   PATCHFILE=$2
478    
479     if [[ -z $2 ]]
480     then
481     PATCHFILE=$1
482    
483     ## patch level auto-detection, get patch level
484     for ((i=0; i < 10; i++))
485     do
486     patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null
487     if [[ $? = 0 ]]
488     then
489     PATCHOPTS="-Np${i}"
490     break
491     fi
492     done
493     fi
494    
495   echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"   echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}"
496   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}   patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE}
497  }  }
498    
499    mlibtoolize()
500    {
501     local opts="$@"
502     [[ -z ${opts} ]] && opts="--copy --force"
503    
504     libtoolize ${opts} || die "running: mlibtoolize ${opts}"
505    }
506    
507  minstalldocs()  minstalldocs()
508  {  {
# Line 412  setup_distcc_environment() Line 557  setup_distcc_environment()
557  {  {
558   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
559   then   then
560   echo "Using DistCC for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}"
561   export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"   export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH"
562    
563   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"   export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed"
# Line 427  setup_ccache_environment() Line 572  setup_ccache_environment()
572  {  {
573   if [ -x /usr/bin/ccache ]   if [ -x /usr/bin/ccache ]
574   then   then
575   echo "Using CCache for compilation ..."   echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}"
576   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"   export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH"
577   fi   fi
578  }  }
# Line 451  fix_mage_deps() Line 596  fix_mage_deps()
596   # fix DEPEND   # fix DEPEND
597   while read sym dep   while read sym dep
598   do   do
599     # ignore empty lines
600     [[ -z ${dep} ]] && continue
601    
602   cat="$(dirname ${dep})"   cat="$(dirname ${dep})"
603   # change if not virtual   # change if not virtual
604   if [[ ${cat} = virtual ]]   if [[ ${cat} = virtual ]]
# Line 503  EOF Line 651  EOF
651  # special tags:  # special tags:
652  #   PKGTYPE               type of pkg  #   PKGTYPE               type of pkg
653  #   INHERITS              which functions get included  #   INHERITS              which functions get included
654  #   SPECIAL_FUNCTIONS     special functions wich should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
655  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
656  #  #
657  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
# Line 531  build_mage_script() Line 679  build_mage_script()
679   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"   dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
680    
681   # show what we are doing   # show what we are doing
682   echo "Generating Mage file:"   echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}"
683   echo "  ${dest}"   echo "${dest}"
684    
685   install -d "$(dirname ${dest})"   install -d "$(dirname ${dest})"
686   # now build the mage file   # now build the mage file
687   > ${dest}   > ${dest}
688    
689   # header   # header
690   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.51 2007-01-22 00:24:14 niro Exp $' >> ${dest}   echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest}
691   echo  >> ${dest}   echo  >> ${dest}
692    
693   # pgkname and state   # pgkname and state
# Line 647  regen_mage_tree() Line 795  regen_mage_tree()
795   # now unset all uneeded vars to be safe   # now unset all uneeded vars to be safe
796   # unset PKGNAME <-- don't do that; smage needs this var   # unset PKGNAME <-- don't do that; smage needs this var
797   # unset to be safe (quotes needed !)   # unset to be safe (quotes needed !)
798   for i in ${SPECIAL_FUNCTIONS}  # for i in ${SPECIAL_FUNCTIONS}
799   do  # do
800   unset "${i}"  # unset "${i}"
801   done  # done
802   unset SPECIAL_FUNCTIONS   unset SPECIAL_FUNCTIONS
803   for i in ${SPECIAL_VARS}  # for i in ${SPECIAL_VARS}
804   do  # do
805   unset "${i}"  # unset "${i}"
806   done  # done
807   unset SPECIAL_VARS   unset SPECIAL_VARS
808   unset STATE   unset STATE
809   unset DESCRIPTION   unset DESCRIPTION
# Line 738  generate_package_md5sum() Line 886  generate_package_md5sum()
886   # build pkg-md5-sum only if requested   # build pkg-md5-sum only if requested
887   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
888   then   then
889   echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... "   echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}"
890    
891   # abort if not exist   # abort if not exist
892   if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]   if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ]
893   then   then
894   echo "! exists"   echo -e "${COLRED}! exists${COLDEFAULT}"
895   return 0   return 0
896   fi   fi
897    
# Line 757  generate_package_md5sum() Line 905  generate_package_md5sum()
905   # gen md5sum   # gen md5sum
906   ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \   ( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \
907   > ${dest}/${pkgname}.md5   > ${dest}/${pkgname}.md5
908   echo "done"   echo -e "${COLGREEN}done${COLDEFAULT}"
909   fi   fi
910  }  }
911    
# Line 983  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUI Line 1131  PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUI
1131  MD5DIR="$(dirname ${SMAGENAME})/md5"  MD5DIR="$(dirname ${SMAGENAME})/md5"
1132    
1133  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
1134  echo "Compiling ${PKGNAME}"  echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}"
1135    
1136  # auto regen mage tree if requested  # auto regen mage tree if requested
1137  regen_mage_tree  regen_mage_tree
# Line 992  if [[ ${CREATE_SRC_PKG_TARBALL} = true ] Line 1140  if [[ ${CREATE_SRC_PKG_TARBALL} = true ]
1140  then  then
1141   if [[ -d ${SOURCEDIR}/${PNAME} ]]   if [[ -d ${SOURCEDIR}/${PNAME} ]]
1142   then   then
1143   echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"   echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}"
1144   rm -rf ${SOURCEDIR}/${PNAME}   rm -rf ${SOURCEDIR}/${PNAME}
1145   fi   fi
1146  fi  fi
# Line 1061  src_install || die "src_install failed" Line 1209  src_install || die "src_install failed"
1209    
1210    
1211  # compressing doc, info & man files  # compressing doc, info & man files
 echo -e "Compressing man-pages ..."  
1212  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [ -d ${BUILDDIR}/builded/usr/share/man ]
1213  then  then
1214     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
1215   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man
1216  fi  fi
1217    
 echo -e "Compressing info-pages ..."  
1218  if [ -d ${BUILDDIR}/builded/usr/share/info ]  if [ -d ${BUILDDIR}/builded/usr/share/info ]
1219  then  then
1220     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
1221   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info
1222  fi  fi
1223    
# Line 1079  case ${NOSTRIP} in Line 1227  case ${NOSTRIP} in
1227   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1228   ;;   ;;
1229   *)   *)
1230   echo -e "Stripping binaries ..."   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1231   mstripbins ${BINDIR}   mstripbins ${BINDIR}
1232   echo -e "Stripping libraries ..."   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1233   mstriplibs ${BINDIR}   mstriplibs ${BINDIR}
1234   ;;   ;;
1235  esac  esac
# Line 1117  case ${NOPKGBUILD} in Line 1265  case ${NOPKGBUILD} in
1265   --parch "${ARCH}" \   --parch "${ARCH}" \
1266   --target "${target}"   --target "${target}"
1267    
1268   echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n"   echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1269   done   done
1270   else   else
1271   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
# Line 1130  case ${NOPKGBUILD} in Line 1278  case ${NOPKGBUILD} in
1278   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1279   --parch "${ARCH}"   --parch "${ARCH}"
1280    
1281   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}"
1282   fi   fi
1283    
1284   # build src-pkg-tarball if requested   # build src-pkg-tarball if requested

Legend:
Removed from v.419  
changed lines
  Added in v.833