Annotation of /branches/R11-stable/include/mtools.sminc
Parent Directory | Revision Log
Revision 6654 -
(hide annotations)
(download)
Tue Sep 14 16:46:32 2010 UTC (14 years, 2 months ago) by niro
Original Path: branches/magellan-next/include/mtools.sminc
File size: 14305 byte(s)
Tue Sep 14 16:46:32 2010 UTC (14 years, 2 months ago) by niro
Original Path: branches/magellan-next/include/mtools.sminc
File size: 14305 byte(s)
imported from trunk
1 | niro | 2 | # $Header: /magellan-cvs/smage/include/mtools.sminc,v 1.39 2008/04/20 08:28:23 niro Exp $ |
2 | # some special build tools | ||
3 | |||
4 | # automatical inherit mtools.minc | ||
5 | # this will provide the service management functions | ||
6 | INHERITS="${INHERITS} mtools" | ||
7 | |||
8 | niro | 4804 | # get the pname right with splitpackages |
9 | mpname() | ||
10 | { | ||
11 | local pname="${PNAME}" | ||
12 | niro | 4807 | [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname="${SPLIT_PACKAGE_BASE}" |
13 | niro | 4804 | |
14 | echo "${pname}" | ||
15 | } | ||
16 | |||
17 | niro | 2 | # installs initscripts |
18 | # minstallrc /path/to/rc-script {destfilename} | ||
19 | minstallrc() | ||
20 | { | ||
21 | local rcscript | ||
22 | local file | ||
23 | |||
24 | [[ -z "$1" ]] && die "No initscript given" | ||
25 | |||
26 | # if no fullpath given use file from sourcedir | ||
27 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
28 | then | ||
29 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
30 | niro | 2 | else |
31 | file="$1" | ||
32 | fi | ||
33 | |||
34 | if [[ -n "$2" ]] | ||
35 | then | ||
36 | rcscript="$2" | ||
37 | else | ||
38 | rcscript="$(basename ${file})" | ||
39 | fi | ||
40 | |||
41 | # needed directory | ||
42 | install -d ${BINDIR}/etc/rc.d/init.d || die | ||
43 | |||
44 | # install our initscript | ||
45 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/etc/rc.d/init.d/${rcscript} || die |
46 | niro | 2 | } |
47 | |||
48 | # installs environment files | ||
49 | # minstallenv /path/to/envdfile {destfilename} | ||
50 | minstallenv() | ||
51 | { | ||
52 | local envdfile | ||
53 | local file | ||
54 | |||
55 | [[ -z "$1" ]] && die "No envd file given" | ||
56 | |||
57 | # if no fullpath given use file from sourcedir | ||
58 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
59 | then | ||
60 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
61 | niro | 2 | else |
62 | file="$1" | ||
63 | fi | ||
64 | |||
65 | if [[ -n "$2" ]] | ||
66 | then | ||
67 | envdfile="$2" | ||
68 | else | ||
69 | envdfile="$(basename ${file})" | ||
70 | fi | ||
71 | |||
72 | # needed directory | ||
73 | install -d ${BINDIR}/etc/env.d || die | ||
74 | |||
75 | # install our envfile | ||
76 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/env.d/${envdfile} || die |
77 | niro | 2 | } |
78 | |||
79 | # installs system configuration files | ||
80 | # minstallconf /path/to/confdfile {destfilename} | ||
81 | minstallconf() | ||
82 | { | ||
83 | local confdfile | ||
84 | local file | ||
85 | |||
86 | [[ -z "$1" ]] && die "No confd file given" | ||
87 | |||
88 | # if no fullpath given use file from sourcedir | ||
89 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
90 | then | ||
91 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
92 | niro | 2 | else |
93 | file="$1" | ||
94 | fi | ||
95 | |||
96 | if [[ -n "$2" ]] | ||
97 | then | ||
98 | confdfile="$2" | ||
99 | else | ||
100 | confdfile="$(basename ${file})" | ||
101 | fi | ||
102 | |||
103 | # needed directory | ||
104 | install -d ${BINDIR}/etc/conf.d || die | ||
105 | |||
106 | # install our configfile | ||
107 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/conf.d/${confdfile} || die |
108 | niro | 2 | } |
109 | |||
110 | # installs system configuration files to etc | ||
111 | # minstalletc /path/to/etcfile {destfilename} {destdir path} | ||
112 | minstalletc() | ||
113 | { | ||
114 | local etcfile | ||
115 | local file | ||
116 | local destdir | ||
117 | |||
118 | [[ -z "$1" ]] && die "No etc file given" | ||
119 | |||
120 | # if no fullpath given use file from sourcedir | ||
121 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
122 | then | ||
123 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
124 | niro | 2 | else |
125 | file="$1" | ||
126 | fi | ||
127 | |||
128 | if [[ -n "$2" ]] | ||
129 | then | ||
130 | etcfile="$2" | ||
131 | else | ||
132 | etcfile="$(basename ${file})" | ||
133 | fi | ||
134 | |||
135 | if [[ -n "$3" ]] | ||
136 | then | ||
137 | destdir="$3" | ||
138 | else | ||
139 | destdir="/etc" | ||
140 | fi | ||
141 | |||
142 | # needed directory | ||
143 | install -d ${BINDIR}/${destdir} || die | ||
144 | |||
145 | # install our configfile | ||
146 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die |
147 | niro | 2 | } |
148 | |||
149 | niro | 2032 | minstalludevrule() |
150 | niro | 2031 | { |
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 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
160 | niro | 2031 | 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 | niro | 2032 | # install our udev rule |
175 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die | ||
176 | niro | 2031 | } |
177 | |||
178 | niro | 2032 | 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 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
189 | niro | 2032 | 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 | niro | 4579 | 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 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
218 | niro | 4579 | 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 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
247 | niro | 4579 | 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 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
276 | niro | 4579 | 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 | niro | 2 | # install man files to appropiate dirs |
295 | # minstallman /path/to/manfile.foo | ||
296 | minstallman() | ||
297 | { | ||
298 | local manfile | ||
299 | local mandir | ||
300 | local file | ||
301 | |||
302 | [[ -z "$@" ]] && die "No man file given" | ||
303 | |||
304 | for file in $@ | ||
305 | do | ||
306 | manfile="$(basename ${file})" | ||
307 | mandir="man${manfile##*.}" | ||
308 | |||
309 | install -d ${BINDIR}/usr/share/man/${mandir} || die | ||
310 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/man/${mandir}/${manfile} || die |
311 | niro | 2 | done |
312 | } | ||
313 | |||
314 | # install info files to appropiate dirs | ||
315 | # minstallinfo /path/to/infofile.foo | ||
316 | minstallinfo() | ||
317 | { | ||
318 | local file | ||
319 | |||
320 | [[ -z "$@" ]] && die "No info file given" | ||
321 | |||
322 | for file in $@ | ||
323 | do | ||
324 | install -d ${BINDIR}/usr/share/info || die | ||
325 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/info/$(basename ${file}) || die |
326 | niro | 2 | done |
327 | } | ||
328 | |||
329 | # install html files to appropiate dirs | ||
330 | # minstallhtml /path/to/infofile.foo | ||
331 | minstallhtml() | ||
332 | { | ||
333 | local file | ||
334 | local subfile | ||
335 | local prefix | ||
336 | local subprefix | ||
337 | |||
338 | # handle prefix | ||
339 | case "$1" in | ||
340 | --prefix|-p) shift; prefix="$1"; shift ;; | ||
341 | esac | ||
342 | |||
343 | [[ -z "$@" ]] && die "No html file given" | ||
344 | |||
345 | for file in $@ | ||
346 | do | ||
347 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html${prefix} || die | ||
348 | |||
349 | if [[ -d ${file} ]] | ||
350 | then | ||
351 | for subfile in ${file}/* | ||
352 | do | ||
353 | subprefix="$(dirname ${subfile/$(dirname ${file})/})" | ||
354 | subprefix="${prefix}${subprefix}/" | ||
355 | |||
356 | minstallhtml --prefix ${subprefix} ${subfile} || die | ||
357 | done | ||
358 | else | ||
359 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html/${prefix}$(basename ${file}) || die |
360 | niro | 2 | fi |
361 | done | ||
362 | } | ||
363 | |||
364 | # install pixmaps to appropiate dirs | ||
365 | # minstallpixmap srcname destname {/path/to} | ||
366 | minstallpixmap() | ||
367 | { | ||
368 | local file | ||
369 | local destdir | ||
370 | local destfile | ||
371 | |||
372 | [[ -z "$1" ]] && die "No pixmap given" | ||
373 | |||
374 | # if no fullpath given use file from sourcedir | ||
375 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
376 | then | ||
377 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
378 | niro | 2 | else |
379 | file="$1" | ||
380 | fi | ||
381 | |||
382 | if [[ -n "$2" ]] | ||
383 | then | ||
384 | destfile="$2" | ||
385 | else | ||
386 | destfile="$(basename ${file})" | ||
387 | fi | ||
388 | |||
389 | if [[ -n "$3" ]] | ||
390 | then | ||
391 | destdir="$3" | ||
392 | else | ||
393 | destdir="/usr/share/pixmaps" | ||
394 | fi | ||
395 | |||
396 | # needed directory | ||
397 | install -d ${BINDIR}/${destdir} || die | ||
398 | |||
399 | # install our pixmap | ||
400 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die |
401 | niro | 2 | } |
402 | |||
403 | # installs pam configuration files | ||
404 | # minstallpam /path/to/pamfile {destfilename} | ||
405 | minstallpam() | ||
406 | { | ||
407 | local pamfile | ||
408 | local file | ||
409 | |||
410 | [[ -z "$1" ]] && die "No pam file given" | ||
411 | |||
412 | # if no fullpath given use file from sourcedir | ||
413 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
414 | then | ||
415 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
416 | niro | 2 | else |
417 | file="$1" | ||
418 | fi | ||
419 | |||
420 | if [[ -n "$2" ]] | ||
421 | then | ||
422 | pamfile="$2" | ||
423 | else | ||
424 | pamfile="$(basename ${file})" | ||
425 | fi | ||
426 | |||
427 | # needed directory | ||
428 | install -d ${BINDIR}/etc/pam.d || die | ||
429 | |||
430 | # install our configfile | ||
431 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/pam.d/${pamfile} || die |
432 | niro | 2 | } |
433 | |||
434 | # installs cronjobs | ||
435 | # minstallcron [hourly|daily|weekly|monthly] /path/to/cronfile {destfilename} | ||
436 | minstallcron() | ||
437 | { | ||
438 | local cronfile | ||
439 | local loop | ||
440 | local file | ||
441 | |||
442 | [[ -z "$1" ]] && die "No loop rythem given [hourly|daily|weekly|monthly]" | ||
443 | [[ -z "$2" ]] && die "No cronfile given" | ||
444 | |||
445 | loop="$1" | ||
446 | |||
447 | # if no fullpath given use file from sourcedir | ||
448 | if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] | ||
449 | then | ||
450 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
451 | niro | 2 | else |
452 | file="$2" | ||
453 | fi | ||
454 | |||
455 | if [[ -n "$3" ]] | ||
456 | then | ||
457 | cronfile="$3" | ||
458 | else | ||
459 | cronfile="$(basename ${file})" | ||
460 | fi | ||
461 | |||
462 | # needed directory | ||
463 | install -m0750 -d ${BINDIR}/etc/cron.${loop} || die | ||
464 | |||
465 | # install our cronfile | ||
466 | niro | 1113 | install -v -m 0750 -o root -g root ${file} ${BINDIR}/etc/cron.${loop}/${cronfile} || die |
467 | niro | 2 | } |
468 | |||
469 | |||
470 | # installs logrotate configuration files | ||
471 | # minstallpam /path/to/logrotatefile {destfilename} | ||
472 | minstalllog() | ||
473 | { | ||
474 | local logfile | ||
475 | local file | ||
476 | |||
477 | [[ -z "$1" ]] && die "No logrotate file given" | ||
478 | |||
479 | # if no fullpath given use file from sourcedir | ||
480 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
481 | then | ||
482 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
483 | niro | 2 | else |
484 | file="$1" | ||
485 | fi | ||
486 | |||
487 | if [[ -n "$2" ]] | ||
488 | then | ||
489 | logfile="$2" | ||
490 | else | ||
491 | logfile="$(basename ${file})" | ||
492 | fi | ||
493 | |||
494 | # needed directory | ||
495 | install -d ${BINDIR}/etc/logrotate.d || die | ||
496 | |||
497 | # install our configfile | ||
498 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/logrotate.d/${logfile} || die |
499 | niro | 2 | } |
500 | |||
501 | |||
502 | # installs given directories | ||
503 | # minstalldir /path/to/dest/dir {/path/to/dest/dirN} | ||
504 | minstalldir() | ||
505 | { | ||
506 | local argv="$@" | ||
507 | local dest | ||
508 | |||
509 | [[ -z ${argv} ]] && die "No dest dir given" | ||
510 | for dest in ${argv} | ||
511 | do | ||
512 | [[ -d ${BINDIR}${dest} ]] && continue | ||
513 | niro | 1113 | install -v -d ${BINDIR}/${dest} || die |
514 | niro | 2 | done |
515 | } | ||
516 | |||
517 | |||
518 | # install files to given path (defaults to /usr/bin) | ||
519 | # minstallfile {-s} /path/to/file {/path/to/dest} | ||
520 | minstallfile() | ||
521 | { | ||
522 | local file | ||
523 | local dest | ||
524 | |||
525 | [[ -z $1 ]] && die "No etc file given" | ||
526 | |||
527 | if [[ $1 = -s ]] | ||
528 | then | ||
529 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
530 | niro | 2 | dest="$3" |
531 | if [[ -z $3 ]] | ||
532 | then | ||
533 | dest=/usr/bin | ||
534 | install -d ${BINDIR}/${dest} || die | ||
535 | fi | ||
536 | else | ||
537 | file="$1" | ||
538 | dest="$2" | ||
539 | if [[ -z $2 ]] | ||
540 | then | ||
541 | dest=/usr/bin | ||
542 | install -d ${BINDIR}/${dest} || die | ||
543 | fi | ||
544 | fi | ||
545 | |||
546 | # install our configfile | ||
547 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die |
548 | niro | 2 | } |
549 | |||
550 | # installs executables to given path | ||
551 | # minstallexec {-s} /path/to/exec {/path/to/dest} | ||
552 | minstallexec() | ||
553 | { | ||
554 | local file | ||
555 | local dest | ||
556 | |||
557 | [[ -z $1 ]] && die "No file given" | ||
558 | |||
559 | if [[ $1 = -s ]] | ||
560 | then | ||
561 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
562 | niro | 2 | dest="$3" |
563 | if [[ -z $3 ]] | ||
564 | then | ||
565 | dest=/usr/bin | ||
566 | install -d ${BINDIR}/${dest} || die | ||
567 | fi | ||
568 | else | ||
569 | file="$1" | ||
570 | dest="$2" | ||
571 | if [[ -z $2 ]] | ||
572 | then | ||
573 | dest=/usr/bin | ||
574 | install -d ${BINDIR}/${dest} || die | ||
575 | fi | ||
576 | fi | ||
577 | |||
578 | # install our configfile | ||
579 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
580 | niro | 2 | } |
581 | |||
582 | # installs executables to given path | ||
583 | # minstalllib {-s} /path/to/exec {/path/to/dest} | ||
584 | minstalllib() | ||
585 | { | ||
586 | local file | ||
587 | local dest | ||
588 | niro | 4806 | local verbose="-v" |
589 | niro | 2 | |
590 | niro | 4806 | # check for busybox as it doesn'tz support 'ln -v' |
591 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" | ||
592 | |||
593 | niro | 2 | [[ -z $1 ]] && die "No file given" |
594 | |||
595 | if [[ $1 = -s ]] | ||
596 | then | ||
597 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
598 | niro | 2 | dest="$3" |
599 | if [[ -z $3 ]] | ||
600 | then | ||
601 | dest=/usr/$(mlibdir) | ||
602 | install -d ${BINDIR}/${dest} || die | ||
603 | fi | ||
604 | else | ||
605 | file="$1" | ||
606 | dest="$2" | ||
607 | if [[ -z $2 ]] | ||
608 | then | ||
609 | dest=/usr/$(mlibdir) | ||
610 | install -d ${BINDIR}/${dest} || die | ||
611 | fi | ||
612 | fi | ||
613 | |||
614 | # install our library | ||
615 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
616 | niro | 2 | |
617 | # create libtool symlinks | ||
618 | # 1. - library.so.1.0.0 -> library.so.1.0 | ||
619 | if [ "${file%.*}" != *.so ] | ||
620 | then | ||
621 | niro | 4806 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) |
622 | niro | 2 | fi |
623 | # 2. - library.so.1.0.0 -> library.so.1 | ||
624 | if [ "${file%.*.*}" != *.so ] | ||
625 | then | ||
626 | niro | 4806 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) |
627 | niro | 2 | fi |
628 | } | ||
629 | |||
630 | niro | 2166 | 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="--recursive" | ||
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="--recursive --force" | ||
648 | source="$2" | ||
649 | dest="$3" | ||
650 | fi | ||
651 | |||
652 | [[ -z ${source} ]] && die "No source given." | ||
653 | [[ -z ${dest} ]] && die "No dest given." | ||
654 | |||
655 | cp -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
656 | } | ||
657 | |||
658 | mmove() | ||
659 | { | ||
660 | local source="$1" | ||
661 | local dest="$2" | ||
662 | local opts | ||
663 | |||
664 | # force | ||
665 | if [[ $1 = -f ]] | ||
666 | then | ||
667 | niro | 4805 | opts="--force" |
668 | niro | 2166 | source="$2" |
669 | dest="$3" | ||
670 | fi | ||
671 | |||
672 | [[ -z ${source} ]] && die "No source given." | ||
673 | [[ -z ${dest} ]] && die "No dest given." | ||
674 | |||
675 | mv -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
676 | } | ||
677 | |||
678 | # mark directories undeletable | ||
679 | niro | 2 | mkeepdir() |
680 | { | ||
681 | local keepdir | ||
682 | [[ -z "$1" ]] && die "No directory given" | ||
683 | |||
684 | keepdir="$1" | ||
685 | niro | 1113 | install -v -d ${BINDIR}/${keepdir} || die |
686 | niro | 2 | touch ${BINDIR}/${keepdir}/.keep || die |
687 | } | ||
688 | |||
689 | # creates empty files | ||
690 | memptyfile() | ||
691 | { | ||
692 | local file | ||
693 | local path | ||
694 | |||
695 | [[ -z "$1" ]] && die "No file given" | ||
696 | |||
697 | file="$1" | ||
698 | path="$(dirname ${file})" | ||
699 | |||
700 | install -d ${BINDIR}/${path} || die | ||
701 | touch ${BINDIR}/${file} || die | ||
702 | } | ||
703 | |||
704 | mchown() | ||
705 | { | ||
706 | local owner="$1" | ||
707 | local path="$2" | ||
708 | local recursive | ||
709 | |||
710 | # recursive | ||
711 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
712 | then | ||
713 | local recursive="--recursive" | ||
714 | local owner="$2" | ||
715 | local path="$3" | ||
716 | fi | ||
717 | |||
718 | [[ -z ${owner} ]] && die "No owner given." | ||
719 | [[ -z ${path} ]] && die "No path given." | ||
720 | |||
721 | niro | 1113 | chown -v ${recursive} ${owner} ${BINDIR}/${path} || die |
722 | niro | 2 | } |
723 | |||
724 | mchmod() | ||
725 | { | ||
726 | local posix="$1" | ||
727 | local path="$2" | ||
728 | local recursive | ||
729 | |||
730 | # recursive | ||
731 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
732 | then | ||
733 | local recursive="--recursive" | ||
734 | local posix="$2" | ||
735 | local path="$3" | ||
736 | fi | ||
737 | |||
738 | [[ -z ${posix} ]] && die "No posix given." | ||
739 | [[ -z ${path} ]] && die "No path given." | ||
740 | |||
741 | niro | 1113 | chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die |
742 | niro | 2 | } |
743 | |||
744 | mlink() | ||
745 | { | ||
746 | local symlink="$1" | ||
747 | local pathto="$2" | ||
748 | niro | 4806 | local verbose="-v" |
749 | niro | 2 | |
750 | niro | 4806 | # check for busybox as it doesn'tz support 'ln -v' |
751 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" | ||
752 | |||
753 | niro | 2 | [[ -z ${symlink} ]] && die "No symlink given." |
754 | [[ -z ${pathto} ]] && die "No path given." | ||
755 | |||
756 | niro | 4806 | ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
757 | niro | 2 | } |