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 2032 by niro, Fri Jun 12 11:01:39 2009 UTC branches/magellan-next/include/mtools.sminc revision 8642 by niro, Wed Jul 27 11:09:50 2011 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    # get the bindir right with splitpackages
18    mbindir()
19    {
20     echo "${BINDIR}"
21    }
22    
23  # installs initscripts  # installs initscripts
24  # minstallrc /path/to/rc-script {destfilename}  # minstallrc /path/to/rc-script {destfilename}
25  minstallrc()  minstallrc()
# Line 17  minstallrc() Line 32  minstallrc()
32   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
33   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
34   then   then
35   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
36   else   else
37   file="$1"   file="$1"
38   fi   fi
# Line 48  minstallenv() Line 63  minstallenv()
63   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
64   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
65   then   then
66   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
67   else   else
68   file="$1"   file="$1"
69   fi   fi
# Line 79  minstallconf() Line 94  minstallconf()
94   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
95   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
96   then   then
97   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
98   else   else
99   file="$1"   file="$1"
100   fi   fi
# Line 111  minstalletc() Line 126  minstalletc()
126   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
127   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
128   then   then
129   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
130   else   else
131   file="$1"   file="$1"
132   fi   fi
# Line 147  minstalludevrule() Line 162  minstalludevrule()
162   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
163   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
164   then   then
165   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
166   else   else
167   file="$1"   file="$1"
168   fi   fi
# Line 176  minstalludevhelper() Line 191  minstalludevhelper()
191   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
192   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
193   then   then
194   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
195   else   else
196   file="$1"   file="$1"
197   fi   fi
# Line 195  minstalludevhelper() Line 210  minstalludevhelper()
210   install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die   install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die
211  }  }
212    
213    minstallhalinformation()
214    {
215     local halrule
216     local file
217    
218     [[ -z "$1" ]] && die "No hal rule given"
219    
220     # if no fullpath given use file from sourcedir
221     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
222     then
223     file="${SOURCEDIR}/$(mpname)/$1"
224     else
225     file="$1"
226     fi
227    
228     if [[ -n "$2" ]]
229     then
230     halrule="$2"
231     else
232     halrule="$(basename ${file})"
233     fi
234    
235     # needed directory
236     install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die
237    
238     # install our udev rule
239     install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die
240    }
241    
242    minstallhalpolicy()
243    {
244     local halrule
245     local file
246    
247     [[ -z "$1" ]] && die "No hal rule given"
248    
249     # if no fullpath given use file from sourcedir
250     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
251     then
252     file="${SOURCEDIR}/$(mpname)/$1"
253     else
254     file="$1"
255     fi
256    
257     if [[ -n "$2" ]]
258     then
259     halrule="$2"
260     else
261     halrule="$(basename ${file})"
262     fi
263    
264     # needed directory
265     install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die
266    
267     # install our udev rule
268     install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die
269    }
270    
271    minstallhalpreprobe()
272    {
273     local halrule
274     local file
275    
276     [[ -z "$1" ]] && die "No hal rule given"
277    
278     # if no fullpath given use file from sourcedir
279     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
280     then
281     file="${SOURCEDIR}/$(mpname)/$1"
282     else
283     file="$1"
284     fi
285    
286     if [[ -n "$2" ]]
287     then
288     halrule="$2"
289     else
290     halrule="$(basename ${file})"
291     fi
292    
293     # needed directory
294     install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die
295    
296     # install our udev rule
297     install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die
298    }
299    
300  # install man files to appropiate dirs  # install man files to appropiate dirs
301  # minstallman /path/to/manfile.foo  # minstallman /path/to/manfile.foo
302  minstallman()  minstallman()
# Line 278  minstallpixmap() Line 380  minstallpixmap()
380   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
381   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
382   then   then
383   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
384   else   else
385   file="$1"   file="$1"
386   fi   fi
# Line 316  minstallpam() Line 418  minstallpam()
418   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
419   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
420   then   then
421   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
422   else   else
423   file="$1"   file="$1"
424   fi   fi
# Line 351  minstallcron() Line 453  minstallcron()
453   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
454   if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]]   if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]]
455   then   then
456   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
457   else   else
458   file="$2"   file="$2"
459   fi   fi
# Line 383  minstalllog() Line 485  minstalllog()
485   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
486   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
487   then   then
488   file="${SOURCEDIR}/${PNAME}/$1"   file="${SOURCEDIR}/$(mpname)/$1"
489   else   else
490   file="$1"   file="$1"
491   fi   fi
# Line 430  minstallfile() Line 532  minstallfile()
532    
533   if [[ $1 = -s ]]   if [[ $1 = -s ]]
534   then   then
535   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
536   dest="$3"   dest="$3"
537   if [[ -z $3 ]]   if [[ -z $3 ]]
538   then   then
# Line 462  minstallexec() Line 564  minstallexec()
564    
565   if [[ $1 = -s ]]   if [[ $1 = -s ]]
566   then   then
567   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
568   dest="$3"   dest="$3"
569   if [[ -z $3 ]]   if [[ -z $3 ]]
570   then   then
# Line 489  minstalllib() Line 591  minstalllib()
591  {  {
592   local file   local file
593   local dest   local dest
594     local verbose="-v"
595    
596     # check for busybox as it doesn'tz support 'ln -v'
597     [[ $(readlink $(which ln)) = */busybox ]] && verbose=""
598    
599   [[ -z $1 ]] && die "No file given"   [[ -z $1 ]] && die "No file given"
600    
601   if [[ $1 = -s ]]   if [[ $1 = -s ]]
602   then   then
603   file="${SOURCEDIR}/${PNAME}/$2"   file="${SOURCEDIR}/$(mpname)/$2"
604   dest="$3"   dest="$3"
605   if [[ -z $3 ]]   if [[ -z $3 ]]
606   then   then
# Line 518  minstalllib() Line 624  minstalllib()
624   # 1. - library.so.1.0.0 -> library.so.1.0   # 1. - library.so.1.0.0 -> library.so.1.0
625   if [ "${file%.*}" != *.so ]   if [ "${file%.*}" != *.so ]
626   then   then
627   ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*})   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*})
628   fi   fi
629   # 2. - library.so.1.0.0 -> library.so.1   # 2. - library.so.1.0.0 -> library.so.1
630   if [ "${file%.*.*}" != *.so ]   if [ "${file%.*.*}" != *.so ]
631   then   then
632   ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*})   ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*})
633     fi
634    }
635    
636    mcopy()
637    {
638     local source="$1"
639     local dest="$2"
640     local opts
641    
642     # recursive
643     if [[ $1 = -r ]] || [[ $1 = -R ]]
644     then
645     opts="--recursive"
646     source="$2"
647     dest="$3"
648     fi
649    
650     # recursive
651     if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]
652     then
653     opts="--recursive --force"
654     source="$2"
655     dest="$3"
656     fi
657    
658     [[ -z ${source} ]] && die "No source given."
659     [[ -z ${dest} ]] && die "No dest given."
660    
661     cp -v ${opts} ${source} ${BINDIR}/${dest} || die
662    }
663    
664    mmove()
665    {
666     local source="$1"
667     local dest="$2"
668     local opts
669    
670     # force
671     if [[ $1 = -f ]]
672     then
673     opts="--force"
674     source="$2"
675     dest="$3"
676   fi   fi
677    
678     [[ -z ${source} ]] && die "No source given."
679     [[ -z ${dest} ]] && die "No dest given."
680    
681     mv -v ${opts} ${source} ${BINDIR}/${dest} || die
682  }  }
683    
684  # mark directoris undeletable  # mark directories undeletable
685  mkeepdir()  mkeepdir()
686  {  {
687   local keepdir   local keepdir
# Line 597  mlink() Line 751  mlink()
751  {  {
752   local symlink="$1"   local symlink="$1"
753   local pathto="$2"   local pathto="$2"
754     local verbose="-v"
755    
756     # check for busybox as it doesn'tz support 'ln -v'
757     [[ $(readlink $(which ln)) = */busybox ]] && verbose=""
758    
759   [[ -z ${symlink} ]] && die "No symlink given."   [[ -z ${symlink} ]] && die "No symlink given."
760   [[ -z ${pathto} ]] && die "No path given."   [[ -z ${pathto} ]] && die "No path given."
761    
762   ln -v -snf ${symlink} ${BINDIR}/${pathto} || die   ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die
763    }
764    
765    # installs systemd units
766    # minstallunit /path/to/unit-file {destfilename}
767    minstallunit()
768    {
769     local unit
770     local file
771    
772     [[ -z "$1" ]] && die "No unit given"
773    
774     # if no fullpath given use file from sourcedir
775     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
776     then
777     file="${SOURCEDIR}/$(mpname)/$1"
778     else
779     file="$1"
780     fi
781    
782     if [[ -n "$2" ]]
783     then
784     unit="$2"
785     else
786     unit="$(basename ${file})"
787     fi
788    
789     # needed directory
790     install -d ${BINDIR}/lib/systemd/system || die
791    
792     # install our initscript
793     install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/systemd/system/${unit} || die
794    }
795    
796    # installs systemd tmp configs to /etc/tmpfiles.d
797    # minstalltmp /path/to/tmpdfile {destfilename}
798    minstalltmp()
799    {
800     local tmpdfile
801     local file
802    
803     [[ -z "$1" ]] && die "No tmpd file given"
804    
805     # if no fullpath given use file from sourcedir
806     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
807     then
808     file="${SOURCEDIR}/$(mpname)/$1"
809     else
810     file="$1"
811     fi
812    
813     if [[ -n "$2" ]]
814     then
815     tmpdfile="$2"
816     else
817     tmpdfile="$(basename ${file})"
818     fi
819    
820     # needed directory
821     install -d ${BINDIR}/etc/tmpfiles.d || die
822    
823     # install our tmpdfile
824     install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die
825    }
826    
827    mclearconfig()
828    {
829     local confdir
830     local prefix="${BINDIR}"
831     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
832    
833     # no bindir prefix if requested
834     case $1 in
835     -b|--no-bindir) prefix="";;
836     esac
837    
838     confdir="$(dirname ${MCONFIG})"
839     if [[ ! -d ${prefix}/${confdir} ]]
840     then
841     install -d ${prefix}/${confdir} || die
842     fi
843     : > ${prefix}/${MCONFIG}
844    }
845    
846    maddconfig()
847    {
848     local argv="$1"
849     local confdir
850     local prefix="${BINDIR}"
851    
852     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
853    
854     # no bindir prefix if requested
855     case $1 in
856     -b|--no-bindir) prefix=""; argv="$2" ;;
857     esac
858    
859     [[ -z ${argv} ]] && die "No  argument given!"
860    
861     confdir="$(dirname ${MCONFIG})"
862     if [[ ! -d ${prefix}/${confdir} ]]
863     then
864     install -d ${prefix}/${confdir} || die
865     fi
866     echo "${argv}" >> ${prefix}/${MCONFIG} || die
867  }  }

Legend:
Removed from v.2032  
changed lines
  Added in v.8642