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.62 2007-11-28 10:47:50 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 |
|
|
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} " |
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_compile() |
src_compile() |
333 |
{ |
{ |
334 |
echo "no src_compile defined" |
echo "no src_compile defined" |
|
sleep 2 |
|
335 |
return 0 |
return 0 |
336 |
} |
} |
337 |
|
|
338 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
339 |
|
src_check() |
340 |
|
{ |
341 |
|
echo "no src_check defined" |
342 |
|
return 0 |
343 |
|
} |
344 |
|
|
345 |
|
# 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 |
|
|
442 |
popd > /dev/null |
popd > /dev/null |
443 |
fi |
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 |
456 |
|
;; |
457 |
tbz2|mpks|mpk) |
tbz2|mpks|mpk) |
458 |
tar --no-same-owner -xvjf ${SOURCEDIR}/${PNAME}/${SRCFILE} -C ${DEST} || die ".tbz2 unpack failed." |
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} || die ".tgz unpack failed." |
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) |
rar) |
467 |
unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
unrar x ${SOURCEDIR}/${PNAME}/${SRCFILE} ${DEST} || die ".rar unpack failed." |
468 |
;; |
;; |
516 |
mlibtoolize() |
mlibtoolize() |
517 |
{ |
{ |
518 |
local opts="$@" |
local opts="$@" |
519 |
[[ -z ${opts} ]] && opts="--copy --force" |
[[ -z ${opts} ]] && opts="--verbose --install --force" |
520 |
|
|
521 |
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
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 |
{ |
{ |
534 |
local docfiles |
local docfiles |
555 |
{ |
{ |
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 |
[[ -z ${STRIP_DYN_LIB} ]] && STRIP_DYN_LIB="--strip-debug" |
560 |
|
find ${stripdir} ! -type d | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_LIB} 2> /dev/null |
561 |
} |
} |
562 |
|
|
563 |
mstripbins() |
mstripbins() |
564 |
{ |
{ |
565 |
local stripdir="$@" |
local stripdir="$@" |
566 |
|
|
567 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
568 |
find ${stripdir} | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null |
[[ -z ${STRIP_DYN_BIN} ]] && STRIP_DYN_BIN="--strip-debug" |
569 |
|
find ${stripdir} ! -type d | xargs file | grep "executable" | grep ELF | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_DYN_BIN} 2> /dev/null |
570 |
|
} |
571 |
|
|
572 |
|
mstripstatic() |
573 |
|
{ |
574 |
|
local stripdir="$@" |
575 |
|
|
576 |
|
[[ -z ${stripdir} ]] && stripdir="${BINDIR}" |
577 |
|
[[ -z ${STRIP_STATIC_LIB} ]] && STRIP_STATIC_LIB="--strip-debug" |
578 |
|
find ${stripdir} ! -type d | xargs file | grep "ar archive" | cut -f 1 -d : | xargs --no-run-if-empty strip ${STRIP_STATIC_LIB} 2> /dev/null |
579 |
} |
} |
580 |
|
|
581 |
mcompressdocs() |
mcompressdocs() |
750 |
# now build the mage file |
# now build the mage file |
751 |
> ${dest} |
> ${dest} |
752 |
|
|
|
# header |
|
|
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} |
|
|
echo >> ${dest} |
|
|
|
|
753 |
# pgkname and state |
# pgkname and state |
754 |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
echo "PKGNAME=\"${PNAME}${target}-${PVER}-\${ARCH}-${PBUILD}\"" >> ${dest} |
755 |
echo "STATE=\"${STATE}\"" >> ${dest} |
echo "STATE=\"${STATE}\"" >> ${dest} |
|
echo >> ${dest} |
|
756 |
|
|
757 |
# description and homepage |
# description and homepage |
758 |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
echo "DESCRIPTION=\"${DESCRIPTION}\"" >> ${dest} |
759 |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
echo "HOMEPAGE=\"${HOMEPAGE}\"" >> ${dest} |
|
echo >> ${dest} |
|
760 |
|
|
761 |
# special tags and vars |
# special tags and vars |
762 |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
echo "PKGTYPE=\"${PKGTYPE}\"" >> ${dest} |
763 |
|
|
764 |
# echo MAGE_TARGETS ## note -target is needed ! |
# echo MAGE_TARGETS ## note -target is needed ! |
765 |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
echo "MAGE_TARGETS=\"${target}\"" >> ${dest} |
|
echo >> ${dest} |
|
766 |
|
|
767 |
# split package base |
# split package base |
768 |
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
echo "SPLIT_PACKAGE_BASE=\"${split_pkg_base}\"" >> ${dest} |
|
echo >> ${dest} |
|
769 |
|
|
770 |
# add special vars |
# add special vars |
771 |
if [ -n "${SPECIAL_VARS}" ] |
if [ -n "${SPECIAL_VARS}" ] |
776 |
# being tricky here :) |
# being tricky here :) |
777 |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
echo "${i}=\"$(eval echo \$${i})\"" >> ${dest} |
778 |
done |
done |
|
echo >> ${dest} |
|
779 |
fi |
fi |
780 |
|
|
781 |
# add at least all includes |
# add at least all includes |
787 |
do |
do |
788 |
echo -n " ${i}" >> ${dest} |
echo -n " ${i}" >> ${dest} |
789 |
done |
done |
790 |
echo >> ${dest} |
# a CRLF is needed here! |
791 |
|
echo >> ${dest} |
792 |
fi |
fi |
|
echo >> ${dest} |
|
793 |
|
|
794 |
# deps and provides |
# deps and provides |
795 |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
echo "DEPEND=\"$(fix_mage_deps "${target}" "${DEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
796 |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
echo "SDEPEND=\"$(fix_mage_deps "${target}" "${SDEPEND}")\"" >> ${dest} |
|
echo >> ${dest} |
|
797 |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
echo "PROVIDE=\"${PROVIDE}\"" >> ${dest} |
|
echo >> ${dest} |
|
798 |
|
|
799 |
# add special functions |
# add special functions |
800 |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
if [ -n "${SPECIAL_FUNCTIONS}" ] |
804 |
do |
do |
805 |
# add to mage (quotes needed !) |
# add to mage (quotes needed !) |
806 |
typeset -f "${i}" >> ${dest} |
typeset -f "${i}" >> ${dest} |
|
echo >> ${dest} |
|
807 |
# unset to be safe (quotes needed !) |
# unset to be safe (quotes needed !) |
808 |
#unset "${i}" <-- later to get every target built |
#unset "${i}" <-- later to get every target built |
809 |
done |
done |
|
echo >> ${dest} |
|
810 |
fi |
fi |
811 |
|
|
812 |
# pre|post-install|removes |
# pre|post-install|removes |
813 |
typeset -f preinstall >> ${dest} |
typeset -f preinstall >> ${dest} |
|
echo >> ${dest} |
|
814 |
typeset -f postinstall >> ${dest} |
typeset -f postinstall >> ${dest} |
|
echo >> ${dest} |
|
815 |
typeset -f preremove >> ${dest} |
typeset -f preremove >> ${dest} |
|
echo >> ${dest} |
|
816 |
typeset -f postremove >> ${dest} |
typeset -f postremove >> ${dest} |
|
echo >> ${dest} |
|
817 |
} |
} |
818 |
|
|
819 |
regen_mage_tree() |
regen_mage_tree() |
820 |
{ |
{ |
821 |
local i |
local subpackage |
822 |
|
|
823 |
# build them only if requested |
# build them only if requested |
824 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
829 |
# build for each target a mage file |
# build for each target a mage file |
830 |
# run it with several targets |
# run it with several targets |
831 |
echo |
echo |
832 |
for i in ${MAGE_TARGETS} |
for subpackage in ${MAGE_TARGETS} |
833 |
do |
do |
834 |
build_mage_script --target "${i}" |
build_mage_script --target "${subpackage}" |
835 |
done |
done |
836 |
echo |
echo |
837 |
|
|
844 |
# build for each subpackage a mage file |
# build for each subpackage a mage file |
845 |
# run it with several targets |
# run it with several targets |
846 |
echo |
echo |
847 |
for i in ${SPLIT_PACKAGES} |
for subpackage in ${SPLIT_PACKAGES} |
848 |
do |
do |
849 |
# get the right variables for the split |
# get the right variables for the split |
850 |
export PNAME="${i}" |
export PNAME="${subpackage}" |
851 |
split_info_${i} |
split_info_${subpackage} |
852 |
|
# get the preinstall etc |
853 |
|
split_export_inherits ${subpackage} |
854 |
build_mage_script --split-pkg-base "${split_pkg_base}" |
build_mage_script --split-pkg-base "${split_pkg_base}" |
855 |
|
# delete split preinstall etc |
856 |
|
split_delete_inherits ${subpackage} |
857 |
# restore smage environment |
# restore smage environment |
858 |
split_restore_variables |
split_restore_variables |
859 |
done |
done |
1039 |
unset -f SAVED_postremove |
unset -f SAVED_postremove |
1040 |
} |
} |
1041 |
|
|
1042 |
|
split_export_inherits() |
1043 |
|
{ |
1044 |
|
local subpackage="$1" |
1045 |
|
local func |
1046 |
|
local newfunc |
1047 |
|
|
1048 |
|
for func in preinstall postinstall preremove postremove |
1049 |
|
do |
1050 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1051 |
|
then |
1052 |
|
newfunc=$(typeset -f ${func}_${subpackage}) |
1053 |
|
newfunc="${newfunc/_${subpackage} (/ (}" |
1054 |
|
eval "${newfunc}" |
1055 |
|
fi |
1056 |
|
done |
1057 |
|
} |
1058 |
|
|
1059 |
|
split_delete_inherits() |
1060 |
|
{ |
1061 |
|
local subpackage="$1" |
1062 |
|
local func |
1063 |
|
|
1064 |
|
for func in preinstall postinstall preremove postremove |
1065 |
|
do |
1066 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1067 |
|
then |
1068 |
|
unset -f ${func} |
1069 |
|
fi |
1070 |
|
done |
1071 |
|
} |
1072 |
|
|
1073 |
export_inherits() |
export_inherits() |
1074 |
{ |
{ |
1075 |
local include="$1" |
local include="$1" |
1231 |
MD5DIR="$3" |
MD5DIR="$3" |
1232 |
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
[[ -z ${MD5DIR} ]] && MD5DIR="$(dirname ${SMAGENAME})/md5" |
1233 |
|
|
1234 |
source ${SMAGENAME} || die "download source failed" |
smagesource ${SMAGENAME} || die "download source failed" |
1235 |
|
|
1236 |
# overridable sourcedir; must be declared after source of the smage2 |
# overridable sourcedir; must be declared after source of the smage2 |
1237 |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
CALC_SOURCEDIR="${CALC_SOURCEDIR:="${SOURCEDIR}/${PNAME}"}" |
1305 |
# get smage |
# get smage |
1306 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1307 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1308 |
source ${SMAGENAME} || die "download source failed" |
smagesource ${SMAGENAME} || die "download source failed" |
1309 |
|
|
1310 |
download_sources |
download_sources |
1311 |
exit 0 |
exit 0 |
1317 |
# set correct SMAGENAME |
# set correct SMAGENAME |
1318 |
SMAGENAME="$2" |
SMAGENAME="$2" |
1319 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1320 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1321 |
|
|
1322 |
regen_mage_tree |
regen_mage_tree |
1323 |
|
|
1379 |
|
|
1380 |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
echo -e "${COLGREEN}create-src-tarball called for ${COLBLUE}${SMAGENAME}${COLGREEN} ...${COLDEFAULT}" |
1381 |
|
|
1382 |
source ${SMAGENAME} || die "regen: smage2 not found" |
smagesource ${SMAGENAME} || die "regen: smage2 not found" |
1383 |
|
|
1384 |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
if [[ -d ${SOURCEDIR}/${PNAME} ]] |
1385 |
then |
then |
1428 |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
[ -z "${CFLAGS}" ] && die "no CFLAGS variable found in ${MAGERC}" |
1429 |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
[ -z "${CXXFLAGS}" ] && die "no CXXFLAGS variable found in ${MAGERC}" |
1430 |
|
|
1431 |
source ${SMAGENAME} || die "source failed" |
smagesource ${SMAGENAME} || die "source failed" |
1432 |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
PKGNAME="${PNAME}-${PVER}-${ARCH}-${PBUILD}" |
1433 |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
MD5DIR="$(dirname ${SMAGENAME})/md5" |
1434 |
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
SMAGE_LOG_CMD="tee -a /var/log/smage/${PKGNAME}.log" |
1454 |
# fixes some issues with these functions |
# fixes some issues with these functions |
1455 |
export -f src_prepare || die "src_prepare export failed" |
export -f src_prepare || die "src_prepare export failed" |
1456 |
export -f src_compile || die "src_compile export failed" |
export -f src_compile || die "src_compile export failed" |
1457 |
|
export -f src_check || die "src_check export failed" |
1458 |
export -f src_install || die "src_install export failed" |
export -f src_install || die "src_install export failed" |
1459 |
|
|
1460 |
# fixes some compile issues |
# fixes some compile issues |
1472 |
# setup ccache |
# setup ccache |
1473 |
[[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
[[ ${SMAGE_USE_CCACHE} = true ]] && setup_ccache_environment |
1474 |
|
|
1475 |
# small sleep to show our settings |
# clean up builddir if a previously one exist |
|
sleep 1 |
|
|
|
|
|
# cleans up build if a previously one exists |
|
1476 |
if [ -d ${BUILDDIR} ] |
if [ -d ${BUILDDIR} ] |
1477 |
then |
then |
1478 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
1479 |
fi |
fi |
1480 |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
1481 |
|
|
1482 |
# cleans up srcdir if a previously unpacked one exists |
# clean up srcdir if a previously unpacked one exist |
1483 |
if [ -d ${SRCDIR} ] |
if [ -d ${SRCDIR} ] |
1484 |
then |
then |
1485 |
rm -rf ${SRCDIR} |
rm -rf ${SRCDIR} |
1486 |
fi |
fi |
1487 |
|
|
1488 |
# 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 |
1489 |
if [ -d ${BINDIR} ] |
if [ -d ${BINDIR} ] |
1490 |
then |
then |
1491 |
rm -rf ${BINDIR} |
rm -rf ${BINDIR} |
1492 |
fi |
fi |
1493 |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
install -d ${BINDIR} || die "couldn't create \$BINDIR." |
1494 |
|
|
1495 |
# cleans up package temp dir if a previous build exists |
# clean up package temp dir if a previous build exist |
1496 |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
if [ -d ${BUILDDIR}/${PKGNAME} ] |
1497 |
then |
then |
1498 |
rm -rf ${BUILDDIR}/${PKGNAME} |
rm -rf ${BUILDDIR}/${PKGNAME} |
1499 |
fi |
fi |
1500 |
|
|
1501 |
# cleans up timestamp if one exists |
# setup build logging |
|
if [ -f /var/tmp/timestamp ] |
|
|
then |
|
|
mage rmstamp |
|
|
fi |
|
|
|
|
|
# setup build loggins |
|
1502 |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1503 |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1504 |
|
|
1510 |
die_pipestatus 0 "src_compile failed" |
die_pipestatus 0 "src_compile failed" |
1511 |
step_by_step $_ |
step_by_step $_ |
1512 |
|
|
1513 |
|
# only run checks if requested |
1514 |
|
if [[ ${MAGE_CHECK} != true ]] |
1515 |
|
then |
1516 |
|
echo "MAGE_CHECK not requested; src_check() will not be run!" | ${SMAGE_LOG_CMD} |
1517 |
|
step_by_step src_check |
1518 |
|
else |
1519 |
|
src_check | ${SMAGE_LOG_CMD} |
1520 |
|
die_pipestatus 0 "src_check failed" |
1521 |
|
step_by_step $_ |
1522 |
|
fi |
1523 |
|
|
1524 |
# build several subpackages |
# build several subpackages |
1525 |
if [[ -n ${SPLIT_PACKAGES} ]] |
if [[ -n ${SPLIT_PACKAGES} ]] |
1526 |
then |
then |
1582 |
do |
do |
1583 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1584 |
mstripbins ${BINDIR}_${subpackage} |
mstripbins ${BINDIR}_${subpackage} |
1585 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" |
1586 |
mstriplibs ${BINDIR}_${subpackage} |
mstriplibs ${BINDIR}_${subpackage} |
1587 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" |
1588 |
|
mstripstatic ${BINDIR}_${subpackage} |
1589 |
done |
done |
1590 |
else |
else |
1591 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1592 |
mstripbins ${BINDIR} |
mstripbins ${BINDIR} |
1593 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" |
1594 |
mstriplibs ${BINDIR} |
mstriplibs ${BINDIR} |
1595 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" |
1596 |
|
mstripstatic ${BINDIR} |
1597 |
fi |
fi |
1598 |
;; |
;; |
1599 |
esac |
esac |
1609 |
then |
then |
1610 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1611 |
do |
do |
1612 |
# check if an special target_pkgbuild exists |
# check if a special target_pkgbuild exists |
1613 |
if typeset -f ${target}_pkgbuild > /dev/null |
if typeset -f ${target}_pkgbuild > /dev/null |
1614 |
then |
then |
1615 |
# run it |
# run it |