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.16 2005-07-31 11:57:05 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-r19 |
15 |
PKGSUFFIX="mpk" |
PKGSUFFIX="mpk" |
16 |
SMAGENAME="$1" |
SMAGENAME="$1" |
17 |
SMAGESUFFIX="smage2" |
SMAGESUFFIX="smage2" |
20 |
#SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts" |
#SMAGE2RSYNC="rsync://192.168.0.2/smage2-scripts" |
21 |
MLIBDIR=/usr/lib/mage |
MLIBDIR=/usr/lib/mage |
22 |
|
|
23 |
|
# export default C locale |
24 |
|
export LC_ALL=C |
25 |
|
|
26 |
source /etc/mage.rc |
source /etc/mage.rc |
27 |
|
|
28 |
showversion() { |
showversion() { |
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" |
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 |
setup_distcc_environment(){ |
setup_distcc_environment(){ |
361 |
if [ -x /usr/bin/distcc ] |
if [ -x /usr/bin/distcc ] |
362 |
then |
then |
397 |
fi |
fi |
398 |
} |
} |
399 |
|
|
400 |
|
# print out our version |
401 |
|
showversion |
402 |
|
echo |
403 |
|
|
404 |
if [ -z "$1" ] |
if [ -z "$1" ] |
405 |
then |
then |
|
showversion |
|
|
echo |
|
406 |
echo "No .smage2 file given. Exiting." |
echo "No .smage2 file given. Exiting." |
407 |
echo |
echo |
408 |
exit 1 |
exit 1 |
411 |
#updating smage2-scripts |
#updating smage2-scripts |
412 |
if [ "$1" == "update" ] |
if [ "$1" == "update" ] |
413 |
then |
then |
414 |
|
if [ ! -d ${SOURCEDIR} ] |
415 |
|
then |
416 |
|
install -d ${SOURCEDIR} |
417 |
|
fi |
418 |
|
syncsmage2 |
419 |
|
exit 0 |
420 |
|
fi |
421 |
|
|
422 |
|
#creates md5sums for smages to given dir |
423 |
|
if [ "$1" == "calcmd5" ] |
424 |
|
then |
425 |
|
if [ $# -ge 3 ] |
426 |
|
then |
427 |
|
SMAGENAME="$2" |
428 |
|
MD5DIR="$3" |
429 |
|
source ${SMAGENAME} || die "download source failed" |
430 |
|
|
431 |
|
# overridable sourcedir; must be declared after source of the smage2 |
432 |
|
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
433 |
|
|
434 |
|
[ -z "${SRC_URI}" ] && die "Nothing declared to calculate." |
435 |
|
|
436 |
|
# end of array |
437 |
|
EOA=${#SRC_URI[*]} |
438 |
|
|
439 |
|
[ ! -d ${MD5DIR} ] && install -d ${MD5DIR} |
440 |
|
|
441 |
|
# clear md5sum file |
442 |
|
MY_MD5_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
443 |
|
echo -n > ${MY_MD5_FILE} |
444 |
|
|
445 |
|
for ((i=0; i < EOA; i++)) |
446 |
|
do |
447 |
|
# url to file |
448 |
|
my_SRC_URI="$(echo ${SRC_URI[${i}]} | cut -d' ' -f1)" |
449 |
|
|
450 |
|
# subdir in sources dir; the my_SRCI_URI file goes to there |
451 |
|
my_SRC_URI_DEST="$(echo ${SRC_URI[${i}]} | cut -d' ' -f2)" |
452 |
|
|
453 |
|
# if my_src_uri_dest is not equal my_src_uri; than an other dir is used |
454 |
|
if [[ ${my_SRC_URI_DEST} != ${my_SRC_URI} ]] |
455 |
|
then |
456 |
|
MY_SRC_FILE="${my_SRC_URI_DEST}/$(basename ${SRC_URI[${i}]})" |
457 |
|
else |
458 |
|
MY_SRC_FILE="$(basename ${SRC_URI[${i}]})" |
459 |
|
fi |
460 |
|
|
461 |
|
if [ -e "${CALC_SOURCEDIR}/${MY_SRC_FILE}" ] |
462 |
|
then |
463 |
|
echo "calculating $(basename ${MY_SRC_FILE}) ..." |
464 |
|
( cd ${CALC_SOURCEDIR}; md5sum "${MY_SRC_FILE}" ) >> ${MY_MD5_FILE} |
465 |
|
else |
466 |
|
echo "WARNING: File '$(basename ${MY_SRC_FILE}) not found in ${CALC_SOURCEDIR}." |
467 |
|
fi |
468 |
|
|
469 |
|
# unset them to be shure |
470 |
|
unset my_SRC_URI |
471 |
|
unset my_SRC_URI_DEST |
472 |
|
unset my_SRC_URI_MIRROR |
473 |
|
unset my_SOURCEDIR |
474 |
|
done |
475 |
|
|
476 |
|
echo |
477 |
|
echo "Calculating of md5 sums for '$(basename ${SMAGENAME} .${SMAGESUFFIX})' done." |
478 |
|
echo |
479 |
|
else |
480 |
|
echo "Usage: Calculating MD5 Sums:" |
481 |
|
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
482 |
|
echo |
483 |
|
echo |
484 |
|
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
485 |
|
echo |
486 |
|
exit 1 |
487 |
|
fi |
488 |
|
|
489 |
|
exit 0 |
490 |
|
fi |
491 |
|
|
492 |
|
#download sources |
493 |
|
if [ "$1" == "download" -a -n "$2" ] |
494 |
|
then |
495 |
showversion |
showversion |
496 |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
if [ ! -d ${SMAGESCRIPTSDIR} ] |
497 |
then |
then |
498 |
install -d ${SMAGESCRIPTSDIR} |
install -d ${SMAGESCRIPTSDIR} |
499 |
fi |
fi |
500 |
syncsmage2 |
|
501 |
|
# get smage |
502 |
|
SMAGENAME="$2" |
503 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
504 |
|
source ${SMAGENAME} || die "download source failed" |
505 |
|
|
506 |
|
download_sources |
507 |
exit 0 |
exit 0 |
508 |
fi |
fi |
509 |
|
|
|
|
|
510 |
if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] |
if [ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] |
511 |
then |
then |
512 |
die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
556 |
|
|
557 |
source ${SMAGENAME} || die "source failed" |
source ${SMAGENAME} || die "source failed" |
558 |
PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${CHOST%%-*}-${PBUILD}" |
559 |
|
MD5DIR="$(dirname ${SMAGENAME})/md5" |
560 |
|
|
561 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
562 |
|
echo "Compiling ${PKGNAME}" |
563 |
|
|
564 |
|
#download sources |
565 |
|
download_sources |
566 |
|
|
567 |
#fixes some issues with these functions |
#fixes some issues with these functions |
568 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
569 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
655 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
656 |
fi |
fi |
657 |
|
|
658 |
|
# stripping all bins and libs |
659 |
|
case ${NOSTRIP} in |
660 |
|
true|TRUE|yes|y) |
661 |
|
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
662 |
|
;; |
663 |
|
*) |
664 |
|
echo -e "Stripping binaries ..." |
665 |
|
mstripbins ${BINDIR} |
666 |
|
echo -e "Stripping libraries ..." |
667 |
|
mstriplibs ${BINDIR} |
668 |
|
;; |
669 |
|
esac |
670 |
|
|
671 |
#the new buildpkg command |
#the new buildpkg command |
672 |
case ${NOPKGBUILD} in |
case ${NOPKGBUILD} in |
673 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
681 |
|
|
682 |
#for sure |
#for sure |
683 |
unset NOPKGBUILD |
unset NOPKGBUILD |
684 |
|
unset NOSTRIP |
685 |
|
|
686 |
xtitleclean |
xtitleclean |
687 |
#echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
#echo -e "\nPackage ${PKGNAME} successfully builded.\n" |