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