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.30 2005-08-21 21:23:48 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 |
|
# 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() |
# 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: |
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 |
|
# |
482 |
|
# gets called with build_mage_script target |
483 |
build_mage_script() |
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.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.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 |
|
|
567 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
568 |
#unset "${i}" <-- later to get every target built |
#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 |
build_mage_script "${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 |
615 |
unset "${i}" |
unset "${i}" |
616 |
done |
done |
617 |
unset SPECIAL_FUNCTIONS |
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 |