--- branches/magellan-next/include/mtools.sminc 2011/07/19 15:55:06 8469 +++ trunk/include/mtools.sminc 2012/12/21 13:38:40 14484 @@ -1,4 +1,4 @@ -# $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 @@ -150,6 +150,7 @@ { local udevrule local file + local udevrulesddir="/usr/lib/udev/rules.d" [[ -z "$1" ]] && die "No udev rule given" @@ -169,16 +170,17 @@ fi # needed directory - install -d ${BINDIR}/etc/udev/rules.d || die + install -d ${BINDIR}${udevrulesddir} || die # install our udev rule - install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die + install -v -m 0644 -o root -g root ${file} ${BINDIR}${udevrulesddir}/${udevrule} || die } minstalludevhelper() { local udevhelper local file + local udevdir="/usr/lib/udev" [[ -z "$1" ]] && die "No udev helper given" @@ -198,10 +200,10 @@ fi # needed directory - install -d ${BINDIR}/lib/udev || die + install -d ${BINDIR}${udevdir} || die # install our udev-helper - install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die + install -v -m 0755 -o root -g root ${file} ${BINDIR}${udevdir}/${udevhelper} || die } minstallhalinformation() @@ -468,7 +470,7 @@ # installs logrotate configuration files -# minstallpam /path/to/logrotatefile {destfilename} +# minstalllog /path/to/logrotatefile {destfilename} minstalllog() { local logfile @@ -587,7 +589,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 +616,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 } @@ -636,7 +652,7 @@ # recursive if [[ $1 = -r ]] || [[ $1 = -R ]] then - opts="--recursive" + opts="-R" source="$2" dest="$3" fi @@ -644,7 +660,14 @@ # recursive if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] then - opts="--recursive --force" + opts="-R -f" + source="$2" + dest="$3" + fi + + if [[ $1 = -a ]] + then + opts="-a" source="$2" dest="$3" fi @@ -655,6 +678,31 @@ cp -v ${opts} ${source} ${BINDIR}/${dest} || die } +mdelete() +{ + local dest="$1" + local opts + + # recursive + if [[ $1 = -r ]] || [[ $1 = -R ]] + then + opts="-r" + dest="$2" + fi + + # recursive + if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] + then + opts="-r -f" + dest="$2" + fi + + [[ -z ${dest} ]] && die "No dest given." + [[ ! -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist." + + rm -v ${opts} ${BINDIR}/${dest} || die +} + mmove() { local source="$1" @@ -664,7 +712,7 @@ # force if [[ $1 = -f ]] then - opts="--force" + opts="-f" source="$2" dest="$3" fi @@ -710,7 +758,7 @@ # recursive if [[ $1 = -r ]] || [[ $1 = -R ]] then - local recursive="--recursive" + local recursive="-R" local owner="$2" local path="$3" fi @@ -730,7 +778,7 @@ # recursive if [[ $1 = -r ]] || [[ $1 = -R ]] then - local recursive="--recursive" + local recursive="-R" local posix="$2" local path="$3" fi @@ -762,6 +810,7 @@ { local unit local file + local systemdunitdir="/usr/lib/systemd/system" [[ -z "$1" ]] && die "No unit given" @@ -781,10 +830,10 @@ fi # needed directory - install -d ${BINDIR}/lib/systemd/system || die + install -d ${BINDIR}${prefix}${systemdunitdir} || die # install our initscript - install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/systemd/system/${unit} || die + install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}${systemdunitdir}/${unit} || die } # installs systemd tmp configs to /etc/tmpfiles.d