4 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
5 |
|
|
6 |
# SMAGE2 |
# SMAGE2 |
7 |
# version: 0.3.6-r10 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.10 2005-06-01 15:49:20 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 ## |
14 |
SMAGEVERSION=0.3.6-r10 |
SMAGEVERSION=0.3.6-r15 |
15 |
PKGSUFFIX="mpk" |
PKGSUFFIX="mpk" |
16 |
SMAGENAME="$1" |
SMAGENAME="$1" |
17 |
SMAGESUFFIX="smage2" |
SMAGESUFFIX="smage2" |
84 |
xtitleclean |
xtitleclean |
85 |
} |
} |
86 |
|
|
87 |
|
# $1 filename |
88 |
|
get_db_md5_sum() { |
89 |
|
local DB_FILE |
90 |
|
local MD5_FILE |
91 |
|
local i |
92 |
|
|
93 |
|
DB_ENTRY="$(basename $1)" |
94 |
|
MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} ${SMAGESUFFIX})" |
95 |
|
|
96 |
|
i="$(cat ${MD5_FILE}| grep ${DB_ENTRY} | cut -d' ' -f1)" |
97 |
|
|
98 |
|
echo "${i}" |
99 |
|
} |
100 |
|
|
101 |
|
download_sources() { |
102 |
|
|
103 |
|
[ -z "${SRC_URI}" ] && echo -e "\nNothing declared to download.\n" && return 0 |
104 |
|
|
105 |
|
local EOA=${#SRC_URI[*]} |
106 |
|
local my_SRC_URI |
107 |
|
local my_SRC_URI_DEST |
108 |
|
local my_SRC_URI_MIRROR |
109 |
|
local my_SOURCEDIR |
110 |
|
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
111 |
|
local FETCHING |
112 |
|
local i mirror |
113 |
|
|
114 |
|
|
115 |
|
#install SRCDIR/PNAME if not exist |
116 |
|
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
117 |
|
|
118 |
|
# check if FETCHING is needed |
119 |
|
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
120 |
|
if [[ $? == 0 ]] |
121 |
|
then |
122 |
|
# md5's ok, not fetching needed |
123 |
|
FETCHING=false |
124 |
|
else |
125 |
|
FETCHING=true |
126 |
|
fi |
127 |
|
|
128 |
|
for ((i=0; i < EOA; i++)) |
129 |
|
do |
130 |
|
# url to file |
131 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
132 |
|
|
133 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
134 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
135 |
|
|
136 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
137 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
138 |
|
then |
139 |
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}/${my_SRC_URI_DEST}" |
140 |
|
else |
141 |
|
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
142 |
|
fi |
143 |
|
|
144 |
|
# if an mirrored file than replace first the mirror uri |
145 |
|
if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] |
146 |
|
then |
147 |
|
for mirror in ${MIRRORS} |
148 |
|
do |
149 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|mirror:/|${mirror}/sources|g")" |
150 |
|
|
151 |
|
#echo "DEBUG: ${MY_SRC_URI}" |
152 |
|
if [[ ${FETCHING} == true ]] |
153 |
|
then |
154 |
|
echo "==> fetching ${my_SRC_URI_MIRROR}" |
155 |
|
wget \ |
156 |
|
--passive-ftp \ |
157 |
|
--tries 3 \ |
158 |
|
--continue \ |
159 |
|
--progress bar \ |
160 |
|
--directory-prefix="${my_SOURCEDIR}" \ |
161 |
|
"${my_SRC_URI_MIRROR}" |
162 |
|
if [ "$?" == "0" ] |
163 |
|
then |
164 |
|
break |
165 |
|
else |
166 |
|
continue |
167 |
|
fi |
168 |
|
fi |
169 |
|
done |
170 |
|
else |
171 |
|
#echo "DEBUG: ${SRC_URI[${i}]}" |
172 |
|
if [[ ${FETCHING} == true ]] |
173 |
|
then |
174 |
|
echo "==> fetching ${my_SRC_URI}" |
175 |
|
wget \ |
176 |
|
--passive-ftp \ |
177 |
|
--tries 3 \ |
178 |
|
--continue \ |
179 |
|
--progress bar \ |
180 |
|
--directory-prefix="${my_SOURCEDIR}" \ |
181 |
|
"${my_SRC_URI}" |
182 |
|
if [ "$?" == "0" ] |
183 |
|
then |
184 |
|
break |
185 |
|
else |
186 |
|
continue |
187 |
|
fi |
188 |
|
fi |
189 |
|
fi |
190 |
|
|
191 |
|
# unset them to be shure |
192 |
|
unset my_SRC_URI |
193 |
|
unset my_SRC_URI_DEST |
194 |
|
unset my_SRC_URI_MIRROR |
195 |
|
unset my_SOURCEDIR |
196 |
|
done |
197 |
|
|
198 |
|
# recheck md5 sums |
199 |
|
echo |
200 |
|
echo ">== Checking MD5 sums:" |
201 |
|
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
202 |
|
echo |
203 |
|
|
204 |
|
# not needed anymore |
205 |
|
unset SRC_URI |
206 |
|
} |
207 |
|
|
208 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that not exist in smage file |
209 |
src_prepare() { |
src_prepare() { |
210 |
echo "no src_prepare defined" |
echo "no src_prepare defined" |
339 |
done |
done |
340 |
} |
} |
341 |
|
|
342 |
|
mstriplibs() { |
343 |
|
local stripdir="$@" |
344 |
|
|
345 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
346 |
|
find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
347 |
|
} |
348 |
|
|
349 |
|
mstripbins() { |
350 |
|
local stripdir="$@" |
351 |
|
|
352 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
353 |
|
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
354 |
|
} |
355 |
|
|
356 |
setup_distcc_environment(){ |
setup_distcc_environment(){ |
357 |
if [ -x /usr/bin/distcc ] |
if [ -x /usr/bin/distcc ] |
358 |
then |
then |
393 |
fi |
fi |
394 |
} |
} |
395 |
|
|
396 |
|
# print out our version |
397 |
|
showversion |
398 |
|
echo |
399 |
|
|
400 |
if [ -z "$1" ] |
if [ -z "$1" ] |
401 |
then |
then |
|
showversion |
|
|
echo |
|
402 |
echo "No .smage2 file given. Exiting." |
echo "No .smage2 file given. Exiting." |
403 |
echo |
echo |
404 |
exit 1 |
exit 1 |
407 |
#updating smage2-scripts |
#updating smage2-scripts |
408 |
if [ "$1" == "update" ] |
if [ "$1" == "update" ] |
409 |
then |
then |
410 |
|
if [ ! -d ${SOURCEDIR} ] |
411 |
|
then |
412 |
|
install -d ${SOURCEDIR} |
413 |
|
fi |
414 |
|
syncsmage2 |
415 |
|
exit 0 |
416 |
|
fi |
417 |
|
|
418 |
|
#creates md5sums for smages to given dir |
419 |
|
if [ "$1" == "calcmd5" ] |
420 |
|
then |
421 |
|
if [ $# -ge 3 ] |
422 |
|
then |
423 |
|
SMAGENAME="$2" |
424 |
|
MD5DIR="$3" |
425 |
|
source ${SMAGENAME} || die "download source failed" |
426 |
|
|
427 |
|
# overridable sourcedir; must be declared after source of the smage2 |
428 |
|
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
429 |
|
|
430 |
|
[ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
431 |
|
|
432 |
|
# end of array |
433 |
|
EOA=${#SRC_URI[*]} |
434 |
|
|
435 |
|
[ ! -d ${MD5DIR} ] && install -d ${MD5DIR} |
436 |
|
|
437 |
|
# clear md5sum file |
438 |
|
MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
439 |
|
echo -n > ${MY_MD5_FILE} |
440 |
|
|
441 |
|
for ((i=0; i < EOA; i++)) |
442 |
|
do |
443 |
|
# url to file |
444 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
445 |
|
|
446 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
447 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
448 |
|
|
449 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
450 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
451 |
|
then |
452 |
|
MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" |
453 |
|
else |
454 |
|
MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
455 |
|
fi |
456 |
|
|
457 |
|
if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
458 |
|
then |
459 |
|
echo "calculating $(basename ${MY_SRC_FILE}) ..." |
460 |
|
( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} |
461 |
|
else |
462 |
|
echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
463 |
|
fi |
464 |
|
|
465 |
|
# unset them to be shure |
466 |
|
unset my_SRC_URI |
467 |
|
unset my_SRC_URI_DEST |
468 |
|
unset my_SRC_URI_MIRROR |
469 |
|
unset my_SOURCEDIR |
470 |
|
done |
471 |
|
|
472 |
|
echo |
473 |
|
echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." |
474 |
|
echo |
475 |
|
else |
476 |
|
echo "Usage: Calculating MD5 Sums:" |
477 |
|
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
478 |
|
echo |
479 |
|
echo |
480 |
|
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
481 |
|
echo |
482 |
|
exit 1 |
483 |
|
fi |
484 |
|
|
485 |
|
exit 0 |
486 |
|
fi |
487 |
|
|
488 |
|
#download sources |
489 |
|
if [ "$1" == "download" -a -n "$2" ] |
490 |
|
then |
491 |
showversion |
showversion |
492 |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
493 |
then |
then |
494 |
install -d ${SMAGESCRIPTSDIR} |
install -d ${SMAGESCRIPTSDIR} |
495 |
fi |
fi |
496 |
syncsmage2 |
|
497 |
|
# get smage |
498 |
|
SMAGENAME="$2" |
499 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
500 |
|
source ${SMAGENAME} || die "download source failed" |
501 |
|
|
502 |
|
download_sources |
503 |
exit 0 |
exit 0 |
504 |
fi |
fi |
505 |
|
|
|
|
|
506 |
if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] |
if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] |
507 |
then |
then |
508 |
die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
552 |
|
|
553 |
source ${SMAGENAME} || die "source failed" |
source ${SMAGENAME} || die "source failed" |
554 |
PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}" |
555 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
556 |
|
|
557 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
558 |
|
echo "Compiling ${PKGNAME}" |
559 |
|
|
560 |
|
#download sources |
561 |
|
download_sources |
562 |
|
|
563 |
#fixes some issues with these functions |
#fixes some issues with these functions |
564 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
565 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
651 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
652 |
fi |
fi |
653 |
|
|
654 |
|
# stripping all bins and libs |
655 |
|
case ${NOSTRIP} in |
656 |
|
true|TRUE|yes|y) |
657 |
|
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
658 |
|
;; |
659 |
|
*) |
660 |
|
echo -e "Stripping binaries ..." |
661 |
|
mstripbins ${BINDIR} |
662 |
|
echo -e "Stripping libraries ..." |
663 |
|
mstriplibs ${BINDIR} |
664 |
|
;; |
665 |
|
esac |
666 |
|
|
667 |
#the new buildpkg command |
#the new buildpkg command |
668 |
case ${NOPKGBUILD} in |
case ${NOPKGBUILD} in |
669 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |