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.24 2005-08-19 14:14:59 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 # <-- '-' is essential ! (build_mage_script needs this) |
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 |
|
# abort on virtual |
429 |
|
[[ ${cat} = virtual ]] && continue |
430 |
|
|
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 |
|
|
438 |
|
# do not add empty lines |
439 |
|
if [ -z "${NDEPEND}" ] |
440 |
|
then |
441 |
|
NDEPEND="${sym} ${cat}/${pname}${target}-${pver}" |
442 |
|
else |
443 |
|
NDEPEND="${NDEPEND} |
444 |
|
${sym} ${cat}/${pname}${target}-${pver}" |
445 |
|
fi |
446 |
|
|
447 |
|
unset cat pname pver |
448 |
|
done << EOF |
449 |
|
${depend} |
450 |
|
EOF |
451 |
|
# set NDEPEND to DEPEND |
452 |
|
depend="${NDEPEND}" |
453 |
|
fi |
454 |
|
|
455 |
|
echo "${depend}" |
456 |
|
} |
457 |
|
|
458 |
|
# build_mage_script(): helper functions for regen_mage_tree() |
459 |
# generates an mage file with given information in smage file |
# generates an mage file with given information in smage file |
460 |
# needs at least: |
# needs at least: |
461 |
# PNAME name of pkg |
# PNAME name of pkg |
477 |
# |
# |
478 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
479 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
480 |
alx_create_mage_file() |
# |
481 |
|
# gets called with build_mage_script target # <-- '-' is essential ! |
482 |
|
build_mage_script() |
483 |
{ |
{ |
484 |
local magefile |
local magefile |
485 |
local dest |
local dest |
486 |
local suffix |
local target |
487 |
local sym |
local sym |
488 |
local depname |
local depname |
489 |
|
|
491 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
492 |
|
|
493 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
494 |
suffix="$1" |
target="$1" |
495 |
|
|
496 |
# name of magefile |
# name of magefile |
497 |
magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
498 |
|
|
499 |
# destination to magefile |
# destination to magefile |
500 |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}" |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
501 |
|
|
502 |
# show what we are doing |
# show what we are doing |
503 |
echo "Generating Mage file:" |
echo "Generating Mage file:" |
508 |
> ${dest} |
> ${dest} |
509 |
|
|
510 |
# header |
# header |
511 |
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.24 2005-08-19 14:14:59 niro Exp $' >> ${dest} |
512 |
echo >> ${dest} |
echo >> ${dest} |
513 |
|
|
514 |
# pgkname and state |
# pgkname and state |
515 |
echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
516 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
517 |
echo >> ${dest} |
echo >> ${dest} |
518 |
|
|
536 |
echo >> ${dest} |
echo >> ${dest} |
537 |
|
|
538 |
# deps and provides |
# deps and provides |
539 |
echo "DEPEND=\"${DEPEND}\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
540 |
echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
541 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
542 |
echo >> ${dest} |
echo >> ${dest} |
543 |
|
|
550 |
# add to mage (quotes needed !) |
# add to mage (quotes needed !) |
551 |
typeset -f "${i}" >> ${dest} |
typeset -f "${i}" >> ${dest} |
552 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
553 |
unset "${i}" |
#unset "${i}" <-- later to get every target built |
554 |
done |
done |
555 |
fi |
fi |
556 |
|
|
576 |
for i in ${MAGE_TARGETS} |
for i in ${MAGE_TARGETS} |
577 |
do |
do |
578 |
echo |
echo |
579 |
alx_create_mage_file "${i}" |
build_mage_script "-${i}" |
580 |
echo |
echo |
581 |
done |
done |
582 |
fi |
fi |
583 |
|
|
584 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
585 |
unset PKGNAME |
# unset PKGNAME <-- don't do that; smage needs this var |
586 |
|
# unset to be safe (quotes needed !) |
587 |
|
for i in ${SPECIAL_FUNCTIONS} |
588 |
|
do |
589 |
|
unset "${i}" |
590 |
|
done |
591 |
|
unset SPECIAL_FUNCTIONS |
592 |
unset STATE |
unset STATE |
593 |
unset DESCRIPTION |
unset DESCRIPTION |
594 |
unset HOMEPAGE |
unset HOMEPAGE |
597 |
unset DEPEND |
unset DEPEND |
598 |
unset SDEPEND |
unset SDEPEND |
599 |
unset PROVIDE |
unset PROVIDE |
|
unset SPECIAL_FUNCTIONS |
|
600 |
unset preinstall |
unset preinstall |
601 |
unset postinstall |
unset postinstall |
602 |
unset preremove |
unset preremove |
614 |
exit 1 |
exit 1 |
615 |
fi |
fi |
616 |
|
|
617 |
#updating smage2-scripts |
# updating smage2-scripts |
618 |
if [ "$1" == "update" ] |
if [ "$1" == "update" ] |
619 |
then |
then |
620 |
if [ ! -d ${SOURCEDIR} ] |
if [ ! -d ${SOURCEDIR} ] |
625 |
exit 0 |
exit 0 |
626 |
fi |
fi |
627 |
|
|
628 |
#creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
629 |
if [ "$1" == "calcmd5" ] |
if [ "$1" == "calcmd5" ] |
630 |
then |
then |
631 |
if [ $# -ge 3 ] |
if [ $# -ge 3 ] |
695 |
exit 0 |
exit 0 |
696 |
fi |
fi |
697 |
|
|
698 |
#download sources |
# download sources |
699 |
if [ "$1" == "download" -a -n "$2" ] |
if [ "$1" == "download" -a -n "$2" ] |
700 |
then |
then |
701 |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
769 |
# auto regen mage tree if requested |
# auto regen mage tree if requested |
770 |
regen_mage_tree |
regen_mage_tree |
771 |
|
|
772 |
#download sources |
# download sources |
773 |
download_sources |
download_sources |
774 |
|
|
775 |
#fixes some issues with these functions |
# fixes some issues with these functions |
776 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
777 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
778 |
export -f src_install || die "src_install export failed" |
export -f src_install || die "src_install export failed" |
779 |
|
|
780 |
#fixes some compile issues |
# fixes some compile issues |
781 |
export CHOST="${CHOST}" || die "CHOST export failed" |
export CHOST="${CHOST}" || die "CHOST export failed" |
782 |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
783 |
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
785 |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
786 |
|
|
787 |
|
|
788 |
#setup distcc |
# setup distcc |
789 |
#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 |
790 |
if [ "${SMAGE_USE_DISTCC}" == "true" ] |
if [ "${SMAGE_USE_DISTCC}" == "true" ] |
791 |
then |
then |
792 |
setup_distcc_environment |
setup_distcc_environment |
793 |
fi |
fi |
794 |
|
|
795 |
#setup ccache |
# setup ccache |
796 |
if [ "${SMAGE_USE_CCACHE}" == "true" ] |
if [ "${SMAGE_USE_CCACHE}" == "true" ] |
797 |
then |
then |
798 |
setup_ccache_environment |
setup_ccache_environment |
813 |
#read |
#read |
814 |
#debug end |
#debug end |
815 |
|
|
816 |
#cleans up build if a previously one exists |
# cleans up build if a previously one exists |
817 |
if [ -d ${BUILDDIR} ] |
if [ -d ${BUILDDIR} ] |
818 |
then |
then |
819 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
820 |
fi |
fi |
821 |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
822 |
|
|
823 |
#cleans up srcdir if a previously unpacked one exists |
# cleans up srcdir if a previously unpacked one exists |
824 |
if [ -d ${SRCDIR} ] |
if [ -d ${SRCDIR} ] |
825 |
then |
then |
826 |
rm -rf ${SRCDIR} |
rm -rf ${SRCDIR} |
827 |
fi |
fi |
828 |
|
|
829 |
#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 |
830 |
if [ -d ${BINDIR} ] |
if [ -d ${BINDIR} ] |
831 |
then |
then |
832 |
rm -rf ${BINDIR} |
rm -rf ${BINDIR} |
833 |
fi |
fi |
834 |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
835 |
|
|
836 |
#cleans up package temp dir if a previous build exists |
# cleans up package temp dir if a previous build exists |
837 |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
838 |
then |
then |
839 |
rm -rf ${BUILDDIR}/${PKGNAME} |
rm -rf ${BUILDDIR}/${PKGNAME} |
840 |
fi |
fi |
841 |
|
|
842 |
#cleans up timestamp if one exists |
# cleans up timestamp if one exists |
843 |
if [ -f /var/tmp/timestamp ] |
if [ -f /var/tmp/timestamp ] |
844 |
then |
then |
845 |
mage rmstamp |
mage rmstamp |
850 |
src_install || die "src_install failed" |
src_install || die "src_install failed" |
851 |
|
|
852 |
|
|
853 |
#compressing doc, info & man files |
# compressing doc, info & man files |
854 |
echo -e "Compressing man-pages ..." |
echo -e "Compressing man-pages ..." |
855 |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
856 |
then |
then |
876 |
;; |
;; |
877 |
esac |
esac |
878 |
|
|
879 |
#the new buildpkg command |
# the new buildpkg command |
880 |
case ${NOPKGBUILD} in |
case ${NOPKGBUILD} in |
881 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
882 |
echo -e "NOPGKBUILD=true detected; Package will not be build ..." |
echo -e "NOPGKBUILD=true detected; Package will not be build ..." |
883 |
;; |
;; |
884 |
*) |
*) |
885 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
# build serveral targets |
886 |
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
if [ -n "${MAGE_TARGETS}" ] |
887 |
|
then |
888 |
|
for target in ${MAGE_TARGETS} |
889 |
|
do |
890 |
|
# check if an special target_pkgbuild exists |
891 |
|
if typeset -f ${target}_pkgbuild > /dev/null |
892 |
|
then |
893 |
|
# run it |
894 |
|
${target}_pkgbuild |
895 |
|
fi |
896 |
|
# now create the target package |
897 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
898 |
|
"${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \ |
899 |
|
${BINDIR} || die "target: ${target} package-build failed" |
900 |
|
echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n" |
901 |
|
done |
902 |
|
else |
903 |
|
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
904 |
|
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
905 |
|
fi |
906 |
;; |
;; |
907 |
esac |
esac |
908 |
|
|
909 |
#for sure |
# for sure |
910 |
unset NOPKGBUILD |
unset NOPKGBUILD |
911 |
unset NOSTRIP |
unset NOSTRIP |
912 |
|
|