--- trunk/include/mtools.sminc 2012/06/26 14:57:12 12652 +++ trunk/include/mtools.sminc 2013/10/09 13:09:29 19668 @@ -1,11 +1,7 @@ -# $Header: /magellan-cvs/smage/include/mtools.sminc,v 1.39 2008/04/20 08:28:23 niro Exp $ +# $Id$ # some special build tools -# automatical inherit mtools.minc -# this will provide the service management functions -INHERITS="${INHERITS} mtools" - -# get the pname right with splitpackages +# get the pname right with split-packages mpname() { local pname="${PNAME}" @@ -14,37 +10,6 @@ echo "${pname}" } -# installs initscripts -# minstallrc /path/to/rc-script {destfilename} -minstallrc() -{ - local rcscript - local file - - [[ -z "$1" ]] && die "No initscript given" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - rcscript="$2" - else - rcscript="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}/etc/rc.d/init.d || die - - # install our initscript - install -v -m 0755 -o root -g root ${file} ${BINDIR}/etc/rc.d/init.d/${rcscript} || die -} - # installs environment files # minstallenv /path/to/envdfile {destfilename} minstallenv() @@ -146,151 +111,6 @@ install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die } -minstalludevrule() -{ - local udevrule - local file - - [[ -z "$1" ]] && die "No udev rule given" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - udevrule="$2" - else - udevrule="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}/lib/udev/rules.d || die - - # install our udev rule - install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/udev/rules.d/${udevrule} || die -} - -minstalludevhelper() -{ - local udevhelper - local file - - [[ -z "$1" ]] && die "No udev helper given" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - udevhelper="$2" - else - udevhelper="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}/lib/udev || die - - # install our udev-helper - install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die -} - -minstallhalinformation() -{ - local halrule - local file - - [[ -z "$1" ]] && die "No hal rule given" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - halrule="$2" - else - halrule="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die - - # install our udev rule - install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die -} - -minstallhalpolicy() -{ - local halrule - local file - - [[ -z "$1" ]] && die "No hal rule given" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - halrule="$2" - else - halrule="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die - - # install our udev rule - install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die -} - -minstallhalpreprobe() -{ - local halrule - local file - - [[ -z "$1" ]] && die "No hal rule given" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - halrule="$2" - else - halrule="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die - - # install our udev rule - install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die -} - # install man files to appropiate dirs # minstallman /path/to/manfile.foo minstallman() @@ -587,7 +407,7 @@ local dest local verbose="-v" - # check for busybox as it doesn'tz support 'ln -v' + # check for busybox as it doesn't support 'ln -v' [[ $(readlink $(which ln)) = */busybox ]] && verbose="" [[ -z $1 ]] && die "No file given" @@ -614,16 +434,30 @@ # install our library install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die - # create libtool symlinks - # 1. - library.so.1.0.0 -> library.so.1.0 - if [ "${file%.*}" != *.so ] - then - ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) - fi - # 2. - library.so.1.0.0 -> library.so.1 - if [ "${file%.*.*}" != *.so ] + # prefer scanelf + if [[ -x $(type -P scanelf) ]] then - ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) + local soname="$(scanelf -qBF '%S#p' ${file})" + ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/${soname} || die + else + echo -e "${COLYELLOW}minstalllib(): Warning: scanelf not found, using fallback symlink method${COLDEFAULT}" + + # create libtool symlinks + # 1. - library.so.1.0.0 -> library.so.1.0 + if [ "${file%.*}" != *.so ] + then + ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) || die + fi + # 2. - library.so.1.0.0 -> library.so.1 + if [ "${file%.*.*}" != *.so ] + then + ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) || die + fi + # 3. - library.so.1.0.0.0 -> library.so.1 + if [ "${file%.*.*.*}" != *.so ] + then + ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*.*}) || die + fi fi } @@ -667,6 +501,13 @@ local dest="$1" local opts + # enforce + if [[ $1 = -f ]] + then + opts="-f" + dest="$2" + fi + # recursive if [[ $1 = -r ]] || [[ $1 = -R ]] then @@ -682,7 +523,7 @@ fi [[ -z ${dest} ]] && die "No dest given." - [[ -e ${dest} ]] && die "Dest does not exist." + [[ ! -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist." rm -v ${opts} ${BINDIR}/${dest} || die } @@ -788,73 +629,6 @@ ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die } -# installs systemd units -# minstallunit /path/to/unit-file {destfilename} -minstallunit() -{ - local unit - local file - local prefix - - [[ -z "$1" ]] && die "No unit given" - - # get the right prefix for newer systemd - [[ -x /bin/systemctl ]] && prefix="" - [[ -x /usr/bin/systemctl ]] && prefix="/usr" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - unit="$2" - else - unit="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}${prefix}/lib/systemd/system || die - - # install our initscript - install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}/lib/systemd/system/${unit} || die -} - -# installs systemd tmp configs to /etc/tmpfiles.d -# minstalltmp /path/to/tmpdfile {destfilename} -minstalltmp() -{ - local tmpdfile - local file - - [[ -z "$1" ]] && die "No tmpd file given" - - # if no fullpath given use file from sourcedir - if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] - then - file="${SOURCEDIR}/$(mpname)/$1" - else - file="$1" - fi - - if [[ -n "$2" ]] - then - tmpdfile="$2" - else - tmpdfile="$(basename ${file})" - fi - - # needed directory - install -d ${BINDIR}/etc/tmpfiles.d || die - - # install our tmpdfile - install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die -} - mclearconfig() { local confdir @@ -887,7 +661,7 @@ -b|--no-bindir) prefix=""; argv="$2" ;; esac - [[ -z ${argv} ]] && die "No argument given!" + #[[ -z ${argv} ]] && die "No argument given!" confdir="$(dirname ${MCONFIG})" if [[ ! -d ${prefix}/${confdir} ]]