Magellan Linux

Diff of /branches/mage-0_3_7-r6/mage/usr/lib/mage/smage2.sh

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

trunk/mage/usr/lib/mage/smage2.sh revision 85 by niro, Wed Jun 1 16:10:19 2005 UTC branches/mage-0_3_7-r6/mage/usr/lib/mage/smage2.sh revision 217, Sun Aug 28 19:23:57 2005 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.11 2005-06-01 16:10:19 niro Exp $  # $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.36 2005-08-28 19:23:04 niro Exp $
8    
9  #01.10.2004  #01.10.2004
10  # added ccache support  # added ccache support
11  # added distcc support  # added distcc support
12    
13  ## setup ##  ## setup ##
 SMAGEVERSION=0.3.6-r16  
14  PKGSUFFIX="mpk"  PKGSUFFIX="mpk"
15  SMAGENAME="$1"  SMAGENAME="$1"
16  SMAGESUFFIX="smage2"  SMAGESUFFIX="smage2"
# Line 19  SMAGESUFFIX="smage2" Line 18  SMAGESUFFIX="smage2"
18  #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"  #SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts"
19  #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"  #SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts"
20  MLIBDIR=/usr/lib/mage  MLIBDIR=/usr/lib/mage
21    SMAGEVERSION="$( < ${MLIBDIR}/version)"
22    
23    # export default C locale
24    export LC_ALL=C
25    
26  source /etc/mage.rc  source /etc/mage.rc
27    
# Line 179  download_sources() { Line 182  download_sources() {
182   --progress bar \   --progress bar \
183   --directory-prefix="${my_SOURCEDIR}" \   --directory-prefix="${my_SOURCEDIR}" \
184   "${my_SRC_URI}"   "${my_SRC_URI}"
185   if [ "$?" == "0" ]  # only needed to run through a list of mirrors
186   then  # if [ "$?" == "0" ]
187   break  # then
188   else  # break
189   continue  # else
190   fi  # continue
191    # fi
192   fi   fi
193   fi   fi
194    
# Line 226  src_install() { Line 230  src_install() {
230   return 0   return 0
231  }  }
232    
   
 build_mage_script() {  
  return 0  
 }  
   
233  mconfigure() {  mconfigure() {
234   if [ -x ./configure ]   if [ -x ./configure ]
235   then   then
# Line 353  mstripbins() { Line 352  mstripbins() {
352   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
353  }  }
354    
355    sminclude() {
356     local i
357    
358     if [[ -n "$@" ]]
359     then
360     for i in $@
361     do
362     echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc"
363     source ${SMAGESCRIPTSDIR}/include/${i}.sminc
364     done
365     echo
366     fi
367    }
368    
369  setup_distcc_environment(){  setup_distcc_environment(){
370   if [ -x /usr/bin/distcc ]   if [ -x /usr/bin/distcc ]
371   then   then
# Line 393  setup_ccache_environment(){ Line 406  setup_ccache_environment(){
406   fi   fi
407  }  }
408    
409    
410    # fixes given dependencies to match a MAGE_TARGET
411    # fix_mage_deps -target s/depend # <-- note -target !
412    fix_mage_deps() {
413     local target="$1"
414     local depend="$2"
415     local NDEPEND
416     local sym dep cat pver pname
417    
418     # deps and provides are special
419     # they must be fixed to match the target
420    
421     # run this only if target and depend is not empty
422     if [ -n "${target}" ] && [ -n "${depend}" ]
423     then
424     # fix DEPEND
425     while read sym dep
426     do
427     cat="$(dirname ${dep})"
428     # change if not virtual
429     if [[ ${cat} = virtual ]]
430     then
431     pname="$(basename ${dep})"
432     else
433     # fix pver to target-pver
434     # to get pname-target-pver
435    
436     # doing it backwards !
437     pver="${dep##*-}"
438     # full pver
439     pname="$(basename ${dep/-${pver}/})${target}-${pver}"
440     fi
441    
442     # do not add empty lines
443     if [ -z "${NDEPEND}" ]
444     then
445     NDEPEND="${sym} ${cat}/${pname}"
446     else
447     NDEPEND="${NDEPEND}
448     ${sym} ${cat}/${pname}"
449     fi
450    
451     unset cat pname pver
452     done << EOF
453    ${depend}
454    EOF
455     # set NDEPEND to DEPEND
456     depend="${NDEPEND}"
457     fi
458    
459     echo "${depend}"
460    }
461    
462    # build_mage_script(): helper functions for regen_mage_tree()
463    # generates an mage file with given information in smage file
464    # needs at least:
465    #   PNAME                 name of pkg
466    #   PVER                  version
467    #   PBUILD                revision
468    #   PCATEGORIE            categorie of the pkg
469    #   STATE                 state of pkg stable|unstable|old
470    #   DESCRIPTION           va short description (opt)
471    #   HOMEPAGE              homepage (opt)
472    #   DEPEND                runtime dependencies (opt)
473    #   SDEPEND               add. needed deps to build the pkg (opt)
474    #   PROVIDE               provides a virtual (opt)
475    #
476    # special tags:
477    #   PKGTYPE               type of pkg
478    #   INHERITS              which functions get included
479    #   SPECIAL_FUNCTIONS     special functions wich should also be added
480    #                         warning: they get killed before the build starts !
481    #
482    #   MAGE_TREE_DEST        target destination of the generated tree
483    #   REGEN_MAGE_TREE       set to 'true' to enable this
484    #
485    # gets called with build_mage_script target
486    build_mage_script()
487    {
488     local magefile
489     local dest
490     local target
491     local sym
492     local depname
493    
494     # if MAGE_TREE_DEST not set use BUILDDIR
495     : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
496    
497     # determinate which suffix this mage file should get, if any
498     [ -n "$1" ] && target="-$1"
499    
500     # name of magefile
501     magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
502    
503     # destination to magefile
504     dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}"
505    
506     # show what we are doing
507     echo "Generating Mage file:"
508     echo "  ${dest}"
509    
510     install -d "$(dirname ${dest})"
511     # now build the mage file
512     > ${dest}
513    
514     # header
515     echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.36 2005-08-28 19:23:04 niro Exp $' >> ${dest}
516     echo  >> ${dest}
517    
518     # pgkname and state
519     echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest}
520     echo "STATE=\"${STATE}\"" >> ${dest}
521     echo >> ${dest}
522    
523     # description and homepage
524     echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest}
525     echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest}
526     echo >> ${dest}
527    
528     # special tags and vars
529     echo "PKGTYPE=\"${PKGTYPE}\""  >> ${dest}
530    
531     # echo MAGE_TARGETS ## note -target is needed !
532     echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
533     echo >> ${dest}
534    
535     # add special vars
536     if [ -n "${SPECIAL_VARS}" ]
537     then
538     local i
539     for i in ${SPECIAL_VARS}
540     do
541     # being tricky here :)
542     echo "${i}=\"$(eval echo \$${i})\"" >> ${dest}
543     done
544     echo  >> ${dest}
545     fi
546    
547     # add at least all includes
548     if [ -n "${INHERITS}" ]
549     then
550     echo -n "minclude"  >> ${dest}
551     local i
552     for i in ${INHERITS}
553     do
554     echo -n " ${i}"  >> ${dest}
555     done
556     echo  >> ${dest}
557     fi
558     echo >> ${dest}
559    
560     # deps and provides
561     echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest}
562     echo >> ${dest}
563     echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest}
564     echo >> ${dest}
565     echo "PROVIDE=\"${PROVIDE}\"" >> ${dest}
566     echo >> ${dest}
567    
568     # add special functions
569     if [ -n "${SPECIAL_FUNCTIONS}" ]
570     then
571     local i
572     for i in ${SPECIAL_FUNCTIONS}
573     do
574     # add to mage (quotes needed !)
575     typeset -f "${i}" >> ${dest}
576     echo >> ${dest}
577     # unset to be safe (quotes needed !)
578     #unset "${i}" <-- later to get every target built
579     done
580     echo  >> ${dest}
581     fi
582    
583     # pre|post-install|removes
584     typeset -f preinstall >> ${dest}
585     echo  >> ${dest}
586     typeset -f postinstall >> ${dest}
587     echo  >> ${dest}
588     typeset -f preremove >> ${dest}
589     echo  >> ${dest}
590     typeset -f postremove >> ${dest}
591     echo  >> ${dest}
592    }
593    
594    regen_mage_tree()
595    {
596     local i
597    
598     # build them only if requested
599     if [[ ${REGEN_MAGE_TREE} = true ]]
600     then
601     # run it without targets
602     if [ -z "${MAGE_TARGETS}" ]
603     then
604     echo
605     build_mage_script
606     echo
607     else
608    
609     # build for each target an mage file
610     # run it with several targets
611     for i in ${MAGE_TARGETS}
612     do
613     echo
614     build_mage_script "${i}"
615     echo
616     done
617     fi
618     fi
619    
620     # now unset all uneeded vars to be safe
621     # unset PKGNAME <-- don't do that; smage needs this var
622     # unset to be safe (quotes needed !)
623     for i in ${SPECIAL_FUNCTIONS}
624     do
625     unset "${i}"
626     done
627     unset SPECIAL_FUNCTIONS
628     for i in ${SPECIAL_VARS}
629     do
630     unset "${i}"
631     done
632     unset SPECIAL_VARS
633     unset STATE
634     unset DESCRIPTION
635     unset HOMEPAGE
636     unset PKGTYPE
637     unset INHERITS
638     unset DEPEND
639     unset SDEPEND
640     unset PROVIDE
641     unset preinstall
642     unset postinstall
643     unset preremove
644     unset postremove
645    }
646    
647  # print out our version  # print out our version
648  showversion  showversion
649  echo  echo
# Line 404  then Line 655  then
655   exit 1   exit 1
656  fi  fi
657    
658  #updating smage2-scripts  # updating smage2-scripts
659  if [ "$1" == "update" ]  if [ "$1" == "update" ]
660  then  then
661   if [ ! -d ${SOURCEDIR} ]   if [ ! -d ${SOURCEDIR} ]
# Line 415  then Line 666  then
666   exit 0   exit 0
667  fi  fi
668    
669  #creates md5sums for smages to given dir  # creates md5sums for smages to given dir
670  if [ "$1" == "calcmd5" ]  if [ "$1" == "calcmd5" ]
671  then  then
672   if [ $# -ge 3 ]   if [ $# -ge 3 ]
# Line 485  then Line 736  then
736   exit 0   exit 0
737  fi  fi
738    
739  #download sources  # download sources
740  if [ "$1" == "download" -a -n "$2" ]  if [ "$1" == "download" -a -n "$2" ]
741  then  then
  showversion  
742   if [ ! -d ${SMAGESCRIPTSDIR} ]   if [ ! -d ${SMAGESCRIPTSDIR} ]
743   then   then
744   install -d ${SMAGESCRIPTSDIR}   install -d ${SMAGESCRIPTSDIR}
# Line 503  then Line 753  then
753   exit 0   exit 0
754  fi  fi
755    
756    # regen-mage-tree
757    if [ "$1" == "only-regen-tree" -a -n "$2" ]
758    then
759     # set correct SMAGENAME
760     SMAGENAME="$2"
761     MD5DIR="$(dirname ${SMAGENAME})/md5"
762     source ${SMAGENAME} || die "regen: smage2 not found"
763    
764     regen_mage_tree
765     exit 0
766    fi
767    
768  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]  if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ]
769  then  then
770   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."   die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting."
# Line 557  MD5DIR="$(dirname ${SMAGENAME})/md5" Line 819  MD5DIR="$(dirname ${SMAGENAME})/md5"
819  xtitle "Compiling ${PKGNAME}"  xtitle "Compiling ${PKGNAME}"
820  echo "Compiling ${PKGNAME}"  echo "Compiling ${PKGNAME}"
821    
822  #download sources  # auto regen mage tree if requested
823    regen_mage_tree
824    
825    # download sources
826  download_sources  download_sources
827    
828  #fixes some issues with these functions  # fixes some issues with these functions
829  export -f src_prepare || die "src_prepare export failed"  export -f src_prepare || die "src_prepare export failed"
830  export -f src_compile || die "src_compile export failed"  export -f src_compile || die "src_compile export failed"
831  export -f src_install || die "src_install export failed"  export -f src_install || die "src_install export failed"
832    
833  #fixes some compile issues  # fixes some compile issues
834  export CHOST="${CHOST}" || die "CHOST export failed"  export CHOST="${CHOST}" || die "CHOST export failed"
835  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"  export CFLAGS="${CFLAGS}" || die "CFLAGS export failed"
836  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"  export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed"
# Line 573  export BINDIR="${BINDIR}" || die "BINDIR Line 838  export BINDIR="${BINDIR}" || die "BINDIR
838  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"  export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed"
839    
840    
841  #setup distcc  # setup distcc
842  #distcc mus be setup *before* ccache, as ccache need to be before distcc in path  # distcc mus be setup *before* ccache, as ccache need to be before distcc in path
843  if [ "${SMAGE_USE_DISTCC}" == "true" ]  if [ "${SMAGE_USE_DISTCC}" == "true" ]
844  then  then
845   setup_distcc_environment   setup_distcc_environment
846  fi  fi
847    
848  #setup ccache  # setup ccache
849  if [ "${SMAGE_USE_CCACHE}" == "true" ]  if [ "${SMAGE_USE_CCACHE}" == "true" ]
850  then  then
851   setup_ccache_environment   setup_ccache_environment
# Line 601  sleep 1 Line 866  sleep 1
866  #read  #read
867  #debug end  #debug end
868    
869  #cleans up build if a previously one exists  # cleans up build if a previously one exists
870  if [ -d ${BUILDDIR} ]  if [ -d ${BUILDDIR} ]
871  then  then
872   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."   rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR."
873  fi  fi
874  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."  install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR."
875    
876  #cleans up srcdir if a previously unpacked one exists  # cleans up srcdir if a previously unpacked one exists
877  if [ -d ${SRCDIR} ]  if [ -d ${SRCDIR} ]
878  then  then
879   rm -rf ${SRCDIR}   rm -rf ${SRCDIR}
880  fi  fi
881    
882  #cleans up bindir if a previous build exists or creates a new one  # cleans up bindir if a previous build exists or creates a new one
883  if [ -d ${BINDIR} ]  if [ -d ${BINDIR} ]
884  then  then
885   rm -rf ${BINDIR}   rm -rf ${BINDIR}
886  fi  fi
887  install -d ${BINDIR} || die "couldn't create \$BINDIR."  install -d ${BINDIR} || die "couldn't create \$BINDIR."
888    
889  #cleans up package temp dir if a previous build exists  # cleans up package temp dir if a previous build exists
890  if [ -d ${BUILDDIR}/${PKGNAME} ]  if [ -d ${BUILDDIR}/${PKGNAME} ]
891  then  then
892   rm -rf ${BUILDDIR}/${PKGNAME}   rm -rf ${BUILDDIR}/${PKGNAME}
893  fi  fi
894    
895  #cleans up timestamp if one exists  # cleans up timestamp if one exists
896  if [ -f /var/tmp/timestamp ]  if [ -f /var/tmp/timestamp ]
897  then  then
898   mage rmstamp   mage rmstamp
# Line 638  src_compile || die "src_compile failed" Line 903  src_compile || die "src_compile failed"
903  src_install || die "src_install failed"  src_install || die "src_install failed"
904    
905    
906  #compressing doc, info & man files  # compressing doc, info & man files
907  echo -e "Compressing man-pages ..."  echo -e "Compressing man-pages ..."
908  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [ -d ${BUILDDIR}/builded/usr/share/man ]
909  then  then
# Line 664  case ${NOSTRIP} in Line 929  case ${NOSTRIP} in
929   ;;   ;;
930  esac  esac
931    
932  #the new buildpkg command  # the new buildpkg command
933  case ${NOPKGBUILD} in  case ${NOPKGBUILD} in
934   true|TRUE|yes|y)   true|TRUE|yes|y)
935   echo -e "NOPGKBUILD=true detected; Package will not be build ..."   echo -e "NOPGKBUILD=true detected; Package will not be build ..."
936   ;;   ;;
937   *)   *)
938   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   # build serveral targets
939   echo -e "\nPackage ${PKGNAME} successfully builded.\n"   if [ -n "${MAGE_TARGETS}" ]
940     then
941     for target in ${MAGE_TARGETS}
942     do
943     # check if an special target_pkgbuild exists
944     if typeset -f ${target}_pkgbuild > /dev/null
945     then
946     # run it
947     ${target}_pkgbuild
948     fi
949     # now create the target package
950     ${MLIBDIR}/pkgbuild_dir.sh \
951     "${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \
952     ${BINDIR} || die "target: ${target} package-build failed"
953     echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n"
954     done
955     else
956     ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
957     echo -e "\nPackage ${PKGNAME} successfully builded.\n"
958     fi
959   ;;   ;;
960  esac  esac
961    
962  #for sure  # for sure
963  unset NOPKGBUILD  unset NOPKGBUILD
964  unset NOSTRIP  unset NOSTRIP
965    

Legend:
Removed from v.85  
changed lines
  Added in v.217