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.31 2005-08-21 21:36:54 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 # <-- 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 |
|
pname="$(basename ${dep})" |
432 |
|
else |
433 |
|
# fix pver to target-pver |
434 |
|
# to get pname-target-pver |
435 |
|
|
436 |
|
# doing it backwards ! |
437 |
|
pver="${dep##*-}" |
438 |
|
# full pver |
439 |
|
pname="$(basename ${dep/-${pver}/})${target}-${pver}" |
440 |
|
fi |
441 |
|
|
442 |
|
# do not add empty lines |
443 |
|
if [ -z "${NDEPEND}" ] |
444 |
|
then |
445 |
|
NDEPEND="${sym} ${cat}/${pname}" |
446 |
|
else |
447 |
|
NDEPEND="${NDEPEND} |
448 |
|
${sym} ${cat}/${pname}${target}" |
449 |
|
fi |
450 |
|
|
451 |
|
unset cat pname pver |
452 |
|
done << EOF |
453 |
|
${depend} |
454 |
|
EOF |
455 |
|
# set NDEPEND to DEPEND |
456 |
|
depend="${NDEPEND}" |
457 |
|
fi |
458 |
|
|
459 |
|
echo "${depend}" |
460 |
|
} |
461 |
|
|
462 |
# build_mage_script(): helper functions for regen_mage_tree() |
# build_mage_script(): helper functions for regen_mage_tree() |
463 |
# generates an mage file with given information in smage file |
# generates an mage file with given information in smage file |
464 |
# needs at least: |
# needs at least: |
481 |
# |
# |
482 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
483 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
484 |
|
# |
485 |
|
# gets called with build_mage_script target |
486 |
build_mage_script() |
build_mage_script() |
487 |
{ |
{ |
488 |
local magefile |
local magefile |
489 |
local dest |
local dest |
490 |
local suffix |
local target |
491 |
local sym |
local sym |
492 |
local depname |
local depname |
493 |
|
|
495 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
496 |
|
|
497 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
498 |
suffix="$1" |
[ -n "$1" ] && target="-$1" |
499 |
|
|
500 |
# name of magefile |
# name of magefile |
501 |
magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
502 |
|
|
503 |
# destination to magefile |
# destination to magefile |
504 |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}" |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
505 |
|
|
506 |
# show what we are doing |
# show what we are doing |
507 |
echo "Generating Mage file:" |
echo "Generating Mage file:" |
512 |
> ${dest} |
> ${dest} |
513 |
|
|
514 |
# header |
# header |
515 |
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.31 2005-08-21 21:36:54 niro Exp $' >> ${dest} |
516 |
echo >> ${dest} |
echo >> ${dest} |
517 |
|
|
518 |
# pgkname and state |
# pgkname and state |
519 |
echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
520 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
521 |
echo >> ${dest} |
echo >> ${dest} |
522 |
|
|
525 |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
526 |
echo >> ${dest} |
echo >> ${dest} |
527 |
|
|
528 |
# special tags |
# special tags and vars |
529 |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
530 |
|
# add special vars |
531 |
|
if [ -n "${SPECIAL_VARS}" ] |
532 |
|
then |
533 |
|
local i |
534 |
|
for i in ${SPECIAL_VARS} |
535 |
|
do |
536 |
|
# being tricky here :) |
537 |
|
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
538 |
|
done |
539 |
|
echo >> ${dest} |
540 |
|
fi |
541 |
|
# add at least all includes |
542 |
if [ -n "${INHERITS}" ] |
if [ -n "${INHERITS}" ] |
543 |
then |
then |
544 |
echo -n "minclude" >> ${dest} |
echo -n "minclude" >> ${dest} |
552 |
echo >> ${dest} |
echo >> ${dest} |
553 |
|
|
554 |
# deps and provides |
# deps and provides |
555 |
echo "DEPEND=\"${DEPEND}\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
556 |
echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} |
echo >> ${dest} |
557 |
|
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
558 |
|
echo >> ${dest} |
559 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
560 |
echo >> ${dest} |
echo >> ${dest} |
561 |
|
|
570 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
571 |
#unset "${i}" <-- later to get every target built |
#unset "${i}" <-- later to get every target built |
572 |
done |
done |
573 |
|
echo >> ${dest} |
574 |
fi |
fi |
575 |
|
|
576 |
# pre|post-install|removes |
# pre|post-install|removes |
591 |
# build them only if requested |
# build them only if requested |
592 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
593 |
then |
then |
594 |
# build for each target an mage file |
# run it without targets |
595 |
for i in ${MAGE_TARGETS} |
if [ -z "${MAGE_TARGETS}" ] |
596 |
do |
then |
597 |
echo |
echo |
598 |
build_mage_script "${i}" |
build_mage_script |
599 |
echo |
echo |
600 |
done |
else |
601 |
|
|
602 |
|
# build for each target an mage file |
603 |
|
# run it with several targets |
604 |
|
for i in ${MAGE_TARGETS} |
605 |
|
do |
606 |
|
echo |
607 |
|
build_mage_script "${i}" |
608 |
|
echo |
609 |
|
done |
610 |
|
fi |
611 |
fi |
fi |
612 |
|
|
613 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
618 |
unset "${i}" |
unset "${i}" |
619 |
done |
done |
620 |
unset SPECIAL_FUNCTIONS |
unset SPECIAL_FUNCTIONS |
621 |
|
for i in ${SPECIAL_VARS} |
622 |
|
do |
623 |
|
unset "${i}" |
624 |
|
done |
625 |
|
unset SPECIAL_VARS |
626 |
unset STATE |
unset STATE |
627 |
unset DESCRIPTION |
unset DESCRIPTION |
628 |
unset HOMEPAGE |
unset HOMEPAGE |