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 1113 by niro, Wed Apr 22 18:57:15 2009 UTC trunk/include/mtools.sminc revision 11761 by niro, Tue Mar 27 12:11:21 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 137  minstalletc() Line 146  minstalletc()
146   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
147  }  }
148    
149    minstalludevrule()
150    {
151     local udevrule
152     local file
153    
154     [[ -z "$1" ]] && die "No udev rule given"
155    
156     # if no fullpath given use file from sourcedir
157     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
158     then
159     file="${SOURCEDIR}/$(mpname)/$1"
160     else
161     file="$1"
162     fi
163    
164     if [[ -n "$2" ]]
165     then
166     udevrule="$2"
167     else
168     udevrule="$(basename ${file})"
169     fi
170    
171     # needed directory
172     install -d ${BINDIR}/etc/udev/rules.d || die
173    
174     # install our udev rule
175     install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die
176    }
177    
178    minstalludevhelper()
179    {
180     local udevhelper
181     local file
182    
183     [[ -z "$1" ]] && die "No udev helper given"
184    
185     # if no fullpath given use file from sourcedir
186     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
187     then
188     file="${SOURCEDIR}/$(mpname)/$1"
189     else
190     file="$1"
191     fi
192    
193     if [[ -n "$2" ]]
194     then
195     udevhelper="$2"
196     else
197     udevhelper="$(basename ${file})"
198     fi
199    
200     # needed directory
201     install -d ${BINDIR}/lib/udev || die
202    
203     # install our udev-helper
204     install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die
205    }
206    
207    minstallhalinformation()
208    {
209     local halrule
210     local file
211    
212     [[ -z "$1" ]] && die "No hal rule given"
213    
214     # if no fullpath given use file from sourcedir
215     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
216     then
217     file="${SOURCEDIR}/$(mpname)/$1"
218     else
219     file="$1"
220     fi
221    
222     if [[ -n "$2" ]]
223     then
224     halrule="$2"
225     else
226     halrule="$(basename ${file})"
227     fi
228    
229     # needed directory
230     install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die
231    
232     # install our udev rule
233     install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die
234    }
235    
236    minstallhalpolicy()
237    {
238     local halrule
239     local file
240    
241     [[ -z "$1" ]] && die "No hal rule given"
242    
243     # if no fullpath given use file from sourcedir
244     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
245     then
246     file="${SOURCEDIR}/$(mpname)/$1"
247     else
248     file="$1"
249     fi
250    
251     if [[ -n "$2" ]]
252     then
253     halrule="$2"
254     else
255     halrule="$(basename ${file})"
256     fi
257    
258     # needed directory
259     install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die
260    
261     # install our udev rule
262     install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die
263    }
264    
265    minstallhalpreprobe()
266    {
267     local halrule
268     local file
269    
270     [[ -z "$1" ]] && die "No hal rule given"
271    
272     # if no fullpath given use file from sourcedir
273     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
274     then
275     file="${SOURCEDIR}/$(mpname)/$1"
276     else
277     file="$1"
278     fi
279    
280     if [[ -n "$2" ]]
281     then
282     halrule="$2"
283     else
284     halrule="$(basename ${file})"
285     fi
286    
287     # needed directory
288     install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die
289    
290     # install our udev rule
291     install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die
292    }
293    
294  # install man files to appropiate dirs  # install man files to appropiate dirs
295  # minstallman /path/to/manfile.foo  # minstallman /path/to/manfile.foo
296  minstallman()  minstallman()
# Line 220  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 258  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 293  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 314  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 325  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 372  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 404  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 431  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 460  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    
630  # mark directoris undeletable  mcopy()
631    {
632     local source="$1"
633     local dest="$2"
634     local opts
635    
636     # recursive
637     if [[ $1 = -r ]] || [[ $1 = -R ]]
638     then
639     opts="-R"
640     source="$2"
641     dest="$3"
642     fi
643    
644     # recursive
645     if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]
646     then
647     opts="-R -f"
648     source="$2"
649     dest="$3"
650     fi
651    
652     if [[ $1 = -a ]]
653     then
654     opts="-a"
655     source="$2"
656     dest="$3"
657     fi
658    
659     [[ -z ${source} ]] && die "No source given."
660     [[ -z ${dest} ]] && die "No dest given."
661    
662     cp -v ${opts} ${source} ${BINDIR}/${dest} || die
663    }
664    
665    mmove()
666    {
667     local source="$1"
668     local dest="$2"
669     local opts
670    
671     # force
672     if [[ $1 = -f ]]
673     then
674     opts="-f"
675     source="$2"
676     dest="$3"
677     fi
678    
679     [[ -z ${source} ]] && die "No source given."
680     [[ -z ${dest} ]] && die "No dest given."
681    
682     mv -v ${opts} ${source} ${BINDIR}/${dest} || die
683    }
684    
685    # mark directories undeletable
686  mkeepdir()  mkeepdir()
687  {  {
688   local keepdir   local keepdir
# Line 504  mchown() Line 717  mchown()
717   # recursive   # recursive
718   if [[ $1 = -r ]] || [[ $1 = -R ]]   if [[ $1 = -r ]] || [[ $1 = -R ]]
719   then   then
720   local recursive="--recursive"   local recursive="-R"
721   local owner="$2"   local owner="$2"
722   local path="$3"   local path="$3"
723   fi   fi
# Line 524  mchmod() Line 737  mchmod()
737   # recursive   # recursive
738   if [[ $1 = -r ]] || [[ $1 = -R ]]   if [[ $1 = -r ]] || [[ $1 = -R ]]
739   then   then
740   local recursive="--recursive"   local recursive="-R"
741   local posix="$2"   local posix="$2"
742   local path="$3"   local path="$3"
743   fi   fi
# Line 539  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     local prefix
773    
774     [[ -z "$1" ]] && die "No unit given"
775    
776     # get the right prefix for newer systemd
777     [[ -x /bin/systemctl ]] && prefix=""
778     [[ -x /usr/bin/systemctl ]] && prefix="/usr"
779    
780     # if no fullpath given use file from sourcedir
781     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
782     then
783     file="${SOURCEDIR}/$(mpname)/$1"
784     else
785     file="$1"
786     fi
787    
788     if [[ -n "$2" ]]
789     then
790     unit="$2"
791     else
792     unit="$(basename ${file})"
793     fi
794    
795     # needed directory
796     install -d ${BINDIR}${prefix}/lib/systemd/system || die
797    
798     # install our initscript
799     install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}/lib/systemd/system/${unit} || die
800    }
801    
802    # installs systemd tmp configs to /etc/tmpfiles.d
803    # minstalltmp /path/to/tmpdfile {destfilename}
804    minstalltmp()
805    {
806     local tmpdfile
807     local file
808    
809     [[ -z "$1" ]] && die "No tmpd file given"
810    
811     # if no fullpath given use file from sourcedir
812     if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
813     then
814     file="${SOURCEDIR}/$(mpname)/$1"
815     else
816     file="$1"
817     fi
818    
819     if [[ -n "$2" ]]
820     then
821     tmpdfile="$2"
822     else
823     tmpdfile="$(basename ${file})"
824     fi
825    
826     # needed directory
827     install -d ${BINDIR}/etc/tmpfiles.d || die
828    
829     # install our tmpdfile
830     install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die
831    }
832    
833    mclearconfig()
834    {
835     local confdir
836     local prefix="${BINDIR}"
837     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
838    
839     # no bindir prefix if requested
840     case $1 in
841     -b|--no-bindir) prefix="";;
842     esac
843    
844     confdir="$(dirname ${MCONFIG})"
845     if [[ ! -d ${prefix}/${confdir} ]]
846     then
847     install -d ${prefix}/${confdir} || die
848     fi
849     : > ${prefix}/${MCONFIG}
850    }
851    
852    maddconfig()
853    {
854     local argv="$1"
855     local confdir
856     local prefix="${BINDIR}"
857    
858     [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
859    
860     # no bindir prefix if requested
861     case $1 in
862     -b|--no-bindir) prefix=""; argv="$2" ;;
863     esac
864    
865     [[ -z ${argv} ]] && die "No  argument given!"
866    
867     confdir="$(dirname ${MCONFIG})"
868     if [[ ! -d ${prefix}/${confdir} ]]
869     then
870     install -d ${prefix}/${confdir} || die
871     fi
872     echo "${argv}" >> ${prefix}/${MCONFIG} || die
873  }  }

Legend:
Removed from v.1113  
changed lines
  Added in v.11761