Annotation of /trunk/include/mtools.sminc
Parent Directory | Revision Log
Revision 4579 -
(hide annotations)
(download)
Fri Dec 25 18:32:07 2009 UTC (14 years, 10 months ago) by niro
Original Path: trunk/core/include/mtools.sminc
File size: 13845 byte(s)
Fri Dec 25 18:32:07 2009 UTC (14 years, 10 months ago) by niro
Original Path: trunk/core/include/mtools.sminc
File size: 13845 byte(s)
-added minstallhalinformation(), minstallhalpolicy(), minstallhalpreprobe()
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 | # installs initscripts | ||
9 | # minstallrc /path/to/rc-script {destfilename} | ||
10 | minstallrc() | ||
11 | { | ||
12 | local rcscript | ||
13 | local file | ||
14 | |||
15 | [[ -z "$1" ]] && die "No initscript given" | ||
16 | |||
17 | # if no fullpath given use file from sourcedir | ||
18 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
19 | then | ||
20 | file="${SOURCEDIR}/${PNAME}/$1" | ||
21 | else | ||
22 | file="$1" | ||
23 | fi | ||
24 | |||
25 | if [[ -n "$2" ]] | ||
26 | then | ||
27 | rcscript="$2" | ||
28 | else | ||
29 | rcscript="$(basename ${file})" | ||
30 | fi | ||
31 | |||
32 | # needed directory | ||
33 | install -d ${BINDIR}/etc/rc.d/init.d || die | ||
34 | |||
35 | # install our initscript | ||
36 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/etc/rc.d/init.d/${rcscript} || die |
37 | niro | 2 | } |
38 | |||
39 | # installs environment files | ||
40 | # minstallenv /path/to/envdfile {destfilename} | ||
41 | minstallenv() | ||
42 | { | ||
43 | local envdfile | ||
44 | local file | ||
45 | |||
46 | [[ -z "$1" ]] && die "No envd file given" | ||
47 | |||
48 | # if no fullpath given use file from sourcedir | ||
49 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
50 | then | ||
51 | file="${SOURCEDIR}/${PNAME}/$1" | ||
52 | else | ||
53 | file="$1" | ||
54 | fi | ||
55 | |||
56 | if [[ -n "$2" ]] | ||
57 | then | ||
58 | envdfile="$2" | ||
59 | else | ||
60 | envdfile="$(basename ${file})" | ||
61 | fi | ||
62 | |||
63 | # needed directory | ||
64 | install -d ${BINDIR}/etc/env.d || die | ||
65 | |||
66 | # install our envfile | ||
67 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/env.d/${envdfile} || die |
68 | niro | 2 | } |
69 | |||
70 | # installs system configuration files | ||
71 | # minstallconf /path/to/confdfile {destfilename} | ||
72 | minstallconf() | ||
73 | { | ||
74 | local confdfile | ||
75 | local file | ||
76 | |||
77 | [[ -z "$1" ]] && die "No confd file given" | ||
78 | |||
79 | # if no fullpath given use file from sourcedir | ||
80 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
81 | then | ||
82 | file="${SOURCEDIR}/${PNAME}/$1" | ||
83 | else | ||
84 | file="$1" | ||
85 | fi | ||
86 | |||
87 | if [[ -n "$2" ]] | ||
88 | then | ||
89 | confdfile="$2" | ||
90 | else | ||
91 | confdfile="$(basename ${file})" | ||
92 | fi | ||
93 | |||
94 | # needed directory | ||
95 | install -d ${BINDIR}/etc/conf.d || die | ||
96 | |||
97 | # install our configfile | ||
98 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/conf.d/${confdfile} || die |
99 | niro | 2 | } |
100 | |||
101 | # installs system configuration files to etc | ||
102 | # minstalletc /path/to/etcfile {destfilename} {destdir path} | ||
103 | minstalletc() | ||
104 | { | ||
105 | local etcfile | ||
106 | local file | ||
107 | local destdir | ||
108 | |||
109 | [[ -z "$1" ]] && die "No etc file given" | ||
110 | |||
111 | # if no fullpath given use file from sourcedir | ||
112 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
113 | then | ||
114 | file="${SOURCEDIR}/${PNAME}/$1" | ||
115 | else | ||
116 | file="$1" | ||
117 | fi | ||
118 | |||
119 | if [[ -n "$2" ]] | ||
120 | then | ||
121 | etcfile="$2" | ||
122 | else | ||
123 | etcfile="$(basename ${file})" | ||
124 | fi | ||
125 | |||
126 | if [[ -n "$3" ]] | ||
127 | then | ||
128 | destdir="$3" | ||
129 | else | ||
130 | destdir="/etc" | ||
131 | fi | ||
132 | |||
133 | # needed directory | ||
134 | install -d ${BINDIR}/${destdir} || die | ||
135 | |||
136 | # install our configfile | ||
137 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die |
138 | niro | 2 | } |
139 | |||
140 | niro | 2032 | minstalludevrule() |
141 | niro | 2031 | { |
142 | local udevrule | ||
143 | local file | ||
144 | |||
145 | [[ -z "$1" ]] && die "No udev rule given" | ||
146 | |||
147 | # if no fullpath given use file from sourcedir | ||
148 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
149 | then | ||
150 | file="${SOURCEDIR}/${PNAME}/$1" | ||
151 | else | ||
152 | file="$1" | ||
153 | fi | ||
154 | |||
155 | if [[ -n "$2" ]] | ||
156 | then | ||
157 | udevrule="$2" | ||
158 | else | ||
159 | udevrule="$(basename ${file})" | ||
160 | fi | ||
161 | |||
162 | # needed directory | ||
163 | install -d ${BINDIR}/etc/udev/rules.d || die | ||
164 | |||
165 | niro | 2032 | # install our udev rule |
166 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die | ||
167 | niro | 2031 | } |
168 | |||
169 | niro | 2032 | minstalludevhelper() |
170 | { | ||
171 | local udevhelper | ||
172 | local file | ||
173 | |||
174 | [[ -z "$1" ]] && die "No udev helper given" | ||
175 | |||
176 | # if no fullpath given use file from sourcedir | ||
177 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
178 | then | ||
179 | file="${SOURCEDIR}/${PNAME}/$1" | ||
180 | else | ||
181 | file="$1" | ||
182 | fi | ||
183 | |||
184 | if [[ -n "$2" ]] | ||
185 | then | ||
186 | udevhelper="$2" | ||
187 | else | ||
188 | udevhelper="$(basename ${file})" | ||
189 | fi | ||
190 | |||
191 | # needed directory | ||
192 | install -d ${BINDIR}/lib/udev || die | ||
193 | |||
194 | # install our udev-helper | ||
195 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die | ||
196 | } | ||
197 | |||
198 | niro | 4579 | minstallhalinformation() |
199 | { | ||
200 | local halrule | ||
201 | local file | ||
202 | |||
203 | [[ -z "$1" ]] && die "No hal rule given" | ||
204 | |||
205 | # if no fullpath given use file from sourcedir | ||
206 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
207 | then | ||
208 | file="${SOURCEDIR}/${PNAME}/$1" | ||
209 | else | ||
210 | file="$1" | ||
211 | fi | ||
212 | |||
213 | if [[ -n "$2" ]] | ||
214 | then | ||
215 | halrule="$2" | ||
216 | else | ||
217 | halrule="$(basename ${file})" | ||
218 | fi | ||
219 | |||
220 | # needed directory | ||
221 | install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die | ||
222 | |||
223 | # install our udev rule | ||
224 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die | ||
225 | } | ||
226 | |||
227 | minstallhalpolicy() | ||
228 | { | ||
229 | local halrule | ||
230 | local file | ||
231 | |||
232 | [[ -z "$1" ]] && die "No hal rule given" | ||
233 | |||
234 | # if no fullpath given use file from sourcedir | ||
235 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
236 | then | ||
237 | file="${SOURCEDIR}/${PNAME}/$1" | ||
238 | else | ||
239 | file="$1" | ||
240 | fi | ||
241 | |||
242 | if [[ -n "$2" ]] | ||
243 | then | ||
244 | halrule="$2" | ||
245 | else | ||
246 | halrule="$(basename ${file})" | ||
247 | fi | ||
248 | |||
249 | # needed directory | ||
250 | install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die | ||
251 | |||
252 | # install our udev rule | ||
253 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die | ||
254 | } | ||
255 | |||
256 | minstallhalpreprobe() | ||
257 | { | ||
258 | local halrule | ||
259 | local file | ||
260 | |||
261 | [[ -z "$1" ]] && die "No hal rule given" | ||
262 | |||
263 | # if no fullpath given use file from sourcedir | ||
264 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
265 | then | ||
266 | file="${SOURCEDIR}/${PNAME}/$1" | ||
267 | else | ||
268 | file="$1" | ||
269 | fi | ||
270 | |||
271 | if [[ -n "$2" ]] | ||
272 | then | ||
273 | halrule="$2" | ||
274 | else | ||
275 | halrule="$(basename ${file})" | ||
276 | fi | ||
277 | |||
278 | # needed directory | ||
279 | install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die | ||
280 | |||
281 | # install our udev rule | ||
282 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die | ||
283 | } | ||
284 | |||
285 | niro | 2 | # install man files to appropiate dirs |
286 | # minstallman /path/to/manfile.foo | ||
287 | minstallman() | ||
288 | { | ||
289 | local manfile | ||
290 | local mandir | ||
291 | local file | ||
292 | |||
293 | [[ -z "$@" ]] && die "No man file given" | ||
294 | |||
295 | for file in $@ | ||
296 | do | ||
297 | manfile="$(basename ${file})" | ||
298 | mandir="man${manfile##*.}" | ||
299 | |||
300 | install -d ${BINDIR}/usr/share/man/${mandir} || die | ||
301 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/man/${mandir}/${manfile} || die |
302 | niro | 2 | done |
303 | } | ||
304 | |||
305 | # install info files to appropiate dirs | ||
306 | # minstallinfo /path/to/infofile.foo | ||
307 | minstallinfo() | ||
308 | { | ||
309 | local file | ||
310 | |||
311 | [[ -z "$@" ]] && die "No info file given" | ||
312 | |||
313 | for file in $@ | ||
314 | do | ||
315 | install -d ${BINDIR}/usr/share/info || die | ||
316 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/info/$(basename ${file}) || die |
317 | niro | 2 | done |
318 | } | ||
319 | |||
320 | # install html files to appropiate dirs | ||
321 | # minstallhtml /path/to/infofile.foo | ||
322 | minstallhtml() | ||
323 | { | ||
324 | local file | ||
325 | local subfile | ||
326 | local prefix | ||
327 | local subprefix | ||
328 | |||
329 | # handle prefix | ||
330 | case "$1" in | ||
331 | --prefix|-p) shift; prefix="$1"; shift ;; | ||
332 | esac | ||
333 | |||
334 | [[ -z "$@" ]] && die "No html file given" | ||
335 | |||
336 | for file in $@ | ||
337 | do | ||
338 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html${prefix} || die | ||
339 | |||
340 | if [[ -d ${file} ]] | ||
341 | then | ||
342 | for subfile in ${file}/* | ||
343 | do | ||
344 | subprefix="$(dirname ${subfile/$(dirname ${file})/})" | ||
345 | subprefix="${prefix}${subprefix}/" | ||
346 | |||
347 | minstallhtml --prefix ${subprefix} ${subfile} || die | ||
348 | done | ||
349 | else | ||
350 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html/${prefix}$(basename ${file}) || die |
351 | niro | 2 | fi |
352 | done | ||
353 | } | ||
354 | |||
355 | # install pixmaps to appropiate dirs | ||
356 | # minstallpixmap srcname destname {/path/to} | ||
357 | minstallpixmap() | ||
358 | { | ||
359 | local file | ||
360 | local destdir | ||
361 | local destfile | ||
362 | |||
363 | [[ -z "$1" ]] && die "No pixmap given" | ||
364 | |||
365 | # if no fullpath given use file from sourcedir | ||
366 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
367 | then | ||
368 | file="${SOURCEDIR}/${PNAME}/$1" | ||
369 | else | ||
370 | file="$1" | ||
371 | fi | ||
372 | |||
373 | if [[ -n "$2" ]] | ||
374 | then | ||
375 | destfile="$2" | ||
376 | else | ||
377 | destfile="$(basename ${file})" | ||
378 | fi | ||
379 | |||
380 | if [[ -n "$3" ]] | ||
381 | then | ||
382 | destdir="$3" | ||
383 | else | ||
384 | destdir="/usr/share/pixmaps" | ||
385 | fi | ||
386 | |||
387 | # needed directory | ||
388 | install -d ${BINDIR}/${destdir} || die | ||
389 | |||
390 | # install our pixmap | ||
391 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die |
392 | niro | 2 | } |
393 | |||
394 | # installs pam configuration files | ||
395 | # minstallpam /path/to/pamfile {destfilename} | ||
396 | minstallpam() | ||
397 | { | ||
398 | local pamfile | ||
399 | local file | ||
400 | |||
401 | [[ -z "$1" ]] && die "No pam file given" | ||
402 | |||
403 | # if no fullpath given use file from sourcedir | ||
404 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
405 | then | ||
406 | file="${SOURCEDIR}/${PNAME}/$1" | ||
407 | else | ||
408 | file="$1" | ||
409 | fi | ||
410 | |||
411 | if [[ -n "$2" ]] | ||
412 | then | ||
413 | pamfile="$2" | ||
414 | else | ||
415 | pamfile="$(basename ${file})" | ||
416 | fi | ||
417 | |||
418 | # needed directory | ||
419 | install -d ${BINDIR}/etc/pam.d || die | ||
420 | |||
421 | # install our configfile | ||
422 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/pam.d/${pamfile} || die |
423 | niro | 2 | } |
424 | |||
425 | # installs cronjobs | ||
426 | # minstallcron [hourly|daily|weekly|monthly] /path/to/cronfile {destfilename} | ||
427 | minstallcron() | ||
428 | { | ||
429 | local cronfile | ||
430 | local loop | ||
431 | local file | ||
432 | |||
433 | [[ -z "$1" ]] && die "No loop rythem given [hourly|daily|weekly|monthly]" | ||
434 | [[ -z "$2" ]] && die "No cronfile given" | ||
435 | |||
436 | loop="$1" | ||
437 | |||
438 | # if no fullpath given use file from sourcedir | ||
439 | if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] | ||
440 | then | ||
441 | file="${SOURCEDIR}/${PNAME}/$2" | ||
442 | else | ||
443 | file="$2" | ||
444 | fi | ||
445 | |||
446 | if [[ -n "$3" ]] | ||
447 | then | ||
448 | cronfile="$3" | ||
449 | else | ||
450 | cronfile="$(basename ${file})" | ||
451 | fi | ||
452 | |||
453 | # needed directory | ||
454 | install -m0750 -d ${BINDIR}/etc/cron.${loop} || die | ||
455 | |||
456 | # install our cronfile | ||
457 | niro | 1113 | install -v -m 0750 -o root -g root ${file} ${BINDIR}/etc/cron.${loop}/${cronfile} || die |
458 | niro | 2 | } |
459 | |||
460 | |||
461 | # installs logrotate configuration files | ||
462 | # minstallpam /path/to/logrotatefile {destfilename} | ||
463 | minstalllog() | ||
464 | { | ||
465 | local logfile | ||
466 | local file | ||
467 | |||
468 | [[ -z "$1" ]] && die "No logrotate file given" | ||
469 | |||
470 | # if no fullpath given use file from sourcedir | ||
471 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
472 | then | ||
473 | file="${SOURCEDIR}/${PNAME}/$1" | ||
474 | else | ||
475 | file="$1" | ||
476 | fi | ||
477 | |||
478 | if [[ -n "$2" ]] | ||
479 | then | ||
480 | logfile="$2" | ||
481 | else | ||
482 | logfile="$(basename ${file})" | ||
483 | fi | ||
484 | |||
485 | # needed directory | ||
486 | install -d ${BINDIR}/etc/logrotate.d || die | ||
487 | |||
488 | # install our configfile | ||
489 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/logrotate.d/${logfile} || die |
490 | niro | 2 | } |
491 | |||
492 | |||
493 | # installs given directories | ||
494 | # minstalldir /path/to/dest/dir {/path/to/dest/dirN} | ||
495 | minstalldir() | ||
496 | { | ||
497 | local argv="$@" | ||
498 | local dest | ||
499 | |||
500 | [[ -z ${argv} ]] && die "No dest dir given" | ||
501 | for dest in ${argv} | ||
502 | do | ||
503 | [[ -d ${BINDIR}${dest} ]] && continue | ||
504 | niro | 1113 | install -v -d ${BINDIR}/${dest} || die |
505 | niro | 2 | done |
506 | } | ||
507 | |||
508 | |||
509 | # install files to given path (defaults to /usr/bin) | ||
510 | # minstallfile {-s} /path/to/file {/path/to/dest} | ||
511 | minstallfile() | ||
512 | { | ||
513 | local file | ||
514 | local dest | ||
515 | |||
516 | [[ -z $1 ]] && die "No etc file given" | ||
517 | |||
518 | if [[ $1 = -s ]] | ||
519 | then | ||
520 | file="${SOURCEDIR}/${PNAME}/$2" | ||
521 | dest="$3" | ||
522 | if [[ -z $3 ]] | ||
523 | then | ||
524 | dest=/usr/bin | ||
525 | install -d ${BINDIR}/${dest} || die | ||
526 | fi | ||
527 | else | ||
528 | file="$1" | ||
529 | dest="$2" | ||
530 | if [[ -z $2 ]] | ||
531 | then | ||
532 | dest=/usr/bin | ||
533 | install -d ${BINDIR}/${dest} || die | ||
534 | fi | ||
535 | fi | ||
536 | |||
537 | # install our configfile | ||
538 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die |
539 | niro | 2 | } |
540 | |||
541 | # installs executables to given path | ||
542 | # minstallexec {-s} /path/to/exec {/path/to/dest} | ||
543 | minstallexec() | ||
544 | { | ||
545 | local file | ||
546 | local dest | ||
547 | |||
548 | [[ -z $1 ]] && die "No file given" | ||
549 | |||
550 | if [[ $1 = -s ]] | ||
551 | then | ||
552 | file="${SOURCEDIR}/${PNAME}/$2" | ||
553 | dest="$3" | ||
554 | if [[ -z $3 ]] | ||
555 | then | ||
556 | dest=/usr/bin | ||
557 | install -d ${BINDIR}/${dest} || die | ||
558 | fi | ||
559 | else | ||
560 | file="$1" | ||
561 | dest="$2" | ||
562 | if [[ -z $2 ]] | ||
563 | then | ||
564 | dest=/usr/bin | ||
565 | install -d ${BINDIR}/${dest} || die | ||
566 | fi | ||
567 | fi | ||
568 | |||
569 | # install our configfile | ||
570 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
571 | niro | 2 | } |
572 | |||
573 | # installs executables to given path | ||
574 | # minstalllib {-s} /path/to/exec {/path/to/dest} | ||
575 | minstalllib() | ||
576 | { | ||
577 | local file | ||
578 | local dest | ||
579 | |||
580 | [[ -z $1 ]] && die "No file given" | ||
581 | |||
582 | if [[ $1 = -s ]] | ||
583 | then | ||
584 | file="${SOURCEDIR}/${PNAME}/$2" | ||
585 | dest="$3" | ||
586 | if [[ -z $3 ]] | ||
587 | then | ||
588 | dest=/usr/$(mlibdir) | ||
589 | install -d ${BINDIR}/${dest} || die | ||
590 | fi | ||
591 | else | ||
592 | file="$1" | ||
593 | dest="$2" | ||
594 | if [[ -z $2 ]] | ||
595 | then | ||
596 | dest=/usr/$(mlibdir) | ||
597 | install -d ${BINDIR}/${dest} || die | ||
598 | fi | ||
599 | fi | ||
600 | |||
601 | # install our library | ||
602 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
603 | niro | 2 | |
604 | # create libtool symlinks | ||
605 | # 1. - library.so.1.0.0 -> library.so.1.0 | ||
606 | if [ "${file%.*}" != *.so ] | ||
607 | then | ||
608 | niro | 1113 | ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) |
609 | niro | 2 | fi |
610 | # 2. - library.so.1.0.0 -> library.so.1 | ||
611 | if [ "${file%.*.*}" != *.so ] | ||
612 | then | ||
613 | niro | 1113 | ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) |
614 | niro | 2 | fi |
615 | } | ||
616 | |||
617 | niro | 2166 | mcopy() |
618 | { | ||
619 | local source="$1" | ||
620 | local dest="$2" | ||
621 | local opts | ||
622 | |||
623 | # recursive | ||
624 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
625 | then | ||
626 | opts="--recursive" | ||
627 | source="$2" | ||
628 | dest="$3" | ||
629 | fi | ||
630 | |||
631 | # recursive | ||
632 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] | ||
633 | then | ||
634 | opts="--recursive --force" | ||
635 | source="$2" | ||
636 | dest="$3" | ||
637 | fi | ||
638 | |||
639 | [[ -z ${source} ]] && die "No source given." | ||
640 | [[ -z ${dest} ]] && die "No dest given." | ||
641 | |||
642 | cp -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
643 | } | ||
644 | |||
645 | mmove() | ||
646 | { | ||
647 | local source="$1" | ||
648 | local dest="$2" | ||
649 | local opts | ||
650 | |||
651 | # force | ||
652 | if [[ $1 = -f ]] | ||
653 | then | ||
654 | opts="--recursive" | ||
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 | mv -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
663 | } | ||
664 | |||
665 | # mark directories undeletable | ||
666 | niro | 2 | mkeepdir() |
667 | { | ||
668 | local keepdir | ||
669 | [[ -z "$1" ]] && die "No directory given" | ||
670 | |||
671 | keepdir="$1" | ||
672 | niro | 1113 | install -v -d ${BINDIR}/${keepdir} || die |
673 | niro | 2 | touch ${BINDIR}/${keepdir}/.keep || die |
674 | } | ||
675 | |||
676 | # creates empty files | ||
677 | memptyfile() | ||
678 | { | ||
679 | local file | ||
680 | local path | ||
681 | |||
682 | [[ -z "$1" ]] && die "No file given" | ||
683 | |||
684 | file="$1" | ||
685 | path="$(dirname ${file})" | ||
686 | |||
687 | install -d ${BINDIR}/${path} || die | ||
688 | touch ${BINDIR}/${file} || die | ||
689 | } | ||
690 | |||
691 | mchown() | ||
692 | { | ||
693 | local owner="$1" | ||
694 | local path="$2" | ||
695 | local recursive | ||
696 | |||
697 | # recursive | ||
698 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
699 | then | ||
700 | local recursive="--recursive" | ||
701 | local owner="$2" | ||
702 | local path="$3" | ||
703 | fi | ||
704 | |||
705 | [[ -z ${owner} ]] && die "No owner given." | ||
706 | [[ -z ${path} ]] && die "No path given." | ||
707 | |||
708 | niro | 1113 | chown -v ${recursive} ${owner} ${BINDIR}/${path} || die |
709 | niro | 2 | } |
710 | |||
711 | mchmod() | ||
712 | { | ||
713 | local posix="$1" | ||
714 | local path="$2" | ||
715 | local recursive | ||
716 | |||
717 | # recursive | ||
718 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
719 | then | ||
720 | local recursive="--recursive" | ||
721 | local posix="$2" | ||
722 | local path="$3" | ||
723 | fi | ||
724 | |||
725 | [[ -z ${posix} ]] && die "No posix given." | ||
726 | [[ -z ${path} ]] && die "No path given." | ||
727 | |||
728 | niro | 1113 | chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die |
729 | niro | 2 | } |
730 | |||
731 | mlink() | ||
732 | { | ||
733 | local symlink="$1" | ||
734 | local pathto="$2" | ||
735 | |||
736 | [[ -z ${symlink} ]] && die "No symlink given." | ||
737 | [[ -z ${pathto} ]] && die "No path given." | ||
738 | |||
739 | niro | 1113 | ln -v -snf ${symlink} ${BINDIR}/${pathto} || die |
740 | niro | 2 | } |