1 |
#!/bin/bash |
#!/bin/bash |
2 |
|
# $Id$ |
3 |
|
|
4 |
# compiles/installs .smage2 source install scripts |
# compiles/installs .smage2 source install scripts |
5 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
6 |
|
|
7 |
# SMAGE2 |
# TODO: record dynlib, gz | xz database |
|
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.55 2007-03-20 01:15:31 niro Exp $ |
|
8 |
|
|
|
#01.10.2004 |
|
|
# added ccache support |
|
|
# added distcc support |
|
9 |
|
|
10 |
# set default user mage.rc |
# set default user mage.rc |
11 |
: ${MAGERC="/etc/mage.rc"} |
: ${MAGERC="/etc/mage.rc"} |
12 |
|
|
13 |
## setup ## |
## setup ## |
|
PKGSUFFIX="mpk" |
|
|
SRCPKGSUFFIX="mpks" |
|
14 |
SMAGENAME="$1" |
SMAGENAME="$1" |
|
SMAGESUFFIX="smage2" |
|
|
MLIBDIR=/usr/lib/mage |
|
15 |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
SMAGEVERSION="$( < ${MLIBDIR}/version)" |
16 |
|
|
|
## only for tests -> normally in /etc/rc.d/init.d/functions |
|
|
COLRED="\033[1;6m\033[31m" |
|
|
COLGREEN="\033[1;6m\033[32m" |
|
|
COLYELLOW="\033[1;6m\033[33m" |
|
|
COLBLUE="\033[1;6m\033[34m" |
|
|
COLMAGENTA="\033[1;6m\033[35m" |
|
|
COLWHITE="\033[1;6m\033[37m" |
|
|
COLGRAY="\033[0;6m\033[37m" |
|
|
COLBOLD="\033[1m" |
|
|
COLDEFAULT="\033[0m" |
|
|
|
|
|
if [[ ${NOCOLORS} = true ]] |
|
|
then |
|
|
COLRED="" |
|
|
COLGREEN="" |
|
|
COLYELLOW="" |
|
|
COLBLUE="" |
|
|
COLMAGENTA="" |
|
|
COLWHITE="" |
|
|
COLGRAY="" |
|
|
COLBOLD="" |
|
|
COLDEFAULT="" |
|
|
fi |
|
|
|
|
17 |
# export default C locale |
# export default C locale |
18 |
export LC_ALL=C |
export LC_ALL=C |
19 |
|
|
20 |
source /etc/mage.rc.global |
source /etc/mage.rc.global |
21 |
source ${MAGERC} |
source ${MAGERC} |
22 |
|
source ${MLIBDIR}/mage4.functions.sh |
23 |
|
|
24 |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
25 |
if [[ -n ${MROOT} ]] |
if [[ -n ${MROOT} ]] |
29 |
export BINDIR=${MROOT}/${BINDIR} |
export BINDIR=${MROOT}/${BINDIR} |
30 |
fi |
fi |
31 |
|
|
32 |
|
# sources the smage file and uses state from distribution file if exist |
33 |
|
# may helpful for repository support later on |
34 |
|
smagesource() |
35 |
|
{ |
36 |
|
local file="$1" |
37 |
|
local mystate |
38 |
|
local mycodename |
39 |
|
|
40 |
|
source ${file} |
41 |
|
|
42 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
43 |
|
|
44 |
|
# do not overide if local state was broken or disabled! |
45 |
|
case ${STATE} in |
46 |
|
broken) return ;; |
47 |
|
disabled) return ;; |
48 |
|
esac |
49 |
|
|
50 |
|
if [ -f ${SMAGESCRIPTSDIR}/distribution ] |
51 |
|
then |
52 |
|
source ${SMAGESCRIPTSDIR}/distribution |
53 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
54 |
|
fi |
55 |
|
# now switch state and export it |
56 |
|
STATE="${mystate}" |
57 |
|
} |
58 |
|
|
59 |
showversion() |
showversion() |
60 |
{ |
{ |
61 |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
70 |
exit 1 |
exit 1 |
71 |
} |
} |
72 |
|
|
73 |
|
die_pipestatus() |
74 |
|
{ |
75 |
|
# the status change if we do any parameter declarations!! |
76 |
|
# dont do this anymore, keep this in mind! |
77 |
|
# |
78 |
|
# local pos="$1" |
79 |
|
# local comment="$2" |
80 |
|
# |
81 |
|
# [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" |
82 |
|
# |
83 |
|
[ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" |
84 |
|
} |
85 |
|
|
86 |
xtitle() |
xtitle() |
87 |
{ |
{ |
88 |
if [[ ${TERM} = xterm ]] |
if [[ ${TERM} = xterm ]] |
150 |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
151 |
local FETCHING |
local FETCHING |
152 |
local i mirror |
local i mirror |
153 |
|
local wget_opts |
154 |
|
|
155 |
|
# filter wget command if busybox was found |
156 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
157 |
|
|
158 |
# install SRCDIR/PNAME if not exist |
# install SRCDIR/PNAME if not exist |
159 |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
160 |
|
|
161 |
# check if FETCHING is needed |
# check if FETCHING is needed |
162 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null ) |
163 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
164 |
then |
then |
165 |
# md5's ok, no fetching needed |
# md5's ok, no fetching needed |
184 |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
185 |
fi |
fi |
186 |
|
|
187 |
|
# create the SOURCEDIR |
188 |
|
install -d ${my_SOURCEDIR} |
189 |
|
|
190 |
# if an mirrored file than replace first the mirror uri |
# if an mirrored file than replace first the mirror uri |
191 |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
192 |
then |
then |
198 |
then |
then |
199 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
200 |
wget \ |
wget \ |
201 |
--passive-ftp \ |
${wget_opts} \ |
202 |
--tries 3 \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
|
--continue \ |
|
|
--progress bar \ |
|
|
--directory-prefix="${my_SOURCEDIR}" \ |
|
203 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
204 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
205 |
then |
then |
219 |
then |
then |
220 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
221 |
wget \ |
wget \ |
222 |
--passive-ftp \ |
${wget_opts} \ |
223 |
--tries 3 \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
|
--continue \ |
|
|
--progress bar \ |
|
|
--directory-prefix="${my_SOURCEDIR}" \ |
|
224 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
225 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
226 |
then |
then |
240 |
then |
then |
241 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
242 |
wget \ |
wget \ |
243 |
--passive-ftp \ |
${wget_opts} \ |
244 |
--tries 3 \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
245 |
--continue \ |
"${my_SRC_URI_MIRROR}" |
246 |
--progress bar \ |
if [[ $? = 0 ]] |
247 |
--directory-prefix="${my_SOURCEDIR}" \ |
then |
248 |
|
break |
249 |
|
else |
250 |
|
continue |
251 |
|
fi |
252 |
|
fi |
253 |
|
done |
254 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]] |
255 |
|
then |
256 |
|
for mirror in ${KDE_MIRRORS} |
257 |
|
do |
258 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")" |
259 |
|
|
260 |
|
if [[ ${FETCHING} = true ]] |
261 |
|
then |
262 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
263 |
|
wget \ |
264 |
|
${wget_opts} \ |
265 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
266 |
|
"${my_SRC_URI_MIRROR}" |
267 |
|
if [[ $? = 0 ]] |
268 |
|
then |
269 |
|
break |
270 |
|
else |
271 |
|
continue |
272 |
|
fi |
273 |
|
fi |
274 |
|
done |
275 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]] |
276 |
|
then |
277 |
|
for mirror in ${GNOME_MIRRORS} |
278 |
|
do |
279 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")" |
280 |
|
|
281 |
|
if [[ ${FETCHING} = true ]] |
282 |
|
then |
283 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
284 |
|
wget \ |
285 |
|
${wget_opts} \ |
286 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
287 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
288 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
289 |
then |
then |
298 |
then |
then |
299 |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
300 |
wget \ |
wget \ |
301 |
--passive-ftp \ |
${wget_opts} \ |
302 |
--tries 3 \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
|
--continue \ |
|
|
--progress bar \ |
|
|
--directory-prefix="${my_SOURCEDIR}" \ |
|
303 |
"${my_SRC_URI}" |
"${my_SRC_URI}" |
304 |
fi |
fi |
305 |
fi |
fi |
314 |
# recheck md5 sums |
# recheck md5 sums |
315 |
echo |
echo |
316 |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
317 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
318 |
echo |
echo |
319 |
|
|
320 |
# not needed anymore |
# not needed anymore |
321 |
unset SRC_URI |
unset SRC_URI |
322 |
} |
} |
323 |
|
|
324 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
325 |
src_prepare() |
src_prepare() |
326 |
{ |
{ |
327 |
echo "no src_prepare defined" |
echo "no src_prepare defined" |
|
sleep 2 |
|
328 |
return 0 |
return 0 |
329 |
} |
} |
330 |
|
|
331 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
332 |
|
src_check() |
333 |
|
{ |
334 |
|
echo "no src_check defined" |
335 |
|
return 0 |
336 |
|
} |
337 |
|
|
338 |
|
# dummy function, used if that does not exist in smage file |
339 |
src_compile() |
src_compile() |
340 |
{ |
{ |
341 |
echo "no src_compile defined" |
echo "no src_compile defined" |
|
sleep 2 |
|
342 |
return 0 |
return 0 |
343 |
} |
} |
344 |
|
|
345 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
346 |
src_install() |
src_install() |
347 |
{ |
{ |
348 |
echo "no src_install defined" |
echo "no src_install defined" |
|
sleep 2 |
|
349 |
return 0 |
return 0 |
350 |
} |
} |
351 |
|
|
364 |
./configure \ |
./configure \ |
365 |
--prefix=/usr \ |
--prefix=/usr \ |
366 |
--host=${CHOST} \ |
--host=${CHOST} \ |
367 |
|
--build=${CHOST} \ |
368 |
--mandir=/usr/share/man \ |
--mandir=/usr/share/man \ |
369 |
--infodir=/usr/share/info \ |
--infodir=/usr/share/info \ |
370 |
--datadir=/usr/share \ |
--datadir=/usr/share \ |
408 |
|
|
409 |
SRCFILE=$1 |
SRCFILE=$1 |
410 |
|
|
411 |
if [ -z "$2" ] |
if [[ -z $2 ]] |
412 |
then |
then |
413 |
DEST=${BUILDDIR} |
DEST=${BUILDDIR} |
414 |
else |
else |
423 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
424 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
425 |
then |
then |
426 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.bz2 unpack failed." |
427 |
|
else |
428 |
|
pushd ${DEST} > /dev/null |
429 |
|
bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." |
430 |
|
popd > /dev/null |
431 |
fi |
fi |
432 |
;; |
;; |
433 |
gz) |
gz) |
435 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
436 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
437 |
then |
then |
438 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.gz unpack failed." |
439 |
|
else |
440 |
|
pushd ${DEST} > /dev/null |
441 |
|
zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." |
442 |
|
popd > /dev/null |
443 |
|
fi |
444 |
|
;; |
445 |
|
xz) |
446 |
|
IFTAR="$(basename $SRCFILE .xz)" |
447 |
|
IFTAR="${IFTAR##*.}" |
448 |
|
if [[ ${IFTAR} = tar ]] |
449 |
|
then |
450 |
|
tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tar.xz unpack failed." |
451 |
|
else |
452 |
|
pushd ${DEST} > /dev/null |
453 |
|
xzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .xz) || die ".xz unpack failed." |
454 |
|
popd > /dev/null |
455 |
fi |
fi |
456 |
;; |
;; |
457 |
tbz2) |
tbz2|mpks|mpk) |
458 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
459 |
;; |
;; |
460 |
tgz) |
tgz) |
461 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
462 |
|
;; |
463 |
|
txz|mpkzs|mpkz) |
464 |
|
tar --no-same-owner -xvJf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".txz unpack failed." |
465 |
|
;; |
466 |
|
rar) |
467 |
|
unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
468 |
|
;; |
469 |
|
zip|xpi) |
470 |
|
unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
471 |
|
;; |
472 |
|
rpm) |
473 |
|
pushd ${DEST} > /dev/null |
474 |
|
rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
475 |
|
tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
476 |
|
if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
477 |
|
then |
478 |
|
rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
479 |
|
fi |
480 |
;; |
;; |
481 |
*) |
*) |
482 |
die "munpack failed" |
die "munpack failed" |
513 |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
514 |
} |
} |
515 |
|
|
516 |
|
mlibtoolize() |
517 |
|
{ |
518 |
|
local opts="$@" |
519 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
520 |
|
|
521 |
|
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
522 |
|
} |
523 |
|
|
524 |
|
mautoreconf() |
525 |
|
{ |
526 |
|
local opts="$@" |
527 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
528 |
|
|
529 |
|
autoreconf ${opts} || die "running: mautoreconf ${opts}" |
530 |
|
} |
531 |
|
|
532 |
minstalldocs() |
minstalldocs() |
533 |
{ |
{ |
539 |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
540 |
fi |
fi |
541 |
|
|
542 |
|
local i |
543 |
for i in ${docfiles} |
for i in ${docfiles} |
544 |
do |
do |
545 |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
if [ -f ${i} ] |
546 |
install -m 0644 ${SRCDIR}/${i}.gz \ |
then |
547 |
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
548 |
|
install -m 0644 ${SRCDIR}/${i}.gz \ |
549 |
|
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
550 |
|
fi |
551 |
done |
done |
552 |
} |
} |
553 |
|
|
556 |
local stripdir="$@" |
local stripdir="$@" |
557 |
|
|
558 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
559 |
find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
find ${stripdir} | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_LIB} 2> /dev/null |
560 |
} |
} |
561 |
|
|
562 |
mstripbins() |
mstripbins() |
564 |
local stripdir="$@" |
local stripdir="$@" |
565 |
|
|
566 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
567 |
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip ${STRIP_DYN_BIN} 2> /dev/null |
568 |
|
} |
569 |
|
|
570 |
|
mstripstatic() |
571 |
|
{ |
572 |
|
local stripdir="$@" |
573 |
|
|
574 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
575 |
|
find ${stripdir} | xargs file | grep "ar archive" | cut -f 1 -d : | xargs strip ${STRIP_STATIC_LIB} 2> /dev/null |
576 |
|
} |
577 |
|
|
578 |
|
mcompressdocs() |
579 |
|
{ |
580 |
|
local bindir="$@" |
581 |
|
|
582 |
|
if [ -d ${bindir}/usr/share/man ] |
583 |
|
then |
584 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
585 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
586 |
|
fi |
587 |
|
|
588 |
|
if [ -d ${bindir}/usr/share/info ] |
589 |
|
then |
590 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
591 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
592 |
|
fi |
593 |
} |
} |
594 |
|
|
595 |
sminclude() |
sminclude() |
705 |
# special tags: |
# special tags: |
706 |
# PKGTYPE type of pkg |
# PKGTYPE type of pkg |
707 |
# INHERITS which functions get included |
# INHERITS which functions get included |
708 |
# SPECIAL_FUNCTIONS special functions wich should also be added |
# SPECIAL_FUNCTIONS special functions which should also be added |
709 |
# warning: they get killed before the build starts ! |
# warning: they get killed before the build starts ! |
710 |
|
# SPLIT_PACKAGES names of all subpackages which are splitted from parent |
711 |
|
# SPLIT_PACKAGE_BASE base package name for splitpackages |
712 |
|
# (only in the resulting magefile} |
713 |
# |
# |
714 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
715 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
720 |
local magefile |
local magefile |
721 |
local dest |
local dest |
722 |
local target |
local target |
723 |
|
local split_pkg_base |
724 |
local sym |
local sym |
725 |
local depname |
local depname |
726 |
|
|
728 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
729 |
|
|
730 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
731 |
[ -n "$1" ] && target="-$1" |
[[ $1 = --target ]] && shift && target="-$1" |
732 |
|
|
733 |
|
# mark package as splitpackage |
734 |
|
[[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
735 |
|
|
736 |
# name of magefile |
# name of magefile |
737 |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
747 |
# now build the mage file |
# now build the mage file |
748 |
> ${dest} |
> ${dest} |
749 |
|
|
|
# header |
|
|
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.55 2007-03-20 01:15:31 niro Exp $' >> ${dest} |
|
|
echo >> ${dest} |
|
|
|
|
750 |
# pgkname and state |
# pgkname and state |
751 |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
752 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
|
echo >> ${dest} |
|
753 |
|
|
754 |
# description and homepage |
# description and homepage |
755 |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
756 |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
|
echo >> ${dest} |
|
757 |
|
|
758 |
# special tags and vars |
# special tags and vars |
759 |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
760 |
|
|
761 |
# echo MAGE_TARGETS ## note -target is needed ! |
# echo MAGE_TARGETS ## note -target is needed ! |
762 |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
763 |
echo >> ${dest} |
|
764 |
|
# split package base |
765 |
|
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
766 |
|
|
767 |
# add special vars |
# add special vars |
768 |
if [ -n "${SPECIAL_VARS}" ] |
if [ -n "${SPECIAL_VARS}" ] |
773 |
# being tricky here :) |
# being tricky here :) |
774 |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
775 |
done |
done |
|
echo >> ${dest} |
|
776 |
fi |
fi |
777 |
|
|
778 |
# add at least all includes |
# add at least all includes |
784 |
do |
do |
785 |
echo -n " ${i}" >> ${dest} |
echo -n " ${i}" >> ${dest} |
786 |
done |
done |
787 |
echo >> ${dest} |
# a CRLF is needed here! |
788 |
|
echo >> ${dest} |
789 |
fi |
fi |
|
echo >> ${dest} |
|
790 |
|
|
791 |
# deps and provides |
# deps and provides |
792 |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
793 |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
794 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
|
echo >> ${dest} |
|
795 |
|
|
796 |
# add special functions |
# add special functions |
797 |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
801 |
do |
do |
802 |
# add to mage (quotes needed !) |
# add to mage (quotes needed !) |
803 |
typeset -f "${i}" >> ${dest} |
typeset -f "${i}" >> ${dest} |
|
echo >> ${dest} |
|
804 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
805 |
#unset "${i}" <-- later to get every target built |
#unset "${i}" <-- later to get every target built |
806 |
done |
done |
|
echo >> ${dest} |
|
807 |
fi |
fi |
808 |
|
|
809 |
# pre|post-install|removes |
# pre|post-install|removes |
810 |
typeset -f preinstall >> ${dest} |
typeset -f preinstall >> ${dest} |
|
echo >> ${dest} |
|
811 |
typeset -f postinstall >> ${dest} |
typeset -f postinstall >> ${dest} |
|
echo >> ${dest} |
|
812 |
typeset -f preremove >> ${dest} |
typeset -f preremove >> ${dest} |
|
echo >> ${dest} |
|
813 |
typeset -f postremove >> ${dest} |
typeset -f postremove >> ${dest} |
|
echo >> ${dest} |
|
814 |
} |
} |
815 |
|
|
816 |
regen_mage_tree() |
regen_mage_tree() |
817 |
{ |
{ |
818 |
local i |
local subpackage |
819 |
|
|
820 |
# build them only if requested |
# build them only if requested |
821 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
822 |
then |
then |
823 |
# run it without targets |
# run it without targets |
824 |
if [ -z "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
825 |
then |
then |
826 |
|
# build for each target a mage file |
827 |
|
# run it with several targets |
828 |
echo |
echo |
829 |
build_mage_script |
for subpackage in ${MAGE_TARGETS} |
830 |
|
do |
831 |
|
build_mage_script --target "${subpackage}" |
832 |
|
done |
833 |
echo |
echo |
|
else |
|
834 |
|
|
835 |
# build for each target an mage file |
# run it for splitpackages |
836 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
837 |
|
then |
838 |
|
local split_pkg_base="${PNAME}" |
839 |
|
# save smage environment |
840 |
|
split_save_variables |
841 |
|
# build for each subpackage a mage file |
842 |
# run it with several targets |
# run it with several targets |
843 |
for i in ${MAGE_TARGETS} |
echo |
844 |
|
for subpackage in ${SPLIT_PACKAGES} |
845 |
do |
do |
846 |
echo |
# get the right variables for the split |
847 |
build_mage_script "${i}" |
export PNAME="${subpackage}" |
848 |
echo |
split_info_${subpackage} |
849 |
|
# get the preinstall etc |
850 |
|
split_export_inherits ${subpackage} |
851 |
|
build_mage_script --split-pkg-base "${split_pkg_base}" |
852 |
|
# delete split preinstall etc |
853 |
|
split_delete_inherits ${subpackage} |
854 |
|
# restore smage environment |
855 |
|
split_restore_variables |
856 |
done |
done |
857 |
|
echo |
858 |
|
# unset all saved smage variables |
859 |
|
split_unset_variables |
860 |
|
|
861 |
|
else |
862 |
|
echo |
863 |
|
build_mage_script |
864 |
|
echo |
865 |
fi |
fi |
866 |
fi |
fi |
867 |
|
|
868 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
869 |
# unset PKGNAME <-- don't do that; smage needs this var |
# unset PKGNAME <-- don't do that; smage needs this var |
870 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
871 |
for i in ${SPECIAL_FUNCTIONS} |
# for i in ${SPECIAL_FUNCTIONS} |
872 |
do |
# do |
873 |
unset "${i}" |
# unset "${i}" |
874 |
done |
# done |
875 |
unset SPECIAL_FUNCTIONS |
unset SPECIAL_FUNCTIONS |
876 |
for i in ${SPECIAL_VARS} |
# for i in ${SPECIAL_VARS} |
877 |
do |
# do |
878 |
unset "${i}" |
# unset "${i}" |
879 |
done |
# done |
880 |
unset SPECIAL_VARS |
unset SPECIAL_VARS |
881 |
unset STATE |
unset STATE |
882 |
unset DESCRIPTION |
unset DESCRIPTION |
892 |
unset postremove |
unset postremove |
893 |
} |
} |
894 |
|
|
895 |
|
split_save_variables() |
896 |
|
{ |
897 |
|
export SAVED_PNAME="${PNAME}" |
898 |
|
export SAVED_PVER="${PVER}" |
899 |
|
export SAVED_PBUILD="${PBUILD}" |
900 |
|
export SAVED_PCATEGORIE="${PCATEGORIE}" |
901 |
|
export SAVED_DESCRIPTION="${DESCRIPTION}" |
902 |
|
export SAVED_HOMEPAGE="${HOMEPAGE}" |
903 |
|
export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
904 |
|
export SAVED_STATE="${STATE}" |
905 |
|
export SAVED_PKGTYPE="${PKGTYPE}" |
906 |
|
export SAVED_INHERITS="${INHERITS}" |
907 |
|
export SAVED_DEPEND="${DEPEND}" |
908 |
|
export SAVED_SDEPEND="${SDEPEND}" |
909 |
|
export SAVED_PROVIDE="${PROVIDE}" |
910 |
|
export SAVED_NOPKGBUILD="${NOPKGBUILD}" |
911 |
|
|
912 |
|
# bindir too |
913 |
|
export SAVED_BINDIR="${BINDIR}" |
914 |
|
|
915 |
|
# export the SPLIT_PACKAGE_BASE |
916 |
|
export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
917 |
|
|
918 |
|
# functions |
919 |
|
if [[ ! -z $(typeset -f preinstall) ]] |
920 |
|
then |
921 |
|
# rename the old one |
922 |
|
local saved_preinstall |
923 |
|
saved_preinstall=SAVED_$(typeset -f preinstall) |
924 |
|
eval "${saved_preinstall}" |
925 |
|
export -f SAVED_preinstall |
926 |
|
fi |
927 |
|
|
928 |
|
if [[ ! -z $(typeset -f postinstall) ]] |
929 |
|
then |
930 |
|
# rename the old one |
931 |
|
local saved_postinstall |
932 |
|
saved_postinstall=SAVED_$(typeset -f postinstall) |
933 |
|
eval "${saved_postinstall}" |
934 |
|
export -f SAVED_postinstall |
935 |
|
fi |
936 |
|
|
937 |
|
if [[ ! -z $(typeset -f preremove) ]] |
938 |
|
then |
939 |
|
# rename the old one |
940 |
|
local saved_preremove |
941 |
|
saved_preremove=SAVED_$(typeset -f preremove) |
942 |
|
eval "${saved_preremove}" |
943 |
|
export -f SAVED_preremove |
944 |
|
fi |
945 |
|
|
946 |
|
if [[ ! -z $(typeset -f postremove) ]] |
947 |
|
then |
948 |
|
# rename the old one |
949 |
|
local saved_postremove |
950 |
|
saved_postremove=SAVED_$(typeset -f postremove) |
951 |
|
eval "${saved_postremove}" |
952 |
|
export -f SAVED_postremove |
953 |
|
fi |
954 |
|
} |
955 |
|
|
956 |
|
split_restore_variables() |
957 |
|
{ |
958 |
|
export PNAME="${SAVED_PNAME}" |
959 |
|
export PVER="${SAVED_PVER}" |
960 |
|
export PBUILD="${SAVED_PBUILD}" |
961 |
|
export PCATEGORIE="${SAVED_PCATEGORIE}" |
962 |
|
export DESCRIPTION="${SAVED_DESCRIPTION}" |
963 |
|
export HOMEPAGE="${SAVED_HOMEPAGE}" |
964 |
|
export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
965 |
|
export STATE="${SAVED_STATE}" |
966 |
|
export PKGTYPE="${SAVED_PKGTYPE}" |
967 |
|
export INHERITS="${SAVED_INHERITS}" |
968 |
|
export DEPEND="${SAVED_DEPEND}" |
969 |
|
export SDEPEND="${SAVED_SDEPEND}" |
970 |
|
export PROVIDE="${SAVED_PROVIDE}" |
971 |
|
export NOPKGBUILD="${SAVED_NOPKGBUILD}" |
972 |
|
|
973 |
|
# bindir too |
974 |
|
export BINDIR="${SAVED_BINDIR}" |
975 |
|
|
976 |
|
# functions |
977 |
|
if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
978 |
|
then |
979 |
|
# rename the old one |
980 |
|
local saved_preinstall |
981 |
|
saved_preinstall=$(typeset -f SAVED_preinstall) |
982 |
|
eval "${saved_preinstall/SAVED_/}" |
983 |
|
export -f preinstall |
984 |
|
fi |
985 |
|
|
986 |
|
if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
987 |
|
then |
988 |
|
# rename the old one |
989 |
|
local saved_postinstall |
990 |
|
saved_postinstall=$(typeset -f SAVED_postinstall) |
991 |
|
eval "${saved_postinstall/SAVED_/}" |
992 |
|
export -f postinstall |
993 |
|
fi |
994 |
|
|
995 |
|
if [[ ! -z $(typeset -f SAVED_preremove) ]] |
996 |
|
then |
997 |
|
# rename the old one |
998 |
|
local saved_preremove |
999 |
|
saved_preremove=$(typeset -f SAVED_preremove) |
1000 |
|
eval "${saved_preremove/SAVED_/}" |
1001 |
|
export -f preremove |
1002 |
|
fi |
1003 |
|
|
1004 |
|
if [[ ! -z $(typeset -f SAVED_postremove) ]] |
1005 |
|
then |
1006 |
|
# rename the old one |
1007 |
|
local saved_postremove |
1008 |
|
saved_postremove=$(typeset -f SAVED_postremove) |
1009 |
|
eval "${saved_postremove/SAVED_/}" |
1010 |
|
export -f postremove |
1011 |
|
fi |
1012 |
|
} |
1013 |
|
|
1014 |
|
split_unset_variables() |
1015 |
|
{ |
1016 |
|
# unset saved vars; not needed anymore |
1017 |
|
unset SAVED_PNAME |
1018 |
|
unset SAVED_PVER |
1019 |
|
unset SAVED_PBUILD |
1020 |
|
unset SAVED_PCATEGORIE |
1021 |
|
unset SAVED_DESCRIPTION |
1022 |
|
unset SAVED_HOMEPAGE |
1023 |
|
unset SAVED_SPECIAL_VARS |
1024 |
|
unset SAVED_STATE |
1025 |
|
unset SAVED_PKGTYPE |
1026 |
|
unset SAVED_INHERITS |
1027 |
|
unset SAVED_DEPEND |
1028 |
|
unset SAVED_SDEPEND |
1029 |
|
unset SAVED_PROVIDE |
1030 |
|
unset SAVED_BINDIR |
1031 |
|
unset SAVED_NOPKGBUILD |
1032 |
|
unset SPLIT_PACKAGE_BASE |
1033 |
|
unset -f SAVED_preinstall |
1034 |
|
unset -f SAVED_postinstall |
1035 |
|
unset -f SAVED_preremove |
1036 |
|
unset -f SAVED_postremove |
1037 |
|
} |
1038 |
|
|
1039 |
|
split_export_inherits() |
1040 |
|
{ |
1041 |
|
local subpackage="$1" |
1042 |
|
local func |
1043 |
|
local newfunc |
1044 |
|
|
1045 |
|
for func in preinstall postinstall preremove postremove |
1046 |
|
do |
1047 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1048 |
|
then |
1049 |
|
newfunc=$(typeset -f ${func}_${subpackage}) |
1050 |
|
newfunc="${newfunc/_${subpackage} (/ (}" |
1051 |
|
eval "${newfunc}" |
1052 |
|
fi |
1053 |
|
done |
1054 |
|
} |
1055 |
|
|
1056 |
|
split_delete_inherits() |
1057 |
|
{ |
1058 |
|
local subpackage="$1" |
1059 |
|
local func |
1060 |
|
|
1061 |
|
for func in preinstall postinstall preremove postremove |
1062 |
|
do |
1063 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1064 |
|
then |
1065 |
|
unset -f ${func} |
1066 |
|
fi |
1067 |
|
done |
1068 |
|
} |
1069 |
|
|
1070 |
export_inherits() |
export_inherits() |
1071 |
{ |
{ |
1072 |
local include="$1" |
local include="$1" |
1128 |
# fix target as it may be empty ! |
# fix target as it may be empty ! |
1129 |
[ -n "${target}" ] && target="-${target}" |
[ -n "${target}" ] && target="-${target}" |
1130 |
|
|
1131 |
|
|
1132 |
# build pkgname |
# build pkgname |
1133 |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
1134 |
|
|
1148 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1149 |
|
|
1150 |
# setup md5 dir |
# setup md5 dir |
1151 |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1152 |
install -d ${dest} |
install -d ${dest} |
1153 |
|
|
1154 |
# gen md5sum |
# gen md5sum |
1186 |
echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" |
echo -e "${COLGREEN}Source package ${COLBLUE}${PNAME}-${PVER}-${PBUILD}.${SRCPKGSUFFIX} ${COLGREEN}successfully builded.${COLDEFAULT}" |
1187 |
} |
} |
1188 |
|
|
1189 |
|
step_by_step() |
1190 |
|
{ |
1191 |
|
if [[ ${STEP_BY_STEP} = true ]] |
1192 |
|
then |
1193 |
|
echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1194 |
|
echo "Press [enter] to continue" |
1195 |
|
read |
1196 |
|
fi |
1197 |
|
} |
1198 |
|
|
1199 |
|
|
1200 |
# print out our version |
# print out our version |
1201 |
showversion |
showversion |
1222 |
# creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
1223 |
if [[ $1 = calcmd5 ]] |
if [[ $1 = calcmd5 ]] |
1224 |
then |
then |
1225 |
if [ $# -ge 3 ] |
if [ $# -ge 2 ] |
1226 |
then |
then |
1227 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1228 |
MD5DIR="$3" |
MD5DIR="$3" |
1229 |
source ${SMAGENAME} || die "download source failed" |
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1230 |
|
|
1231 |
|
smagesource ${SMAGENAME} || die "download source failed" |
1232 |
|
|
1233 |
# overridable sourcedir; must be declared after source of the smage2 |
# overridable sourcedir; must be declared after source of the smage2 |
1234 |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
1280 |
echo |
echo |
1281 |
else |
else |
1282 |
echo "Usage: Calculating MD5 Sums:" |
echo "Usage: Calculating MD5 Sums:" |
1283 |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1284 |
echo |
echo |
1285 |
echo |
echo |
1286 |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
1302 |
# get smage |
# get smage |
1303 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1304 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1305 |
source ${SMAGENAME} || die "download source failed" |
smagesource ${SMAGENAME} || die "download source failed" |
1306 |
|
|
1307 |
download_sources |
download_sources |
1308 |
exit 0 |
exit 0 |
1314 |
# set correct SMAGENAME |
# set correct SMAGENAME |
1315 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1316 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1317 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1318 |
|
|
1319 |
regen_mage_tree |
regen_mage_tree |
1320 |
|
|
1321 |
# build md5sum for existing packages |
# build several targets |
1322 |
generate_package_md5sum \ |
if [[ -n ${MAGE_TARGETS} ]] |
1323 |
--pcat "${PCATEGORIE}" \ |
then |
1324 |
--pname "${PNAME}" \ |
for target in ${MAGE_TARGETS} |
1325 |
--pver "${PVER}" \ |
do |
1326 |
--pbuild "${PBUILD}" \ |
# build md5sum for existing packages |
1327 |
--parch "${ARCH}" \ |
generate_package_md5sum \ |
1328 |
--target "${target}" |
--pcat "${PCATEGORIE}" \ |
1329 |
|
--pname "${PNAME}" \ |
1330 |
|
--pver "${PVER}" \ |
1331 |
|
--pbuild "${PBUILD}" \ |
1332 |
|
--parch "${ARCH}" \ |
1333 |
|
--target "${target}" |
1334 |
|
done |
1335 |
|
|
1336 |
|
# build several subpackages |
1337 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1338 |
|
then |
1339 |
|
split_save_variables |
1340 |
|
for subpackage in ${SPLIT_PACKAGES} |
1341 |
|
do |
1342 |
|
# get the right variables for the split |
1343 |
|
export PNAME="${subpackage}" |
1344 |
|
split_info_${subpackage} |
1345 |
|
# build md5sum for existing packages |
1346 |
|
generate_package_md5sum \ |
1347 |
|
--pcat "${PCATEGORIE}" \ |
1348 |
|
--pname "${PNAME}" \ |
1349 |
|
--pver "${PVER}" \ |
1350 |
|
--pbuild "${PBUILD}" \ |
1351 |
|
--parch "${ARCH}" |
1352 |
|
# restore smage environment |
1353 |
|
split_restore_variables |
1354 |
|
done |
1355 |
|
# unset all saved smage variables |
1356 |
|
split_unset_variables |
1357 |
|
|
1358 |
|
else |
1359 |
|
# build md5sum for existing packages |
1360 |
|
generate_package_md5sum \ |
1361 |
|
--pcat "${PCATEGORIE}" \ |
1362 |
|
--pname "${PNAME}" \ |
1363 |
|
--pver "${PVER}" \ |
1364 |
|
--pbuild "${PBUILD}" \ |
1365 |
|
--parch "${ARCH}" |
1366 |
|
fi |
1367 |
|
|
1368 |
exit 0 |
exit 0 |
1369 |
fi |
fi |
1376 |
|
|
1377 |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1378 |
|
|
1379 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1380 |
|
|
1381 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1382 |
then |
then |
1425 |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
1426 |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
1427 |
|
|
1428 |
source ${SMAGENAME} || die "source failed" |
smagesource ${SMAGENAME} || die "source failed" |
1429 |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1430 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1431 |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1432 |
|
|
1433 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
1434 |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1451 |
# fixes some issues with these functions |
# fixes some issues with these functions |
1452 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
1453 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
1454 |
|
export -f src_check || die "src_check export failed" |
1455 |
export -f src_install || die "src_install export failed" |
export -f src_install || die "src_install export failed" |
1456 |
|
|
1457 |
# fixes some compile issues |
# fixes some compile issues |
1469 |
# setup ccache |
# setup ccache |
1470 |
[[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
[[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
1471 |
|
|
1472 |
# small sleep to show our settings |
# clean up builddir if a previously one exist |
|
sleep 1 |
|
|
|
|
|
# cleans up build if a previously one exists |
|
1473 |
if [ -d ${BUILDDIR} ] |
if [ -d ${BUILDDIR} ] |
1474 |
then |
then |
1475 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
1476 |
fi |
fi |
1477 |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
1478 |
|
|
1479 |
# cleans up srcdir if a previously unpacked one exists |
# clean up srcdir if a previously unpacked one exist |
1480 |
if [ -d ${SRCDIR} ] |
if [ -d ${SRCDIR} ] |
1481 |
then |
then |
1482 |
rm -rf ${SRCDIR} |
rm -rf ${SRCDIR} |
1483 |
fi |
fi |
1484 |
|
|
1485 |
# cleans up bindir if a previous build exists or creates a new one |
# clean up bindir if a previous build exist or create a new one |
1486 |
if [ -d ${BINDIR} ] |
if [ -d ${BINDIR} ] |
1487 |
then |
then |
1488 |
rm -rf ${BINDIR} |
rm -rf ${BINDIR} |
1501 |
mage rmstamp |
mage rmstamp |
1502 |
fi |
fi |
1503 |
|
|
1504 |
src_prepare || die "src_prepare failed" |
# setup build logging |
1505 |
src_compile || die "src_compile failed" |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1506 |
src_install || die "src_install failed" |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1507 |
|
|
1508 |
|
src_prepare | ${SMAGE_LOG_CMD} |
1509 |
|
die_pipestatus 0 "src_prepare failed" |
1510 |
|
step_by_step $_ |
1511 |
|
|
1512 |
|
src_compile | ${SMAGE_LOG_CMD} |
1513 |
|
die_pipestatus 0 "src_compile failed" |
1514 |
|
step_by_step $_ |
1515 |
|
|
1516 |
|
# only run checks if requested |
1517 |
|
if [[ ${MAGE_CHECK} != true ]] |
1518 |
|
then |
1519 |
|
echo "MAGE_CHECK not requested; src_check() will not be run!" | ${SMAGE_LOG_CMD} |
1520 |
|
step_by_step src_check |
1521 |
|
else |
1522 |
|
src_check | ${SMAGE_LOG_CMD} |
1523 |
|
die_pipestatus 0 "src_check failed" |
1524 |
|
step_by_step $_ |
1525 |
|
fi |
1526 |
|
|
1527 |
# compressing doc, info & man files |
# build several subpackages |
1528 |
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
if [[ -n ${SPLIT_PACKAGES} ]] |
1529 |
then |
then |
1530 |
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
# save bindir & pname |
1531 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man |
split_save_variables |
1532 |
|
export SAVED_BINDIR="${BINDIR}" |
1533 |
|
for subpackage in ${SPLIT_PACKAGES} |
1534 |
|
do |
1535 |
|
if typeset -f src_install_${subpackage} > /dev/null |
1536 |
|
then |
1537 |
|
# export subpackage bindir |
1538 |
|
export BINDIR="${SAVED_BINDIR}_${subpackage}" |
1539 |
|
# export PNAME, several internal function and include |
1540 |
|
# rely on this variable |
1541 |
|
export PNAME="${subpackage}" |
1542 |
|
|
1543 |
|
echo |
1544 |
|
echo -en "${COLBLUE}*** ${COLDEFAULT}" |
1545 |
|
echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" |
1546 |
|
echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
1547 |
|
echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
1548 |
|
|
1549 |
|
src_install_${subpackage} | ${SMAGE_LOG_CMD} |
1550 |
|
die_pipestatus 0 "src_install_${subpackage} failed" |
1551 |
|
step_by_step $_ |
1552 |
|
fi |
1553 |
|
done |
1554 |
|
# restore bindir & pname |
1555 |
|
split_restore_variables |
1556 |
|
# unset all saved smage variables |
1557 |
|
split_unset_variables |
1558 |
|
else |
1559 |
|
src_install | ${SMAGE_LOG_CMD} |
1560 |
|
die_pipestatus 0 "src_install failed" |
1561 |
|
step_by_step $_ |
1562 |
fi |
fi |
1563 |
|
|
1564 |
if [ -d ${BUILDDIR}/builded/usr/share/info ] |
# compressing doc, info & man files |
1565 |
|
if [[ -n ${SPLIT_PACKAGES} ]] |
1566 |
then |
then |
1567 |
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
for subpackage in ${SPLIT_PACKAGES} |
1568 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
do |
1569 |
|
mcompressdocs ${BINDIR}_${subpackage} |
1570 |
|
done |
1571 |
|
else |
1572 |
|
mcompressdocs ${BINDIR} |
1573 |
fi |
fi |
1574 |
|
|
1575 |
|
|
1576 |
# stripping all bins and libs |
# stripping all bins and libs |
1577 |
case ${NOSTRIP} in |
case ${NOSTRIP} in |
1578 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
1579 |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
1580 |
;; |
;; |
1581 |
*) |
*) |
1582 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
if [[ -n ${SPLIT_PACKAGES} ]] |
1583 |
mstripbins ${BINDIR} |
then |
1584 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
for subpackage in ${SPLIT_PACKAGES} |
1585 |
mstriplibs ${BINDIR} |
do |
1586 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1587 |
|
mstripbins ${BINDIR}_${subpackage} |
1588 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" |
1589 |
|
mstriplibs ${BINDIR}_${subpackage} |
1590 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" |
1591 |
|
mstripstatic ${BINDIR}_${subpackage} |
1592 |
|
done |
1593 |
|
else |
1594 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1595 |
|
mstripbins ${BINDIR} |
1596 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" |
1597 |
|
mstriplibs ${BINDIR} |
1598 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" |
1599 |
|
mstripstatic ${BINDIR} |
1600 |
|
fi |
1601 |
;; |
;; |
1602 |
esac |
esac |
1603 |
|
|
1608 |
;; |
;; |
1609 |
*) |
*) |
1610 |
# build several targets |
# build several targets |
1611 |
if [ -n "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
1612 |
then |
then |
1613 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1614 |
do |
do |
1615 |
# check if an special target_pkgbuild exists |
# check if a special target_pkgbuild exists |
1616 |
if typeset -f ${target}_pkgbuild > /dev/null |
if typeset -f ${target}_pkgbuild > /dev/null |
1617 |
then |
then |
1618 |
# run it |
# run it |
1634 |
|
|
1635 |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1636 |
done |
done |
1637 |
|
|
1638 |
|
# build several subpackages |
1639 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1640 |
|
then |
1641 |
|
split_save_variables |
1642 |
|
for subpackage in ${SPLIT_PACKAGES} |
1643 |
|
do |
1644 |
|
# get the right variables for the split |
1645 |
|
export PNAME="${subpackage}" |
1646 |
|
split_info_${PNAME} |
1647 |
|
|
1648 |
|
# jump to next one if NOPKGBUILD is set in split_info |
1649 |
|
case ${NOPKGBUILD} in |
1650 |
|
true|TRUE|yes|y) continue ;; |
1651 |
|
esac |
1652 |
|
|
1653 |
|
# check if an special subpackage_pkgbuild exists |
1654 |
|
if typeset -f ${PNAME}_pkgbuild > /dev/null |
1655 |
|
then |
1656 |
|
# run it |
1657 |
|
${PNAME}_pkgbuild |
1658 |
|
fi |
1659 |
|
# now create the target package |
1660 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
1661 |
|
"${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ |
1662 |
|
"${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" |
1663 |
|
|
1664 |
|
# build pkg-md5-sum if requested |
1665 |
|
generate_package_md5sum \ |
1666 |
|
--pcat "${PCATEGORIE}" \ |
1667 |
|
--pname "${PNAME}" \ |
1668 |
|
--pver "${PVER}" \ |
1669 |
|
--pbuild "${PBUILD}" \ |
1670 |
|
--parch "${ARCH}" |
1671 |
|
|
1672 |
|
echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1673 |
|
|
1674 |
|
# restore smage environment |
1675 |
|
split_restore_variables |
1676 |
|
done |
1677 |
|
# unset all saved smage variables |
1678 |
|
split_unset_variables |
1679 |
|
|
1680 |
else |
else |
1681 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
1682 |
|
|
1696 |
;; |
;; |
1697 |
esac |
esac |
1698 |
|
|
1699 |
|
if [[ ${SMAGE_BUILD_LOGGING} != false ]] |
1700 |
|
then |
1701 |
|
bzip2 -9f /var/log/smage/${PKGNAME}.log |
1702 |
|
else |
1703 |
|
[[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log |
1704 |
|
fi |
1705 |
|
|
1706 |
# for sure |
# for sure |
1707 |
unset NOPKGBUILD |
unset NOPKGBUILD |
1708 |
unset NOSTRIP |
unset NOSTRIP |