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.23 2005-08-19 03:43:56 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.26 2005-08-20 15:51:14 niro Exp $ |
8 |
|
|
9 |
#01.10.2004 |
#01.10.2004 |
10 |
# added ccache support |
# added ccache support |
406 |
fi |
fi |
407 |
} |
} |
408 |
|
|
409 |
|
|
410 |
|
# fixes given dependencies to match a MAGE_TARGET |
411 |
|
# fix_mage_deps target s/depend |
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() |
# 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: |
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 |
|
# |
481 |
|
# gets called with build_mage_script target |
482 |
build_mage_script() |
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" |
[ -n "$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.23 2005-08-19 03:43:56 niro Exp $' >> ${dest} |
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.26 2005-08-20 15:51:14 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 |
|
|
554 |
done |
done |
555 |
fi |
fi |
556 |
|
|
557 |
|
# add special vars |
558 |
|
if [ -n "${SPECIAL_VARS}" ] |
559 |
|
then |
560 |
|
local i |
561 |
|
for i in ${SPECIAL_VARS} |
562 |
|
do |
563 |
|
# being tricky here :) |
564 |
|
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
565 |
|
done |
566 |
|
fi |
567 |
|
|
568 |
# pre|post-install|removes |
# pre|post-install|removes |
569 |
typeset -f preinstall >> ${dest} |
typeset -f preinstall >> ${dest} |
570 |
echo >> ${dest} |
echo >> ${dest} |
583 |
# build them only if requested |
# build them only if requested |
584 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
585 |
then |
then |
586 |
# build for each target an mage file |
# run it without targets |
587 |
for i in ${MAGE_TARGETS} |
if [ -z "${MAGE_TARGETS}" ] |
588 |
do |
then |
589 |
echo |
echo |
590 |
build_mage_script "${i}" |
build_mage_script |
591 |
echo |
echo |
592 |
done |
else |
593 |
|
|
594 |
|
# build for each target an mage file |
595 |
|
# run it with several targets |
596 |
|
for i in ${MAGE_TARGETS} |
597 |
|
do |
598 |
|
echo |
599 |
|
build_mage_script "${i}" |
600 |
|
echo |
601 |
|
done |
602 |
|
fi |
603 |
fi |
fi |
604 |
|
|
605 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
610 |
unset "${i}" |
unset "${i}" |
611 |
done |
done |
612 |
unset SPECIAL_FUNCTIONS |
unset SPECIAL_FUNCTIONS |
613 |
|
for i in ${SPECIAL_VARS} |
614 |
|
do |
615 |
|
unset "${i}" |
616 |
|
done |
617 |
|
unset SPECIAL_VARS |
618 |
unset STATE |
unset STATE |
619 |
unset DESCRIPTION |
unset DESCRIPTION |
620 |
unset HOMEPAGE |
unset HOMEPAGE |