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.22 2005-08-19 02:24:12 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.30 2005-08-21 21:23:48 niro Exp $ |
8 |
|
|
9 |
#01.10.2004 |
#01.10.2004 |
10 |
# added ccache support |
# added ccache support |
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 |
406 |
fi |
fi |
407 |
} |
} |
408 |
|
|
409 |
# alx_create_mage_file: helper functions for regen_mage_tree() |
|
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 |
|
# fix pver to target-pver |
432 |
|
# to get pname-target-pver |
433 |
|
|
434 |
|
# doing it backwards ! |
435 |
|
pver="${dep##*-}" |
436 |
|
pname=$(basename ${dep/-${pver}/}) |
437 |
|
fi |
438 |
|
|
439 |
|
# do not add empty lines |
440 |
|
if [ -z "${NDEPEND}" ] |
441 |
|
then |
442 |
|
NDEPEND="${sym} ${cat}/${pname}${target}-${pver}" |
443 |
|
else |
444 |
|
NDEPEND="${NDEPEND} |
445 |
|
${sym} ${cat}/${pname}${target}-${pver}" |
446 |
|
fi |
447 |
|
|
448 |
|
unset cat pname pver |
449 |
|
done << EOF |
450 |
|
${depend} |
451 |
|
EOF |
452 |
|
# set NDEPEND to DEPEND |
453 |
|
depend="${NDEPEND}" |
454 |
|
fi |
455 |
|
|
456 |
|
echo "${depend}" |
457 |
|
} |
458 |
|
|
459 |
|
# build_mage_script(): helper functions for regen_mage_tree() |
460 |
# generates an mage file with given information in smage file |
# generates an mage file with given information in smage file |
461 |
# needs at least: |
# needs at least: |
462 |
# PNAME name of pkg |
# PNAME name of pkg |
478 |
# |
# |
479 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
480 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
481 |
alx_create_mage_file() |
# |
482 |
|
# gets called with build_mage_script target |
483 |
|
build_mage_script() |
484 |
{ |
{ |
485 |
local magefile |
local magefile |
486 |
local dest |
local dest |
487 |
local suffix |
local target |
488 |
local sym |
local sym |
489 |
local depname |
local depname |
490 |
|
|
492 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
493 |
|
|
494 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
495 |
suffix="$1" |
[ -n "$1" ] && target="-$1" |
496 |
|
|
497 |
# name of magefile |
# name of magefile |
498 |
magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
499 |
|
|
500 |
# destination to magefile |
# destination to magefile |
501 |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}" |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
502 |
|
|
503 |
# show what we are doing |
# show what we are doing |
504 |
echo "Generating Mage file:" |
echo "Generating Mage file:" |
509 |
> ${dest} |
> ${dest} |
510 |
|
|
511 |
# header |
# header |
512 |
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.22 2005-08-19 02:24:12 niro Exp $' >> ${dest} |
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.30 2005-08-21 21:23:48 niro Exp $' >> ${dest} |
513 |
echo >> ${dest} |
echo >> ${dest} |
514 |
|
|
515 |
# pgkname and state |
# pgkname and state |
516 |
echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
517 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
518 |
echo >> ${dest} |
echo >> ${dest} |
519 |
|
|
522 |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
523 |
echo >> ${dest} |
echo >> ${dest} |
524 |
|
|
525 |
# special tags |
# special tags and vars |
526 |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
527 |
|
# add special vars |
528 |
|
if [ -n "${SPECIAL_VARS}" ] |
529 |
|
then |
530 |
|
local i |
531 |
|
for i in ${SPECIAL_VARS} |
532 |
|
do |
533 |
|
# being tricky here :) |
534 |
|
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
535 |
|
done |
536 |
|
echo >> ${dest} |
537 |
|
fi |
538 |
|
# add at least all includes |
539 |
if [ -n "${INHERITS}" ] |
if [ -n "${INHERITS}" ] |
540 |
then |
then |
541 |
echo -n "minclude" >> ${dest} |
echo -n "minclude" >> ${dest} |
549 |
echo >> ${dest} |
echo >> ${dest} |
550 |
|
|
551 |
# deps and provides |
# deps and provides |
552 |
echo "DEPEND=\"${DEPEND}\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
553 |
echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} |
echo >> ${dest} |
554 |
|
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
555 |
|
echo >> ${dest} |
556 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
557 |
echo >> ${dest} |
echo >> ${dest} |
558 |
|
|
565 |
# add to mage (quotes needed !) |
# add to mage (quotes needed !) |
566 |
typeset -f "${i}" >> ${dest} |
typeset -f "${i}" >> ${dest} |
567 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
568 |
unset "${i}" |
#unset "${i}" <-- later to get every target built |
569 |
done |
done |
570 |
|
echo >> ${dest} |
571 |
fi |
fi |
572 |
|
|
573 |
# pre|post-install|removes |
# pre|post-install|removes |
588 |
# build them only if requested |
# build them only if requested |
589 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
590 |
then |
then |
591 |
# build for each target an mage file |
# run it without targets |
592 |
for i in ${MAGE_TARGETS} |
if [ -z "${MAGE_TARGETS}" ] |
593 |
do |
then |
594 |
echo |
echo |
595 |
alx_create_mage_file "${i}" |
build_mage_script |
596 |
echo |
echo |
597 |
done |
else |
598 |
|
|
599 |
|
# build for each target an mage file |
600 |
|
# run it with several targets |
601 |
|
for i in ${MAGE_TARGETS} |
602 |
|
do |
603 |
|
echo |
604 |
|
build_mage_script "${i}" |
605 |
|
echo |
606 |
|
done |
607 |
|
fi |
608 |
fi |
fi |
609 |
|
|
610 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
611 |
unset PKGNAME |
# unset PKGNAME <-- don't do that; smage needs this var |
612 |
|
# unset to be safe (quotes needed !) |
613 |
|
for i in ${SPECIAL_FUNCTIONS} |
614 |
|
do |
615 |
|
unset "${i}" |
616 |
|
done |
617 |
|
unset SPECIAL_FUNCTIONS |
618 |
|
for i in ${SPECIAL_VARS} |
619 |
|
do |
620 |
|
unset "${i}" |
621 |
|
done |
622 |
|
unset SPECIAL_VARS |
623 |
unset STATE |
unset STATE |
624 |
unset DESCRIPTION |
unset DESCRIPTION |
625 |
unset HOMEPAGE |
unset HOMEPAGE |
628 |
unset DEPEND |
unset DEPEND |
629 |
unset SDEPEND |
unset SDEPEND |
630 |
unset PROVIDE |
unset PROVIDE |
|
unset SPECIAL_FUNCTIONS |
|
631 |
unset preinstall |
unset preinstall |
632 |
unset postinstall |
unset postinstall |
633 |
unset preremove |
unset preremove |
645 |
exit 1 |
exit 1 |
646 |
fi |
fi |
647 |
|
|
648 |
#updating smage2-scripts |
# updating smage2-scripts |
649 |
if [ "$1" == "update" ] |
if [ "$1" == "update" ] |
650 |
then |
then |
651 |
if [ ! -d ${SOURCEDIR} ] |
if [ ! -d ${SOURCEDIR} ] |
656 |
exit 0 |
exit 0 |
657 |
fi |
fi |
658 |
|
|
659 |
#creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
660 |
if [ "$1" == "calcmd5" ] |
if [ "$1" == "calcmd5" ] |
661 |
then |
then |
662 |
if [ $# -ge 3 ] |
if [ $# -ge 3 ] |
726 |
exit 0 |
exit 0 |
727 |
fi |
fi |
728 |
|
|
729 |
#download sources |
# download sources |
730 |
if [ "$1" == "download" -a -n "$2" ] |
if [ "$1" == "download" -a -n "$2" ] |
731 |
then |
then |
732 |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
800 |
# auto regen mage tree if requested |
# auto regen mage tree if requested |
801 |
regen_mage_tree |
regen_mage_tree |
802 |
|
|
803 |
#download sources |
# download sources |
804 |
download_sources |
download_sources |
805 |
|
|
806 |
#fixes some issues with these functions |
# fixes some issues with these functions |
807 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
808 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
809 |
export -f src_install || die "src_install export failed" |
export -f src_install || die "src_install export failed" |
810 |
|
|
811 |
#fixes some compile issues |
# fixes some compile issues |
812 |
export CHOST="${CHOST}" || die "CHOST export failed" |
export CHOST="${CHOST}" || die "CHOST export failed" |
813 |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
814 |
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
816 |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
817 |
|
|
818 |
|
|
819 |
#setup distcc |
# setup distcc |
820 |
#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 |
821 |
if [ "${SMAGE_USE_DISTCC}" == "true" ] |
if [ "${SMAGE_USE_DISTCC}" == "true" ] |
822 |
then |
then |
823 |
setup_distcc_environment |
setup_distcc_environment |
824 |
fi |
fi |
825 |
|
|
826 |
#setup ccache |
# setup ccache |
827 |
if [ "${SMAGE_USE_CCACHE}" == "true" ] |
if [ "${SMAGE_USE_CCACHE}" == "true" ] |
828 |
then |
then |
829 |
setup_ccache_environment |
setup_ccache_environment |
844 |
#read |
#read |
845 |
#debug end |
#debug end |
846 |
|
|
847 |
#cleans up build if a previously one exists |
# cleans up build if a previously one exists |
848 |
if [ -d ${BUILDDIR} ] |
if [ -d ${BUILDDIR} ] |
849 |
then |
then |
850 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
851 |
fi |
fi |
852 |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
853 |
|
|
854 |
#cleans up srcdir if a previously unpacked one exists |
# cleans up srcdir if a previously unpacked one exists |
855 |
if [ -d ${SRCDIR} ] |
if [ -d ${SRCDIR} ] |
856 |
then |
then |
857 |
rm -rf ${SRCDIR} |
rm -rf ${SRCDIR} |
858 |
fi |
fi |
859 |
|
|
860 |
#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 |
861 |
if [ -d ${BINDIR} ] |
if [ -d ${BINDIR} ] |
862 |
then |
then |
863 |
rm -rf ${BINDIR} |
rm -rf ${BINDIR} |
864 |
fi |
fi |
865 |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
866 |
|
|
867 |
#cleans up package temp dir if a previous build exists |
# cleans up package temp dir if a previous build exists |
868 |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
869 |
then |
then |
870 |
rm -rf ${BUILDDIR}/${PKGNAME} |
rm -rf ${BUILDDIR}/${PKGNAME} |
871 |
fi |
fi |
872 |
|
|
873 |
#cleans up timestamp if one exists |
# cleans up timestamp if one exists |
874 |
if [ -f /var/tmp/timestamp ] |
if [ -f /var/tmp/timestamp ] |
875 |
then |
then |
876 |
mage rmstamp |
mage rmstamp |
881 |
src_install || die "src_install failed" |
src_install || die "src_install failed" |
882 |
|
|
883 |
|
|
884 |
#compressing doc, info & man files |
# compressing doc, info & man files |
885 |
echo -e "Compressing man-pages ..." |
echo -e "Compressing man-pages ..." |
886 |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
887 |
then |
then |
907 |
;; |
;; |
908 |
esac |
esac |
909 |
|
|
910 |
#the new buildpkg command |
# the new buildpkg command |
911 |
case ${NOPKGBUILD} in |
case ${NOPKGBUILD} in |
912 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
913 |
echo -e "NOPGKBUILD=true detected; Package will not be build ..." |
echo -e "NOPGKBUILD=true detected; Package will not be build ..." |
914 |
;; |
;; |
915 |
*) |
*) |
916 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
# build serveral targets |
917 |
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
if [ -n "${MAGE_TARGETS}" ] |
918 |
|
then |
919 |
|
for target in ${MAGE_TARGETS} |
920 |
|
do |
921 |
|
# check if an special target_pkgbuild exists |
922 |
|
if typeset -f ${target}_pkgbuild > /dev/null |
923 |
|
then |
924 |
|
# run it |
925 |
|
${target}_pkgbuild |
926 |
|
fi |
927 |
|
# now create the target package |
928 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
929 |
|
"${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \ |
930 |
|
${BINDIR} || die "target: ${target} package-build failed" |
931 |
|
echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n" |
932 |
|
done |
933 |
|
else |
934 |
|
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
935 |
|
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
936 |
|
fi |
937 |
;; |
;; |
938 |
esac |
esac |
939 |
|
|
940 |
#for sure |
# for sure |
941 |
unset NOPKGBUILD |
unset NOPKGBUILD |
942 |
unset NOSTRIP |
unset NOSTRIP |
943 |
|
|