Magellan Linux

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

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

trunk/core/include/mtools.sminc revision 4806 by niro, Sun Jan 3 20:27:59 2010 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}"
8   [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname ="${SPLIT_PACKAGE_BASE}"   [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname="${SPLIT_PACKAGE_BASE}"
9    
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 468  minstallcron() Line 288  minstallcron()
288    
289    
290  # installs logrotate configuration files  # installs logrotate configuration files
291  # minstallpam /path/to/logrotatefile {destfilename}  # minstalllog /path/to/logrotatefile {destfilename}
292  minstalllog()  minstalllog()
293  {  {
294   local logfile   local logfile
# 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 ]  
  then  
  ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*})  
  fi  
  # 2. - library.so.1.0.0 -> library.so.1  
  if [ "${file%.*.*}" != *.so ]  
439   then   then
440   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*})   local soname="$(scanelf -qBF '%S#p' ${file})"
441     ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/${soname} || die
442     else
443     echo -e "${COLYELLOW}minstalllib(): Warning: scanelf not found, using fallback symlink method${COLDEFAULT}"
444    
445     # 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"
483     dest="$3"
484     fi
485    
486     if [[ $1 = -a ]]
487     then
488     opts="-a"
489   source="$2"   source="$2"
490   dest="$3"   dest="$3"
491   fi   fi
# Line 655  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 664  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 710  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 730  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 755  mlink() Line 628  mlink()
628    
629   ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die   ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die
630  }  }
631    
632    mclearconfig()
633    {
634     local confdir
635     local prefix="${BINDIR}"
636     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
637    
638     # no bindir prefix if requested
639     case $1 in
640     -b|--no-bindir) prefix="";;
641     esac
642    
643     confdir="$(dirname ${MCONFIG})"
644     if [[ ! -d ${prefix}/${confdir} ]]
645     then
646     install -d ${prefix}/${confdir} || die
647     fi
648     : > ${prefix}/${MCONFIG}
649    }
650    
651    maddconfig()
652    {
653     local argv="$1"
654     local confdir
655     local prefix="${BINDIR}"
656    
657     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
658    
659     # no bindir prefix if requested
660     case $1 in
661     -b|--no-bindir) prefix=""; argv="$2" ;;
662     esac
663    
664     #[[ -z ${argv} ]] && die "No  argument given!"
665    
666     confdir="$(dirname ${MCONFIG})"
667     if [[ ! -d ${prefix}/${confdir} ]]
668     then
669     install -d ${prefix}/${confdir} || die
670     fi
671     echo "${argv}" >> ${prefix}/${MCONFIG} || die
672    }

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