Magellan Linux

Diff of /branches/R11-unstable/include/mtools.sminc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

branches/magellan-next/include/mtools.sminc revision 9862 by niro, Fri Jan 13 19:21:26 2012 UTC trunk/include/mtools.sminc revision 19668 by niro, Wed Oct 9 13:09:29 2013 UTC
# Line 1  Line 1 
1  # $Header: /magellan-cvs/smage/include/mtools.sminc,v 1.39 2008/04/20 08:28:23 niro Exp $  # $Id$
2  # some special build tools  # some special build tools
3    
4  # automatical inherit mtools.minc  # get the pname right with split-packages
 # this will provide the service management functions  
 INHERITS="${INHERITS} mtools"  
   
 # get the pname right with splitpackages  
5  mpname()  mpname()
6  {  {
7   local pname="${PNAME}"   local pname="${PNAME}"
# Line 14  mpname() Line 10  mpname()
10   echo "${pname}"   echo "${pname}"
11  }  }
12    
 # 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  
 }  
   
13  # installs environment files  # installs environment files
14  # minstallenv /path/to/envdfile {destfilename}  # minstallenv /path/to/envdfile {destfilename}
15  minstallenv()  minstallenv()
# Line 146  minstalletc() Line 111  minstalletc()
111   install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die   install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die
112  }  }
113    
 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  
 }  
   
114  # install man files to appropiate dirs  # install man files to appropiate dirs
115  # minstallman /path/to/manfile.foo  # minstallman /path/to/manfile.foo
116  minstallman()  minstallman()
# Line 587  minstalllib() Line 407  minstalllib()
407   local dest   local dest
408   local verbose="-v"   local verbose="-v"
409    
410   # check for busybox as it doesn'tz support 'ln -v'   # check for busybox as it doesn't support 'ln -v'
411   [[ $(readlink $(which ln)) = */busybox ]] && verbose=""   [[ $(readlink $(which ln)) = */busybox ]] && verbose=""
412    
413   [[ -z $1 ]] && die "No file given"   [[ -z $1 ]] && die "No file given"
# Line 614  minstalllib() Line 434  minstalllib()
434   # install our library   # install our library
435   install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die   install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die
436    
437   # create libtool symlinks   # prefer scanelf
438   # 1. - library.so.1.0.0 -> library.so.1.0   if [[ -x $(type -P scanelf) ]]
  if [ "${file%.*}" != *.so ]  
439   then   then
440   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*})   local soname="$(scanelf -qBF '%S#p' ${file})"
441   fi   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/${soname} || die
442   # 2. - library.so.1.0.0 -> library.so.1   else
443   if [ "${file%.*.*}" != *.so ]   echo -e "${COLYELLOW}minstalllib(): Warning: scanelf not found, using fallback symlink method${COLDEFAULT}"
444   then  
445   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*})   # create libtool symlinks
446     # 1. - library.so.1.0.0 -> library.so.1.0
447     if [ "${file%.*}" != *.so ]
448     then
449     ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) || die
450     fi
451     # 2. - library.so.1.0.0 -> library.so.1
452     if [ "${file%.*.*}" != *.so ]
453     then
454     ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) || die
455     fi
456     # 3. - library.so.1.0.0.0 -> library.so.1
457     if [ "${file%.*.*.*}" != *.so ]
458     then
459     ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*.*}) || die
460     fi
461   fi   fi
462  }  }
463    
# Line 636  mcopy() Line 470  mcopy()
470   # recursive   # recursive
471   if [[ $1 = -r ]] || [[ $1 = -R ]]   if [[ $1 = -r ]] || [[ $1 = -R ]]
472   then   then
473   opts="--recursive"   opts="-R"
474   source="$2"   source="$2"
475   dest="$3"   dest="$3"
476   fi   fi
# Line 644  mcopy() Line 478  mcopy()
478   # recursive   # recursive
479   if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]   if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]
480   then   then
481   opts="--recursive --force"   opts="-R -f"
482   source="$2"   source="$2"
483   dest="$3"   dest="$3"
484   fi   fi
485    
486   if [[ $1 = -a ]]   if [[ $1 = -a ]]
487   then   then
488   opts="--archive"   opts="-a"
489   source="$2"   source="$2"
490   dest="$3"   dest="$3"
491   fi   fi
# Line 662  mcopy() Line 496  mcopy()
496   cp -v ${opts} ${source} ${BINDIR}/${dest} || die   cp -v ${opts} ${source} ${BINDIR}/${dest} || die
497  }  }
498    
499    mdelete()
500    {
501     local dest="$1"
502     local opts
503    
504     # enforce
505     if [[ $1 = -f ]]
506     then
507     opts="-f"
508     dest="$2"
509     fi
510    
511     # recursive
512     if [[ $1 = -r ]] || [[ $1 = -R ]]
513     then
514     opts="-r"
515     dest="$2"
516     fi
517    
518     # recursive
519     if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]
520     then
521     opts="-r -f"
522     dest="$2"
523     fi
524    
525     [[ -z ${dest} ]] && die "No dest given."
526     [[ ! -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist."
527    
528     rm -v ${opts} ${BINDIR}/${dest} || die
529    }
530    
531  mmove()  mmove()
532  {  {
533   local source="$1"   local source="$1"
# Line 671  mmove() Line 537  mmove()
537   # force   # force
538   if [[ $1 = -f ]]   if [[ $1 = -f ]]
539   then   then
540   opts="--force"   opts="-f"
541   source="$2"   source="$2"
542   dest="$3"   dest="$3"
543   fi   fi
# Line 717  mchown() Line 583  mchown()
583   # recursive   # recursive
584   if [[ $1 = -r ]] || [[ $1 = -R ]]   if [[ $1 = -r ]] || [[ $1 = -R ]]
585   then   then
586   local recursive="--recursive"   local recursive="-R"
587   local owner="$2"   local owner="$2"
588   local path="$3"   local path="$3"
589   fi   fi
# Line 737  mchmod() Line 603  mchmod()
603   # recursive   # recursive
604   if [[ $1 = -r ]] || [[ $1 = -R ]]   if [[ $1 = -r ]] || [[ $1 = -R ]]
605   then   then
606   local recursive="--recursive"   local recursive="-R"
607   local posix="$2"   local posix="$2"
608   local path="$3"   local path="$3"
609   fi   fi
# Line 763  mlink() Line 629  mlink()
629   ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die   ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die
630  }  }
631    
 # installs systemd units  
 # minstallunit /path/to/unit-file {destfilename}  
 minstallunit()  
 {  
  local unit  
  local file  
   
  [[ -z "$1" ]] && die "No unit 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  
  unit="$2"  
  else  
  unit="$(basename ${file})"  
  fi  
   
  # needed directory  
  install -d ${BINDIR}/lib/systemd/system || die  
   
  # install our initscript  
  install -v -m 0644 -o root -g root ${file} ${BINDIR}/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  
 }  
   
632  mclearconfig()  mclearconfig()
633  {  {
634   local confdir   local confdir
# Line 857  maddconfig() Line 661  maddconfig()
661   -b|--no-bindir) prefix=""; argv="$2" ;;   -b|--no-bindir) prefix=""; argv="$2" ;;
662   esac   esac
663    
664   [[ -z ${argv} ]] && die "No  argument given!"   #[[ -z ${argv} ]] && die "No  argument given!"
665    
666   confdir="$(dirname ${MCONFIG})"   confdir="$(dirname ${MCONFIG})"
667   if [[ ! -d ${prefix}/${confdir} ]]   if [[ ! -d ${prefix}/${confdir} ]]

Legend:
Removed from v.9862  
changed lines
  Added in v.19668