4 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
5 |
|
|
6 |
# SMAGE2 |
# SMAGE2 |
7 |
# version: 0.3.6-r13 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.22 2005-08-19 02:24:12 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-r13 |
|
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 |
|
|
103 |
|
|
104 |
download_sources() { |
download_sources() { |
105 |
|
|
106 |
[ -z "${SRC_URI}" ] && echo "Nothing declared to download." && return 0 |
[ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
107 |
|
|
108 |
local EOA=${#SRC_URI[*]} |
local EOA=${#SRC_URI[*]} |
109 |
local MY_SRC_URI |
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" |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
114 |
local FETCHING |
local FETCHING |
115 |
local i mirror |
local i mirror |
119 |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
120 |
|
|
121 |
# check if FETCHING is needed |
# check if FETCHING is needed |
122 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} > /dev/null ) |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
123 |
if [[ $? == 0 ]] |
if [[ $? == 0 ]] |
124 |
then |
then |
125 |
# md5's ok, not fetching needed |
# md5's ok, not fetching needed |
130 |
|
|
131 |
for ((i=0; i < EOA; i++)) |
for ((i=0; i < EOA; i++)) |
132 |
do |
do |
133 |
# get MD5 sum from database |
# 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 |
# if an mirrored file than replace first the mirror uri |
148 |
if [ -n "$(echo ${SRC_URI[${i}]} | grep 'mirror://')" ] |
if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] |
149 |
then |
then |
150 |
for mirror in ${MIRRORS} |
for mirror in ${MIRRORS} |
151 |
do |
do |
152 |
MY_SRC_URI="$(echo ${SRC_URI[${i}]} | sed "s|mirror:/|${mirror}/sources|g")" |
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
153 |
|
|
154 |
#echo "DEBUG: ${MY_SRC_URI}" |
#echo "DEBUG: ${MY_SRC_URI}" |
155 |
if [[ ${FETCHING} == true ]] |
if [[ ${FETCHING} == true ]] |
156 |
then |
then |
157 |
echo "==> fetching ${MY_SRC_URI}" |
echo "==> fetching ${my_SRC_URI_MIRROR}" |
158 |
wget \ |
wget \ |
159 |
--passive-ftp \ |
--passive-ftp \ |
160 |
--tries 3 \ |
--tries 3 \ |
161 |
--continue \ |
--continue \ |
162 |
--progress bar \ |
--progress bar \ |
163 |
--directory-prefix="${SOURCEDIR}/${PNAME}" \ |
--directory-prefix="${my_SOURCEDIR}" \ |
164 |
"${MY_SRC_URI}" |
"${my_SRC_URI_MIRROR}" |
165 |
if [ "$?" == "0" ] |
if [ "$?" == "0" ] |
166 |
then |
then |
167 |
break |
break |
174 |
#echo "DEBUG: ${SRC_URI[${i}]}" |
#echo "DEBUG: ${SRC_URI[${i}]}" |
175 |
if [[ ${FETCHING} == true ]] |
if [[ ${FETCHING} == true ]] |
176 |
then |
then |
177 |
echo "==> fetching ${SRC_URI[${i}]}" |
echo "==> fetching ${my_SRC_URI}" |
178 |
wget \ |
wget \ |
179 |
--passive-ftp \ |
--passive-ftp \ |
180 |
--tries 3 \ |
--tries 3 \ |
181 |
--continue \ |
--continue \ |
182 |
--progress bar \ |
--progress bar \ |
183 |
--directory-prefix="${SOURCEDIR}/${PNAME}" \ |
--directory-prefix="${my_SOURCEDIR}" \ |
184 |
"${MY_SRC_URI}" |
"${my_SRC_URI}" |
185 |
if [ "$?" == "0" ] |
# only needed to run through a list of mirrors |
186 |
then |
# if [ "$?" == "0" ] |
187 |
break |
# then |
188 |
else |
# break |
189 |
continue |
# else |
190 |
fi |
# continue |
191 |
|
# fi |
192 |
fi |
fi |
193 |
fi |
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 |
done |
201 |
|
|
202 |
# recheck md5 sums |
# recheck md5 sums |
203 |
echo |
echo |
204 |
echo ">== Checking MD5 sums:" |
echo ">== Checking MD5 sums:" |
205 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} || die "md5 failed") |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
206 |
echo |
echo |
207 |
|
|
208 |
# not needed anymore |
# not needed anymore |
343 |
done |
done |
344 |
} |
} |
345 |
|
|
346 |
|
mstriplibs() { |
347 |
|
local stripdir="$@" |
348 |
|
|
349 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
350 |
|
find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
351 |
|
} |
352 |
|
|
353 |
|
mstripbins() { |
354 |
|
local stripdir="$@" |
355 |
|
|
356 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
357 |
|
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
358 |
|
} |
359 |
|
|
360 |
|
sminclude() { |
361 |
|
local i |
362 |
|
|
363 |
|
if [[ -n "$@" ]] |
364 |
|
then |
365 |
|
for i in $@ |
366 |
|
do |
367 |
|
echo "--- Including ${SMAGESCRIPTSDIR}/include/${i}.sminc" |
368 |
|
source ${SMAGESCRIPTSDIR}/include/${i}.sminc |
369 |
|
done |
370 |
|
echo |
371 |
|
fi |
372 |
|
} |
373 |
|
|
374 |
setup_distcc_environment(){ |
setup_distcc_environment(){ |
375 |
if [ -x /usr/bin/distcc ] |
if [ -x /usr/bin/distcc ] |
376 |
then |
then |
411 |
fi |
fi |
412 |
} |
} |
413 |
|
|
414 |
|
# alx_create_mage_file: helper functions for regen_mage_tree() |
415 |
|
# generates an mage file with given information in smage file |
416 |
|
# needs at least: |
417 |
|
# PNAME name of pkg |
418 |
|
# PVER version |
419 |
|
# PBUILD revision |
420 |
|
# PCATEGORIE categorie of the pkg |
421 |
|
# STATE state of pkg stable|unstable|old |
422 |
|
# DESCRIPTION va short description (opt) |
423 |
|
# HOMEPAGE homepage (opt) |
424 |
|
# DEPEND runtime dependencies (opt) |
425 |
|
# SDEPEND add. needed deps to build the pkg (opt) |
426 |
|
# PROVIDE provides a virtual (opt) |
427 |
|
# |
428 |
|
# special tags: |
429 |
|
# PKGTYPE type of pkg |
430 |
|
# INHERITS which functions get included |
431 |
|
# SPECIAL_FUNCTIONS special functions wich should also be added |
432 |
|
# warning: they get killed before the build starts ! |
433 |
|
# |
434 |
|
# MAGE_TREE_DEST target destination of the generated tree |
435 |
|
# REGEN_MAGE_TREE set to 'true' to enable this |
436 |
|
alx_create_mage_file() |
437 |
|
{ |
438 |
|
local magefile |
439 |
|
local dest |
440 |
|
local suffix |
441 |
|
local sym |
442 |
|
local depname |
443 |
|
|
444 |
|
# if MAGE_TREE_DEST not set use BUILDDIR |
445 |
|
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
446 |
|
|
447 |
|
# determinate which suffix this mage file should get, if any |
448 |
|
suffix="$1" |
449 |
|
|
450 |
|
# name of magefile |
451 |
|
magefile="${PNAME}${suffix}-${PVER}-${PBUILD}.mage" |
452 |
|
|
453 |
|
# destination to magefile |
454 |
|
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${suffix}/${magefile}" |
455 |
|
|
456 |
|
# show what we are doing |
457 |
|
echo "Generating Mage file:" |
458 |
|
echo " ${dest}" |
459 |
|
|
460 |
|
install -d "$(dirname ${dest})" |
461 |
|
# now build the mage file |
462 |
|
> ${dest} |
463 |
|
|
464 |
|
# header |
465 |
|
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} |
466 |
|
echo >> ${dest} |
467 |
|
|
468 |
|
# pgkname and state |
469 |
|
echo "PKGNAME=\"${PNAME}${suffix}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
470 |
|
echo "STATE=\"${STATE}\"" >> ${dest} |
471 |
|
echo >> ${dest} |
472 |
|
|
473 |
|
# description and homepage |
474 |
|
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
475 |
|
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
476 |
|
echo >> ${dest} |
477 |
|
|
478 |
|
# special tags |
479 |
|
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
480 |
|
if [ -n "${INHERITS}" ] |
481 |
|
then |
482 |
|
echo -n "minclude" >> ${dest} |
483 |
|
local i |
484 |
|
for i in ${INHERITS} |
485 |
|
do |
486 |
|
echo -n " ${i}" >> ${dest} |
487 |
|
done |
488 |
|
echo >> ${dest} |
489 |
|
fi |
490 |
|
echo >> ${dest} |
491 |
|
|
492 |
|
# deps and provides |
493 |
|
echo "DEPEND=\"${DEPEND}\"" >> ${dest} |
494 |
|
echo "SDEPEND=\"${SDEPEND}\"" >> ${dest} |
495 |
|
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
496 |
|
echo >> ${dest} |
497 |
|
|
498 |
|
# add special functions |
499 |
|
if [ -n "${SPECIAL_FUNCTIONS}" ] |
500 |
|
then |
501 |
|
local i |
502 |
|
for i in ${SPECIAL_FUNCTIONS} |
503 |
|
do |
504 |
|
# add to mage (quotes needed !) |
505 |
|
typeset -f "${i}" >> ${dest} |
506 |
|
# unset to be safe (quotes needed !) |
507 |
|
unset "${i}" |
508 |
|
done |
509 |
|
fi |
510 |
|
|
511 |
|
# pre|post-install|removes |
512 |
|
typeset -f preinstall >> ${dest} |
513 |
|
echo >> ${dest} |
514 |
|
typeset -f postinstall >> ${dest} |
515 |
|
echo >> ${dest} |
516 |
|
typeset -f preremove >> ${dest} |
517 |
|
echo >> ${dest} |
518 |
|
typeset -f postremove >> ${dest} |
519 |
|
echo >> ${dest} |
520 |
|
} |
521 |
|
|
522 |
|
regen_mage_tree() |
523 |
|
{ |
524 |
|
local i |
525 |
|
|
526 |
|
# build them only if requested |
527 |
|
if [[ ${REGEN_MAGE_TREE} = true ]] |
528 |
|
then |
529 |
|
# build for each target an mage file |
530 |
|
for i in ${MAGE_TARGETS} |
531 |
|
do |
532 |
|
echo |
533 |
|
alx_create_mage_file "${i}" |
534 |
|
echo |
535 |
|
done |
536 |
|
fi |
537 |
|
|
538 |
|
# now unset all uneeded vars to be safe |
539 |
|
unset PKGNAME |
540 |
|
unset STATE |
541 |
|
unset DESCRIPTION |
542 |
|
unset HOMEPAGE |
543 |
|
unset PKGTYPE |
544 |
|
unset INHERITS |
545 |
|
unset DEPEND |
546 |
|
unset SDEPEND |
547 |
|
unset PROVIDE |
548 |
|
unset SPECIAL_FUNCTIONS |
549 |
|
unset preinstall |
550 |
|
unset postinstall |
551 |
|
unset preremove |
552 |
|
unset postremove |
553 |
|
} |
554 |
|
|
555 |
# print out our version |
# print out our version |
556 |
showversion |
showversion |
557 |
echo |
echo |
579 |
then |
then |
580 |
if [ $# -ge 3 ] |
if [ $# -ge 3 ] |
581 |
then |
then |
|
# overridable sourcedir |
|
|
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
|
|
|
|
582 |
SMAGENAME="$2" |
SMAGENAME="$2" |
583 |
MD5DIR="$3" |
MD5DIR="$3" |
584 |
source ${SMAGENAME} || die "download source failed" |
source ${SMAGENAME} || die "download source failed" |
585 |
|
|
586 |
|
# overridable sourcedir; must be declared after source of the smage2 |
587 |
|
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
588 |
|
|
589 |
[ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
[ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
590 |
|
|
591 |
# end of array |
# end of array |
599 |
|
|
600 |
for ((i=0; i < EOA; i++)) |
for ((i=0; i < EOA; i++)) |
601 |
do |
do |
602 |
MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
# url to file |
603 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
604 |
|
|
605 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
606 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
607 |
|
|
608 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
609 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
610 |
|
then |
611 |
|
MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" |
612 |
|
else |
613 |
|
MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
614 |
|
fi |
615 |
|
|
616 |
if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
617 |
then |
then |
618 |
echo "calculating $(basename ${MY_SRC_FILE}) ..." |
echo "calculating $(basename ${MY_SRC_FILE}) ..." |
620 |
else |
else |
621 |
echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
622 |
fi |
fi |
623 |
|
|
624 |
|
# unset them to be shure |
625 |
|
unset my_SRC_URI |
626 |
|
unset my_SRC_URI_DEST |
627 |
|
unset my_SRC_URI_MIRROR |
628 |
|
unset my_SOURCEDIR |
629 |
done |
done |
630 |
|
|
631 |
echo |
echo |
647 |
#download sources |
#download sources |
648 |
if [ "$1" == "download" -a -n "$2" ] |
if [ "$1" == "download" -a -n "$2" ] |
649 |
then |
then |
|
showversion |
|
650 |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
651 |
then |
then |
652 |
install -d ${SMAGESCRIPTSDIR} |
install -d ${SMAGESCRIPTSDIR} |
715 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
716 |
echo "Compiling ${PKGNAME}" |
echo "Compiling ${PKGNAME}" |
717 |
|
|
718 |
|
# auto regen mage tree if requested |
719 |
|
regen_mage_tree |
720 |
|
|
721 |
#download sources |
#download sources |
722 |
download_sources |
download_sources |
723 |
|
|
812 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
813 |
fi |
fi |
814 |
|
|
815 |
|
# stripping all bins and libs |
816 |
|
case ${NOSTRIP} in |
817 |
|
true|TRUE|yes|y) |
818 |
|
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
819 |
|
;; |
820 |
|
*) |
821 |
|
echo -e "Stripping binaries ..." |
822 |
|
mstripbins ${BINDIR} |
823 |
|
echo -e "Stripping libraries ..." |
824 |
|
mstriplibs ${BINDIR} |
825 |
|
;; |
826 |
|
esac |
827 |
|
|
828 |
#the new buildpkg command |
#the new buildpkg command |
829 |
case ${NOPKGBUILD} in |
case ${NOPKGBUILD} in |
830 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
838 |
|
|
839 |
#for sure |
#for sure |
840 |
unset NOPKGBUILD |
unset NOPKGBUILD |
841 |
|
unset NOSTRIP |
842 |
|
|
843 |
xtitleclean |
xtitleclean |
844 |
#echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
#echo -e "\nPackage ${PKGNAME} successfully builded.\n" |