Magellan Linux

Diff of /smage/branches/alx07x-unstable/include/mtools.sminc

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

smage/branches/alx-0_6_0/include/mtools.sminc revision 1665 by niro, Sat Jan 22 23:35:03 2011 UTC smage/trunk/include/mtools.sminc revision 5218 by niro, Mon Dec 16 10:20:15 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    
13  # installs initscripts  # installs given source to dest, but does not create any dest directories
14  # minstallrc /path/to/rc-script {destfilename}  # mcopy {[-r|-rf|-a]} /path/to/source /path/to/dest
15  minstallrc()  mcopy()
16  {  {
17   local rcscript   local source="$1"
18   local file   local dest="$2"
19     local opts
20    
21   [[ -z "$1" ]] && die "No initscript given"   # recursive
22     if [[ $1 = -r ]] || [[ $1 = -R ]]
23     then
24     opts="-R"
25     source="$2"
26     dest="$3"
27     fi
28    
29   # if no fullpath given use file from sourcedir   # recursive
30   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]
31   then   then
32   file="${SOURCEDIR}/$(mpname)/$1"   opts="-R -f"
33   else   source="$2"
34   file="$1"   dest="$3"
35   fi   fi
36    
37   if [[ -n "$2" ]]   if [[ $1 = -a ]]
38   then   then
39   rcscript="$2"   opts="-a"
40   else   source="$2"
41   rcscript="$(basename ${file})"   dest="$3"
42   fi   fi
43    
44   # needed directory   [[ -z ${source} ]] && die "No source given."
45   install -d ${BINDIR}/etc/rc.d/init.d || die   [[ -z ${dest} ]] && die "No dest given."
46    
47   # install our initscript   cp -v ${opts} ${source} ${BINDIR}/${dest} || die
  install -v -m 0755 -o root -g root ${file} ${BINDIR}/etc/rc.d/init.d/${rcscript} || die  
48  }  }
49    
50  # installs environment files  # deletes given target
51  # minstallenv /path/to/envdfile {destfilename}  # mdelete {[-f|-r|-rf]} /path/to/target
52  minstallenv()  mdelete()
53  {  {
54   local envdfile   local dest="$1"
55   local file   local opts
56    
57   [[ -z "$1" ]] && die "No envd file given"   # enforce
58     if [[ $1 = -f ]]
59     then
60     opts="-f"
61     dest="$2"
62     fi
63    
64   # if no fullpath given use file from sourcedir   # recursive
65   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ $1 = -r ]] || [[ $1 = -R ]]
66   then   then
67   file="${SOURCEDIR}/$(mpname)/$1"   opts="-r"
68   else   dest="$2"
  file="$1"  
69   fi   fi
70    
71   if [[ -n "$2" ]]   # recursive
72     if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]
73   then   then
74   envdfile="$2"   opts="-r -f"
75   else   dest="$2"
  envdfile="$(basename ${file})"  
76   fi   fi
77    
78   # needed directory   [[ -z ${dest} ]] && die "No dest given."
79   install -d ${BINDIR}/etc/env.d || die   [[ ! -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist."
80    
81   # install our envfile   rm -v ${opts} ${BINDIR}/${dest} || die
  install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/env.d/${envdfile} || die  
82  }  }
83    
84  # installs system configuration files  # moves given source to dest, but does not create any dest directories
85  # minstallconf /path/to/confdfile {destfilename}  # mmove {-f} /path/to/source /path/to/dest
86  minstallconf()  mmove()
87  {  {
88   local confdfile   local source="$1"
89   local file   local dest="$2"
90     local opts
  [[ -z "$1" ]] && die "No confd file given"  
91    
92   # if no fullpath given use file from sourcedir   # force
93   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ $1 = -f ]]
94   then   then
95   file="${SOURCEDIR}/$(mpname)/$1"   opts="-f"
96   else   source="$2"
97   file="$1"   dest="$3"
98   fi   fi
99    
100   if [[ -n "$2" ]]   [[ -z ${source} ]] && die "No source given."
101     [[ -z ${dest} ]] && die "No dest given."
102    
103     mv -v ${opts} ${source} ${BINDIR}/${dest} || die
104    }
105    
106    # changes owner of destination
107    # mchown {-r} owner /path/to/dest
108    mchown()
109    {
110     local owner="$1"
111     local path="$2"
112     local recursive
113    
114     # recursive
115     if [[ $1 = -r ]] || [[ $1 = -R ]]
116   then   then
117   confdfile="$2"   local recursive="-R"
118   else   local owner="$2"
119   confdfile="$(basename ${file})"   local path="$3"
120   fi   fi
121    
122   # needed directory   [[ -z ${owner} ]] && die "No owner given."
123   install -d ${BINDIR}/etc/conf.d || die   [[ -z ${path} ]] && die "No path given."
124    
125   # install our configfile   chown -v ${recursive} ${owner} ${BINDIR}/${path} || die
  install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/conf.d/${confdfile} || die  
126  }  }
127    
128  # installs system configuration files to etc  # changes permission of destination
129  # minstalletc /path/to/etcfile {destfilename} {destdir path}  # mchmod {-r} permision /path/to/dest
130  minstalletc()  mchmod()
131  {  {
132   local etcfile   local posix="$1"
133   local file   local path="$2"
134   local destdir   local recursive
   
  [[ -z "$1" ]] && die "No etc file given"  
135    
136   # if no fullpath given use file from sourcedir   # recursive
137   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ $1 = -r ]] || [[ $1 = -R ]]
138   then   then
139   file="${SOURCEDIR}/$(mpname)/$1"   local recursive="-R"
140   else   local posix="$2"
141   file="$1"   local path="$3"
142   fi   fi
143    
144   if [[ -n "$2" ]]   [[ -z ${posix} ]] && die "No posix given."
145   then   [[ -z ${path} ]] && die "No path given."
  etcfile="$2"  
  else  
  etcfile="$(basename ${file})"  
  fi  
146    
147   if [[ -n "$3" ]]   chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die
148    }
149    
150    # creates a symlink of source to destination
151    # mlink /path/to/source /path/to/symlink
152    mlink()
153    {
154     local symlink="$1"
155     local pathto="$2"
156     local verbose="-v"
157    
158     # check for busybox as it doesn't support 'ln -v'
159     need_busybox_support ln && verbose=""
160    
161     [[ -z ${symlink} ]] && die "No symlink given."
162     [[ -z ${pathto} ]] && die "No path given."
163    
164     ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die
165    }
166    
167    # installs given directories
168    # minstalldir /path/to/dest/dir {/path/to/dest/dirN}
169    minstalldir()
170    {
171     local argv="$@"
172     local dest
173    
174     [[ -z ${argv} ]] && die "No dest dir given"
175     for dest in ${argv}
176     do
177     [[ -d ${BINDIR}${dest} ]] && continue
178     install -v -d ${BINDIR}/${dest} || die
179     done
180    }
181    
182    # install files to given path (defaults to /usr/bin)
183    # minstallfile {-s} /path/to/file {/path/to/dest}
184    minstallfile()
185    {
186     local file
187     local dest
188    
189     [[ -z $1 ]] && die "No etc file given"
190    
191     if [[ $1 = -s ]]
192   then   then
193   destdir="$3"   file="${SOURCEDIR}/$(mpname)/$2"
194     dest="$3"
195     if [[ -z $3 ]]
196     then
197     dest=/usr/bin
198     fi
199   else   else
200   destdir="/etc"   file="$1"
201     dest="$2"
202     if [[ -z $2 ]]
203     then
204     dest=/usr/bin
205     fi
206   fi   fi
207    
208   # needed directory   # needed directory
209   install -d ${BINDIR}/${destdir} || die   minstalldir ${dest} || die
210    
211   # install our configfile   # install our configfile
212   install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die   install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die
213  }  }
214    
215  minstalludevrule()  # installs executables to given path
216    # minstallexec {-s} /path/to/exec {/path/to/dest}
217    minstallexec()
218  {  {
  local udevrule  
219   local file   local file
220     local dest
221    
222   [[ -z "$1" ]] && die "No udev rule given"   [[ -z $1 ]] && die "No file given"
223    
224   # if no fullpath given use file from sourcedir   if [[ $1 = -s ]]
  if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]  
225   then   then
226   file="${SOURCEDIR}/$(mpname)/$1"   file="${SOURCEDIR}/$(mpname)/$2"
227     dest="$3"
228     if [[ -z $3 ]]
229     then
230     dest=/usr/bin
231     fi
232   else   else
233   file="$1"   file="$1"
234   fi   dest="$2"
235     if [[ -z $2 ]]
236   if [[ -n "$2" ]]   then
237   then   dest=/usr/bin
238   udevrule="$2"   fi
  else  
  udevrule="$(basename ${file})"  
239   fi   fi
240    
241   # needed directory   # needed directory
242   install -d ${BINDIR}/etc/udev/rules.d || die   minstalldir ${dest} || die
243    
244   # install our udev rule   # install our configfile
245   install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die   install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die
246  }  }
247    
248  minstalludevhelper()  # installs executables to given path
249    # minstalllib {-s} /path/to/exec {/path/to/dest}
250    minstalllib()
251  {  {
  local udevhelper  
252   local file   local file
253     local dest
254    
255   [[ -z "$1" ]] && die "No udev helper given"   [[ -z $1 ]] && die "No file given"
256    
257   # if no fullpath given use file from sourcedir   if [[ $1 = -s ]]
  if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]  
258   then   then
259   file="${SOURCEDIR}/$(mpname)/$1"   file="${SOURCEDIR}/$(mpname)/$2"
260     dest="$3"
261     if [[ -z $3 ]]
262     then
263     dest=/usr/$(mlibdir)
264     fi
265   else   else
266   file="$1"   file="$1"
267     dest="$2"
268     if [[ -z $2 ]]
269     then
270     dest=/usr/$(mlibdir)
271     fi
272   fi   fi
273    
274   if [[ -n "$2" ]]   # needed directory
275     minstalldir ${dest} || die
276    
277     # install our library
278     minstallexec ${file} ${dest} || die
279    
280     # prefer scanelf
281     if [[ -x $(type -P scanelf) ]]
282   then   then
283   udevhelper="$2"   local soname="$(scanelf -qBF '%S#p' ${file})"
284     mlink $(basename ${file}) ${dest}/${soname} || die
285   else   else
286   udevhelper="$(basename ${file})"   echo -e "${COLYELLOW}minstalllib(): Warning: scanelf not found, using fallback symlink method${COLDEFAULT}"
  fi  
287    
288   # needed directory   # create libtool symlinks
289   install -d ${BINDIR}/lib/udev || die   # 1. - library.so.1.0.0 -> library.so.1.0
290     if [ "${file%.*}" != *.so ]
291   # install our udev-helper   then
292   install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die   mlink $(basename ${file}) ${dest}/$(basename ${file%.*}) || die
293     fi
294     # 2. - library.so.1.0.0 -> library.so.1
295     if [ "${file%.*.*}" != *.so ]
296     then
297     mlink $(basename ${file}) ${dest}/$(basename ${file%.*.*}) || die
298     fi
299     # 3. - library.so.1.0.0.0 -> library.so.1
300     if [ "${file%.*.*.*}" != *.so ]
301     then
302     mlink $(basename ${file}) ${dest}/$(basename ${file%.*.*.*}) || die
303     fi
304     fi
305  }  }
306    
307  minstallhalinformation()  # installs environment files
308    # minstallenv /path/to/envdfile {destfilename}
309    minstallenv()
310  {  {
311   local halrule   local envdfile
312   local file   local file
313    
314   [[ -z "$1" ]] && die "No hal rule given"   [[ -z "$1" ]] && die "No envd file given"
315    
316   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
317   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
# Line 221  minstallhalinformation() Line 323  minstallhalinformation()
323    
324   if [[ -n "$2" ]]   if [[ -n "$2" ]]
325   then   then
326   halrule="$2"   envdfile="$2"
327   else   else
328   halrule="$(basename ${file})"   envdfile="$(basename ${file})"
329   fi   fi
330    
331   # needed directory   # needed directory
332   install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die   minstalldir /etc/env.d || die
333    
334   # install our udev rule   # install our envfile
335   install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die   minstallfile ${file} /etc/env.d/${envdfile} || die
336  }  }
337    
338  minstallhalpolicy()  # installs system configuration files
339    # minstallconf /path/to/confdfile {destfilename}
340    minstallconf()
341  {  {
342   local halrule   local confdfile
343   local file   local file
344    
345   [[ -z "$1" ]] && die "No hal rule given"   [[ -z "$1" ]] && die "No confd file given"
346    
347   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
348   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
# Line 250  minstallhalpolicy() Line 354  minstallhalpolicy()
354    
355   if [[ -n "$2" ]]   if [[ -n "$2" ]]
356   then   then
357   halrule="$2"   confdfile="$2"
358   else   else
359   halrule="$(basename ${file})"   confdfile="$(basename ${file})"
360   fi   fi
361    
362   # needed directory   # needed directory
363   install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die   minstalldir /etc/conf.d || die
364    
365   # install our udev rule   # install our configfile
366   install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die   minstallfile ${file} /etc/conf.d/${confdfile} || die
367  }  }
368    
369  minstallhalpreprobe()  # installs system configuration files to etc
370    # minstalletc /path/to/etcfile {destfilename} {destdir path}
371    minstalletc()
372  {  {
373   local halrule   local etcfile
374   local file   local file
375     local destdir
376    
377   [[ -z "$1" ]] && die "No hal rule given"   [[ -z "$1" ]] && die "No etc file given"
378    
379   # if no fullpath given use file from sourcedir   # if no fullpath given use file from sourcedir
380   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]   if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]]
# Line 279  minstallhalpreprobe() Line 386  minstallhalpreprobe()
386    
387   if [[ -n "$2" ]]   if [[ -n "$2" ]]
388   then   then
389   halrule="$2"   etcfile="$2"
390   else   else
391   halrule="$(basename ${file})"   etcfile="$(basename ${file})"
392     fi
393    
394     if [[ -n "$3" ]]
395     then
396     destdir="$3"
397     else
398     destdir="/etc"
399   fi   fi
400    
401   # needed directory   # needed directory
402   install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die   minstalldir ${destdir} || die
403    
404   # install our udev rule   # install our configfile
405   install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die   minstallfile ${file} ${destdir}/${etcfile} || die
406  }  }
407    
408  # install man files to appropiate dirs  # install man files to appropiate dirs
# Line 306  minstallman() Line 420  minstallman()
420   manfile="$(basename ${file})"   manfile="$(basename ${file})"
421   mandir="man${manfile##*.}"   mandir="man${manfile##*.}"
422    
423   install -d ${BINDIR}/usr/share/man/${mandir} || die   minstalldir /usr/share/man/${mandir} || die
424   install -v -m0644 ${file} ${BINDIR}/usr/share/man/${mandir}/${manfile} || die   minstallfile ${file} /usr/share/man/${mandir}/${manfile} || die
425   done   done
426  }  }
427    
# Line 321  minstallinfo() Line 435  minstallinfo()
435    
436   for file in $@   for file in $@
437   do   do
438   install -d ${BINDIR}/usr/share/info || die   minstalldir /usr/share/info || die
439   install -v -m0644 ${file} ${BINDIR}/usr/share/info/$(basename ${file}) || die   minstallfile ${file} /usr/share/info/$(basename ${file}) || die
440   done   done
441  }  }
442    
# Line 344  minstallhtml() Line 458  minstallhtml()
458    
459   for file in $@   for file in $@
460   do   do
461   install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html${prefix} || die   minstalldir /usr/share/doc/${PNAME}-${PVER}/html${prefix} || die
462    
463   if [[ -d ${file} ]]   if [[ -d ${file} ]]
464   then   then
# Line 356  minstallhtml() Line 470  minstallhtml()
470   minstallhtml --prefix ${subprefix} ${subfile} || die   minstallhtml --prefix ${subprefix} ${subfile} || die
471   done   done
472   else   else
473   install -v -m0644 ${file} ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html/${prefix}$(basename ${file}) || die   minstallfile ${file} /usr/share/doc/${PNAME}-${PVER}/html/${prefix}$(basename ${file}) || die
474   fi   fi
475   done   done
476  }  }
# Line 394  minstallpixmap() Line 508  minstallpixmap()
508   fi   fi
509    
510   # needed directory   # needed directory
511   install -d ${BINDIR}/${destdir} || die   minstalldir ${destdir} || die
512    
513   # install our pixmap   # install our pixmap
514   install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die   minstallfile ${file} ${destdir}/${destfile} || die
515  }  }
516    
517  # installs pam configuration files  # installs pam configuration files
# Line 425  minstallpam() Line 539  minstallpam()
539   fi   fi
540    
541   # needed directory   # needed directory
542   install -d ${BINDIR}/etc/pam.d || die   minstalldir /etc/pam.d || die
543    
544   # install our configfile   # install our configfile
545   install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/pam.d/${pamfile} || die   minstallfile ${file} /etc/pam.d/${pamfile} || die
546  }  }
547    
548  # installs cronjobs  # installs cronjobs
# Line 460  minstallcron() Line 574  minstallcron()
574   fi   fi
575    
576   # needed directory   # needed directory
577   install -m0750 -d ${BINDIR}/etc/cron.${loop} || die   minstalldir /etc/cron.${loop} || die
578     mchmod 0750 /etc/cron.${loop} || die
579    
580   # install our cronfile   # install our cronfile
581   install -v -m 0750 -o root -g root ${file} ${BINDIR}/etc/cron.${loop}/${cronfile} || die   minstallexec ${file} /etc/cron.${loop}/${cronfile} || die
582     mchmod 0750 ${file} /etc/cron.${loop}/${cronfile} || die
583  }  }
584    
   
585  # installs logrotate configuration files  # installs logrotate configuration files
586  # minstallpam /path/to/logrotatefile {destfilename}  # minstalllog /path/to/logrotatefile {destfilename}
587  minstalllog()  minstalllog()
588  {  {
589   local logfile   local logfile
# Line 492  minstalllog() Line 607  minstalllog()
607   fi   fi
608    
609   # needed directory   # needed directory
610   install -d ${BINDIR}/etc/logrotate.d || die   minstalldir /etc/logrotate.d || die
611    
612   # install our configfile   # install our configfile
613   install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/logrotate.d/${logfile} || die   minstallfile ${file} /etc/logrotate.d/${logfile} || die
 }  
   
   
 # installs given directories  
 # minstalldir /path/to/dest/dir {/path/to/dest/dirN}  
 minstalldir()  
 {  
  local argv="$@"  
  local dest  
   
  [[ -z ${argv} ]] && die "No dest dir given"  
  for dest in ${argv}  
  do  
  [[ -d ${BINDIR}${dest} ]] && continue  
  install -v -d ${BINDIR}/${dest} || die  
  done  
 }  
   
   
 # install files to given path (defaults to /usr/bin)  
 # minstallfile {-s} /path/to/file {/path/to/dest}  
 minstallfile()  
 {  
  local file  
  local dest  
   
  [[ -z $1 ]] && die "No etc file given"  
   
  if [[ $1 = -s ]]  
  then  
  file="${SOURCEDIR}/$(mpname)/$2"  
  dest="$3"  
  if [[ -z $3 ]]  
  then  
  dest=/usr/bin  
  install -d ${BINDIR}/${dest} || die  
  fi  
  else  
  file="$1"  
  dest="$2"  
  if [[ -z $2 ]]  
  then  
  dest=/usr/bin  
  install -d ${BINDIR}/${dest} || die  
  fi  
  fi  
   
  # install our configfile  
  install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die  
 }  
   
 # installs executables to given path  
 # minstallexec {-s} /path/to/exec {/path/to/dest}  
 minstallexec()  
 {  
  local file  
  local dest  
   
  [[ -z $1 ]] && die "No file given"  
   
  if [[ $1 = -s ]]  
  then  
  file="${SOURCEDIR}/$(mpname)/$2"  
  dest="$3"  
  if [[ -z $3 ]]  
  then  
  dest=/usr/bin  
  install -d ${BINDIR}/${dest} || die  
  fi  
  else  
  file="$1"  
  dest="$2"  
  if [[ -z $2 ]]  
  then  
  dest=/usr/bin  
  install -d ${BINDIR}/${dest} || die  
  fi  
  fi  
   
  # install our configfile  
  install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die  
 }  
   
 # installs executables to given path  
 # minstalllib {-s} /path/to/exec {/path/to/dest}  
 minstalllib()  
 {  
  local file  
  local dest  
  local verbose="-v"  
   
  # check for busybox as it doesn'tz support 'ln -v'  
  [[ $(readlink $(which ln)) = */busybox ]] && verbose=""  
   
  [[ -z $1 ]] && die "No file given"  
   
  if [[ $1 = -s ]]  
  then  
  file="${SOURCEDIR}/$(mpname)/$2"  
  dest="$3"  
  if [[ -z $3 ]]  
  then  
  dest=/usr/$(mlibdir)  
  install -d ${BINDIR}/${dest} || die  
  fi  
  else  
  file="$1"  
  dest="$2"  
  if [[ -z $2 ]]  
  then  
  dest=/usr/$(mlibdir)  
  install -d ${BINDIR}/${dest} || die  
  fi  
  fi  
   
  # install our library  
  install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die  
   
  # create libtool symlinks  
  # 1. - library.so.1.0.0 -> library.so.1.0  
  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 ]  
  then  
  ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*})  
  fi  
 }  
   
 mcopy()  
 {  
  local source="$1"  
  local dest="$2"  
  local opts  
   
  # recursive  
  if [[ $1 = -r ]] || [[ $1 = -R ]]  
  then  
  opts="--recursive"  
  source="$2"  
  dest="$3"  
  fi  
   
  # recursive  
  if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]]  
  then  
  opts="--recursive --force"  
  source="$2"  
  dest="$3"  
  fi  
   
  [[ -z ${source} ]] && die "No source given."  
  [[ -z ${dest} ]] && die "No dest given."  
   
  cp -v ${opts} ${source} ${BINDIR}/${dest} || die  
 }  
   
 mmove()  
 {  
  local source="$1"  
  local dest="$2"  
  local opts  
   
  # force  
  if [[ $1 = -f ]]  
  then  
  opts="--force"  
  source="$2"  
  dest="$3"  
  fi  
   
  [[ -z ${source} ]] && die "No source given."  
  [[ -z ${dest} ]] && die "No dest given."  
   
  mv -v ${opts} ${source} ${BINDIR}/${dest} || die  
614  }  }
615    
616  # mark directories undeletable  # mark directories undeletable
# Line 682  mkeepdir() Line 620  mkeepdir()
620   [[ -z "$1" ]] && die "No directory given"   [[ -z "$1" ]] && die "No directory given"
621    
622   keepdir="$1"   keepdir="$1"
623   install -v -d ${BINDIR}/${keepdir} || die   minstalldir ${keepdir} || die
624   touch ${BINDIR}/${keepdir}/.keep || die   touch ${BINDIR}/${keepdir}/.keep || die
625  }  }
626    
# Line 697  memptyfile() Line 635  memptyfile()
635   file="$1"   file="$1"
636   path="$(dirname ${file})"   path="$(dirname ${file})"
637    
638   install -d ${BINDIR}/${path} || die   minstalldir ${path} || die
639   touch ${BINDIR}/${file} || die   touch ${BINDIR}/${file} || die
640  }  }
641    
642  mchown()  mclearconfig()
643  {  {
644   local owner="$1"   local confdir
645   local path="$2"   local prefix="${BINDIR}"
646   local recursive   [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
647    
648     # no bindir prefix if requested
649     case $1 in
650     -b|--no-bindir) prefix="";;
651     esac
652    
653   # recursive   confdir="$(dirname ${MCONFIG})"
654   if [[ $1 = -r ]] || [[ $1 = -R ]]   if [[ ! -d ${prefix}/${confdir} ]]
655   then   then
656   local recursive="--recursive"   install -d ${prefix}/${confdir} || die
  local owner="$2"  
  local path="$3"  
657   fi   fi
658     : > ${prefix}/${MCONFIG}
  [[ -z ${owner} ]] && die "No owner given."  
  [[ -z ${path} ]] && die "No path given."  
   
  chown -v ${recursive} ${owner} ${BINDIR}/${path} || die  
659  }  }
660    
661  mchmod()  maddconfig()
662  {  {
663   local posix="$1"   local argv="$1"
664   local path="$2"   local confdir
665   local recursive   local prefix="${BINDIR}"
   
  # recursive  
  if [[ $1 = -r ]] || [[ $1 = -R ]]  
  then  
  local recursive="--recursive"  
  local posix="$2"  
  local path="$3"  
  fi  
   
  [[ -z ${posix} ]] && die "No posix given."  
  [[ -z ${path} ]] && die "No path given."  
666    
667   chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die   [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!"
 }  
668    
669  mlink()   # no bindir prefix if requested
670  {   case $1 in
671   local symlink="$1"   -b|--no-bindir) prefix=""; argv="$2" ;;
672   local pathto="$2"   esac
  local verbose="-v"  
   
  # check for busybox as it doesn'tz support 'ln -v'  
  [[ $(readlink $(which ln)) = */busybox ]] && verbose=""  
673    
674   [[ -z ${symlink} ]] && die "No symlink given."   #[[ -z ${argv} ]] && die "No  argument given!"
  [[ -z ${pathto} ]] && die "No path given."  
675    
676   ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die   confdir="$(dirname ${MCONFIG})"
677     if [[ ! -d ${prefix}/${confdir} ]]
678     then
679     install -d ${prefix}/${confdir} || die
680     fi
681     echo "${argv}" >> ${prefix}/${MCONFIG} || die
682  }  }

Legend:
Removed from v.1665  
changed lines
  Added in v.5218