Magellan Linux

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

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

revision 942 by niro, Fri Nov 20 19:41:27 2009 UTC revision 943 by niro, Fri Nov 20 22:39:11 2009 UTC
# Line 75  die() Line 75  die()
75    
76  die_pipestatus()  die_pipestatus()
77  {  {
78   local pos="$1"   # the status change if we do any parameter declarations!!
79   local comment="$2"   # dont do this anymore, keep this in mind!
80     #
81   [ ${PIPESTATUS[${pos}]} -gt 0 ] && die "${comment}"   # local pos="$1"
82     # local comment="$2"
83     #
84     # [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}"
85     #
86     [ ${PIPESTATUS[$1]} -ne 0 ] && die "$2"
87  }  }
88    
89  xtitle()  xtitle()
# Line 549  mstripbins() Line 554  mstripbins()
554   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
555  }  }
556    
557    mcompressdocs()
558    {
559     local bindir="$@"
560    
561     if [ -d ${bindir}/usr/share/man ]
562     then
563     echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"
564     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man
565     fi
566    
567     if [ -d ${bindir}/usr/share/info ]
568     then
569     echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"
570     ${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info
571     fi
572    }
573    
574  sminclude()  sminclude()
575  {  {
576   local i   local i
# Line 664  EOF Line 686  EOF
686  #   INHERITS              which functions get included  #   INHERITS              which functions get included
687  #   SPECIAL_FUNCTIONS     special functions which should also be added  #   SPECIAL_FUNCTIONS     special functions which should also be added
688  #                         warning: they get killed before the build starts !  #                         warning: they get killed before the build starts !
689    #   SPLIT_PACKAGES        names of all subpackages which are splitted from parent
690    #   SPLIT_PACKAGE_BASE    base package name for splitpackages
691    #                         (only in the resulting magefile}
692  #  #
693  #   MAGE_TREE_DEST        target destination of the generated tree  #   MAGE_TREE_DEST        target destination of the generated tree
694  #   REGEN_MAGE_TREE       set to 'true' to enable this  #   REGEN_MAGE_TREE       set to 'true' to enable this
# Line 674  build_mage_script() Line 699  build_mage_script()
699   local magefile   local magefile
700   local dest   local dest
701   local target   local target
702     local split_pkg_base
703   local sym   local sym
704   local depname   local depname
705    
# Line 681  build_mage_script() Line 707  build_mage_script()
707   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}   : ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree}
708    
709   # determinate which suffix this mage file should get, if any   # determinate which suffix this mage file should get, if any
710   [ -n "$1" ] && target="-$1"   [[ $1 = --target ]] && shift && target="-$1"
711    
712     # mark package as splitpackage
713     [[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1"
714    
715   # name of magefile   # name of magefile
716   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"   magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage"
# Line 718  build_mage_script() Line 747  build_mage_script()
747   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}   echo "MAGE_TARGETS=\"${target}\"" >> ${dest}
748   echo >> ${dest}   echo >> ${dest}
749    
750     # split package base
751     echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest}
752     echo >> ${dest}
753    
754   # add special vars   # add special vars
755   if [ -n "${SPECIAL_VARS}" ]   if [ -n "${SPECIAL_VARS}" ]
756   then   then
# Line 785  regen_mage_tree() Line 818  regen_mage_tree()
818   if [[ ${REGEN_MAGE_TREE} = true ]]   if [[ ${REGEN_MAGE_TREE} = true ]]
819   then   then
820   # run it without targets   # run it without targets
821   if [ -z "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
822   then   then
823     # build for each target a mage file
824     # run it with several targets
825   echo   echo
826   build_mage_script   for i in ${MAGE_TARGETS}
827     do
828     build_mage_script --target "${i}"
829     done
830   echo   echo
  else  
831    
832   # build for each target an mage file   # run it for splitpackages
833     elif [[ -n ${SPLIT_PACKAGES} ]]
834     then
835     local split_pkg_base="${PNAME}"
836     # save smage environment
837     split_save_variables
838     # build for each subpackage a mage file
839   # run it with several targets   # run it with several targets
840   for i in ${MAGE_TARGETS}   echo
841     for i in ${SPLIT_PACKAGES}
842   do   do
843   echo   # get the right variables for the split
844   build_mage_script "${i}"   export PNAME="${i}"
845   echo   split_info_${i}
846     build_mage_script --split-pkg-base "${split_pkg_base}"
847   done   done
848     echo
849     # restore smage environment
850     split_restore_variables
851    
852     else
853     echo
854     build_mage_script
855     echo
856   fi   fi
857   fi   fi
858    
# Line 830  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    
902     # functions
903     if [[ ! -z $(typeset -f preinstall) ]]
904     then
905     # rename the old one
906     local saved_preinstall
907     saved_preinstall=SAVED_$(typeset -f preinstall)
908     eval "${saved_preinstall}"
909     export -f SAVED_preinstall
910     fi
911    
912     if [[ ! -z $(typeset -f postinstall) ]]
913     then
914     # rename the old one
915     local saved_postinstall
916     saved_postinstall=SAVED_$(typeset -f postinstall)
917     eval "${saved_postinstall}"
918     export -f SAVED_postinstall
919     fi
920    
921     if [[ ! -z $(typeset -f preremove) ]]
922     then
923     # rename the old one
924     local saved_preremove
925     saved_preremove=SAVED_$(typeset -f preremove)
926     eval "${saved_preremove}"
927     export -f SAVED_preremove
928     fi
929    
930     if [[ ! -z $(typeset -f postremove) ]]
931     then
932     # rename the old one
933     local saved_postremove
934     saved_postremove=SAVED_$(typeset -f postremove)
935     eval "${saved_postremove}"
936     export -f SAVED_postremove
937     fi
938    }
939    
940    split_restore_variables()
941    {
942     export PNAME="${SAVED_PNAME}"
943     export PVER="${SAVED_PVER}"
944     export PBUILD="${SAVED_PBUILD}"
945     export PCATEGORIE="${SAVED_PCATEGORIE}"
946     export DESCRIPTION="${SAVED_DESCRIPTION}"
947     export HOMEPAGE="${SAVED_HOMEPAGE}"
948     export SPECIAL_VARS="${SAVED_SPECIAL_VARS}"
949     export STATE="${SAVED_STATE}"
950     export PKGTYPE="${SAVED_PKGTYPE}"
951     export INHERITS="${SAVED_INHERITS}"
952     export DEPEND="${SAVED_DEPEND}"
953     export SDEPEND="${SAVED_SDEPEND}"
954     export PROVIDE="${SAVED_PROVIDE}"
955    
956     # functions
957     if [[ ! -z $(typeset -f SAVED_preinstall) ]]
958     then
959     # rename the old one
960     local saved_preinstall
961     saved_preinstall=$(typeset -f SAVED_preinstall)
962     eval "${saved_preinstall/SAVED_/}"
963     export -f preinstall
964     fi
965    
966     if [[ ! -z $(typeset -f SAVED_postinstall) ]]
967     then
968     # rename the old one
969     local saved_postinstall
970     saved_postinstall=$(typeset -f SAVED_postinstall)
971     eval "${saved_postinstall/SAVED_/}"
972     export -f postinstall
973     fi
974    
975     if [[ ! -z $(typeset -f SAVED_preremove) ]]
976     then
977     # rename the old one
978     local saved_preremove
979     saved_preremove=$(typeset -f SAVED_preremove)
980     eval "${saved_preremove/SAVED_/}"
981     export -f preremove
982     fi
983    
984     if [[ ! -z $(typeset -f SAVED_postremove) ]]
985     then
986     # rename the old one
987     local saved_postremove
988     saved_postremove=$(typeset -f SAVED_postremove)
989     eval "${saved_postremove/SAVED_/}"
990     export -f postremove
991     fi
992    
993     # unset saved vars; not needed anymore
994     unset SAVED_PNAME
995     unset SAVED_PVER
996     unset SAVED_PBUILD
997     unset SAVED_PCATEGORIE
998     unset SAVED_DESCRIPTION
999     unset SAVED_HOMEPAGE
1000     unset SAVED_SPECIAL_VARS
1001     unset SAVED_STATE
1002     unset SAVED_PKGTYPE
1003     unset SAVED_INHERITS
1004     unset SAVED_DEPEND
1005     unset SAVED_SDEPEND
1006     unset SAVED_PROVIDE
1007     unset -f SAVED_preinstall
1008     unset -f SAVED_postinstall
1009     unset -f SAVED_preremove
1010     unset -f SAVED_postremove
1011    }
1012    
1013  export_inherits()  export_inherits()
1014  {  {
1015   local include="$1"   local include="$1"
# Line 1080  then Line 1260  then
1260   regen_mage_tree   regen_mage_tree
1261    
1262   # build several targets   # build several targets
1263   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1264   then   then
1265   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1266   do   do
# Line 1093  then Line 1273  then
1273   --parch "${ARCH}" \   --parch "${ARCH}" \
1274   --target "${target}"   --target "${target}"
1275   done   done
1276    
1277     # build several subpackages
1278     elif [[ -n ${SPLIT_PACKAGES} ]]
1279     then
1280     split_save_variables
1281     for subpackage in ${SPLIT_PACKAGE}
1282     do
1283     # get the right variables for the split
1284     export PNAME="${subpackage}"
1285     split_info_${subpackage}
1286     # build md5sum for existing packages
1287     generate_package_md5sum \
1288     --pcat "${PCATEGORIE}" \
1289     --pname "${PNAME}" \
1290     --pver "${PVER}" \
1291     --pbuild "${PBUILD}" \
1292     --parch "${ARCH}"
1293     done
1294     split_restore_variables
1295    
1296   else   else
1297   # build md5sum for existing packages   # build md5sum for existing packages
1298   generate_package_md5sum \   generate_package_md5sum \
# Line 1100  then Line 1300  then
1300   --pname "${PNAME}" \   --pname "${PNAME}" \
1301   --pver "${PVER}" \   --pver "${PVER}" \
1302   --pbuild "${PBUILD}" \   --pbuild "${PBUILD}" \
1303   --parch "${ARCH}" \   --parch "${ARCH}"
  --target "${target}"  
1304   fi   fi
1305    
1306   exit 0   exit 0
# Line 1254  src_compile | ${SMAGE_LOG_CMD} Line 1453  src_compile | ${SMAGE_LOG_CMD}
1453  die_pipestatus 0 "src_compile failed"  die_pipestatus 0 "src_compile failed"
1454  step_by_step $_  step_by_step $_
1455    
1456  src_install | ${SMAGE_LOG_CMD}  # build several subpackages
1457  die_pipestatus 0 "src_install failed"  if [[ -n ${SPLIT_PACKAGES} ]]
1458  step_by_step $_  then
1459     # save bindir
1460     export SAVED_BINDIR="${BINDIR}"
1461     for subpackage in ${SPLIT_PACKAGES}
1462     do
1463     if typeset -f src_install_${subpackage} > /dev/null
1464     then
1465     # export subpackage bindir
1466     export BINDIR="${SAVED_BINDIR}_${subpackage}"
1467     src_install_${subpackage} | ${SMAGE_LOG_CMD}
1468     die_pipestatus 0 "src_install_${subpackage} failed"
1469     step_by_step $_
1470     fi
1471     done
1472     # restore bindir
1473     export BINDIR="${SAVED_BINDIR}"
1474     unset SAVED_BINDIR
1475    else
1476     src_install | ${SMAGE_LOG_CMD}
1477     die_pipestatus 0 "src_install failed"
1478     step_by_step $_
1479    fi
1480    
1481    echo -e "${COLGREEN}DEB${COLRED}UG!${COLDEFAULT}"
1482    
1483  # compressing doc, info & man files  # compressing doc, info & man files
1484  if [ -d ${BUILDDIR}/builded/usr/share/man ]  if [[ -n ${SPLIT_PACKAGES} ]]
1485  then  then
1486   echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGE}
1487   ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man   do
1488     mcompressdocs ${BINDIR}_${subpackage}
1489     done
1490    else
1491     mcompressdocs ${BINDIR}
1492  fi  fi
1493    
 if [ -d ${BUILDDIR}/builded/usr/share/info ]  
 then  
  echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}"  
  ${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info  
 fi  
1494    
1495  # stripping all bins and libs  # stripping all bins and libs
1496  case ${NOSTRIP} in  case ${NOSTRIP} in
# Line 1278  case ${NOSTRIP} in Line 1498  case ${NOSTRIP} in
1498   echo -e "NOSTRIP=true detected; Package will not be stripped ..."   echo -e "NOSTRIP=true detected; Package will not be stripped ..."
1499   ;;   ;;
1500   *)   *)
1501   echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"   if [[ -n ${SPLIT_PACKAGES} ]]
1502   mstripbins ${BINDIR}   then
1503   echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"   for subpackage in ${SPLIT_PACKAGE}
1504   mstriplibs ${BINDIR}   do
1505     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1506     mstripbins ${BINDIR}_${subpackage}
1507     echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1508     mstriplibs ${BINDIR}_${subpackage}
1509     done
1510     else
1511     echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}"
1512     mstripbins ${BINDIR}
1513     echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}"
1514     mstriplibs ${BINDIR}
1515     fi
1516   ;;   ;;
1517  esac  esac
1518    
# Line 1292  case ${NOPKGBUILD} in Line 1523  case ${NOPKGBUILD} in
1523   ;;   ;;
1524   *)   *)
1525   # build several targets   # build several targets
1526   if [ -n "${MAGE_TARGETS}" ]   if [[ -n ${MAGE_TARGETS} ]]
1527   then   then
1528   for target in ${MAGE_TARGETS}   for target in ${MAGE_TARGETS}
1529   do   do
# Line 1318  case ${NOPKGBUILD} in Line 1549  case ${NOPKGBUILD} in
1549    
1550   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}"
1551   done   done
1552    
1553     # build several subpackages
1554     elif [[ -n ${SPLIT_PACKAGES} ]]
1555     then
1556     split_save_variables
1557     for subpackage in ${SPLIT_PACKAGES}
1558     do
1559     # get the right variables for the split
1560     export PNAME="${subpackage}"
1561     split_info_${PNAME}
1562    
1563     # check if an special subpackage_pkgbuild exists
1564     if typeset -f ${PNAME}_pkgbuild > /dev/null
1565     then
1566     # run it
1567     ${PNAME}_pkgbuild
1568     fi
1569     # now create the target package
1570     ${MLIBDIR}/pkgbuild_dir.sh \
1571     "${PNAME}-${PVER}-${ARCH}-${PBUILD}" \
1572     "${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed"
1573    
1574     # build pkg-md5-sum if requested
1575     generate_package_md5sum \
1576     --pcat "${PCATEGORIE}" \
1577     --pname "${PNAME}" \
1578     --pver "${PVER}" \
1579     --pbuild "${PBUILD}" \
1580     --parch "${ARCH}"
1581    
1582     echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}"
1583     done
1584     split_restore_variables
1585    
1586   else   else
1587   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"   ${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed"
1588    

Legend:
Removed from v.942  
changed lines
  Added in v.943