4 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
5 |
|
|
6 |
# SMAGE2 |
# SMAGE2 |
7 |
# version: 0.3.6-r12 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.35 2005-08-22 00:16:41 niro Exp $ |
8 |
|
|
9 |
#01.10.2004 |
#01.10.2004 |
10 |
# added ccache support |
# added ccache support |
11 |
# added distcc support |
# added distcc support |
12 |
|
|
13 |
## setup ## |
## setup ## |
|
SMAGEVERSION=0.3.6-r11 |
|
14 |
PKGSUFFIX="mpk" |
PKGSUFFIX="mpk" |
15 |
SMAGENAME="$1" |
SMAGENAME="$1" |
16 |
SMAGESUFFIX="smage2" |
SMAGESUFFIX="smage2" |
18 |
#SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts" |
#SMAGESCRIPTSDIR="/bootstrap/smage2-install-scripts" |
19 |
#SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts" |
#SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts" |
20 |
MLIBDIR=/usr/lib/mage |
MLIBDIR=/usr/lib/mage |
21 |
|
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
22 |
|
|
23 |
|
# export default C locale |
24 |
|
export LC_ALL=C |
25 |
|
|
26 |
source /etc/mage.rc |
source /etc/mage.rc |
27 |
|
|
87 |
xtitleclean |
xtitleclean |
88 |
} |
} |
89 |
|
|
90 |
|
# $1 filename |
91 |
|
get_db_md5_sum() { |
92 |
|
local DB_FILE |
93 |
|
local MD5_FILE |
94 |
|
local i |
95 |
|
|
96 |
|
DB_ENTRY="$(basename $1)" |
97 |
|
MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})" |
98 |
|
|
99 |
|
i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)" |
100 |
|
|
101 |
|
echo "${i}" |
102 |
|
} |
103 |
|
|
104 |
|
download_sources() { |
105 |
|
|
106 |
|
[ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
107 |
|
|
108 |
|
local EOA=${#SRC_URI[*]} |
109 |
|
local my_SRC_URI |
110 |
|
local my_SRC_URI_DEST |
111 |
|
local my_SRC_URI_MIRROR |
112 |
|
local my_SOURCEDIR |
113 |
|
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
114 |
|
local FETCHING |
115 |
|
local i mirror |
116 |
|
|
117 |
|
|
118 |
|
#install SRCDIR/PNAME if not exist |
119 |
|
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
120 |
|
|
121 |
|
# check if FETCHING is needed |
122 |
|
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
123 |
|
if [[ $? == 0 ]] |
124 |
|
then |
125 |
|
# md5's ok, not fetching needed |
126 |
|
FETCHING=false |
127 |
|
else |
128 |
|
FETCHING=true |
129 |
|
fi |
130 |
|
|
131 |
|
for ((i=0; i < EOA; i++)) |
132 |
|
do |
133 |
|
# url to file |
134 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
135 |
|
|
136 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
137 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
138 |
|
|
139 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
140 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
141 |
|
then |
142 |
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}" |
143 |
|
else |
144 |
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
145 |
|
fi |
146 |
|
|
147 |
|
# if an mirrored file than replace first the mirror uri |
148 |
|
if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] |
149 |
|
then |
150 |
|
for mirror in ${MIRRORS} |
151 |
|
do |
152 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
153 |
|
|
154 |
|
#echo "DEBUG: ${MY_SRC_URI}" |
155 |
|
if [[ ${FETCHING} == true ]] |
156 |
|
then |
157 |
|
echo "==> fetching ${my_SRC_URI_MIRROR}" |
158 |
|
wget \ |
159 |
|
--passive-ftp \ |
160 |
|
--tries 3 \ |
161 |
|
--continue \ |
162 |
|
--progress bar \ |
163 |
|
--directory-prefix="${my_SOURCEDIR}" \ |
164 |
|
"${my_SRC_URI_MIRROR}" |
165 |
|
if [ "$?" == "0" ] |
166 |
|
then |
167 |
|
break |
168 |
|
else |
169 |
|
continue |
170 |
|
fi |
171 |
|
fi |
172 |
|
done |
173 |
|
else |
174 |
|
#echo "DEBUG: ${SRC_URI[${i}]}" |
175 |
|
if [[ ${FETCHING} == true ]] |
176 |
|
then |
177 |
|
echo "==> fetching ${my_SRC_URI}" |
178 |
|
wget \ |
179 |
|
--passive-ftp \ |
180 |
|
--tries 3 \ |
181 |
|
--continue \ |
182 |
|
--progress bar \ |
183 |
|
--directory-prefix="${my_SOURCEDIR}" \ |
184 |
|
"${my_SRC_URI}" |
185 |
|
# only needed to run through a list of mirrors |
186 |
|
# if [ "$?" == "0" ] |
187 |
|
# then |
188 |
|
# break |
189 |
|
# else |
190 |
|
# continue |
191 |
|
# fi |
192 |
|
fi |
193 |
|
fi |
194 |
|
|
195 |
|
# unset them to be shure |
196 |
|
unset my_SRC_URI |
197 |
|
unset my_SRC_URI_DEST |
198 |
|
unset my_SRC_URI_MIRROR |
199 |
|
unset my_SOURCEDIR |
200 |
|
done |
201 |
|
|
202 |
|
# recheck md5 sums |
203 |
|
echo |
204 |
|
echo ">== Checking MD5 sums:" |
205 |
|
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
206 |
|
echo |
207 |
|
|
208 |
|
# not needed anymore |
209 |
|
unset SRC_URI |
210 |
|
} |
211 |
|
|
212 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that not exist in smage file |
213 |
src_prepare() { |
src_prepare() { |
214 |
echo "no src_prepare defined" |
echo "no src_prepare defined" |
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 |
338 |
done |
done |
339 |
} |
} |
340 |
|
|
341 |
|
mstriplibs() { |
342 |
|
local stripdir="$@" |
343 |
|
|
344 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
345 |
|
find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
346 |
|
} |
347 |
|
|
348 |
|
mstripbins() { |
349 |
|
local stripdir="$@" |
350 |
|
|
351 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
352 |
|
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
353 |
|
} |
354 |
|
|
355 |
|
sminclude() { |
356 |
|
local i |
357 |
|
|
358 |
|
if [[ -n "$@" ]] |
359 |
|
then |
360 |
|
for i in $@ |
361 |
|
do |
362 |
|
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
363 |
|
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
364 |
|
done |
365 |
|
echo |
366 |
|
fi |
367 |
|
} |
368 |
|
|
369 |
setup_distcc_environment(){ |
setup_distcc_environment(){ |
370 |
if [ -x /usr/bin/distcc ] |
if [ -x /usr/bin/distcc ] |
371 |
then |
then |
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}" |
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() |
463 |
|
# generates an mage file with given information in smage file |
464 |
|
# needs at least: |
465 |
|
# PNAME name of pkg |
466 |
|
# PVER version |
467 |
|
# PBUILD revision |
468 |
|
# PCATEGORIE categorie of the pkg |
469 |
|
# STATE state of pkg stable|unstable|old |
470 |
|
# DESCRIPTION va short description (opt) |
471 |
|
# HOMEPAGE homepage (opt) |
472 |
|
# DEPEND runtime dependencies (opt) |
473 |
|
# SDEPEND add. needed deps to build the pkg (opt) |
474 |
|
# PROVIDE provides a virtual (opt) |
475 |
|
# |
476 |
|
# special tags: |
477 |
|
# PKGTYPE type of pkg |
478 |
|
# INHERITS which functions get included |
479 |
|
# SPECIAL_FUNCTIONS special functions wich should also be added |
480 |
|
# warning: they get killed before the build starts ! |
481 |
|
# |
482 |
|
# MAGE_TREE_DEST target destination of the generated tree |
483 |
|
# REGEN_MAGE_TREE set to 'true' to enable this |
484 |
|
# |
485 |
|
# gets called with build_mage_script target |
486 |
|
build_mage_script() |
487 |
|
{ |
488 |
|
local magefile |
489 |
|
local dest |
490 |
|
local target |
491 |
|
local sym |
492 |
|
local depname |
493 |
|
|
494 |
|
# if MAGE_TREE_DEST not set use BUILDDIR |
495 |
|
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
496 |
|
|
497 |
|
# determinate which suffix this mage file should get, if any |
498 |
|
[ -n "$1" ] && target="-$1" |
499 |
|
|
500 |
|
# name of magefile |
501 |
|
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
502 |
|
|
503 |
|
# destination to magefile |
504 |
|
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
505 |
|
|
506 |
|
# show what we are doing |
507 |
|
echo "Generating Mage file:" |
508 |
|
echo " ${dest}" |
509 |
|
|
510 |
|
install -d "$(dirname ${dest})" |
511 |
|
# now build the mage file |
512 |
|
> ${dest} |
513 |
|
|
514 |
|
# header |
515 |
|
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.35 2005-08-22 00:16:41 niro Exp $' >> ${dest} |
516 |
|
echo >> ${dest} |
517 |
|
|
518 |
|
# pgkname and state |
519 |
|
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
520 |
|
echo "STATE=\"${STATE}\"" >> ${dest} |
521 |
|
echo >> ${dest} |
522 |
|
|
523 |
|
# description and homepage |
524 |
|
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
525 |
|
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
526 |
|
echo >> ${dest} |
527 |
|
|
528 |
|
# special tags and vars |
529 |
|
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}" ] |
543 |
|
then |
544 |
|
echo -n "minclude" >> ${dest} |
545 |
|
local i |
546 |
|
for i in ${INHERITS} |
547 |
|
do |
548 |
|
echo -n " ${i}" >> ${dest} |
549 |
|
done |
550 |
|
echo >> ${dest} |
551 |
|
fi |
552 |
|
echo >> ${dest} |
553 |
|
|
554 |
|
# deps and provides |
555 |
|
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
556 |
|
echo >> ${dest} |
557 |
|
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
558 |
|
echo >> ${dest} |
559 |
|
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
560 |
|
echo >> ${dest} |
561 |
|
|
562 |
|
# add special functions |
563 |
|
if [ -n "${SPECIAL_FUNCTIONS}" ] |
564 |
|
then |
565 |
|
local i |
566 |
|
for i in ${SPECIAL_FUNCTIONS} |
567 |
|
do |
568 |
|
# add to mage (quotes needed !) |
569 |
|
typeset -f "${i}" >> ${dest} |
570 |
|
# unset to be safe (quotes needed !) |
571 |
|
#unset "${i}" <-- later to get every target built |
572 |
|
done |
573 |
|
echo >> ${dest} |
574 |
|
fi |
575 |
|
|
576 |
|
# pre|post-install|removes |
577 |
|
typeset -f preinstall >> ${dest} |
578 |
|
echo >> ${dest} |
579 |
|
typeset -f postinstall >> ${dest} |
580 |
|
echo >> ${dest} |
581 |
|
typeset -f preremove >> ${dest} |
582 |
|
echo >> ${dest} |
583 |
|
typeset -f postremove >> ${dest} |
584 |
|
echo >> ${dest} |
585 |
|
|
586 |
|
# echo MAGE_TARGETS ## note -target is needed ! |
587 |
|
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
588 |
|
} |
589 |
|
|
590 |
|
regen_mage_tree() |
591 |
|
{ |
592 |
|
local i |
593 |
|
|
594 |
|
# build them only if requested |
595 |
|
if [[ ${REGEN_MAGE_TREE} = true ]] |
596 |
|
then |
597 |
|
# run it without targets |
598 |
|
if [ -z "${MAGE_TARGETS}" ] |
599 |
|
then |
600 |
|
echo |
601 |
|
build_mage_script |
602 |
|
echo |
603 |
|
else |
604 |
|
|
605 |
|
# build for each target an mage file |
606 |
|
# run it with several targets |
607 |
|
for i in ${MAGE_TARGETS} |
608 |
|
do |
609 |
|
echo |
610 |
|
build_mage_script "${i}" |
611 |
|
echo |
612 |
|
done |
613 |
|
fi |
614 |
|
fi |
615 |
|
|
616 |
|
# now unset all uneeded vars to be safe |
617 |
|
# unset PKGNAME <-- don't do that; smage needs this var |
618 |
|
# unset to be safe (quotes needed !) |
619 |
|
for i in ${SPECIAL_FUNCTIONS} |
620 |
|
do |
621 |
|
unset "${i}" |
622 |
|
done |
623 |
|
unset SPECIAL_FUNCTIONS |
624 |
|
for i in ${SPECIAL_VARS} |
625 |
|
do |
626 |
|
unset "${i}" |
627 |
|
done |
628 |
|
unset SPECIAL_VARS |
629 |
|
unset STATE |
630 |
|
unset DESCRIPTION |
631 |
|
unset HOMEPAGE |
632 |
|
unset PKGTYPE |
633 |
|
unset INHERITS |
634 |
|
unset DEPEND |
635 |
|
unset SDEPEND |
636 |
|
unset PROVIDE |
637 |
|
unset preinstall |
638 |
|
unset postinstall |
639 |
|
unset preremove |
640 |
|
unset postremove |
641 |
|
} |
642 |
|
|
643 |
|
# print out our version |
644 |
|
showversion |
645 |
|
echo |
646 |
|
|
647 |
if [ -z "$1" ] |
if [ -z "$1" ] |
648 |
then |
then |
|
showversion |
|
|
echo |
|
649 |
echo "No .smage2 file given. Exiting." |
echo "No .smage2 file given. Exiting." |
650 |
echo |
echo |
651 |
exit 1 |
exit 1 |
652 |
fi |
fi |
653 |
|
|
654 |
#updating smage2-scripts |
# updating smage2-scripts |
655 |
if [ "$1" == "update" ] |
if [ "$1" == "update" ] |
656 |
then |
then |
657 |
showversion |
if [ ! -d ${SOURCEDIR} ] |
658 |
|
then |
659 |
|
install -d ${SOURCEDIR} |
660 |
|
fi |
661 |
|
syncsmage2 |
662 |
|
exit 0 |
663 |
|
fi |
664 |
|
|
665 |
|
# creates md5sums for smages to given dir |
666 |
|
if [ "$1" == "calcmd5" ] |
667 |
|
then |
668 |
|
if [ $# -ge 3 ] |
669 |
|
then |
670 |
|
SMAGENAME="$2" |
671 |
|
MD5DIR="$3" |
672 |
|
source ${SMAGENAME} || die "download source failed" |
673 |
|
|
674 |
|
# overridable sourcedir; must be declared after source of the smage2 |
675 |
|
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
676 |
|
|
677 |
|
[ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
678 |
|
|
679 |
|
# end of array |
680 |
|
EOA=${#SRC_URI[*]} |
681 |
|
|
682 |
|
[ ! -d ${MD5DIR} ] && install -d ${MD5DIR} |
683 |
|
|
684 |
|
# clear md5sum file |
685 |
|
MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
686 |
|
echo -n > ${MY_MD5_FILE} |
687 |
|
|
688 |
|
for ((i=0; i < EOA; i++)) |
689 |
|
do |
690 |
|
# url to file |
691 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
692 |
|
|
693 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
694 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
695 |
|
|
696 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
697 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
698 |
|
then |
699 |
|
MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" |
700 |
|
else |
701 |
|
MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
702 |
|
fi |
703 |
|
|
704 |
|
if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
705 |
|
then |
706 |
|
echo "calculating $(basename ${MY_SRC_FILE}) ..." |
707 |
|
( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} |
708 |
|
else |
709 |
|
echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
710 |
|
fi |
711 |
|
|
712 |
|
# unset them to be shure |
713 |
|
unset my_SRC_URI |
714 |
|
unset my_SRC_URI_DEST |
715 |
|
unset my_SRC_URI_MIRROR |
716 |
|
unset my_SOURCEDIR |
717 |
|
done |
718 |
|
|
719 |
|
echo |
720 |
|
echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." |
721 |
|
echo |
722 |
|
else |
723 |
|
echo "Usage: Calculating MD5 Sums:" |
724 |
|
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
725 |
|
echo |
726 |
|
echo |
727 |
|
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
728 |
|
echo |
729 |
|
exit 1 |
730 |
|
fi |
731 |
|
|
732 |
|
exit 0 |
733 |
|
fi |
734 |
|
|
735 |
|
# download sources |
736 |
|
if [ "$1" == "download" -a -n "$2" ] |
737 |
|
then |
738 |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
739 |
then |
then |
740 |
install -d ${SMAGESCRIPTSDIR} |
install -d ${SMAGESCRIPTSDIR} |
741 |
fi |
fi |
742 |
syncsmage2 |
|
743 |
|
# get smage |
744 |
|
SMAGENAME="$2" |
745 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
746 |
|
source ${SMAGENAME} || die "download source failed" |
747 |
|
|
748 |
|
download_sources |
749 |
exit 0 |
exit 0 |
750 |
fi |
fi |
751 |
|
|
752 |
|
# regen-mage-tree |
753 |
|
if [ "$1" == "only-regen-tree" -a -n "$2" ] |
754 |
|
then |
755 |
|
# set correct SMAGENAME |
756 |
|
SMAGENAME="$2" |
757 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
758 |
|
source ${SMAGENAME} || die "regen: smage2 not found" |
759 |
|
|
760 |
|
regen_mage_tree |
761 |
|
exit 0 |
762 |
|
fi |
763 |
|
|
764 |
if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] |
if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] |
765 |
then |
then |
810 |
|
|
811 |
source ${SMAGENAME} || die "source failed" |
source ${SMAGENAME} || die "source failed" |
812 |
PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}" |
813 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
814 |
|
|
815 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
816 |
#fixes some issues with these functions |
echo "Compiling ${PKGNAME}" |
817 |
|
|
818 |
|
# auto regen mage tree if requested |
819 |
|
regen_mage_tree |
820 |
|
|
821 |
|
# download sources |
822 |
|
download_sources |
823 |
|
|
824 |
|
# fixes some issues with these functions |
825 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
826 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
827 |
export -f src_install || die "src_install export failed" |
export -f src_install || die "src_install export failed" |
828 |
|
|
829 |
#fixes some compile issues |
# fixes some compile issues |
830 |
export CHOST="${CHOST}" || die "CHOST export failed" |
export CHOST="${CHOST}" || die "CHOST export failed" |
831 |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
export CFLAGS="${CFLAGS}" || die "CFLAGS export failed" |
832 |
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
export CXXFLAGS="${CFLAGS}" || die "CXXFLAGS export failed" |
834 |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
export MAKEOPTS="${MAKEOPTS}" || die "MAKEOPTS export failed" |
835 |
|
|
836 |
|
|
837 |
#setup distcc |
# setup distcc |
838 |
#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 |
839 |
if [ "${SMAGE_USE_DISTCC}" == "true" ] |
if [ "${SMAGE_USE_DISTCC}" == "true" ] |
840 |
then |
then |
841 |
setup_distcc_environment |
setup_distcc_environment |
842 |
fi |
fi |
843 |
|
|
844 |
#setup ccache |
# setup ccache |
845 |
if [ "${SMAGE_USE_CCACHE}" == "true" ] |
if [ "${SMAGE_USE_CCACHE}" == "true" ] |
846 |
then |
then |
847 |
setup_ccache_environment |
setup_ccache_environment |
862 |
#read |
#read |
863 |
#debug end |
#debug end |
864 |
|
|
865 |
#cleans up build if a previously one exists |
# cleans up build if a previously one exists |
866 |
if [ -d ${BUILDDIR} ] |
if [ -d ${BUILDDIR} ] |
867 |
then |
then |
868 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
869 |
fi |
fi |
870 |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
871 |
|
|
872 |
#cleans up srcdir if a previously unpacked one exists |
# cleans up srcdir if a previously unpacked one exists |
873 |
if [ -d ${SRCDIR} ] |
if [ -d ${SRCDIR} ] |
874 |
then |
then |
875 |
rm -rf ${SRCDIR} |
rm -rf ${SRCDIR} |
876 |
fi |
fi |
877 |
|
|
878 |
#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 |
879 |
if [ -d ${BINDIR} ] |
if [ -d ${BINDIR} ] |
880 |
then |
then |
881 |
rm -rf ${BINDIR} |
rm -rf ${BINDIR} |
882 |
fi |
fi |
883 |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
884 |
|
|
885 |
#cleans up package temp dir if a previous build exists |
# cleans up package temp dir if a previous build exists |
886 |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
887 |
then |
then |
888 |
rm -rf ${BUILDDIR}/${PKGNAME} |
rm -rf ${BUILDDIR}/${PKGNAME} |
889 |
fi |
fi |
890 |
|
|
891 |
#cleans up timestamp if one exists |
# cleans up timestamp if one exists |
892 |
if [ -f /var/tmp/timestamp ] |
if [ -f /var/tmp/timestamp ] |
893 |
then |
then |
894 |
mage rmstamp |
mage rmstamp |
899 |
src_install || die "src_install failed" |
src_install || die "src_install failed" |
900 |
|
|
901 |
|
|
902 |
#compressing doc, info & man files |
# compressing doc, info & man files |
903 |
echo -e "Compressing man-pages ..." |
echo -e "Compressing man-pages ..." |
904 |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
905 |
then |
then |
912 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
913 |
fi |
fi |
914 |
|
|
915 |
#the new buildpkg command |
# stripping all bins and libs |
916 |
|
case ${NOSTRIP} in |
917 |
|
true|TRUE|yes|y) |
918 |
|
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
919 |
|
;; |
920 |
|
*) |
921 |
|
echo -e "Stripping binaries ..." |
922 |
|
mstripbins ${BINDIR} |
923 |
|
echo -e "Stripping libraries ..." |
924 |
|
mstriplibs ${BINDIR} |
925 |
|
;; |
926 |
|
esac |
927 |
|
|
928 |
|
# the new buildpkg command |
929 |
case ${NOPKGBUILD} in |
case ${NOPKGBUILD} in |
930 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
931 |
echo -e "NOPGKBUILD=true detected; Package will not be build ..." |
echo -e "NOPGKBUILD=true detected; Package will not be build ..." |
932 |
;; |
;; |
933 |
*) |
*) |
934 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
# build serveral targets |
935 |
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
if [ -n "${MAGE_TARGETS}" ] |
936 |
|
then |
937 |
|
for target in ${MAGE_TARGETS} |
938 |
|
do |
939 |
|
# check if an special target_pkgbuild exists |
940 |
|
if typeset -f ${target}_pkgbuild > /dev/null |
941 |
|
then |
942 |
|
# run it |
943 |
|
${target}_pkgbuild |
944 |
|
fi |
945 |
|
# now create the target package |
946 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
947 |
|
"${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD}" \ |
948 |
|
${BINDIR} || die "target: ${target} package-build failed" |
949 |
|
echo -e "\nPackage ${PNAME}-${target}-${PVER}-${CHOST%%-*}-${PBUILD} successfully builded.\n" |
950 |
|
done |
951 |
|
else |
952 |
|
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
953 |
|
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
954 |
|
fi |
955 |
;; |
;; |
956 |
esac |
esac |
957 |
|
|
958 |
#for sure |
# for sure |
959 |
unset NOPKGBUILD |
unset NOPKGBUILD |
960 |
|
unset NOSTRIP |
961 |
|
|
962 |
xtitleclean |
xtitleclean |
963 |
#echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
#echo -e "\nPackage ${PKGNAME} successfully builded.\n" |