Annotation of /trunk/include/mtools.sminc
Parent Directory | Revision Log
Revision 16994 -
(hide annotations)
(download)
Thu Apr 4 14:17:58 2013 UTC (11 years, 7 months ago) by niro
File size: 17276 byte(s)
Thu Apr 4 14:17:58 2013 UTC (11 years, 7 months ago) by niro
File size: 17276 byte(s)
-let maddconfig write empty lines
1 | niro | 14029 | # $Id$ |
2 | niro | 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 | niro | 12655 | local udevrulesddir="/usr/lib/udev/rules.d" |
154 | niro | 2031 | |
155 | [[ -z "$1" ]] && die "No udev rule given" | ||
156 | |||
157 | # if no fullpath given use file from sourcedir | ||
158 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
159 | then | ||
160 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
161 | niro | 2031 | else |
162 | file="$1" | ||
163 | fi | ||
164 | |||
165 | if [[ -n "$2" ]] | ||
166 | then | ||
167 | udevrule="$2" | ||
168 | else | ||
169 | udevrule="$(basename ${file})" | ||
170 | fi | ||
171 | |||
172 | # needed directory | ||
173 | niro | 12655 | install -d ${BINDIR}${udevrulesddir} || die |
174 | niro | 2031 | |
175 | niro | 2032 | # install our udev rule |
176 | niro | 12655 | install -v -m 0644 -o root -g root ${file} ${BINDIR}${udevrulesddir}/${udevrule} || die |
177 | niro | 2031 | } |
178 | |||
179 | niro | 2032 | minstalludevhelper() |
180 | { | ||
181 | local udevhelper | ||
182 | local file | ||
183 | niro | 12655 | local udevdir="/usr/lib/udev" |
184 | niro | 2032 | |
185 | [[ -z "$1" ]] && die "No udev helper given" | ||
186 | |||
187 | # if no fullpath given use file from sourcedir | ||
188 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
189 | then | ||
190 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
191 | niro | 2032 | else |
192 | file="$1" | ||
193 | fi | ||
194 | |||
195 | if [[ -n "$2" ]] | ||
196 | then | ||
197 | udevhelper="$2" | ||
198 | else | ||
199 | udevhelper="$(basename ${file})" | ||
200 | fi | ||
201 | |||
202 | # needed directory | ||
203 | niro | 12655 | install -d ${BINDIR}${udevdir} || die |
204 | niro | 2032 | |
205 | # install our udev-helper | ||
206 | niro | 12655 | install -v -m 0755 -o root -g root ${file} ${BINDIR}${udevdir}/${udevhelper} || die |
207 | niro | 2032 | } |
208 | |||
209 | niro | 4579 | minstallhalinformation() |
210 | { | ||
211 | local halrule | ||
212 | local file | ||
213 | |||
214 | [[ -z "$1" ]] && die "No hal rule given" | ||
215 | |||
216 | # if no fullpath given use file from sourcedir | ||
217 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
218 | then | ||
219 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
220 | niro | 4579 | else |
221 | file="$1" | ||
222 | fi | ||
223 | |||
224 | if [[ -n "$2" ]] | ||
225 | then | ||
226 | halrule="$2" | ||
227 | else | ||
228 | halrule="$(basename ${file})" | ||
229 | fi | ||
230 | |||
231 | # needed directory | ||
232 | install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die | ||
233 | |||
234 | # install our udev rule | ||
235 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die | ||
236 | } | ||
237 | |||
238 | minstallhalpolicy() | ||
239 | { | ||
240 | local halrule | ||
241 | local file | ||
242 | |||
243 | [[ -z "$1" ]] && die "No hal rule given" | ||
244 | |||
245 | # if no fullpath given use file from sourcedir | ||
246 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
247 | then | ||
248 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
249 | niro | 4579 | else |
250 | file="$1" | ||
251 | fi | ||
252 | |||
253 | if [[ -n "$2" ]] | ||
254 | then | ||
255 | halrule="$2" | ||
256 | else | ||
257 | halrule="$(basename ${file})" | ||
258 | fi | ||
259 | |||
260 | # needed directory | ||
261 | install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die | ||
262 | |||
263 | # install our udev rule | ||
264 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die | ||
265 | } | ||
266 | |||
267 | minstallhalpreprobe() | ||
268 | { | ||
269 | local halrule | ||
270 | local file | ||
271 | |||
272 | [[ -z "$1" ]] && die "No hal rule given" | ||
273 | |||
274 | # if no fullpath given use file from sourcedir | ||
275 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
276 | then | ||
277 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
278 | niro | 4579 | else |
279 | file="$1" | ||
280 | fi | ||
281 | |||
282 | if [[ -n "$2" ]] | ||
283 | then | ||
284 | halrule="$2" | ||
285 | else | ||
286 | halrule="$(basename ${file})" | ||
287 | fi | ||
288 | |||
289 | # needed directory | ||
290 | install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die | ||
291 | |||
292 | # install our udev rule | ||
293 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die | ||
294 | } | ||
295 | |||
296 | niro | 2 | # install man files to appropiate dirs |
297 | # minstallman /path/to/manfile.foo | ||
298 | minstallman() | ||
299 | { | ||
300 | local manfile | ||
301 | local mandir | ||
302 | local file | ||
303 | |||
304 | [[ -z "$@" ]] && die "No man file given" | ||
305 | |||
306 | for file in $@ | ||
307 | do | ||
308 | manfile="$(basename ${file})" | ||
309 | mandir="man${manfile##*.}" | ||
310 | |||
311 | install -d ${BINDIR}/usr/share/man/${mandir} || die | ||
312 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/man/${mandir}/${manfile} || die |
313 | niro | 2 | done |
314 | } | ||
315 | |||
316 | # install info files to appropiate dirs | ||
317 | # minstallinfo /path/to/infofile.foo | ||
318 | minstallinfo() | ||
319 | { | ||
320 | local file | ||
321 | |||
322 | [[ -z "$@" ]] && die "No info file given" | ||
323 | |||
324 | for file in $@ | ||
325 | do | ||
326 | install -d ${BINDIR}/usr/share/info || die | ||
327 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/info/$(basename ${file}) || die |
328 | niro | 2 | done |
329 | } | ||
330 | |||
331 | # install html files to appropiate dirs | ||
332 | # minstallhtml /path/to/infofile.foo | ||
333 | minstallhtml() | ||
334 | { | ||
335 | local file | ||
336 | local subfile | ||
337 | local prefix | ||
338 | local subprefix | ||
339 | |||
340 | # handle prefix | ||
341 | case "$1" in | ||
342 | --prefix|-p) shift; prefix="$1"; shift ;; | ||
343 | esac | ||
344 | |||
345 | [[ -z "$@" ]] && die "No html file given" | ||
346 | |||
347 | for file in $@ | ||
348 | do | ||
349 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html${prefix} || die | ||
350 | |||
351 | if [[ -d ${file} ]] | ||
352 | then | ||
353 | for subfile in ${file}/* | ||
354 | do | ||
355 | subprefix="$(dirname ${subfile/$(dirname ${file})/})" | ||
356 | subprefix="${prefix}${subprefix}/" | ||
357 | |||
358 | minstallhtml --prefix ${subprefix} ${subfile} || die | ||
359 | done | ||
360 | else | ||
361 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html/${prefix}$(basename ${file}) || die |
362 | niro | 2 | fi |
363 | done | ||
364 | } | ||
365 | |||
366 | # install pixmaps to appropiate dirs | ||
367 | # minstallpixmap srcname destname {/path/to} | ||
368 | minstallpixmap() | ||
369 | { | ||
370 | local file | ||
371 | local destdir | ||
372 | local destfile | ||
373 | |||
374 | [[ -z "$1" ]] && die "No pixmap given" | ||
375 | |||
376 | # if no fullpath given use file from sourcedir | ||
377 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
378 | then | ||
379 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
380 | niro | 2 | else |
381 | file="$1" | ||
382 | fi | ||
383 | |||
384 | if [[ -n "$2" ]] | ||
385 | then | ||
386 | destfile="$2" | ||
387 | else | ||
388 | destfile="$(basename ${file})" | ||
389 | fi | ||
390 | |||
391 | if [[ -n "$3" ]] | ||
392 | then | ||
393 | destdir="$3" | ||
394 | else | ||
395 | destdir="/usr/share/pixmaps" | ||
396 | fi | ||
397 | |||
398 | # needed directory | ||
399 | install -d ${BINDIR}/${destdir} || die | ||
400 | |||
401 | # install our pixmap | ||
402 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die |
403 | niro | 2 | } |
404 | |||
405 | # installs pam configuration files | ||
406 | # minstallpam /path/to/pamfile {destfilename} | ||
407 | minstallpam() | ||
408 | { | ||
409 | local pamfile | ||
410 | local file | ||
411 | |||
412 | [[ -z "$1" ]] && die "No pam file given" | ||
413 | |||
414 | # if no fullpath given use file from sourcedir | ||
415 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
416 | then | ||
417 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
418 | niro | 2 | else |
419 | file="$1" | ||
420 | fi | ||
421 | |||
422 | if [[ -n "$2" ]] | ||
423 | then | ||
424 | pamfile="$2" | ||
425 | else | ||
426 | pamfile="$(basename ${file})" | ||
427 | fi | ||
428 | |||
429 | # needed directory | ||
430 | install -d ${BINDIR}/etc/pam.d || die | ||
431 | |||
432 | # install our configfile | ||
433 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/pam.d/${pamfile} || die |
434 | niro | 2 | } |
435 | |||
436 | # installs cronjobs | ||
437 | # minstallcron [hourly|daily|weekly|monthly] /path/to/cronfile {destfilename} | ||
438 | minstallcron() | ||
439 | { | ||
440 | local cronfile | ||
441 | local loop | ||
442 | local file | ||
443 | |||
444 | [[ -z "$1" ]] && die "No loop rythem given [hourly|daily|weekly|monthly]" | ||
445 | [[ -z "$2" ]] && die "No cronfile given" | ||
446 | |||
447 | loop="$1" | ||
448 | |||
449 | # if no fullpath given use file from sourcedir | ||
450 | if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] | ||
451 | then | ||
452 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
453 | niro | 2 | else |
454 | file="$2" | ||
455 | fi | ||
456 | |||
457 | if [[ -n "$3" ]] | ||
458 | then | ||
459 | cronfile="$3" | ||
460 | else | ||
461 | cronfile="$(basename ${file})" | ||
462 | fi | ||
463 | |||
464 | # needed directory | ||
465 | install -m0750 -d ${BINDIR}/etc/cron.${loop} || die | ||
466 | |||
467 | # install our cronfile | ||
468 | niro | 1113 | install -v -m 0750 -o root -g root ${file} ${BINDIR}/etc/cron.${loop}/${cronfile} || die |
469 | niro | 2 | } |
470 | |||
471 | |||
472 | # installs logrotate configuration files | ||
473 | niro | 8809 | # minstalllog /path/to/logrotatefile {destfilename} |
474 | niro | 2 | minstalllog() |
475 | { | ||
476 | local logfile | ||
477 | local file | ||
478 | |||
479 | [[ -z "$1" ]] && die "No logrotate file given" | ||
480 | |||
481 | # if no fullpath given use file from sourcedir | ||
482 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
483 | then | ||
484 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
485 | niro | 2 | else |
486 | file="$1" | ||
487 | fi | ||
488 | |||
489 | if [[ -n "$2" ]] | ||
490 | then | ||
491 | logfile="$2" | ||
492 | else | ||
493 | logfile="$(basename ${file})" | ||
494 | fi | ||
495 | |||
496 | # needed directory | ||
497 | install -d ${BINDIR}/etc/logrotate.d || die | ||
498 | |||
499 | # install our configfile | ||
500 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/logrotate.d/${logfile} || die |
501 | niro | 2 | } |
502 | |||
503 | |||
504 | # installs given directories | ||
505 | # minstalldir /path/to/dest/dir {/path/to/dest/dirN} | ||
506 | minstalldir() | ||
507 | { | ||
508 | local argv="$@" | ||
509 | local dest | ||
510 | |||
511 | [[ -z ${argv} ]] && die "No dest dir given" | ||
512 | for dest in ${argv} | ||
513 | do | ||
514 | [[ -d ${BINDIR}${dest} ]] && continue | ||
515 | niro | 1113 | install -v -d ${BINDIR}/${dest} || die |
516 | niro | 2 | done |
517 | } | ||
518 | |||
519 | |||
520 | # install files to given path (defaults to /usr/bin) | ||
521 | # minstallfile {-s} /path/to/file {/path/to/dest} | ||
522 | minstallfile() | ||
523 | { | ||
524 | local file | ||
525 | local dest | ||
526 | |||
527 | [[ -z $1 ]] && die "No etc file given" | ||
528 | |||
529 | if [[ $1 = -s ]] | ||
530 | then | ||
531 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
532 | niro | 2 | dest="$3" |
533 | if [[ -z $3 ]] | ||
534 | then | ||
535 | dest=/usr/bin | ||
536 | install -d ${BINDIR}/${dest} || die | ||
537 | fi | ||
538 | else | ||
539 | file="$1" | ||
540 | dest="$2" | ||
541 | if [[ -z $2 ]] | ||
542 | then | ||
543 | dest=/usr/bin | ||
544 | install -d ${BINDIR}/${dest} || die | ||
545 | fi | ||
546 | fi | ||
547 | |||
548 | # install our configfile | ||
549 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${dest} || die |
550 | niro | 2 | } |
551 | |||
552 | # installs executables to given path | ||
553 | # minstallexec {-s} /path/to/exec {/path/to/dest} | ||
554 | minstallexec() | ||
555 | { | ||
556 | local file | ||
557 | local dest | ||
558 | |||
559 | [[ -z $1 ]] && die "No file given" | ||
560 | |||
561 | if [[ $1 = -s ]] | ||
562 | then | ||
563 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
564 | niro | 2 | dest="$3" |
565 | if [[ -z $3 ]] | ||
566 | then | ||
567 | dest=/usr/bin | ||
568 | install -d ${BINDIR}/${dest} || die | ||
569 | fi | ||
570 | else | ||
571 | file="$1" | ||
572 | dest="$2" | ||
573 | if [[ -z $2 ]] | ||
574 | then | ||
575 | dest=/usr/bin | ||
576 | install -d ${BINDIR}/${dest} || die | ||
577 | fi | ||
578 | fi | ||
579 | |||
580 | # install our configfile | ||
581 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
582 | niro | 2 | } |
583 | |||
584 | # installs executables to given path | ||
585 | # minstalllib {-s} /path/to/exec {/path/to/dest} | ||
586 | minstalllib() | ||
587 | { | ||
588 | local file | ||
589 | local dest | ||
590 | niro | 4806 | local verbose="-v" |
591 | niro | 2 | |
592 | niro | 14029 | # check for busybox as it doesn't support 'ln -v' |
593 | niro | 4806 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" |
594 | |||
595 | niro | 2 | [[ -z $1 ]] && die "No file given" |
596 | |||
597 | if [[ $1 = -s ]] | ||
598 | then | ||
599 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
600 | niro | 2 | dest="$3" |
601 | if [[ -z $3 ]] | ||
602 | then | ||
603 | dest=/usr/$(mlibdir) | ||
604 | install -d ${BINDIR}/${dest} || die | ||
605 | fi | ||
606 | else | ||
607 | file="$1" | ||
608 | dest="$2" | ||
609 | if [[ -z $2 ]] | ||
610 | then | ||
611 | dest=/usr/$(mlibdir) | ||
612 | install -d ${BINDIR}/${dest} || die | ||
613 | fi | ||
614 | fi | ||
615 | |||
616 | # install our library | ||
617 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/${dest} || die |
618 | niro | 2 | |
619 | niro | 14029 | # prefer scanelf |
620 | if [[ -x $(type -P scanelf) ]] | ||
621 | niro | 2 | then |
622 | niro | 14481 | local soname="$(scanelf -qBF '%S#p' ${file})" |
623 | niro | 14029 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/${soname} || die |
624 | else | ||
625 | echo -e "${COLYELLOW}minstalllib(): Warning: scanelf not found, using fallback symlink method${COLDEFAULT}" | ||
626 | |||
627 | # create libtool symlinks | ||
628 | # 1. - library.so.1.0.0 -> library.so.1.0 | ||
629 | if [ "${file%.*}" != *.so ] | ||
630 | then | ||
631 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*}) || die | ||
632 | fi | ||
633 | # 2. - library.so.1.0.0 -> library.so.1 | ||
634 | if [ "${file%.*.*}" != *.so ] | ||
635 | then | ||
636 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*}) || die | ||
637 | fi | ||
638 | # 3. - library.so.1.0.0.0 -> library.so.1 | ||
639 | if [ "${file%.*.*.*}" != *.so ] | ||
640 | then | ||
641 | ln ${verbose} -snf $(basename ${file}) ${BINDIR}/${dest}/$(basename ${file%.*.*.*}) || die | ||
642 | fi | ||
643 | niro | 2 | fi |
644 | } | ||
645 | |||
646 | niro | 2166 | mcopy() |
647 | { | ||
648 | local source="$1" | ||
649 | local dest="$2" | ||
650 | local opts | ||
651 | |||
652 | # recursive | ||
653 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
654 | then | ||
655 | niro | 11761 | opts="-R" |
656 | niro | 2166 | source="$2" |
657 | dest="$3" | ||
658 | fi | ||
659 | |||
660 | # recursive | ||
661 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] | ||
662 | then | ||
663 | niro | 11761 | opts="-R -f" |
664 | niro | 2166 | source="$2" |
665 | dest="$3" | ||
666 | fi | ||
667 | |||
668 | niro | 9862 | if [[ $1 = -a ]] |
669 | then | ||
670 | niro | 11761 | opts="-a" |
671 | niro | 9862 | source="$2" |
672 | dest="$3" | ||
673 | fi | ||
674 | |||
675 | niro | 2166 | [[ -z ${source} ]] && die "No source given." |
676 | [[ -z ${dest} ]] && die "No dest given." | ||
677 | |||
678 | cp -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
679 | } | ||
680 | |||
681 | niro | 12652 | mdelete() |
682 | { | ||
683 | local dest="$1" | ||
684 | local opts | ||
685 | |||
686 | # recursive | ||
687 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
688 | then | ||
689 | opts="-r" | ||
690 | dest="$2" | ||
691 | fi | ||
692 | |||
693 | # recursive | ||
694 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] | ||
695 | then | ||
696 | opts="-r -f" | ||
697 | dest="$2" | ||
698 | fi | ||
699 | |||
700 | [[ -z ${dest} ]] && die "No dest given." | ||
701 | niro | 14484 | [[ ! -e ${BINDIR}/${dest} ]] && die "${BINDIR}/${dest} does not exist." |
702 | niro | 12652 | |
703 | rm -v ${opts} ${BINDIR}/${dest} || die | ||
704 | } | ||
705 | |||
706 | niro | 2166 | mmove() |
707 | { | ||
708 | local source="$1" | ||
709 | local dest="$2" | ||
710 | local opts | ||
711 | |||
712 | # force | ||
713 | if [[ $1 = -f ]] | ||
714 | then | ||
715 | niro | 11761 | opts="-f" |
716 | niro | 2166 | source="$2" |
717 | dest="$3" | ||
718 | fi | ||
719 | |||
720 | [[ -z ${source} ]] && die "No source given." | ||
721 | [[ -z ${dest} ]] && die "No dest given." | ||
722 | |||
723 | mv -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
724 | } | ||
725 | |||
726 | # mark directories undeletable | ||
727 | niro | 2 | mkeepdir() |
728 | { | ||
729 | local keepdir | ||
730 | [[ -z "$1" ]] && die "No directory given" | ||
731 | |||
732 | keepdir="$1" | ||
733 | niro | 1113 | install -v -d ${BINDIR}/${keepdir} || die |
734 | niro | 2 | touch ${BINDIR}/${keepdir}/.keep || die |
735 | } | ||
736 | |||
737 | # creates empty files | ||
738 | memptyfile() | ||
739 | { | ||
740 | local file | ||
741 | local path | ||
742 | |||
743 | [[ -z "$1" ]] && die "No file given" | ||
744 | |||
745 | file="$1" | ||
746 | path="$(dirname ${file})" | ||
747 | |||
748 | install -d ${BINDIR}/${path} || die | ||
749 | touch ${BINDIR}/${file} || die | ||
750 | } | ||
751 | |||
752 | mchown() | ||
753 | { | ||
754 | local owner="$1" | ||
755 | local path="$2" | ||
756 | local recursive | ||
757 | |||
758 | # recursive | ||
759 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
760 | then | ||
761 | niro | 11761 | local recursive="-R" |
762 | niro | 2 | local owner="$2" |
763 | local path="$3" | ||
764 | fi | ||
765 | |||
766 | [[ -z ${owner} ]] && die "No owner given." | ||
767 | [[ -z ${path} ]] && die "No path given." | ||
768 | |||
769 | niro | 1113 | chown -v ${recursive} ${owner} ${BINDIR}/${path} || die |
770 | niro | 2 | } |
771 | |||
772 | mchmod() | ||
773 | { | ||
774 | local posix="$1" | ||
775 | local path="$2" | ||
776 | local recursive | ||
777 | |||
778 | # recursive | ||
779 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
780 | then | ||
781 | niro | 11761 | local recursive="-R" |
782 | niro | 2 | local posix="$2" |
783 | local path="$3" | ||
784 | fi | ||
785 | |||
786 | [[ -z ${posix} ]] && die "No posix given." | ||
787 | [[ -z ${path} ]] && die "No path given." | ||
788 | |||
789 | niro | 1113 | chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die |
790 | niro | 2 | } |
791 | |||
792 | mlink() | ||
793 | { | ||
794 | local symlink="$1" | ||
795 | local pathto="$2" | ||
796 | niro | 4806 | local verbose="-v" |
797 | niro | 2 | |
798 | niro | 4806 | # check for busybox as it doesn'tz support 'ln -v' |
799 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" | ||
800 | |||
801 | niro | 2 | [[ -z ${symlink} ]] && die "No symlink given." |
802 | [[ -z ${pathto} ]] && die "No path given." | ||
803 | |||
804 | niro | 4806 | ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
805 | niro | 2 | } |
806 | niro | 7874 | |
807 | # installs systemd units | ||
808 | # minstallunit /path/to/unit-file {destfilename} | ||
809 | minstallunit() | ||
810 | { | ||
811 | local unit | ||
812 | local file | ||
813 | niro | 12655 | local systemdunitdir="/usr/lib/systemd/system" |
814 | niro | 7874 | |
815 | [[ -z "$1" ]] && die "No unit given" | ||
816 | |||
817 | # if no fullpath given use file from sourcedir | ||
818 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
819 | then | ||
820 | file="${SOURCEDIR}/$(mpname)/$1" | ||
821 | else | ||
822 | file="$1" | ||
823 | fi | ||
824 | |||
825 | if [[ -n "$2" ]] | ||
826 | then | ||
827 | unit="$2" | ||
828 | else | ||
829 | unit="$(basename ${file})" | ||
830 | fi | ||
831 | |||
832 | # needed directory | ||
833 | niro | 12655 | install -d ${BINDIR}${prefix}${systemdunitdir} || die |
834 | niro | 7874 | |
835 | # install our initscript | ||
836 | niro | 12655 | install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}${systemdunitdir}/${unit} || die |
837 | niro | 7874 | } |
838 | |||
839 | # installs systemd tmp configs to /etc/tmpfiles.d | ||
840 | # minstalltmp /path/to/tmpdfile {destfilename} | ||
841 | minstalltmp() | ||
842 | { | ||
843 | local tmpdfile | ||
844 | local file | ||
845 | |||
846 | [[ -z "$1" ]] && die "No tmpd file given" | ||
847 | |||
848 | # if no fullpath given use file from sourcedir | ||
849 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
850 | then | ||
851 | file="${SOURCEDIR}/$(mpname)/$1" | ||
852 | else | ||
853 | file="$1" | ||
854 | fi | ||
855 | |||
856 | if [[ -n "$2" ]] | ||
857 | then | ||
858 | tmpdfile="$2" | ||
859 | else | ||
860 | tmpdfile="$(basename ${file})" | ||
861 | fi | ||
862 | |||
863 | # needed directory | ||
864 | install -d ${BINDIR}/etc/tmpfiles.d || die | ||
865 | |||
866 | # install our tmpdfile | ||
867 | niro | 7876 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die |
868 | niro | 7874 | } |
869 | niro | 8469 | |
870 | mclearconfig() | ||
871 | { | ||
872 | local confdir | ||
873 | local prefix="${BINDIR}" | ||
874 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" | ||
875 | |||
876 | # no bindir prefix if requested | ||
877 | case $1 in | ||
878 | -b|--no-bindir) prefix="";; | ||
879 | esac | ||
880 | |||
881 | confdir="$(dirname ${MCONFIG})" | ||
882 | if [[ ! -d ${prefix}/${confdir} ]] | ||
883 | then | ||
884 | install -d ${prefix}/${confdir} || die | ||
885 | fi | ||
886 | : > ${prefix}/${MCONFIG} | ||
887 | } | ||
888 | |||
889 | maddconfig() | ||
890 | { | ||
891 | local argv="$1" | ||
892 | local confdir | ||
893 | local prefix="${BINDIR}" | ||
894 | |||
895 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" | ||
896 | |||
897 | # no bindir prefix if requested | ||
898 | case $1 in | ||
899 | -b|--no-bindir) prefix=""; argv="$2" ;; | ||
900 | esac | ||
901 | |||
902 | niro | 16994 | #[[ -z ${argv} ]] && die "No argument given!" |
903 | niro | 8469 | |
904 | confdir="$(dirname ${MCONFIG})" | ||
905 | if [[ ! -d ${prefix}/${confdir} ]] | ||
906 | then | ||
907 | install -d ${prefix}/${confdir} || die | ||
908 | fi | ||
909 | echo "${argv}" >> ${prefix}/${MCONFIG} || die | ||
910 | } |