4 |
# needs pkgbuild_dir (mage) |
# needs pkgbuild_dir (mage) |
5 |
|
|
6 |
# SMAGE2 |
# SMAGE2 |
7 |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.50 2007-01-19 23:15:04 niro Exp $ |
# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 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 |
|
# set default user mage.rc |
14 |
|
: ${MAGERC="/etc/mage.rc"} |
15 |
|
|
16 |
## setup ## |
## setup ## |
17 |
PKGSUFFIX="mpk" |
PKGSUFFIX="mpk" |
18 |
SRCPKGSUFFIX="mpks" |
SRCPKGSUFFIX="mpks" |
48 |
# export default C locale |
# export default C locale |
49 |
export LC_ALL=C |
export LC_ALL=C |
50 |
|
|
51 |
source /etc/mage.rc |
source /etc/mage.rc.global |
52 |
|
source ${MAGERC} |
53 |
|
source ${MLIBDIR}/mage4.functions.sh |
54 |
|
|
55 |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
# set PKGDIR and BUILDDIR and BINDIR to MROOT |
56 |
if [[ -n ${MROOT} ]] |
if [[ -n ${MROOT} ]] |
60 |
export BINDIR=${MROOT}/${BINDIR} |
export BINDIR=${MROOT}/${BINDIR} |
61 |
fi |
fi |
62 |
|
|
63 |
|
# sources the smage file and uses state from distribution file if exist |
64 |
|
# may helpful for repository support later on |
65 |
|
smagesource() |
66 |
|
{ |
67 |
|
local file="$1" |
68 |
|
local mystate |
69 |
|
local mycodename |
70 |
|
|
71 |
|
source ${file} |
72 |
|
|
73 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
74 |
|
if [ -f ${SMAGESCRIPTSDIR}/distribution ] |
75 |
|
then |
76 |
|
source ${SMAGESCRIPTSDIR}/distribution |
77 |
|
[[ -n ${STATE} ]] && mystate="${STATE}" |
78 |
|
fi |
79 |
|
# now switch state and export it |
80 |
|
STATE="${mystate}" |
81 |
|
} |
82 |
|
|
83 |
showversion() |
showversion() |
84 |
{ |
{ |
85 |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
echo -en "Magellan Source Install v${SMAGEVERSION} " |
94 |
exit 1 |
exit 1 |
95 |
} |
} |
96 |
|
|
97 |
|
die_pipestatus() |
98 |
|
{ |
99 |
|
# the status change if we do any parameter declarations!! |
100 |
|
# dont do this anymore, keep this in mind! |
101 |
|
# |
102 |
|
# local pos="$1" |
103 |
|
# local comment="$2" |
104 |
|
# |
105 |
|
# [ ${PIPESTATUS[${pos}]} -ne 0 ] && die "${comment}" |
106 |
|
# |
107 |
|
[ ${PIPESTATUS[$1]} -ne 0 ] && die "$2" |
108 |
|
} |
109 |
|
|
110 |
xtitle() |
xtitle() |
111 |
{ |
{ |
112 |
if [[ ${TERM} = xterm ]] |
if [[ ${TERM} = xterm ]] |
174 |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
local DB_MD5_SUM_FILE="${MD5DIR}/$(basename ${SMAGENAME} .${SMAGESUFFIX}).md5" |
175 |
local FETCHING |
local FETCHING |
176 |
local i mirror |
local i mirror |
177 |
|
local wget_opts |
178 |
|
|
179 |
|
# filter wget command if busybox was found |
180 |
|
wget_opts="$(busybox_filter_wget_options ${WGET_FETCH_OPTIONS})" |
181 |
|
|
182 |
# install SRCDIR/PNAME if not exist |
# install SRCDIR/PNAME if not exist |
183 |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
[ ! -d ${SOURCEDIR}/${PNAME} ] && install -d ${SOURCEDIR}/${PNAME} |
184 |
|
|
185 |
# check if FETCHING is needed |
# check if FETCHING is needed |
186 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} &> /dev/null ) |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} &> /dev/null ) |
187 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
188 |
then |
then |
189 |
# md5's ok, not fetching needed |
# md5's ok, no fetching needed |
190 |
FETCHING=false |
FETCHING=false |
191 |
else |
else |
192 |
FETCHING=true |
FETCHING=true |
208 |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
my_SOURCEDIR="${SOURCEDIR}/${PNAME}" |
209 |
fi |
fi |
210 |
|
|
211 |
|
# create the SOURCEDIR |
212 |
|
install -d ${my_SOURCEDIR} |
213 |
|
|
214 |
# if an mirrored file than replace first the mirror uri |
# if an mirrored file than replace first the mirror uri |
215 |
if [ -n "$(echo ${my_SRC_URI} | grep 'mirror://')" ] |
if [[ -n $(echo ${my_SRC_URI} | grep 'mirror://') ]] |
216 |
then |
then |
217 |
for mirror in ${MIRRORS} |
for mirror in ${MIRRORS} |
218 |
do |
do |
220 |
|
|
221 |
if [[ ${FETCHING} = true ]] |
if [[ ${FETCHING} = true ]] |
222 |
then |
then |
223 |
echo "==> fetching ${my_SRC_URI_MIRROR}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
224 |
wget \ |
wget \ |
225 |
--passive-ftp \ |
${wget_opts} \ |
226 |
--tries 3 \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
227 |
--continue \ |
"${my_SRC_URI_MIRROR}" |
228 |
--progress bar \ |
if [[ $? = 0 ]] |
229 |
--directory-prefix="${my_SOURCEDIR}" \ |
then |
230 |
|
break |
231 |
|
else |
232 |
|
continue |
233 |
|
fi |
234 |
|
fi |
235 |
|
done |
236 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'sourceforge://') ]] |
237 |
|
then |
238 |
|
for mirror in ${SOURCEFORGE_MIRRORS} |
239 |
|
do |
240 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|sourceforge:/|${mirror}|g")" |
241 |
|
|
242 |
|
if [[ ${FETCHING} = true ]] |
243 |
|
then |
244 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
245 |
|
wget \ |
246 |
|
${wget_opts} \ |
247 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
248 |
|
"${my_SRC_URI_MIRROR}" |
249 |
|
if [[ $? = 0 ]] |
250 |
|
then |
251 |
|
break |
252 |
|
else |
253 |
|
continue |
254 |
|
fi |
255 |
|
fi |
256 |
|
done |
257 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'gnu://') ]] |
258 |
|
then |
259 |
|
for mirror in ${GNU_MIRRORS} |
260 |
|
do |
261 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnu:/|${mirror}|g")" |
262 |
|
|
263 |
|
if [[ ${FETCHING} = true ]] |
264 |
|
then |
265 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
266 |
|
wget \ |
267 |
|
${wget_opts} \ |
268 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
269 |
|
"${my_SRC_URI_MIRROR}" |
270 |
|
if [[ $? = 0 ]] |
271 |
|
then |
272 |
|
break |
273 |
|
else |
274 |
|
continue |
275 |
|
fi |
276 |
|
fi |
277 |
|
done |
278 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'kde://') ]] |
279 |
|
then |
280 |
|
for mirror in ${KDE_MIRRORS} |
281 |
|
do |
282 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|kde:/|${mirror}|g")" |
283 |
|
|
284 |
|
if [[ ${FETCHING} = true ]] |
285 |
|
then |
286 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
287 |
|
wget \ |
288 |
|
${wget_opts} \ |
289 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
290 |
|
"${my_SRC_URI_MIRROR}" |
291 |
|
if [[ $? = 0 ]] |
292 |
|
then |
293 |
|
break |
294 |
|
else |
295 |
|
continue |
296 |
|
fi |
297 |
|
fi |
298 |
|
done |
299 |
|
elif [[ -n $(echo ${my_SRC_URI} | grep 'gnome://') ]] |
300 |
|
then |
301 |
|
for mirror in ${GNOME_MIRRORS} |
302 |
|
do |
303 |
|
my_SRC_URI_MIRROR="$(echo ${my_SRC_URI} | sed "s|gnome:/|${mirror}|g")" |
304 |
|
|
305 |
|
if [[ ${FETCHING} = true ]] |
306 |
|
then |
307 |
|
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI_MIRROR}${COLDEFAULT}" |
308 |
|
wget \ |
309 |
|
${wget_opts} \ |
310 |
|
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI_MIRROR})" \ |
311 |
"${my_SRC_URI_MIRROR}" |
"${my_SRC_URI_MIRROR}" |
312 |
if [[ $? = 0 ]] |
if [[ $? = 0 ]] |
313 |
then |
then |
320 |
else |
else |
321 |
if [[ ${FETCHING} = true ]] |
if [[ ${FETCHING} = true ]] |
322 |
then |
then |
323 |
echo "==> fetching ${my_SRC_URI}" |
echo -e "${COLBLUE}==>${COLGREEN} fetching ${my_SRC_URI}${COLDEFAULT}" |
324 |
wget \ |
wget \ |
325 |
--passive-ftp \ |
${wget_opts} \ |
326 |
--tries 3 \ |
--output-document="${my_SOURCEDIR}/$(basename ${my_SRC_URI})" \ |
|
--continue \ |
|
|
--progress bar \ |
|
|
--directory-prefix="${my_SOURCEDIR}" \ |
|
327 |
"${my_SRC_URI}" |
"${my_SRC_URI}" |
328 |
fi |
fi |
329 |
fi |
fi |
337 |
|
|
338 |
# recheck md5 sums |
# recheck md5 sums |
339 |
echo |
echo |
340 |
echo ">== Checking MD5 sums:" |
echo -e "${COLBLUE}===${COLGREEN} Checking MD5 sums:${COLDEFAULT}" |
341 |
( cd ${SOURCEDIR}/${PNAME}; md5sum --check ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
( cd ${SOURCEDIR}/${PNAME}; md5sum -c ${DB_MD5_SUM_FILE} ) || die "md5 failed" |
342 |
echo |
echo |
343 |
|
|
344 |
# not needed anymore |
# not needed anymore |
384 |
./configure \ |
./configure \ |
385 |
--prefix=/usr \ |
--prefix=/usr \ |
386 |
--host=${CHOST} \ |
--host=${CHOST} \ |
387 |
|
--build=${CHOST} \ |
388 |
--mandir=/usr/share/man \ |
--mandir=/usr/share/man \ |
389 |
--infodir=/usr/share/info \ |
--infodir=/usr/share/info \ |
390 |
--datadir=/usr/share \ |
--datadir=/usr/share \ |
428 |
|
|
429 |
SRCFILE=$1 |
SRCFILE=$1 |
430 |
|
|
431 |
if [ -z "$2" ] |
if [[ -z $2 ]] |
432 |
then |
then |
433 |
DEST=${BUILDDIR} |
DEST=${BUILDDIR} |
434 |
else |
else |
443 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
444 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
445 |
then |
then |
446 |
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." |
447 |
|
else |
448 |
|
pushd ${DEST} > /dev/null |
449 |
|
bzcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .bz2) || die ".bz2 unpack failed." |
450 |
|
popd > /dev/null |
451 |
fi |
fi |
452 |
;; |
;; |
453 |
gz) |
gz) |
455 |
IFTAR="${IFTAR##*.}" |
IFTAR="${IFTAR##*.}" |
456 |
if [[ ${IFTAR} = tar ]] |
if [[ ${IFTAR} = tar ]] |
457 |
then |
then |
458 |
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." |
459 |
|
else |
460 |
|
pushd ${DEST} > /dev/null |
461 |
|
zcat ${SOURCEDIR}/${PNAME}/${SRCFILE} > ${DEST}/$(basename ${SRCFILE} .gz) || die ".gz unpack failed." |
462 |
|
popd > /dev/null |
463 |
fi |
fi |
464 |
;; |
;; |
465 |
tbz2) |
tbz2|mpks|mpk) |
466 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
467 |
;; |
;; |
468 |
tgz) |
tgz) |
469 |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} |
tar --no-same-owner -xvzf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tgz unpack failed." |
470 |
|
;; |
471 |
|
rar) |
472 |
|
unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
473 |
|
;; |
474 |
|
zip|xpi) |
475 |
|
unzip ${SOURCEDIR}/${PNAME}/${SRCFILE} -d ${DEST} || die ".zip unpack failed." |
476 |
|
;; |
477 |
|
rpm) |
478 |
|
pushd ${DEST} > /dev/null |
479 |
|
rpm2targz ${SOURCEDIR}/${PNAME}/${SRCFILE} || die "rpm2targz: .rpm unpack failed." |
480 |
|
tar --no-same-owner -xvzf ${SRCFILE/.rpm/.tar.gz} || die "tar: .rpm unpack failed." |
481 |
|
if [[ -f ${DEST}/${SRCFILE/.rpm/.tar.gz} ]] |
482 |
|
then |
483 |
|
rm ${DEST}/${SRCFILE/.rpm/.tar.gz} |
484 |
|
fi |
485 |
;; |
;; |
486 |
*) |
*) |
487 |
die "munpack failed" |
die "munpack failed" |
493 |
{ |
{ |
494 |
local PATCHOPTS |
local PATCHOPTS |
495 |
local PATCHFILE |
local PATCHFILE |
496 |
|
local i |
497 |
|
|
498 |
PATCHOPTS=$1 |
PATCHOPTS=$1 |
499 |
PATCHFILE=$2 |
PATCHFILE=$2 |
500 |
|
|
501 |
|
if [[ -z $2 ]] |
502 |
|
then |
503 |
|
PATCHFILE=$1 |
504 |
|
|
505 |
|
## patch level auto-detection, get patch level |
506 |
|
for ((i=0; i < 10; i++)) |
507 |
|
do |
508 |
|
patch --dry-run -Np${i} -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} > /dev/null |
509 |
|
if [[ $? = 0 ]] |
510 |
|
then |
511 |
|
PATCHOPTS="-Np${i}" |
512 |
|
break |
513 |
|
fi |
514 |
|
done |
515 |
|
fi |
516 |
|
|
517 |
echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
echo -e "${COLBLUE}*** ${COLGREEN}Applying patch '${PATCHFILE}'${COLDEFAULT}" |
518 |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
patch "${PATCHOPTS}" -i ${SOURCEDIR}/${PNAME}/${PATCHFILE} |
519 |
} |
} |
520 |
|
|
521 |
|
mlibtoolize() |
522 |
|
{ |
523 |
|
local opts="$@" |
524 |
|
[[ -z ${opts} ]] && opts="--copy --force" |
525 |
|
|
526 |
|
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
527 |
|
} |
528 |
|
|
529 |
|
mautoreconf() |
530 |
|
{ |
531 |
|
local opts="$@" |
532 |
|
[[ -z ${opts} ]] && opts="--verbose --install --force" |
533 |
|
|
534 |
|
autoreconf ${opts} || die "running: mautoreconf ${opts}" |
535 |
|
} |
536 |
|
|
537 |
minstalldocs() |
minstalldocs() |
538 |
{ |
{ |
544 |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "creating doc dirs." |
545 |
fi |
fi |
546 |
|
|
547 |
|
local i |
548 |
for i in ${docfiles} |
for i in ${docfiles} |
549 |
do |
do |
550 |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
if [ -f ${i} ] |
551 |
install -m 0644 ${SRCDIR}/${i}.gz \ |
then |
552 |
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
cat ${i} | gzip -9c > ${i}.gz || die "gzipping docs." |
553 |
|
install -m 0644 ${SRCDIR}/${i}.gz \ |
554 |
|
${BINDIR}/usr/share/doc/${PNAME}-${PVER} || die "coping docs." |
555 |
|
fi |
556 |
done |
done |
557 |
} |
} |
558 |
|
|
572 |
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-unneeded 2> /dev/null |
573 |
} |
} |
574 |
|
|
575 |
|
mcompressdocs() |
576 |
|
{ |
577 |
|
local bindir="$@" |
578 |
|
|
579 |
|
if [ -d ${bindir}/usr/share/man ] |
580 |
|
then |
581 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing man-pages ...${COLDEFAULT}" |
582 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/man |
583 |
|
fi |
584 |
|
|
585 |
|
if [ -d ${bindir}/usr/share/info ] |
586 |
|
then |
587 |
|
echo -e "${COLBLUE}===${COLGREEN} compressing info-pages ...${COLDEFAULT}" |
588 |
|
${MLIBDIR}/compressdoc -g -9 ${bindir}/usr/share/info |
589 |
|
fi |
590 |
|
} |
591 |
|
|
592 |
sminclude() |
sminclude() |
593 |
{ |
{ |
594 |
local i |
local i |
608 |
{ |
{ |
609 |
if [ -x /usr/bin/distcc ] |
if [ -x /usr/bin/distcc ] |
610 |
then |
then |
611 |
echo "Using DistCC for compilation ..." |
echo -e "${COLBLUE}---${COLGREEN} Using DistCC for compilation ...${COLDEFAULT}" |
612 |
export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
export PATH=/usr/$(mlibdir)/distcc/bin:${PATH} || die "distcc: could not export new $PATH" |
613 |
|
|
614 |
export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
export DISTCC_DIR="${DISTCC_DIR}" || die "distcc_dir export failed" |
623 |
{ |
{ |
624 |
if [ -x /usr/bin/ccache ] |
if [ -x /usr/bin/ccache ] |
625 |
then |
then |
626 |
echo "Using CCache for compilation ..." |
echo -e "${COLBLUE}---${COLGREEN} Using CCache for compilation ...${COLDEFAULT}" |
627 |
export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
export PATH=/usr/$(mlibdir)/ccache/bin:${PATH} || die "ccache: could not export new $PATH" |
628 |
fi |
fi |
629 |
} |
} |
647 |
# fix DEPEND |
# fix DEPEND |
648 |
while read sym dep |
while read sym dep |
649 |
do |
do |
650 |
|
# ignore empty lines |
651 |
|
[[ -z ${dep} ]] && continue |
652 |
|
|
653 |
cat="$(dirname ${dep})" |
cat="$(dirname ${dep})" |
654 |
# change if not virtual |
# change if not virtual |
655 |
if [[ ${cat} = virtual ]] |
if [[ ${cat} = virtual ]] |
702 |
# special tags: |
# special tags: |
703 |
# PKGTYPE type of pkg |
# PKGTYPE type of pkg |
704 |
# INHERITS which functions get included |
# INHERITS which functions get included |
705 |
# SPECIAL_FUNCTIONS special functions wich should also be added |
# SPECIAL_FUNCTIONS special functions which should also be added |
706 |
# warning: they get killed before the build starts ! |
# warning: they get killed before the build starts ! |
707 |
|
# SPLIT_PACKAGES names of all subpackages which are splitted from parent |
708 |
|
# SPLIT_PACKAGE_BASE base package name for splitpackages |
709 |
|
# (only in the resulting magefile} |
710 |
# |
# |
711 |
# MAGE_TREE_DEST target destination of the generated tree |
# MAGE_TREE_DEST target destination of the generated tree |
712 |
# REGEN_MAGE_TREE set to 'true' to enable this |
# REGEN_MAGE_TREE set to 'true' to enable this |
717 |
local magefile |
local magefile |
718 |
local dest |
local dest |
719 |
local target |
local target |
720 |
|
local split_pkg_base |
721 |
local sym |
local sym |
722 |
local depname |
local depname |
723 |
|
|
725 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
726 |
|
|
727 |
# determinate which suffix this mage file should get, if any |
# determinate which suffix this mage file should get, if any |
728 |
[ -n "$1" ] && target="-$1" |
[[ $1 = --target ]] && shift && target="-$1" |
729 |
|
|
730 |
|
# mark package as splitpackage |
731 |
|
[[ $1 = --split-pkg-base ]] && shift && split_pkg_base="$1" |
732 |
|
|
733 |
# name of magefile |
# name of magefile |
734 |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
magefile="${PNAME}${target}-${PVER}-${PBUILD}.mage" |
737 |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
dest="${MAGE_TREE_DEST}/${PCATEGORIE}/${PNAME}${target}/${magefile}" |
738 |
|
|
739 |
# show what we are doing |
# show what we are doing |
740 |
echo "Generating Mage file:" |
echo -e "${COLBLUE}===${COLGREEN} generating mage file:${COLDEFAULT}" |
741 |
echo " ${dest}" |
echo "${dest}" |
742 |
|
|
743 |
install -d "$(dirname ${dest})" |
install -d "$(dirname ${dest})" |
744 |
# now build the mage file |
# now build the mage file |
745 |
> ${dest} |
> ${dest} |
746 |
|
|
747 |
# header |
# header |
748 |
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.50 2007-01-19 23:15:04 niro Exp $' >> ${dest} |
echo '# $Header: /home/cvsd/magellan-cvs/magellan-src/mage/usr/lib/mage/smage2.sh,v 1.62 2007-11-28 10:47:50 niro Exp $' >> ${dest} |
749 |
echo >> ${dest} |
echo >> ${dest} |
750 |
|
|
751 |
# pgkname and state |
# pgkname and state |
765 |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
766 |
echo >> ${dest} |
echo >> ${dest} |
767 |
|
|
768 |
|
# split package base |
769 |
|
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
770 |
|
echo >> ${dest} |
771 |
|
|
772 |
# add special vars |
# add special vars |
773 |
if [ -n "${SPECIAL_VARS}" ] |
if [ -n "${SPECIAL_VARS}" ] |
774 |
then |
then |
836 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
837 |
then |
then |
838 |
# run it without targets |
# run it without targets |
839 |
if [ -z "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
840 |
then |
then |
841 |
|
# build for each target a mage file |
842 |
|
# run it with several targets |
843 |
echo |
echo |
844 |
build_mage_script |
for i in ${MAGE_TARGETS} |
845 |
|
do |
846 |
|
build_mage_script --target "${i}" |
847 |
|
done |
848 |
echo |
echo |
|
else |
|
849 |
|
|
850 |
# build for each target an mage file |
# run it for splitpackages |
851 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
852 |
|
then |
853 |
|
local split_pkg_base="${PNAME}" |
854 |
|
# save smage environment |
855 |
|
split_save_variables |
856 |
|
# build for each subpackage a mage file |
857 |
# run it with several targets |
# run it with several targets |
858 |
for i in ${MAGE_TARGETS} |
echo |
859 |
|
for i in ${SPLIT_PACKAGES} |
860 |
do |
do |
861 |
echo |
# get the right variables for the split |
862 |
build_mage_script "${i}" |
export PNAME="${i}" |
863 |
echo |
split_info_${i} |
864 |
|
build_mage_script --split-pkg-base "${split_pkg_base}" |
865 |
|
# restore smage environment |
866 |
|
split_restore_variables |
867 |
done |
done |
868 |
|
echo |
869 |
|
# unset all saved smage variables |
870 |
|
split_unset_variables |
871 |
|
|
872 |
|
else |
873 |
|
echo |
874 |
|
build_mage_script |
875 |
|
echo |
876 |
fi |
fi |
877 |
fi |
fi |
878 |
|
|
879 |
# now unset all uneeded vars to be safe |
# now unset all uneeded vars to be safe |
880 |
# unset PKGNAME <-- don't do that; smage needs this var |
# unset PKGNAME <-- don't do that; smage needs this var |
881 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
882 |
for i in ${SPECIAL_FUNCTIONS} |
# for i in ${SPECIAL_FUNCTIONS} |
883 |
do |
# do |
884 |
unset "${i}" |
# unset "${i}" |
885 |
done |
# done |
886 |
unset SPECIAL_FUNCTIONS |
unset SPECIAL_FUNCTIONS |
887 |
for i in ${SPECIAL_VARS} |
# for i in ${SPECIAL_VARS} |
888 |
do |
# do |
889 |
unset "${i}" |
# unset "${i}" |
890 |
done |
# done |
891 |
unset SPECIAL_VARS |
unset SPECIAL_VARS |
892 |
unset STATE |
unset STATE |
893 |
unset DESCRIPTION |
unset DESCRIPTION |
903 |
unset postremove |
unset postremove |
904 |
} |
} |
905 |
|
|
906 |
|
split_save_variables() |
907 |
|
{ |
908 |
|
export SAVED_PNAME="${PNAME}" |
909 |
|
export SAVED_PVER="${PVER}" |
910 |
|
export SAVED_PBUILD="${PBUILD}" |
911 |
|
export SAVED_PCATEGORIE="${PCATEGORIE}" |
912 |
|
export SAVED_DESCRIPTION="${DESCRIPTION}" |
913 |
|
export SAVED_HOMEPAGE="${HOMEPAGE}" |
914 |
|
export SAVED_SPECIAL_VARS="${SPECIAL_VARS}" |
915 |
|
export SAVED_STATE="${STATE}" |
916 |
|
export SAVED_PKGTYPE="${PKGTYPE}" |
917 |
|
export SAVED_INHERITS="${INHERITS}" |
918 |
|
export SAVED_DEPEND="${DEPEND}" |
919 |
|
export SAVED_SDEPEND="${SDEPEND}" |
920 |
|
export SAVED_PROVIDE="${PROVIDE}" |
921 |
|
export SAVED_NOPKGBUILD="${NOPKGBUILD}" |
922 |
|
|
923 |
|
# bindir too |
924 |
|
export SAVED_BINDIR="${BINDIR}" |
925 |
|
|
926 |
|
# export the SPLIT_PACKAGE_BASE |
927 |
|
export SPLIT_PACKAGE_BASE="${SAVED_PNAME}" |
928 |
|
|
929 |
|
# functions |
930 |
|
if [[ ! -z $(typeset -f preinstall) ]] |
931 |
|
then |
932 |
|
# rename the old one |
933 |
|
local saved_preinstall |
934 |
|
saved_preinstall=SAVED_$(typeset -f preinstall) |
935 |
|
eval "${saved_preinstall}" |
936 |
|
export -f SAVED_preinstall |
937 |
|
fi |
938 |
|
|
939 |
|
if [[ ! -z $(typeset -f postinstall) ]] |
940 |
|
then |
941 |
|
# rename the old one |
942 |
|
local saved_postinstall |
943 |
|
saved_postinstall=SAVED_$(typeset -f postinstall) |
944 |
|
eval "${saved_postinstall}" |
945 |
|
export -f SAVED_postinstall |
946 |
|
fi |
947 |
|
|
948 |
|
if [[ ! -z $(typeset -f preremove) ]] |
949 |
|
then |
950 |
|
# rename the old one |
951 |
|
local saved_preremove |
952 |
|
saved_preremove=SAVED_$(typeset -f preremove) |
953 |
|
eval "${saved_preremove}" |
954 |
|
export -f SAVED_preremove |
955 |
|
fi |
956 |
|
|
957 |
|
if [[ ! -z $(typeset -f postremove) ]] |
958 |
|
then |
959 |
|
# rename the old one |
960 |
|
local saved_postremove |
961 |
|
saved_postremove=SAVED_$(typeset -f postremove) |
962 |
|
eval "${saved_postremove}" |
963 |
|
export -f SAVED_postremove |
964 |
|
fi |
965 |
|
} |
966 |
|
|
967 |
|
split_restore_variables() |
968 |
|
{ |
969 |
|
export PNAME="${SAVED_PNAME}" |
970 |
|
export PVER="${SAVED_PVER}" |
971 |
|
export PBUILD="${SAVED_PBUILD}" |
972 |
|
export PCATEGORIE="${SAVED_PCATEGORIE}" |
973 |
|
export DESCRIPTION="${SAVED_DESCRIPTION}" |
974 |
|
export HOMEPAGE="${SAVED_HOMEPAGE}" |
975 |
|
export SPECIAL_VARS="${SAVED_SPECIAL_VARS}" |
976 |
|
export STATE="${SAVED_STATE}" |
977 |
|
export PKGTYPE="${SAVED_PKGTYPE}" |
978 |
|
export INHERITS="${SAVED_INHERITS}" |
979 |
|
export DEPEND="${SAVED_DEPEND}" |
980 |
|
export SDEPEND="${SAVED_SDEPEND}" |
981 |
|
export PROVIDE="${SAVED_PROVIDE}" |
982 |
|
export NOPKGBUILD="${SAVED_NOPKGBUILD}" |
983 |
|
|
984 |
|
# bindir too |
985 |
|
export BINDIR="${SAVED_BINDIR}" |
986 |
|
|
987 |
|
# functions |
988 |
|
if [[ ! -z $(typeset -f SAVED_preinstall) ]] |
989 |
|
then |
990 |
|
# rename the old one |
991 |
|
local saved_preinstall |
992 |
|
saved_preinstall=$(typeset -f SAVED_preinstall) |
993 |
|
eval "${saved_preinstall/SAVED_/}" |
994 |
|
export -f preinstall |
995 |
|
fi |
996 |
|
|
997 |
|
if [[ ! -z $(typeset -f SAVED_postinstall) ]] |
998 |
|
then |
999 |
|
# rename the old one |
1000 |
|
local saved_postinstall |
1001 |
|
saved_postinstall=$(typeset -f SAVED_postinstall) |
1002 |
|
eval "${saved_postinstall/SAVED_/}" |
1003 |
|
export -f postinstall |
1004 |
|
fi |
1005 |
|
|
1006 |
|
if [[ ! -z $(typeset -f SAVED_preremove) ]] |
1007 |
|
then |
1008 |
|
# rename the old one |
1009 |
|
local saved_preremove |
1010 |
|
saved_preremove=$(typeset -f SAVED_preremove) |
1011 |
|
eval "${saved_preremove/SAVED_/}" |
1012 |
|
export -f preremove |
1013 |
|
fi |
1014 |
|
|
1015 |
|
if [[ ! -z $(typeset -f SAVED_postremove) ]] |
1016 |
|
then |
1017 |
|
# rename the old one |
1018 |
|
local saved_postremove |
1019 |
|
saved_postremove=$(typeset -f SAVED_postremove) |
1020 |
|
eval "${saved_postremove/SAVED_/}" |
1021 |
|
export -f postremove |
1022 |
|
fi |
1023 |
|
} |
1024 |
|
|
1025 |
|
split_unset_variables() |
1026 |
|
{ |
1027 |
|
# unset saved vars; not needed anymore |
1028 |
|
unset SAVED_PNAME |
1029 |
|
unset SAVED_PVER |
1030 |
|
unset SAVED_PBUILD |
1031 |
|
unset SAVED_PCATEGORIE |
1032 |
|
unset SAVED_DESCRIPTION |
1033 |
|
unset SAVED_HOMEPAGE |
1034 |
|
unset SAVED_SPECIAL_VARS |
1035 |
|
unset SAVED_STATE |
1036 |
|
unset SAVED_PKGTYPE |
1037 |
|
unset SAVED_INHERITS |
1038 |
|
unset SAVED_DEPEND |
1039 |
|
unset SAVED_SDEPEND |
1040 |
|
unset SAVED_PROVIDE |
1041 |
|
unset SAVED_BINDIR |
1042 |
|
unset SAVED_NOPKGBUILD |
1043 |
|
unset SPLIT_PACKAGE_BASE |
1044 |
|
unset -f SAVED_preinstall |
1045 |
|
unset -f SAVED_postinstall |
1046 |
|
unset -f SAVED_preremove |
1047 |
|
unset -f SAVED_postremove |
1048 |
|
} |
1049 |
|
|
1050 |
export_inherits() |
export_inherits() |
1051 |
{ |
{ |
1052 |
local include="$1" |
local include="$1" |
1108 |
# fix target as it may be empty ! |
# fix target as it may be empty ! |
1109 |
[ -n "${target}" ] && target="-${target}" |
[ -n "${target}" ] && target="-${target}" |
1110 |
|
|
1111 |
|
|
1112 |
# build pkgname |
# build pkgname |
1113 |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
pkgname="${pname}${target}-${pver}-${parch}-${pbuild}" |
1114 |
|
|
1115 |
# build pkg-md5-sum only if requested |
# build pkg-md5-sum only if requested |
1116 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
1117 |
then |
then |
1118 |
echo -n "Generating a md5sum for ${pkgname}.${PKGSUFFIX} ... " |
echo -ne "${COLBLUE}===${COLGREEN} generating md5's for ${pkgname}.${PKGSUFFIX} ... ${COLDEFAULT}" |
1119 |
|
|
1120 |
# abort if not exist |
# abort if not exist |
1121 |
if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] |
if [ ! -f ${PKGDIR}/${pkgname}.${PKGSUFFIX} ] |
1122 |
then |
then |
1123 |
echo "! exists" |
echo -e "${COLRED}! exists${COLDEFAULT}" |
1124 |
return 0 |
return 0 |
1125 |
fi |
fi |
1126 |
|
|
1128 |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
: ${MAGE_TREE_DEST=${BUILDDIR}/mage-tree} |
1129 |
|
|
1130 |
# setup md5 dir |
# setup md5 dir |
1131 |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}/md5" |
dest="${MAGE_TREE_DEST}/${pcat}/${pname}${target}/md5" |
1132 |
install -d ${dest} |
install -d ${dest} |
1133 |
|
|
1134 |
# gen md5sum |
# gen md5sum |
1135 |
( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ |
( cd ${PKGDIR}; md5sum "${pkgname}.${PKGSUFFIX}" ) \ |
1136 |
> ${dest}/${pkgname}.md5 |
> ${dest}/${pkgname}.md5 |
1137 |
echo "done" |
echo -e "${COLGREEN}done${COLDEFAULT}" |
1138 |
fi |
fi |
1139 |
} |
} |
1140 |
|
|
1152 |
return 0 |
return 0 |
1153 |
fi |
fi |
1154 |
|
|
1155 |
[ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your mage.rc correctly." |
[ -z "${SRCPKGDIR}" ] && die "\$SRCPKGDIR not found. Please setup your ${MAGERC} correctly." |
1156 |
|
|
1157 |
echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
echo -e "${COLGREEN}Creating source package tarball ... ${COLDEFAULT}" |
1158 |
|
|
1166 |
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}" |
1167 |
} |
} |
1168 |
|
|
1169 |
|
step_by_step() |
1170 |
|
{ |
1171 |
|
if [[ ${STEP_BY_STEP} = true ]] |
1172 |
|
then |
1173 |
|
echo -e "${COLRED}Step-by-step enabled! Paused after $1.${COLDEFAULT}" |
1174 |
|
echo "Press [enter] to continue" |
1175 |
|
read |
1176 |
|
fi |
1177 |
|
} |
1178 |
|
|
1179 |
|
|
1180 |
# print out our version |
# print out our version |
1181 |
showversion |
showversion |
1202 |
# creates md5sums for smages to given dir |
# creates md5sums for smages to given dir |
1203 |
if [[ $1 = calcmd5 ]] |
if [[ $1 = calcmd5 ]] |
1204 |
then |
then |
1205 |
if [ $# -ge 3 ] |
if [ $# -ge 2 ] |
1206 |
then |
then |
1207 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1208 |
MD5DIR="$3" |
MD5DIR="$3" |
1209 |
source ${SMAGENAME} || die "download source failed" |
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1210 |
|
|
1211 |
|
smagesource ${SMAGENAME} || die "download source failed" |
1212 |
|
|
1213 |
# overridable sourcedir; must be declared after source of the smage2 |
# overridable sourcedir; must be declared after source of the smage2 |
1214 |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
1260 |
echo |
echo |
1261 |
else |
else |
1262 |
echo "Usage: Calculating MD5 Sums:" |
echo "Usage: Calculating MD5 Sums:" |
1263 |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME /path/to/MD5DIR" |
echo " $(basename $0) calcmd5 /path/to/SMAGENAME [/path/to/MD5DIR]" |
1264 |
echo |
echo |
1265 |
echo |
echo |
1266 |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
echo "Export the CALC_SOURCEDIR variable to override current SOURCEDIRs." |
1282 |
# get smage |
# get smage |
1283 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1284 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1285 |
source ${SMAGENAME} || die "download source failed" |
smagesource ${SMAGENAME} || die "download source failed" |
1286 |
|
|
1287 |
download_sources |
download_sources |
1288 |
exit 0 |
exit 0 |
1294 |
# set correct SMAGENAME |
# set correct SMAGENAME |
1295 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1296 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1297 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1298 |
|
|
1299 |
regen_mage_tree |
regen_mage_tree |
1300 |
|
|
1301 |
# build md5sum for existing packages |
# build several targets |
1302 |
generate_package_md5sum \ |
if [[ -n ${MAGE_TARGETS} ]] |
1303 |
--pcat "${PCATEGORIE}" \ |
then |
1304 |
--pname "${PNAME}" \ |
for target in ${MAGE_TARGETS} |
1305 |
--pver "${PVER}" \ |
do |
1306 |
--pbuild "${PBUILD}" \ |
# build md5sum for existing packages |
1307 |
--parch "${ARCH}" \ |
generate_package_md5sum \ |
1308 |
--target "${target}" |
--pcat "${PCATEGORIE}" \ |
1309 |
|
--pname "${PNAME}" \ |
1310 |
|
--pver "${PVER}" \ |
1311 |
|
--pbuild "${PBUILD}" \ |
1312 |
|
--parch "${ARCH}" \ |
1313 |
|
--target "${target}" |
1314 |
|
done |
1315 |
|
|
1316 |
|
# build several subpackages |
1317 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1318 |
|
then |
1319 |
|
split_save_variables |
1320 |
|
for subpackage in ${SPLIT_PACKAGES} |
1321 |
|
do |
1322 |
|
# get the right variables for the split |
1323 |
|
export PNAME="${subpackage}" |
1324 |
|
split_info_${subpackage} |
1325 |
|
# build md5sum for existing packages |
1326 |
|
generate_package_md5sum \ |
1327 |
|
--pcat "${PCATEGORIE}" \ |
1328 |
|
--pname "${PNAME}" \ |
1329 |
|
--pver "${PVER}" \ |
1330 |
|
--pbuild "${PBUILD}" \ |
1331 |
|
--parch "${ARCH}" |
1332 |
|
# restore smage environment |
1333 |
|
split_restore_variables |
1334 |
|
done |
1335 |
|
# unset all saved smage variables |
1336 |
|
split_unset_variables |
1337 |
|
|
1338 |
|
else |
1339 |
|
# build md5sum for existing packages |
1340 |
|
generate_package_md5sum \ |
1341 |
|
--pcat "${PCATEGORIE}" \ |
1342 |
|
--pname "${PNAME}" \ |
1343 |
|
--pver "${PVER}" \ |
1344 |
|
--pbuild "${PBUILD}" \ |
1345 |
|
--parch "${ARCH}" |
1346 |
|
fi |
1347 |
|
|
1348 |
exit 0 |
exit 0 |
1349 |
fi |
fi |
1356 |
|
|
1357 |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1358 |
|
|
1359 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1360 |
|
|
1361 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1362 |
then |
then |
1397 |
[ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
[ ! -e ${MLIBDIR}/pkgbuild_dir.sh ] && die "Error: ${MLIBDIR}/pkgbuild_dir.sh not found. Aborting." |
1398 |
[ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && |
[ -z "$(basename ${SMAGENAME} | grep .${SMAGESUFFIX})" ] && |
1399 |
die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." |
die "File '$(basename ${SMAGENAME})' is not a sMage v${SMAGEVERSION} file. Aborting." |
1400 |
[ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your mage.rc correctly." |
[ -z "${SOURCEDIR}" ] && die "\$SOURCEDIR not found. Please setup your ${MAGERC} correctly." |
1401 |
[ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your mage.rc correctly." |
[ -z "${SMAGESCRIPTSDIR}" ] && die "\$SMAGESCRIPTSDIR not found. Please setup your ${MAGERC} correctly." |
1402 |
[ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your mage.rc correctly." |
[ -z "${SMAGE2RSYNC}" ] && die "\$SMAGE2RSYNC not found. Please setup your ${MAGERC} correctly." |
1403 |
[ -z "${BINDIR}" ] && die "no BINDIR variable found in /etc/mage.rc" |
[ -z "${BINDIR}" ] && die "no BINDIR variable found in ${MAGERC}" |
1404 |
[ -z "${CHOST}" ] && die "no CHOST variable found in /etc/mage.rc" |
[ -z "${CHOST}" ] && die "no CHOST variable found in ${MAGERC}" |
1405 |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in /etc/mage.rc" |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
1406 |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in /etc/mage.rc" |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
1407 |
|
|
1408 |
source ${SMAGENAME} || die "source failed" |
smagesource ${SMAGENAME} || die "source failed" |
1409 |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1410 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1411 |
|
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1412 |
|
|
1413 |
xtitle "Compiling ${PKGNAME}" |
xtitle "Compiling ${PKGNAME}" |
1414 |
echo "Compiling ${PKGNAME}" |
echo -e "${COLGREEN}Compiling ${PKGNAME}${COLDEFAULT}" |
1415 |
|
|
1416 |
# auto regen mage tree if requested |
# auto regen mage tree if requested |
1417 |
regen_mage_tree |
regen_mage_tree |
1420 |
then |
then |
1421 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1422 |
then |
then |
1423 |
echo -e "${COLGREEN}Deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} deleting old sourcefiles ${COLBLUE}${SOURCEDIR}/${PNAME}${COLGREEN} ...${COLDEFAULT}" |
1424 |
rm -rf ${SOURCEDIR}/${PNAME} |
rm -rf ${SOURCEDIR}/${PNAME} |
1425 |
fi |
fi |
1426 |
fi |
fi |
1483 |
mage rmstamp |
mage rmstamp |
1484 |
fi |
fi |
1485 |
|
|
1486 |
src_prepare || die "src_prepare failed" |
# setup build loggins |
1487 |
src_compile || die "src_compile failed" |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1488 |
src_install || die "src_install failed" |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1489 |
|
|
1490 |
|
src_prepare | ${SMAGE_LOG_CMD} |
1491 |
|
die_pipestatus 0 "src_prepare failed" |
1492 |
|
step_by_step $_ |
1493 |
|
|
1494 |
|
src_compile | ${SMAGE_LOG_CMD} |
1495 |
|
die_pipestatus 0 "src_compile failed" |
1496 |
|
step_by_step $_ |
1497 |
|
|
1498 |
|
# build several subpackages |
1499 |
# compressing doc, info & man files |
if [[ -n ${SPLIT_PACKAGES} ]] |
|
echo -e "Compressing man-pages ..." |
|
|
if [ -d ${BUILDDIR}/builded/usr/share/man ] |
|
1500 |
then |
then |
1501 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/man |
# save bindir & pname |
1502 |
|
split_save_variables |
1503 |
|
export SAVED_BINDIR="${BINDIR}" |
1504 |
|
for subpackage in ${SPLIT_PACKAGES} |
1505 |
|
do |
1506 |
|
if typeset -f src_install_${subpackage} > /dev/null |
1507 |
|
then |
1508 |
|
# export subpackage bindir |
1509 |
|
export BINDIR="${SAVED_BINDIR}_${subpackage}" |
1510 |
|
# export PNAME, several internal function and include |
1511 |
|
# rely on this variable |
1512 |
|
export PNAME="${subpackage}" |
1513 |
|
|
1514 |
|
echo |
1515 |
|
echo -en "${COLBLUE}*** ${COLDEFAULT}" |
1516 |
|
echo -en " Running ${COLGREEN}split src_install()${COLDEFAULT}" |
1517 |
|
echo -en " for subpkg: ${COLBLUE}${PNAME}${COLDEFAULT}" |
1518 |
|
echo -e " - basepkg: ${COLBLUE}${SPLIT_PACKAGE_BASE}${COLDEFAULT} ..." |
1519 |
|
|
1520 |
|
src_install_${subpackage} | ${SMAGE_LOG_CMD} |
1521 |
|
die_pipestatus 0 "src_install_${subpackage} failed" |
1522 |
|
step_by_step $_ |
1523 |
|
fi |
1524 |
|
done |
1525 |
|
# restore bindir & pname |
1526 |
|
split_restore_variables |
1527 |
|
# unset all saved smage variables |
1528 |
|
split_unset_variables |
1529 |
|
else |
1530 |
|
src_install | ${SMAGE_LOG_CMD} |
1531 |
|
die_pipestatus 0 "src_install failed" |
1532 |
|
step_by_step $_ |
1533 |
fi |
fi |
1534 |
|
|
1535 |
echo -e "Compressing info-pages ..." |
# compressing doc, info & man files |
1536 |
if [ -d ${BUILDDIR}/builded/usr/share/info ] |
if [[ -n ${SPLIT_PACKAGES} ]] |
1537 |
then |
then |
1538 |
${MLIBDIR}/compressdoc -g -9 ${BUILDDIR}/builded/usr/share/info |
for subpackage in ${SPLIT_PACKAGES} |
1539 |
|
do |
1540 |
|
mcompressdocs ${BINDIR}_${subpackage} |
1541 |
|
done |
1542 |
|
else |
1543 |
|
mcompressdocs ${BINDIR} |
1544 |
fi |
fi |
1545 |
|
|
1546 |
|
|
1547 |
# stripping all bins and libs |
# stripping all bins and libs |
1548 |
case ${NOSTRIP} in |
case ${NOSTRIP} in |
1549 |
true|TRUE|yes|y) |
true|TRUE|yes|y) |
1550 |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
echo -e "NOSTRIP=true detected; Package will not be stripped ..." |
1551 |
;; |
;; |
1552 |
*) |
*) |
1553 |
echo -e "Stripping binaries ..." |
if [[ -n ${SPLIT_PACKAGES} ]] |
1554 |
mstripbins ${BINDIR} |
then |
1555 |
echo -e "Stripping libraries ..." |
for subpackage in ${SPLIT_PACKAGES} |
1556 |
mstriplibs ${BINDIR} |
do |
1557 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1558 |
|
mstripbins ${BINDIR}_${subpackage} |
1559 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}" |
1560 |
|
mstriplibs ${BINDIR}_${subpackage} |
1561 |
|
done |
1562 |
|
else |
1563 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1564 |
|
mstripbins ${BINDIR} |
1565 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
1566 |
|
mstriplibs ${BINDIR} |
1567 |
|
fi |
1568 |
;; |
;; |
1569 |
esac |
esac |
1570 |
|
|
1575 |
;; |
;; |
1576 |
*) |
*) |
1577 |
# build several targets |
# build several targets |
1578 |
if [ -n "${MAGE_TARGETS}" ] |
if [[ -n ${MAGE_TARGETS} ]] |
1579 |
then |
then |
1580 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1581 |
do |
do |
1599 |
--parch "${ARCH}" \ |
--parch "${ARCH}" \ |
1600 |
--target "${target}" |
--target "${target}" |
1601 |
|
|
1602 |
echo -e "\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n" |
echo -e "${COLGREEN}\nPackage ${PNAME}-${target}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1603 |
done |
done |
1604 |
|
|
1605 |
|
# build several subpackages |
1606 |
|
elif [[ -n ${SPLIT_PACKAGES} ]] |
1607 |
|
then |
1608 |
|
split_save_variables |
1609 |
|
for subpackage in ${SPLIT_PACKAGES} |
1610 |
|
do |
1611 |
|
# get the right variables for the split |
1612 |
|
export PNAME="${subpackage}" |
1613 |
|
split_info_${PNAME} |
1614 |
|
|
1615 |
|
# jump to next one if NOPKGBUILD is set in split_info |
1616 |
|
case ${NOPKGBUILD} in |
1617 |
|
true|TRUE|yes|y) continue ;; |
1618 |
|
esac |
1619 |
|
|
1620 |
|
# check if an special subpackage_pkgbuild exists |
1621 |
|
if typeset -f ${PNAME}_pkgbuild > /dev/null |
1622 |
|
then |
1623 |
|
# run it |
1624 |
|
${PNAME}_pkgbuild |
1625 |
|
fi |
1626 |
|
# now create the target package |
1627 |
|
${MLIBDIR}/pkgbuild_dir.sh \ |
1628 |
|
"${PNAME}-${PVER}-${ARCH}-${PBUILD}" \ |
1629 |
|
"${BINDIR}_${PNAME}" || die "split_package: ${PNAME} package-build failed" |
1630 |
|
|
1631 |
|
# build pkg-md5-sum if requested |
1632 |
|
generate_package_md5sum \ |
1633 |
|
--pcat "${PCATEGORIE}" \ |
1634 |
|
--pname "${PNAME}" \ |
1635 |
|
--pver "${PVER}" \ |
1636 |
|
--pbuild "${PBUILD}" \ |
1637 |
|
--parch "${ARCH}" |
1638 |
|
|
1639 |
|
echo -e "${COLGREEN}\nPackage ${PNAME}-${PVER}-${ARCH}-${PBUILD} successfully builded.\n${COLDEFAULT}" |
1640 |
|
|
1641 |
|
# restore smage environment |
1642 |
|
split_restore_variables |
1643 |
|
done |
1644 |
|
# unset all saved smage variables |
1645 |
|
split_unset_variables |
1646 |
|
|
1647 |
else |
else |
1648 |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
${MLIBDIR}/pkgbuild_dir.sh ${PKGNAME} ${BINDIR} || die "package-build failed" |
1649 |
|
|
1655 |
--pbuild "${PBUILD}" \ |
--pbuild "${PBUILD}" \ |
1656 |
--parch "${ARCH}" |
--parch "${ARCH}" |
1657 |
|
|
1658 |
echo -e "\nPackage ${PKGNAME} successfully builded.\n" |
echo -e "${COLGREEN}\nPackage ${PKGNAME} successfully builded.\n${COLDEFAULT}" |
1659 |
fi |
fi |
1660 |
|
|
1661 |
# build src-pkg-tarball if requested |
# build src-pkg-tarball if requested |
1663 |
;; |
;; |
1664 |
esac |
esac |
1665 |
|
|
1666 |
|
if [[ ${SMAGE_BUILD_LOGGING} != false ]] |
1667 |
|
then |
1668 |
|
bzip2 -9f /var/log/smage/${PKGNAME}.log |
1669 |
|
else |
1670 |
|
[[ -f /var/log/smage/${PKGNAME}.log ]] && rm /var/log/smage/${PKGNAME}.log |
1671 |
|
fi |
1672 |
|
|
1673 |
# for sure |
# for sure |
1674 |
unset NOPKGBUILD |
unset NOPKGBUILD |
1675 |
unset NOSTRIP |
unset NOSTRIP |