Annotation of /trunk/include/mtools.sminc
Parent Directory | Revision Log
Revision 4804 -
(hide annotations)
(download)
Sun Jan 3 20:24:20 2010 UTC (14 years, 10 months ago) by niro
Original Path: trunk/core/include/mtools.sminc
File size: 14026 byte(s)
Sun Jan 3 20:24:20 2010 UTC (14 years, 10 months ago) by niro
Original Path: trunk/core/include/mtools.sminc
File size: 14026 byte(s)
-respect SPLIT_PACKAGES
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 | [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname ="${SPLIT_PACKAGE_BASE}" | ||
13 | |||
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 | |||
589 | [[ -z $1 ]] && die "No file given" | ||
590 | |||
591 | if [[ $1 = -s ]] | ||
592 | then | ||
593 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
594 | niro | 2 | dest="$3" |
595 | if [[ -z $3 ]] | ||
596 | then | ||
597 | dest=/usr/$(mlibdir) | ||
598 | install -d ${BINDIR}/${dest} || die | ||
599 | fi | ||
600 | else | ||
601 | file="$1" | ||
602 | dest="$2" | ||
603 | if [[ -z $2 ]] | ||
604 | then | ||
605 | dest=/usr/$(mlibdir) | ||
606 | install -d ${BINDIR}/${dest} || die | ||
607 | fi | ||
608 | fi | ||
609 | |||
610 | # install our library | ||
611 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
612 | niro | 2 | |
613 | # create libtool symlinks | ||
614 | # 1. - library.so.1.0.0 -> library.so.1.0 | ||
615 | if [ "${file%.*}" != *.so ] | ||
616 | then | ||
617 | niro | 1113 | ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) |
618 | niro | 2 | fi |
619 | # 2. - library.so.1.0.0 -> library.so.1 | ||
620 | if [ "${file%.*.*}" != *.so ] | ||
621 | then | ||
622 | niro | 1113 | ln -v -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) |
623 | niro | 2 | fi |
624 | } | ||
625 | |||
626 | niro | 2166 | mcopy() |
627 | { | ||
628 | local source="$1" | ||
629 | local dest="$2" | ||
630 | local opts | ||
631 | |||
632 | # recursive | ||
633 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
634 | then | ||
635 | opts="--recursive" | ||
636 | source="$2" | ||
637 | dest="$3" | ||
638 | fi | ||
639 | |||
640 | # recursive | ||
641 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] | ||
642 | then | ||
643 | opts="--recursive --force" | ||
644 | source="$2" | ||
645 | dest="$3" | ||
646 | fi | ||
647 | |||
648 | [[ -z ${source} ]] && die "No source given." | ||
649 | [[ -z ${dest} ]] && die "No dest given." | ||
650 | |||
651 | cp -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
652 | } | ||
653 | |||
654 | mmove() | ||
655 | { | ||
656 | local source="$1" | ||
657 | local dest="$2" | ||
658 | local opts | ||
659 | |||
660 | # force | ||
661 | if [[ $1 = -f ]] | ||
662 | then | ||
663 | opts="--recursive" | ||
664 | source="$2" | ||
665 | dest="$3" | ||
666 | fi | ||
667 | |||
668 | [[ -z ${source} ]] && die "No source given." | ||
669 | [[ -z ${dest} ]] && die "No dest given." | ||
670 | |||
671 | mv -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
672 | } | ||
673 | |||
674 | # mark directories undeletable | ||
675 | niro | 2 | mkeepdir() |
676 | { | ||
677 | local keepdir | ||
678 | [[ -z "$1" ]] && die "No directory given" | ||
679 | |||
680 | keepdir="$1" | ||
681 | niro | 1113 | install -v -d ${BINDIR}/${keepdir} || die |
682 | niro | 2 | touch ${BINDIR}/${keepdir}/.keep || die |
683 | } | ||
684 | |||
685 | # creates empty files | ||
686 | memptyfile() | ||
687 | { | ||
688 | local file | ||
689 | local path | ||
690 | |||
691 | [[ -z "$1" ]] && die "No file given" | ||
692 | |||
693 | file="$1" | ||
694 | path="$(dirname ${file})" | ||
695 | |||
696 | install -d ${BINDIR}/${path} || die | ||
697 | touch ${BINDIR}/${file} || die | ||
698 | } | ||
699 | |||
700 | mchown() | ||
701 | { | ||
702 | local owner="$1" | ||
703 | local path="$2" | ||
704 | local recursive | ||
705 | |||
706 | # recursive | ||
707 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
708 | then | ||
709 | local recursive="--recursive" | ||
710 | local owner="$2" | ||
711 | local path="$3" | ||
712 | fi | ||
713 | |||
714 | [[ -z ${owner} ]] && die "No owner given." | ||
715 | [[ -z ${path} ]] && die "No path given." | ||
716 | |||
717 | niro | 1113 | chown -v ${recursive} ${owner} ${BINDIR}/${path} || die |
718 | niro | 2 | } |
719 | |||
720 | mchmod() | ||
721 | { | ||
722 | local posix="$1" | ||
723 | local path="$2" | ||
724 | local recursive | ||
725 | |||
726 | # recursive | ||
727 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
728 | then | ||
729 | local recursive="--recursive" | ||
730 | local posix="$2" | ||
731 | local path="$3" | ||
732 | fi | ||
733 | |||
734 | [[ -z ${posix} ]] && die "No posix given." | ||
735 | [[ -z ${path} ]] && die "No path given." | ||
736 | |||
737 | niro | 1113 | chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die |
738 | niro | 2 | } |
739 | |||
740 | mlink() | ||
741 | { | ||
742 | local symlink="$1" | ||
743 | local pathto="$2" | ||
744 | |||
745 | [[ -z ${symlink} ]] && die "No symlink given." | ||
746 | [[ -z ${pathto} ]] && die "No path given." | ||
747 | |||
748 | niro | 1113 | ln -v -snf ${symlink} ${BINDIR}/${pathto} || die |
749 | niro | 2 | } |