Annotation of /trunk/include/mtools.sminc
Parent Directory | Revision Log
Revision 12653 -
(hide annotations)
(download)
Tue Jun 26 15:38:25 2012 UTC (12 years, 4 months ago) by niro
File size: 16868 byte(s)
Tue Jun 26 15:38:25 2012 UTC (12 years, 4 months ago) by niro
File size: 16868 byte(s)
-fixed dest check
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 | niro | 12652 | install -d ${BINDIR}/lib/udev/rules.d || die |
173 | niro | 2031 | |
174 | niro | 2032 | # install our udev rule |
175 | niro | 12652 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/lib/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 | niro | 8809 | # minstalllog /path/to/logrotatefile {destfilename} |
472 | niro | 2 | 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 | niro | 11761 | opts="-R" |
640 | niro | 2166 | source="$2" |
641 | dest="$3" | ||
642 | fi | ||
643 | |||
644 | # recursive | ||
645 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] | ||
646 | then | ||
647 | niro | 11761 | opts="-R -f" |
648 | niro | 2166 | source="$2" |
649 | dest="$3" | ||
650 | fi | ||
651 | |||
652 | niro | 9862 | if [[ $1 = -a ]] |
653 | then | ||
654 | niro | 11761 | opts="-a" |
655 | niro | 9862 | source="$2" |
656 | dest="$3" | ||
657 | fi | ||
658 | |||
659 | niro | 2166 | [[ -z ${source} ]] && die "No source given." |
660 | [[ -z ${dest} ]] && die "No dest given." | ||
661 | |||
662 | cp -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
663 | } | ||
664 | |||
665 | niro | 12652 | mdelete() |
666 | { | ||
667 | local dest="$1" | ||
668 | local opts | ||
669 | |||
670 | # recursive | ||
671 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
672 | then | ||
673 | opts="-r" | ||
674 | dest="$2" | ||
675 | fi | ||
676 | |||
677 | # recursive | ||
678 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] | ||
679 | then | ||
680 | opts="-r -f" | ||
681 | dest="$2" | ||
682 | fi | ||
683 | |||
684 | [[ -z ${dest} ]] && die "No dest given." | ||
685 | niro | 12653 | [[ -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist." |
686 | niro | 12652 | |
687 | rm -v ${opts} ${BINDIR}/${dest} || die | ||
688 | } | ||
689 | |||
690 | niro | 2166 | mmove() |
691 | { | ||
692 | local source="$1" | ||
693 | local dest="$2" | ||
694 | local opts | ||
695 | |||
696 | # force | ||
697 | if [[ $1 = -f ]] | ||
698 | then | ||
699 | niro | 11761 | opts="-f" |
700 | niro | 2166 | source="$2" |
701 | dest="$3" | ||
702 | fi | ||
703 | |||
704 | [[ -z ${source} ]] && die "No source given." | ||
705 | [[ -z ${dest} ]] && die "No dest given." | ||
706 | |||
707 | mv -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
708 | } | ||
709 | |||
710 | # mark directories undeletable | ||
711 | niro | 2 | mkeepdir() |
712 | { | ||
713 | local keepdir | ||
714 | [[ -z "$1" ]] && die "No directory given" | ||
715 | |||
716 | keepdir="$1" | ||
717 | niro | 1113 | install -v -d ${BINDIR}/${keepdir} || die |
718 | niro | 2 | touch ${BINDIR}/${keepdir}/.keep || die |
719 | } | ||
720 | |||
721 | # creates empty files | ||
722 | memptyfile() | ||
723 | { | ||
724 | local file | ||
725 | local path | ||
726 | |||
727 | [[ -z "$1" ]] && die "No file given" | ||
728 | |||
729 | file="$1" | ||
730 | path="$(dirname ${file})" | ||
731 | |||
732 | install -d ${BINDIR}/${path} || die | ||
733 | touch ${BINDIR}/${file} || die | ||
734 | } | ||
735 | |||
736 | mchown() | ||
737 | { | ||
738 | local owner="$1" | ||
739 | local path="$2" | ||
740 | local recursive | ||
741 | |||
742 | # recursive | ||
743 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
744 | then | ||
745 | niro | 11761 | local recursive="-R" |
746 | niro | 2 | local owner="$2" |
747 | local path="$3" | ||
748 | fi | ||
749 | |||
750 | [[ -z ${owner} ]] && die "No owner given." | ||
751 | [[ -z ${path} ]] && die "No path given." | ||
752 | |||
753 | niro | 1113 | chown -v ${recursive} ${owner} ${BINDIR}/${path} || die |
754 | niro | 2 | } |
755 | |||
756 | mchmod() | ||
757 | { | ||
758 | local posix="$1" | ||
759 | local path="$2" | ||
760 | local recursive | ||
761 | |||
762 | # recursive | ||
763 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
764 | then | ||
765 | niro | 11761 | local recursive="-R" |
766 | niro | 2 | local posix="$2" |
767 | local path="$3" | ||
768 | fi | ||
769 | |||
770 | [[ -z ${posix} ]] && die "No posix given." | ||
771 | [[ -z ${path} ]] && die "No path given." | ||
772 | |||
773 | niro | 1113 | chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die |
774 | niro | 2 | } |
775 | |||
776 | mlink() | ||
777 | { | ||
778 | local symlink="$1" | ||
779 | local pathto="$2" | ||
780 | niro | 4806 | local verbose="-v" |
781 | niro | 2 | |
782 | niro | 4806 | # check for busybox as it doesn'tz support 'ln -v' |
783 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" | ||
784 | |||
785 | niro | 2 | [[ -z ${symlink} ]] && die "No symlink given." |
786 | [[ -z ${pathto} ]] && die "No path given." | ||
787 | |||
788 | niro | 4806 | ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
789 | niro | 2 | } |
790 | niro | 7874 | |
791 | # installs systemd units | ||
792 | # minstallunit /path/to/unit-file {destfilename} | ||
793 | minstallunit() | ||
794 | { | ||
795 | local unit | ||
796 | local file | ||
797 | niro | 10935 | local prefix |
798 | niro | 7874 | |
799 | [[ -z "$1" ]] && die "No unit given" | ||
800 | |||
801 | niro | 10935 | # get the right prefix for newer systemd |
802 | [[ -x /bin/systemctl ]] && prefix="" | ||
803 | [[ -x /usr/bin/systemctl ]] && prefix="/usr" | ||
804 | |||
805 | niro | 7874 | # if no fullpath given use file from sourcedir |
806 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
807 | then | ||
808 | file="${SOURCEDIR}/$(mpname)/$1" | ||
809 | else | ||
810 | file="$1" | ||
811 | fi | ||
812 | |||
813 | if [[ -n "$2" ]] | ||
814 | then | ||
815 | unit="$2" | ||
816 | else | ||
817 | unit="$(basename ${file})" | ||
818 | fi | ||
819 | |||
820 | # needed directory | ||
821 | niro | 10935 | install -d ${BINDIR}${prefix}/lib/systemd/system || die |
822 | niro | 7874 | |
823 | # install our initscript | ||
824 | niro | 10935 | install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}/lib/systemd/system/${unit} || die |
825 | niro | 7874 | } |
826 | |||
827 | # installs systemd tmp configs to /etc/tmpfiles.d | ||
828 | # minstalltmp /path/to/tmpdfile {destfilename} | ||
829 | minstalltmp() | ||
830 | { | ||
831 | local tmpdfile | ||
832 | local file | ||
833 | |||
834 | [[ -z "$1" ]] && die "No tmpd file given" | ||
835 | |||
836 | # if no fullpath given use file from sourcedir | ||
837 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
838 | then | ||
839 | file="${SOURCEDIR}/$(mpname)/$1" | ||
840 | else | ||
841 | file="$1" | ||
842 | fi | ||
843 | |||
844 | if [[ -n "$2" ]] | ||
845 | then | ||
846 | tmpdfile="$2" | ||
847 | else | ||
848 | tmpdfile="$(basename ${file})" | ||
849 | fi | ||
850 | |||
851 | # needed directory | ||
852 | install -d ${BINDIR}/etc/tmpfiles.d || die | ||
853 | |||
854 | # install our tmpdfile | ||
855 | niro | 7876 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die |
856 | niro | 7874 | } |
857 | niro | 8469 | |
858 | mclearconfig() | ||
859 | { | ||
860 | local confdir | ||
861 | local prefix="${BINDIR}" | ||
862 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" | ||
863 | |||
864 | # no bindir prefix if requested | ||
865 | case $1 in | ||
866 | -b|--no-bindir) prefix="";; | ||
867 | esac | ||
868 | |||
869 | confdir="$(dirname ${MCONFIG})" | ||
870 | if [[ ! -d ${prefix}/${confdir} ]] | ||
871 | then | ||
872 | install -d ${prefix}/${confdir} || die | ||
873 | fi | ||
874 | : > ${prefix}/${MCONFIG} | ||
875 | } | ||
876 | |||
877 | maddconfig() | ||
878 | { | ||
879 | local argv="$1" | ||
880 | local confdir | ||
881 | local prefix="${BINDIR}" | ||
882 | |||
883 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" | ||
884 | |||
885 | # no bindir prefix if requested | ||
886 | case $1 in | ||
887 | -b|--no-bindir) prefix=""; argv="$2" ;; | ||
888 | esac | ||
889 | |||
890 | [[ -z ${argv} ]] && die "No argument given!" | ||
891 | |||
892 | confdir="$(dirname ${MCONFIG})" | ||
893 | if [[ ! -d ${prefix}/${confdir} ]] | ||
894 | then | ||
895 | install -d ${prefix}/${confdir} || die | ||
896 | fi | ||
897 | echo "${argv}" >> ${prefix}/${MCONFIG} || die | ||
898 | } |