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" |
329 |
return 0 |
return 0 |
330 |
} |
} |
331 |
|
|
332 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
333 |
src_compile() |
src_compile() |
334 |
{ |
{ |
335 |
echo "no src_compile defined" |
echo "no src_compile defined" |
337 |
return 0 |
return 0 |
338 |
} |
} |
339 |
|
|
340 |
# dummy function, used if that not exist in smage file |
# dummy function, used if that does not exist in smage file |
341 |
src_install() |
src_install() |
342 |
{ |
{ |
343 |
echo "no src_install defined" |
echo "no src_install defined" |
512 |
mlibtoolize() |
mlibtoolize() |
513 |
{ |
{ |
514 |
local opts="$@" |
local opts="$@" |
515 |
[[ -z ${opts} ]] && opts="--copy --force" |
[[ -z ${opts} ]] && opts="--verbose --install --force" |
516 |
|
|
517 |
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
libtoolize ${opts} || die "running: mlibtoolize ${opts}" |
518 |
} |
} |
552 |
local stripdir="$@" |
local stripdir="$@" |
553 |
|
|
554 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
555 |
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 |
556 |
} |
} |
557 |
|
|
558 |
mstripbins() |
mstripbins() |
560 |
local stripdir="$@" |
local stripdir="$@" |
561 |
|
|
562 |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
563 |
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 |
564 |
|
} |
565 |
|
|
566 |
|
mstripstatic() |
567 |
|
{ |
568 |
|
local stripdir="$@" |
569 |
|
|
570 |
|
[ -z "${stripdir}" ] && stripdir=${BINDIR} |
571 |
|
find ${stripdir} | xargs file | grep "ar archive" | cut -f 1 -d : | xargs strip ${STRIP_STATIC_LIB} 2> /dev/null |
572 |
} |
} |
573 |
|
|
574 |
mcompressdocs() |
mcompressdocs() |
811 |
|
|
812 |
regen_mage_tree() |
regen_mage_tree() |
813 |
{ |
{ |
814 |
local i |
local subpackage |
815 |
|
|
816 |
# build them only if requested |
# build them only if requested |
817 |
if [[ ${REGEN_MAGE_TREE} = true ]] |
if [[ ${REGEN_MAGE_TREE} = true ]] |
822 |
# build for each target a mage file |
# build for each target a mage file |
823 |
# run it with several targets |
# run it with several targets |
824 |
echo |
echo |
825 |
for i in ${MAGE_TARGETS} |
for subpackage in ${MAGE_TARGETS} |
826 |
do |
do |
827 |
build_mage_script --target "${i}" |
build_mage_script --target "${subpackage}" |
828 |
done |
done |
829 |
echo |
echo |
830 |
|
|
837 |
# build for each subpackage a mage file |
# build for each subpackage a mage file |
838 |
# run it with several targets |
# run it with several targets |
839 |
echo |
echo |
840 |
for i in ${SPLIT_PACKAGES} |
for subpackage in ${SPLIT_PACKAGES} |
841 |
do |
do |
842 |
# get the right variables for the split |
# get the right variables for the split |
843 |
export PNAME="${i}" |
export PNAME="${subpackage}" |
844 |
split_info_${i} |
split_info_${subpackage} |
845 |
|
# get the preinstall etc |
846 |
|
split_export_inherits ${subpackage} |
847 |
build_mage_script --split-pkg-base "${split_pkg_base}" |
build_mage_script --split-pkg-base "${split_pkg_base}" |
848 |
|
# delete split preinstall etc |
849 |
|
split_delete_inherits ${subpackage} |
850 |
# restore smage environment |
# restore smage environment |
851 |
split_restore_variables |
split_restore_variables |
852 |
done |
done |
1032 |
unset -f SAVED_postremove |
unset -f SAVED_postremove |
1033 |
} |
} |
1034 |
|
|
1035 |
|
split_export_inherits() |
1036 |
|
{ |
1037 |
|
local subpackage="$1" |
1038 |
|
local func |
1039 |
|
local newfunc |
1040 |
|
|
1041 |
|
for func in preinstall postinstall preremove postremove |
1042 |
|
do |
1043 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1044 |
|
then |
1045 |
|
newfunc=$(typeset -f ${func}_${subpackage}) |
1046 |
|
newfunc="${newfunc/_${subpackage} (/ (}" |
1047 |
|
eval "${newfunc}" |
1048 |
|
fi |
1049 |
|
done |
1050 |
|
} |
1051 |
|
|
1052 |
|
split_delete_inherits() |
1053 |
|
{ |
1054 |
|
local subpackage="$1" |
1055 |
|
local func |
1056 |
|
|
1057 |
|
for func in preinstall postinstall preremove postremove |
1058 |
|
do |
1059 |
|
if [[ ! -z $(typeset -f ${func}_${subpackage}) ]] |
1060 |
|
then |
1061 |
|
unset -f ${func} |
1062 |
|
fi |
1063 |
|
done |
1064 |
|
} |
1065 |
|
|
1066 |
export_inherits() |
export_inherits() |
1067 |
{ |
{ |
1068 |
local include="$1" |
local include="$1" |
1467 |
# small sleep to show our settings |
# small sleep to show our settings |
1468 |
sleep 1 |
sleep 1 |
1469 |
|
|
1470 |
# cleans up build if a previously one exists |
# clean up builddir if a previously one exist |
1471 |
if [ -d ${BUILDDIR} ] |
if [ -d ${BUILDDIR} ] |
1472 |
then |
then |
1473 |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
rm -rf ${BUILDDIR}/* || die "couldn't cleanup \$BUILDDIR." |
1474 |
fi |
fi |
1475 |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
install -d ${BUILDDIR} || die "couldn't create \$BUILDDIR." |
1476 |
|
|
1477 |
# cleans up srcdir if a previously unpacked one exists |
# clean up srcdir if a previously unpacked one exist |
1478 |
if [ -d ${SRCDIR} ] |
if [ -d ${SRCDIR} ] |
1479 |
then |
then |
1480 |
rm -rf ${SRCDIR} |
rm -rf ${SRCDIR} |
1481 |
fi |
fi |
1482 |
|
|
1483 |
# 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 |
1484 |
if [ -d ${BINDIR} ] |
if [ -d ${BINDIR} ] |
1485 |
then |
then |
1486 |
rm -rf ${BINDIR} |
rm -rf ${BINDIR} |
1499 |
mage rmstamp |
mage rmstamp |
1500 |
fi |
fi |
1501 |
|
|
1502 |
# setup build loggins |
# setup build logging |
1503 |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
[[ ! -d /var/log/smage ]] && install -d /var/log/smage |
1504 |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
echo -e "### Build started on $(date) ###\n" > /var/log/smage/${PKGNAME}.log |
1505 |
|
|
1572 |
do |
do |
1573 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries for '${subpackage}' ...${COLDEFAULT}" |
1574 |
mstripbins ${BINDIR}_${subpackage} |
mstripbins ${BINDIR}_${subpackage} |
1575 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries for '${subpackage}' ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries for '${subpackage}' ...${COLDEFAULT}" |
1576 |
mstriplibs ${BINDIR}_${subpackage} |
mstriplibs ${BINDIR}_${subpackage} |
1577 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries for '${subpackage}' ...${COLDEFAULT}" |
1578 |
|
mstripstatic ${BINDIR}_${subpackage} |
1579 |
done |
done |
1580 |
else |
else |
1581 |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping binaries ...${COLDEFAULT}" |
1582 |
mstripbins ${BINDIR} |
mstripbins ${BINDIR} |
1583 |
echo -e "${COLBLUE}===${COLGREEN} stripping libraries ...${COLDEFAULT}" |
echo -e "${COLBLUE}===${COLGREEN} stripping dynamic libraries ...${COLDEFAULT}" |
1584 |
mstriplibs ${BINDIR} |
mstriplibs ${BINDIR} |
1585 |
|
echo -e "${COLBLUE}===${COLGREEN} stripping static libraries ...${COLDEFAULT}" |
1586 |
|
mstripstatic ${BINDIR} |
1587 |
fi |
fi |
1588 |
;; |
;; |
1589 |
esac |
esac |
1599 |
then |
then |
1600 |
for target in ${MAGE_TARGETS} |
for target in ${MAGE_TARGETS} |
1601 |
do |
do |
1602 |
# check if an special target_pkgbuild exists |
# check if a special target_pkgbuild exists |
1603 |
if typeset -f ${target}_pkgbuild > /dev/null |
if typeset -f ${target}_pkgbuild > /dev/null |
1604 |
then |
then |
1605 |
# run it |
# run it |