--- trunk/core/include/mtools.sminc 2009/04/22 18:57:15 1113 +++ trunk/core/include/mtools.sminc 2010/01/03 20:34:10 4807 @@ -5,6 +5,15 @@ # this will provide the service management functions INHERITS="${INHERITS} mtools" +# get the pname right with splitpackages +mpname() +{ + local pname="${PNAME}" + [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname="${SPLIT_PACKAGE_BASE}" + + echo "${pname}" +} + # installs initscripts # minstallrc /path/to/rc-script {destfilename} minstallrc() @@ -17,7 +26,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then - file="${SOURCEDIR}/${PNAME}/$1" + file="${SOURCEDIR}/$(mpname)/$1" else file="$1" fi @@ -48,7 +57,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then - file="${SOURCEDIR}/${PNAME}/$1" + file="${SOURCEDIR}/$(mpname)/$1" else file="$1" fi @@ -79,7 +88,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then - file="${SOURCEDIR}/${PNAME}/$1" + file="${SOURCEDIR}/$(mpname)/$1" else file="$1" fi @@ -111,7 +120,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then - file="${SOURCEDIR}/${PNAME}/$1" + file="${SOURCEDIR}/$(mpname)/$1" else file="$1" fi @@ -137,6 +146,151 @@ 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}/etc/udev/rules.d || die + + # install our udev rule + install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/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() @@ -220,7 +374,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then - file="${SOURCEDIR}/${PNAME}/$1" + file="${SOURCEDIR}/$(mpname)/$1" else file="$1" fi @@ -258,7 +412,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then - file="${SOURCEDIR}/${PNAME}/$1" + file="${SOURCEDIR}/$(mpname)/$1" else file="$1" fi @@ -293,7 +447,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] then - file="${SOURCEDIR}/${PNAME}/$2" + file="${SOURCEDIR}/$(mpname)/$2" else file="$2" fi @@ -325,7 +479,7 @@ # if no fullpath given use file from sourcedir if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] then - file="${SOURCEDIR}/${PNAME}/$1" + file="${SOURCEDIR}/$(mpname)/$1" else file="$1" fi @@ -372,7 +526,7 @@ if [[ $1 = -s ]] then - file="${SOURCEDIR}/${PNAME}/$2" + file="${SOURCEDIR}/$(mpname)/$2" dest="$3" if [[ -z $3 ]] then @@ -404,7 +558,7 @@ if [[ $1 = -s ]] then - file="${SOURCEDIR}/${PNAME}/$2" + file="${SOURCEDIR}/$(mpname)/$2" dest="$3" if [[ -z $3 ]] then @@ -431,12 +585,16 @@ { local file local dest + local verbose="-v" + + # check for busybox as it doesn'tz support 'ln -v' + [[ $(readlink $(which ln)) = */busybox ]] && verbose="" [[ -z $1 ]] && die "No file given" if [[ $1 = -s ]] then - file="${SOURCEDIR}/${PNAME}/$2" + file="${SOURCEDIR}/$(mpname)/$2" dest="$3" if [[ -z $3 ]] then @@ -460,16 +618,64 @@ # 1. - library.so.1.0.0 -> library.so.1.0 if [ "${file%.*}" != *.so ] then - ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) + ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) fi # 2. - library.so.1.0.0 -> library.so.1 if [ "${file%.*.*}" != *.so ] then - ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) + ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) + fi +} + +mcopy() +{ + local source="$1" + local dest="$2" + local opts + + # recursive + if [[ $1 = -r ]] || [[ $1 = -R ]] + then + opts="--recursive" + source="$2" + dest="$3" + fi + + # recursive + if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] + then + opts="--recursive --force" + source="$2" + dest="$3" + fi + + [[ -z ${source} ]] && die "No source given." + [[ -z ${dest} ]] && die "No dest given." + + cp -v ${opts} ${source} ${BINDIR}/${dest} || die +} + +mmove() +{ + local source="$1" + local dest="$2" + local opts + + # force + if [[ $1 = -f ]] + then + opts="--force" + source="$2" + dest="$3" fi + + [[ -z ${source} ]] && die "No source given." + [[ -z ${dest} ]] && die "No dest given." + + mv -v ${opts} ${source} ${BINDIR}/${dest} || die } -# mark directoris undeletable +# mark directories undeletable mkeepdir() { local keepdir @@ -539,9 +745,13 @@ { local symlink="$1" local pathto="$2" + local verbose="-v" + + # check for busybox as it doesn'tz support 'ln -v' + [[ $(readlink $(which ln)) = */busybox ]] && verbose="" [[ -z ${symlink} ]] && die "No symlink given." [[ -z ${pathto} ]] && die "No path given." - ln -v -snf ${symlink} ${BINDIR}/${pathto} || die + ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die }