--- trunk/include/mtools.sminc 2013/10/09 13:09:29 19668 +++ trunk/include/mtools.sminc 2013/10/09 13:16:15 19670 @@ -10,6 +10,147 @@ echo "${pname}" } +# installs given directories +# minstalldir /path/to/dest/dir {/path/to/dest/dirN} +minstalldir() +{ + local argv="$@" + local dest + + [[ -z ${argv} ]] && die "No dest dir given" + for dest in ${argv} + do + [[ -d ${BINDIR}${dest} ]] && continue + install -v -d ${BINDIR}/${dest} || die + done +} + +# install files to given path (defaults to /usr/bin) +# minstallfile {-s} /path/to/file {/path/to/dest} +minstallfile() +{ + local file + local dest + + [[ -z $1 ]] && die "No etc file given" + + if [[ $1 = -s ]] + then + file="${SOURCEDIR}/$(mpname)/$2" + dest="$3" + if [[ -z $3 ]] + then + dest=/usr/bin + install -d ${BINDIR}/${dest} || die + fi + else + file="$1" + dest="$2" + if [[ -z $2 ]] + then + dest=/usr/bin + install -d ${BINDIR}/${dest} || die + fi + fi + + # install our configfile + install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die +} + +# installs executables to given path +# minstallexec {-s} /path/to/exec {/path/to/dest} +minstallexec() +{ + local file + local dest + + [[ -z $1 ]] && die "No file given" + + if [[ $1 = -s ]] + then + file="${SOURCEDIR}/$(mpname)/$2" + dest="$3" + if [[ -z $3 ]] + then + dest=/usr/bin + install -d ${BINDIR}/${dest} || die + fi + else + file="$1" + dest="$2" + if [[ -z $2 ]] + then + dest=/usr/bin + install -d ${BINDIR}/${dest} || die + fi + fi + + # install our configfile + install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die +} + +# installs executables to given path +# minstalllib {-s} /path/to/exec {/path/to/dest} +minstalllib() +{ + local file + local dest + local verbose="-v" + + # check for busybox as it doesn't support 'ln -v' + [[ $(readlink $(which ln)) = */busybox ]] && verbose="" + + [[ -z $1 ]] && die "No file given" + + if [[ $1 = -s ]] + then + file="${SOURCEDIR}/$(mpname)/$2" + dest="$3" + if [[ -z $3 ]] + then + dest=/usr/$(mlibdir) + install -d ${BINDIR}/${dest} || die + fi + else + file="$1" + dest="$2" + if [[ -z $2 ]] + then + dest=/usr/$(mlibdir) + install -d ${BINDIR}/${dest} || die + fi + fi + + # install our library + install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die + + # prefer scanelf + if [[ -x $(type -P scanelf) ]] + then + 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 +} + # installs environment files # minstallenv /path/to/envdfile {destfilename} minstallenv() @@ -318,149 +459,6 @@ install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/logrotate.d/${logfile} || die } - -# installs given directories -# minstalldir /path/to/dest/dir {/path/to/dest/dirN} -minstalldir() -{ - local argv="$@" - local dest - - [[ -z ${argv} ]] && die "No dest dir given" - for dest in ${argv} - do - [[ -d ${BINDIR}${dest} ]] && continue - install -v -d ${BINDIR}/${dest} || die - done -} - - -# install files to given path (defaults to /usr/bin) -# minstallfile {-s} /path/to/file {/path/to/dest} -minstallfile() -{ - local file - local dest - - [[ -z $1 ]] && die "No etc file given" - - if [[ $1 = -s ]] - then - file="${SOURCEDIR}/$(mpname)/$2" - dest="$3" - if [[ -z $3 ]] - then - dest=/usr/bin - install -d ${BINDIR}/${dest} || die - fi - else - file="$1" - dest="$2" - if [[ -z $2 ]] - then - dest=/usr/bin - install -d ${BINDIR}/${dest} || die - fi - fi - - # install our configfile - install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die -} - -# installs executables to given path -# minstallexec {-s} /path/to/exec {/path/to/dest} -minstallexec() -{ - local file - local dest - - [[ -z $1 ]] && die "No file given" - - if [[ $1 = -s ]] - then - file="${SOURCEDIR}/$(mpname)/$2" - dest="$3" - if [[ -z $3 ]] - then - dest=/usr/bin - install -d ${BINDIR}/${dest} || die - fi - else - file="$1" - dest="$2" - if [[ -z $2 ]] - then - dest=/usr/bin - install -d ${BINDIR}/${dest} || die - fi - fi - - # install our configfile - install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die -} - -# installs executables to given path -# minstalllib {-s} /path/to/exec {/path/to/dest} -minstalllib() -{ - local file - local dest - local verbose="-v" - - # check for busybox as it doesn't support 'ln -v' - [[ $(readlink $(which ln)) = */busybox ]] && verbose="" - - [[ -z $1 ]] && die "No file given" - - if [[ $1 = -s ]] - then - file="${SOURCEDIR}/$(mpname)/$2" - dest="$3" - if [[ -z $3 ]] - then - dest=/usr/$(mlibdir) - install -d ${BINDIR}/${dest} || die - fi - else - file="$1" - dest="$2" - if [[ -z $2 ]] - then - dest=/usr/$(mlibdir) - install -d ${BINDIR}/${dest} || die - fi - fi - - # install our library - install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die - - # prefer scanelf - if [[ -x $(type -P scanelf) ]] - then - 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 -} - mcopy() { local source="$1"