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 4579 by niro, Fri Dec 25 18:32:07 2009 UTC trunk/include/mtools.sminc revision 9880 by niro, Sat Jan 14 01:48:34 2012 UTC
# Line 5  Line 5 
5  # this will provide the service management functions  # this will provide the service management functions
6  INHERITS="${INHERITS} mtools"  INHERITS="${INHERITS} mtools"
7    
8    # get the pname right with splitpackages
9    mpname()
10    {
11     local pname="${PNAME}"
12     [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname="${SPLIT_PACKAGE_BASE}"
13    
14     echo "${pname}"
15    }
16    
17  # installs initscripts  # installs initscripts
18  # minstallrc /path/to/rc-script {destfilename}  # minstallrc /path/to/rc-script {destfilename}
19  minstallrc()  minstallrc()
# Line 17  minstallrc() Line 26  minstallrc()
26   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
27   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
28   then   then
29   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
30   else   else
31   file="$1"   file="$1"
32   fi   fi
# Line 48  minstallenv() Line 57  minstallenv()
57   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
58   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
59   then   then
60   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
61   else   else
62   file="$1"   file="$1"
63   fi   fi
# Line 79  minstallconf() Line 88  minstallconf()
88   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
89   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
90   then   then
91   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
92   else   else
93   file="$1"   file="$1"
94   fi   fi
# Line 111  minstalletc() Line 120  minstalletc()
120   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
121   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
122   then   then
123   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
124   else   else
125   file="$1"   file="$1"
126   fi   fi
# Line 147  minstalludevrule() Line 156  minstalludevrule()
156   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
157   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
158   then   then
159   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
160   else   else
161   file="$1"   file="$1"
162   fi   fi
# Line 176  minstalludevhelper() Line 185  minstalludevhelper()
185   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
186   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
187   then   then
188   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
189   else   else
190   file="$1"   file="$1"
191   fi   fi
# Line 205  minstallhalinformation() Line 214  minstallhalinformation()
214   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
215   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
216   then   then
217   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
218   else   else
219   file="$1"   file="$1"
220   fi   fi
# Line 234  minstallhalpolicy() Line 243  minstallhalpolicy()
243   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
244   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
245   then   then
246   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
247   else   else
248   file="$1"   file="$1"
249   fi   fi
# Line 263  minstallhalpreprobe() Line 272  minstallhalpreprobe()
272   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
273   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
274   then   then
275   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
276   else   else
277   file="$1"   file="$1"
278   fi   fi
# Line 365  minstallpixmap() Line 374  minstallpixmap()
374   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
375   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
376   then   then
377   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
378   else   else
379   file="$1"   file="$1"
380   fi   fi
# Line 403  minstallpam() Line 412  minstallpam()
412   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
413   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
414   then   then
415   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
416   else   else
417   file="$1"   file="$1"
418   fi   fi
# Line 438  minstallcron() Line 447  minstallcron()
447   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
448   if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]]   if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]]
449   then   then
450   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
451   else   else
452   file="$2"   file="$2"
453   fi   fi
# Line 459  minstallcron() Line 468  minstallcron()
468    
469    
470  # installs logrotate configuration files  # installs logrotate configuration files
471  # minstallpam /path/to/logrotatefile {destfilename}  # minstalllog /path/to/logrotatefile {destfilename}
472  minstalllog()  minstalllog()
473  {  {
474   local logfile   local logfile
# Line 470  minstalllog() Line 479  minstalllog()
479   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
480   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
481   then   then
482   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
483   else   else
484   file="$1"   file="$1"
485   fi   fi
# Line 517  minstallfile() Line 526  minstallfile()
526    
527   if [[ $1 = -s ]]   if [[ $1 = -s ]]
528   then   then
529   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
530   dest="$3"   dest="$3"
531   if [[ -z $3 ]]   if [[ -z $3 ]]
532   then   then
# Line 549  minstallexec() Line 558  minstallexec()
558    
559   if [[ $1 = -s ]]   if [[ $1 = -s ]]
560   then   then
561   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
562   dest="$3"   dest="$3"
563   if [[ -z $3 ]]   if [[ -z $3 ]]
564   then   then
# Line 576  minstalllib() Line 585  minstalllib()
585  {  {
586   local file   local file
587   local dest   local dest
588     local verbose="-v"
589    
590     # check for busybox as it doesn'tz support 'ln -v'
591     [[ $(readlink $(which ln)) = */busybox ]] && verbose=""
592    
593   [[ -z $1 ]] && die "No file given"   [[ -z $1 ]] && die "No file given"
594    
595   if [[ $1 = -s ]]   if [[ $1 = -s ]]
596   then   then
597   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
598   dest="$3"   dest="$3"
599   if [[ -z $3 ]]   if [[ -z $3 ]]
600   then   then
# Line 605  minstalllib() Line 618  minstalllib()
618   # 1. - library.so.1.0.0 -> library.so.1.0   # 1. - library.so.1.0.0 -> library.so.1.0
619   if [ "${file%.*}" != *.so ]   if [ "${file%.*}" != *.so ]
620   then   then
621   ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*})   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*})
622   fi   fi
623   # 2. - library.so.1.0.0 -> library.so.1   # 2. - library.so.1.0.0 -> library.so.1
624   if [ "${file%.*.*}" != *.so ]   if [ "${file%.*.*}" != *.so ]
625   then   then
626   ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*})   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*})
627   fi   fi
628  }  }
629    
# Line 636  mcopy() Line 649  mcopy()
649   dest="$3"   dest="$3"
650   fi   fi
651    
652     if [[ $1 = -a ]]
653     then
654     opts="--archive"
655     source="$2"
656     dest="$3"
657     fi
658    
659   [[ -z ${source} ]] && die "No source given."   [[ -z ${source} ]] && die "No source given."
660   [[ -z ${dest} ]] && die "No dest given."   [[ -z ${dest} ]] && die "No dest given."
661    
# Line 651  mmove() Line 671  mmove()
671   # force   # force
672   if [[ $1 = -f ]]   if [[ $1 = -f ]]
673   then   then
674   opts="--recursive"   opts="--force"
675   source="$2"   source="$2"
676   dest="$3"   dest="$3"
677   fi   fi
# Line 732  mlink() Line 752  mlink()
752  {  {
753   local symlink="$1"   local symlink="$1"
754   local pathto="$2"   local pathto="$2"
755     local verbose="-v"
756    
757     # check for busybox as it doesn'tz support 'ln -v'
758     [[ $(readlink $(which ln)) = */busybox ]] && verbose=""
759    
760   [[ -z ${symlink} ]] && die "No symlink given."   [[ -z ${symlink} ]] && die "No symlink given."
761   [[ -z ${pathto} ]] && die "No path given."   [[ -z ${pathto} ]] && die "No path given."
762    
763   ln -v -snf ${symlink} ${BINDIR}/${pathto} || die   ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die
764    }
765    
766    # installs systemd units
767    # minstallunit /path/to/unit-file {destfilename}
768    minstallunit()
769    {
770     local unit
771     local file
772    
773     [[ -z "$1" ]] && die "No unit given"
774    
775     # if no fullpath given use file from sourcedir
776     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
777     then
778     file="${SOURCEDIR}/$(mpname)/$1"
779     else
780     file="$1"
781     fi
782    
783     if [[ -n "$2" ]]
784     then
785     unit="$2"
786     else
787     unit="$(basename ${file})"
788     fi
789    
790     # needed directory
791     install -d ${BINDIR}/lib/systemd/system || die
792    
793     # install our initscript
794     install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/systemd/system/${unit} || die
795    }
796    
797    # installs systemd tmp configs to /etc/tmpfiles.d
798    # minstalltmp /path/to/tmpdfile {destfilename}
799    minstalltmp()
800    {
801     local tmpdfile
802     local file
803    
804     [[ -z "$1" ]] && die "No tmpd file given"
805    
806     # if no fullpath given use file from sourcedir
807     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
808     then
809     file="${SOURCEDIR}/$(mpname)/$1"
810     else
811     file="$1"
812     fi
813    
814     if [[ -n "$2" ]]
815     then
816     tmpdfile="$2"
817     else
818     tmpdfile="$(basename ${file})"
819     fi
820    
821     # needed directory
822     install -d ${BINDIR}/etc/tmpfiles.d || die
823    
824     # install our tmpdfile
825     install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die
826    }
827    
828    mclearconfig()
829    {
830     local confdir
831     local prefix="${BINDIR}"
832     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
833    
834     # no bindir prefix if requested
835     case $1 in
836     -b|--no-bindir) prefix="";;
837     esac
838    
839     confdir="$(dirname ${MCONFIG})"
840     if [[ ! -d ${prefix}/${confdir} ]]
841     then
842     install -d ${prefix}/${confdir} || die
843     fi
844     : > ${prefix}/${MCONFIG}
845    }
846    
847    maddconfig()
848    {
849     local argv="$1"
850     local confdir
851     local prefix="${BINDIR}"
852    
853     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
854    
855     # no bindir prefix if requested
856     case $1 in
857     -b|--no-bindir) prefix=""; argv="$2" ;;
858     esac
859    
860     [[ -z ${argv} ]] && die "No  argument given!"
861    
862     confdir="$(dirname ${MCONFIG})"
863     if [[ ! -d ${prefix}/${confdir} ]]
864     then
865     install -d ${prefix}/${confdir} || die
866     fi
867     echo "${argv}" >> ${prefix}/${MCONFIG} || die
868  }  }

Legend:
Removed from v.4579  
changed lines
  Added in v.9880