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 |
|
|
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 |
|
|
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 |
} |
} |
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() |
mcompressdocs() |
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 ]] |
826 |
# build for each target a mage file |
# build for each target a mage file |
827 |
# run it with several targets |
# run it with several targets |
828 |
echo |
echo |
829 |
for i in ${MAGE_TARGETS} |
for subpackage in ${MAGE_TARGETS} |
830 |
do |
do |
831 |
build_mage_script --target "${i}" |
build_mage_script --target "${subpackage}" |
832 |
done |
done |
833 |
echo |
echo |
834 |
|
|
841 |
# build for each subpackage a mage file |
# build for each subpackage a mage file |
842 |
# run it with several targets |
# run it with several targets |
843 |
echo |
echo |
844 |
for i in ${SPLIT_PACKAGES} |
for subpackage in ${SPLIT_PACKAGES} |
845 |
do |
do |
846 |
# get the right variables for the split |
# get the right variables for the split |
847 |
export PNAME="${i}" |
export PNAME="${subpackage}" |
848 |
split_info_${i} |
split_info_${subpackage} |
849 |
|
# get the preinstall etc |
850 |
|
split_export_inherits ${subpackage} |
851 |
build_mage_script --split-pkg-base "${split_pkg_base}" |
build_mage_script --split-pkg-base "${split_pkg_base}" |
852 |
|
# delete split preinstall etc |
853 |
|
split_delete_inherits ${subpackage} |
854 |
# restore smage environment |
# restore smage environment |
855 |
split_restore_variables |
split_restore_variables |
856 |
done |
done |
1036 |
unset -f SAVED_postremove |
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" |
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 |
# setup build loggins |
# setup build logging |
1505 |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1506 |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1507 |
|
|
1513 |
die_pipestatus 0 "src_compile failed" |
die_pipestatus 0 "src_compile failed" |
1514 |
step_by_step $_ |
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 |
# build several subpackages |
# build several subpackages |
1528 |
if [[ -n ${SPLIT_PACKAGES} ]] |
if [[ -n ${SPLIT_PACKAGES} ]] |
1529 |
then |
then |
1585 |
do |
do |
1586 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1587 |
mstripbins ${BINDIR}_${subpackage} |
mstripbins ${BINDIR}_${subpackage} |
1588 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" |
1589 |
mstriplibs ${BINDIR}_${subpackage} |
mstriplibs ${BINDIR}_${subpackage} |
1590 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" |
1591 |
|
mstripstatic ${BINDIR}_${subpackage} |
1592 |
done |
done |
1593 |
else |
else |
1594 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1595 |
mstripbins ${BINDIR} |
mstripbins ${BINDIR} |
1596 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" |
1597 |
mstriplibs ${BINDIR} |
mstriplibs ${BINDIR} |
1598 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" |
1599 |
|
mstripstatic ${BINDIR} |
1600 |
fi |
fi |
1601 |
;; |
;; |
1602 |
esac |
esac |
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 |