Annotation of /trunk/include/mtools.sminc
Parent Directory
|
Revision Log
Revision 10935 -
(hide annotations)
(download)
Sun Feb 5 14:10:16 2012 UTC (12 years, 3 months ago) by niro
File size: 16515 byte(s)
Sun Feb 5 14:10:16 2012 UTC (12 years, 3 months ago) by niro
File size: 16515 byte(s)
-respect prefix for newer systemd
1 | niro | 2 | # $Header: /magellan-cvs/smage/include/mtools.sminc,v 1.39 2008/04/20 08:28:23 niro Exp $ |
2 | # some special build tools | ||
3 | |||
4 | # automatical inherit mtools.minc | ||
5 | # this will provide the service management functions | ||
6 | INHERITS="${INHERITS} mtools" | ||
7 | |||
8 | niro | 4804 | # get the pname right with splitpackages |
9 | mpname() | ||
10 | { | ||
11 | local pname="${PNAME}" | ||
12 | niro | 4807 | [[ ! -z ${SPLIT_PACKAGE_BASE} ]] && pname="${SPLIT_PACKAGE_BASE}" |
13 | niro | 4804 | |
14 | echo "${pname}" | ||
15 | } | ||
16 | |||
17 | niro | 2 | # installs initscripts |
18 | # minstallrc /path/to/rc-script {destfilename} | ||
19 | minstallrc() | ||
20 | { | ||
21 | local rcscript | ||
22 | local file | ||
23 | |||
24 | [[ -z "$1" ]] && die "No initscript given" | ||
25 | |||
26 | # if no fullpath given use file from sourcedir | ||
27 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
28 | then | ||
29 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
30 | niro | 2 | else |
31 | file="$1" | ||
32 | fi | ||
33 | |||
34 | if [[ -n "$2" ]] | ||
35 | then | ||
36 | rcscript="$2" | ||
37 | else | ||
38 | rcscript="$(basename ${file})" | ||
39 | fi | ||
40 | |||
41 | # needed directory | ||
42 | install -d ${BINDIR}/etc/rc.d/init.d || die | ||
43 | |||
44 | # install our initscript | ||
45 | niro | 1113 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/etc/rc.d/init.d/${rcscript} || die |
46 | niro | 2 | } |
47 | |||
48 | # installs environment files | ||
49 | # minstallenv /path/to/envdfile {destfilename} | ||
50 | minstallenv() | ||
51 | { | ||
52 | local envdfile | ||
53 | local file | ||
54 | |||
55 | [[ -z "$1" ]] && die "No envd file given" | ||
56 | |||
57 | # if no fullpath given use file from sourcedir | ||
58 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
59 | then | ||
60 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
61 | niro | 2 | else |
62 | file="$1" | ||
63 | fi | ||
64 | |||
65 | if [[ -n "$2" ]] | ||
66 | then | ||
67 | envdfile="$2" | ||
68 | else | ||
69 | envdfile="$(basename ${file})" | ||
70 | fi | ||
71 | |||
72 | # needed directory | ||
73 | install -d ${BINDIR}/etc/env.d || die | ||
74 | |||
75 | # install our envfile | ||
76 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/env.d/${envdfile} || die |
77 | niro | 2 | } |
78 | |||
79 | # installs system configuration files | ||
80 | # minstallconf /path/to/confdfile {destfilename} | ||
81 | minstallconf() | ||
82 | { | ||
83 | local confdfile | ||
84 | local file | ||
85 | |||
86 | [[ -z "$1" ]] && die "No confd file given" | ||
87 | |||
88 | # if no fullpath given use file from sourcedir | ||
89 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
90 | then | ||
91 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
92 | niro | 2 | else |
93 | file="$1" | ||
94 | fi | ||
95 | |||
96 | if [[ -n "$2" ]] | ||
97 | then | ||
98 | confdfile="$2" | ||
99 | else | ||
100 | confdfile="$(basename ${file})" | ||
101 | fi | ||
102 | |||
103 | # needed directory | ||
104 | install -d ${BINDIR}/etc/conf.d || die | ||
105 | |||
106 | # install our configfile | ||
107 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/conf.d/${confdfile} || die |
108 | niro | 2 | } |
109 | |||
110 | # installs system configuration files to etc | ||
111 | # minstalletc /path/to/etcfile {destfilename} {destdir path} | ||
112 | minstalletc() | ||
113 | { | ||
114 | local etcfile | ||
115 | local file | ||
116 | local destdir | ||
117 | |||
118 | [[ -z "$1" ]] && die "No etc file given" | ||
119 | |||
120 | # if no fullpath given use file from sourcedir | ||
121 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
122 | then | ||
123 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
124 | niro | 2 | else |
125 | file="$1" | ||
126 | fi | ||
127 | |||
128 | if [[ -n "$2" ]] | ||
129 | then | ||
130 | etcfile="$2" | ||
131 | else | ||
132 | etcfile="$(basename ${file})" | ||
133 | fi | ||
134 | |||
135 | if [[ -n "$3" ]] | ||
136 | then | ||
137 | destdir="$3" | ||
138 | else | ||
139 | destdir="/etc" | ||
140 | fi | ||
141 | |||
142 | # needed directory | ||
143 | install -d ${BINDIR}/${destdir} || die | ||
144 | |||
145 | # install our configfile | ||
146 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${etcfile} || die |
147 | niro | 2 | } |
148 | |||
149 | niro | 2032 | minstalludevrule() |
150 | niro | 2031 | { |
151 | local udevrule | ||
152 | local file | ||
153 | |||
154 | [[ -z "$1" ]] && die "No udev rule given" | ||
155 | |||
156 | # if no fullpath given use file from sourcedir | ||
157 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
158 | then | ||
159 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
160 | niro | 2031 | else |
161 | file="$1" | ||
162 | fi | ||
163 | |||
164 | if [[ -n "$2" ]] | ||
165 | then | ||
166 | udevrule="$2" | ||
167 | else | ||
168 | udevrule="$(basename ${file})" | ||
169 | fi | ||
170 | |||
171 | # needed directory | ||
172 | install -d ${BINDIR}/etc/udev/rules.d || die | ||
173 | |||
174 | niro | 2032 | # install our udev rule |
175 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/udev/rules.d/${udevrule} || die | ||
176 | niro | 2031 | } |
177 | |||
178 | niro | 2032 | minstalludevhelper() |
179 | { | ||
180 | local udevhelper | ||
181 | local file | ||
182 | |||
183 | [[ -z "$1" ]] && die "No udev helper given" | ||
184 | |||
185 | # if no fullpath given use file from sourcedir | ||
186 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
187 | then | ||
188 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
189 | niro | 2032 | else |
190 | file="$1" | ||
191 | fi | ||
192 | |||
193 | if [[ -n "$2" ]] | ||
194 | then | ||
195 | udevhelper="$2" | ||
196 | else | ||
197 | udevhelper="$(basename ${file})" | ||
198 | fi | ||
199 | |||
200 | # needed directory | ||
201 | install -d ${BINDIR}/lib/udev || die | ||
202 | |||
203 | # install our udev-helper | ||
204 | install -v -m 0755 -o root -g root ${file} ${BINDIR}/lib/udev/${udevhelper} || die | ||
205 | } | ||
206 | |||
207 | niro | 4579 | minstallhalinformation() |
208 | { | ||
209 | local halrule | ||
210 | local file | ||
211 | |||
212 | [[ -z "$1" ]] && die "No hal rule given" | ||
213 | |||
214 | # if no fullpath given use file from sourcedir | ||
215 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
216 | then | ||
217 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
218 | niro | 4579 | else |
219 | file="$1" | ||
220 | fi | ||
221 | |||
222 | if [[ -n "$2" ]] | ||
223 | then | ||
224 | halrule="$2" | ||
225 | else | ||
226 | halrule="$(basename ${file})" | ||
227 | fi | ||
228 | |||
229 | # needed directory | ||
230 | install -d ${BINDIR}/usr/share/hal/fdi/information/20thirdparty || die | ||
231 | |||
232 | # install our udev rule | ||
233 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/information/20thirdparty/${halrule} || die | ||
234 | } | ||
235 | |||
236 | minstallhalpolicy() | ||
237 | { | ||
238 | local halrule | ||
239 | local file | ||
240 | |||
241 | [[ -z "$1" ]] && die "No hal rule given" | ||
242 | |||
243 | # if no fullpath given use file from sourcedir | ||
244 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
245 | then | ||
246 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
247 | niro | 4579 | else |
248 | file="$1" | ||
249 | fi | ||
250 | |||
251 | if [[ -n "$2" ]] | ||
252 | then | ||
253 | halrule="$2" | ||
254 | else | ||
255 | halrule="$(basename ${file})" | ||
256 | fi | ||
257 | |||
258 | # needed directory | ||
259 | install -d ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty || die | ||
260 | |||
261 | # install our udev rule | ||
262 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/policy/20thirdparty/${halrule} || die | ||
263 | } | ||
264 | |||
265 | minstallhalpreprobe() | ||
266 | { | ||
267 | local halrule | ||
268 | local file | ||
269 | |||
270 | [[ -z "$1" ]] && die "No hal rule given" | ||
271 | |||
272 | # if no fullpath given use file from sourcedir | ||
273 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
274 | then | ||
275 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
276 | niro | 4579 | else |
277 | file="$1" | ||
278 | fi | ||
279 | |||
280 | if [[ -n "$2" ]] | ||
281 | then | ||
282 | halrule="$2" | ||
283 | else | ||
284 | halrule="$(basename ${file})" | ||
285 | fi | ||
286 | |||
287 | # needed directory | ||
288 | install -d ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor || die | ||
289 | |||
290 | # install our udev rule | ||
291 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/usr/share/hal/fdi/preprobe/10osvendor/${halrule} || die | ||
292 | } | ||
293 | |||
294 | niro | 2 | # install man files to appropiate dirs |
295 | # minstallman /path/to/manfile.foo | ||
296 | minstallman() | ||
297 | { | ||
298 | local manfile | ||
299 | local mandir | ||
300 | local file | ||
301 | |||
302 | [[ -z "$@" ]] && die "No man file given" | ||
303 | |||
304 | for file in $@ | ||
305 | do | ||
306 | manfile="$(basename ${file})" | ||
307 | mandir="man${manfile##*.}" | ||
308 | |||
309 | install -d ${BINDIR}/usr/share/man/${mandir} || die | ||
310 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/man/${mandir}/${manfile} || die |
311 | niro | 2 | done |
312 | } | ||
313 | |||
314 | # install info files to appropiate dirs | ||
315 | # minstallinfo /path/to/infofile.foo | ||
316 | minstallinfo() | ||
317 | { | ||
318 | local file | ||
319 | |||
320 | [[ -z "$@" ]] && die "No info file given" | ||
321 | |||
322 | for file in $@ | ||
323 | do | ||
324 | install -d ${BINDIR}/usr/share/info || die | ||
325 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/info/$(basename ${file}) || die |
326 | niro | 2 | done |
327 | } | ||
328 | |||
329 | # install html files to appropiate dirs | ||
330 | # minstallhtml /path/to/infofile.foo | ||
331 | minstallhtml() | ||
332 | { | ||
333 | local file | ||
334 | local subfile | ||
335 | local prefix | ||
336 | local subprefix | ||
337 | |||
338 | # handle prefix | ||
339 | case "$1" in | ||
340 | --prefix|-p) shift; prefix="$1"; shift ;; | ||
341 | esac | ||
342 | |||
343 | [[ -z "$@" ]] && die "No html file given" | ||
344 | |||
345 | for file in $@ | ||
346 | do | ||
347 | install -d ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html${prefix} || die | ||
348 | |||
349 | if [[ -d ${file} ]] | ||
350 | then | ||
351 | for subfile in ${file}/* | ||
352 | do | ||
353 | subprefix="$(dirname ${subfile/$(dirname ${file})/})" | ||
354 | subprefix="${prefix}${subprefix}/" | ||
355 | |||
356 | minstallhtml --prefix ${subprefix} ${subfile} || die | ||
357 | done | ||
358 | else | ||
359 | niro | 1113 | install -v -m0644 ${file} ${BINDIR}/usr/share/doc/${PNAME}-${PVER}/html/${prefix}$(basename ${file}) || die |
360 | niro | 2 | fi |
361 | done | ||
362 | } | ||
363 | |||
364 | # install pixmaps to appropiate dirs | ||
365 | # minstallpixmap srcname destname {/path/to} | ||
366 | minstallpixmap() | ||
367 | { | ||
368 | local file | ||
369 | local destdir | ||
370 | local destfile | ||
371 | |||
372 | [[ -z "$1" ]] && die "No pixmap given" | ||
373 | |||
374 | # if no fullpath given use file from sourcedir | ||
375 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
376 | then | ||
377 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
378 | niro | 2 | else |
379 | file="$1" | ||
380 | fi | ||
381 | |||
382 | if [[ -n "$2" ]] | ||
383 | then | ||
384 | destfile="$2" | ||
385 | else | ||
386 | destfile="$(basename ${file})" | ||
387 | fi | ||
388 | |||
389 | if [[ -n "$3" ]] | ||
390 | then | ||
391 | destdir="$3" | ||
392 | else | ||
393 | destdir="/usr/share/pixmaps" | ||
394 | fi | ||
395 | |||
396 | # needed directory | ||
397 | install -d ${BINDIR}/${destdir} || die | ||
398 | |||
399 | # install our pixmap | ||
400 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/${destdir}/${destfile} || die |
401 | niro | 2 | } |
402 | |||
403 | # installs pam configuration files | ||
404 | # minstallpam /path/to/pamfile {destfilename} | ||
405 | minstallpam() | ||
406 | { | ||
407 | local pamfile | ||
408 | local file | ||
409 | |||
410 | [[ -z "$1" ]] && die "No pam file given" | ||
411 | |||
412 | # if no fullpath given use file from sourcedir | ||
413 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
414 | then | ||
415 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$1" |
416 | niro | 2 | else |
417 | file="$1" | ||
418 | fi | ||
419 | |||
420 | if [[ -n "$2" ]] | ||
421 | then | ||
422 | pamfile="$2" | ||
423 | else | ||
424 | pamfile="$(basename ${file})" | ||
425 | fi | ||
426 | |||
427 | # needed directory | ||
428 | install -d ${BINDIR}/etc/pam.d || die | ||
429 | |||
430 | # install our configfile | ||
431 | niro | 1113 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/pam.d/${pamfile} || die |
432 | niro | 2 | } |
433 | |||
434 | # installs cronjobs | ||
435 | # minstallcron [hourly|daily|weekly|monthly] /path/to/cronfile {destfilename} | ||
436 | minstallcron() | ||
437 | { | ||
438 | local cronfile | ||
439 | local loop | ||
440 | local file | ||
441 | |||
442 | [[ -z "$1" ]] && die "No loop rythem given [hourly|daily|weekly|monthly]" | ||
443 | [[ -z "$2" ]] && die "No cronfile given" | ||
444 | |||
445 | loop="$1" | ||
446 | |||
447 | # if no fullpath given use file from sourcedir | ||
448 | if [[ -z $(dirname $2) ]] || [[ $(dirname $2) = . ]] | ||
449 | then | ||
450 | niro | 4804 | file="${SOURCEDIR}/$(mpname)/$2" |
451 | niro | 2 | else |
452 | file="$2" | ||
453 | fi | ||
454 | |||
455 | if [[ -n "$3" ]] | ||
456 | then | ||
457 | cronfile="$3" | ||
458 | else | ||
459 | cronfile="$(basename ${file})" | ||
460 | fi | ||
461 | |||
462 | # needed directory | ||
463 | install -m0750 -d ${BINDIR}/etc/cron.${loop} || die | ||
464 | |||
465 | # install our cronfile | ||
466 | niro | 1113 | install -v -m 0750 -o root -g root ${file} ${BINDIR}/etc/cron.${loop}/${cronfile} || die |
467 | niro | 2 | } |
468 | |||
469 | |||
470 | # installs logrotate configuration files | ||
471 | 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 | opts="--recursive" | ||
640 | source="$2" | ||
641 | dest="$3" | ||
642 | fi | ||
643 | |||
644 | # recursive | ||
645 | if [[ $1 = -rf ]] || [[ $1 = -fr ]] || [[ $1 = -Rf ]] || [[ $1 = -fR ]] | ||
646 | then | ||
647 | opts="--recursive --force" | ||
648 | source="$2" | ||
649 | dest="$3" | ||
650 | fi | ||
651 | |||
652 | niro | 9862 | if [[ $1 = -a ]] |
653 | then | ||
654 | opts="--archive" | ||
655 | 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 | mmove() | ||
666 | { | ||
667 | local source="$1" | ||
668 | local dest="$2" | ||
669 | local opts | ||
670 | |||
671 | # force | ||
672 | if [[ $1 = -f ]] | ||
673 | then | ||
674 | niro | 4805 | opts="--force" |
675 | niro | 2166 | source="$2" |
676 | dest="$3" | ||
677 | fi | ||
678 | |||
679 | [[ -z ${source} ]] && die "No source given." | ||
680 | [[ -z ${dest} ]] && die "No dest given." | ||
681 | |||
682 | mv -v ${opts} ${source} ${BINDIR}/${dest} || die | ||
683 | } | ||
684 | |||
685 | # mark directories undeletable | ||
686 | niro | 2 | mkeepdir() |
687 | { | ||
688 | local keepdir | ||
689 | [[ -z "$1" ]] && die "No directory given" | ||
690 | |||
691 | keepdir="$1" | ||
692 | niro | 1113 | install -v -d ${BINDIR}/${keepdir} || die |
693 | niro | 2 | touch ${BINDIR}/${keepdir}/.keep || die |
694 | } | ||
695 | |||
696 | # creates empty files | ||
697 | memptyfile() | ||
698 | { | ||
699 | local file | ||
700 | local path | ||
701 | |||
702 | [[ -z "$1" ]] && die "No file given" | ||
703 | |||
704 | file="$1" | ||
705 | path="$(dirname ${file})" | ||
706 | |||
707 | install -d ${BINDIR}/${path} || die | ||
708 | touch ${BINDIR}/${file} || die | ||
709 | } | ||
710 | |||
711 | mchown() | ||
712 | { | ||
713 | local owner="$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 owner="$2" | ||
722 | local path="$3" | ||
723 | fi | ||
724 | |||
725 | [[ -z ${owner} ]] && die "No owner given." | ||
726 | [[ -z ${path} ]] && die "No path given." | ||
727 | |||
728 | niro | 1113 | chown -v ${recursive} ${owner} ${BINDIR}/${path} || die |
729 | niro | 2 | } |
730 | |||
731 | mchmod() | ||
732 | { | ||
733 | local posix="$1" | ||
734 | local path="$2" | ||
735 | local recursive | ||
736 | |||
737 | # recursive | ||
738 | if [[ $1 = -r ]] || [[ $1 = -R ]] | ||
739 | then | ||
740 | local recursive="--recursive" | ||
741 | local posix="$2" | ||
742 | local path="$3" | ||
743 | fi | ||
744 | |||
745 | [[ -z ${posix} ]] && die "No posix given." | ||
746 | [[ -z ${path} ]] && die "No path given." | ||
747 | |||
748 | niro | 1113 | chmod -v ${recursive} ${posix} ${BINDIR}/${path} || die |
749 | niro | 2 | } |
750 | |||
751 | mlink() | ||
752 | { | ||
753 | local symlink="$1" | ||
754 | local pathto="$2" | ||
755 | niro | 4806 | local verbose="-v" |
756 | niro | 2 | |
757 | niro | 4806 | # check for busybox as it doesn'tz support 'ln -v' |
758 | [[ $(readlink $(which ln)) = */busybox ]] && verbose="" | ||
759 | |||
760 | niro | 2 | [[ -z ${symlink} ]] && die "No symlink given." |
761 | [[ -z ${pathto} ]] && die "No path given." | ||
762 | |||
763 | niro | 4806 | ln ${verbose} -snf ${symlink} ${BINDIR}/${pathto} || die |
764 | niro | 2 | } |
765 | niro | 7874 | |
766 | # installs systemd units | ||
767 | # minstallunit /path/to/unit-file {destfilename} | ||
768 | minstallunit() | ||
769 | { | ||
770 | local unit | ||
771 | local file | ||
772 | niro | 10935 | local prefix |
773 | niro | 7874 | |
774 | [[ -z "$1" ]] && die "No unit given" | ||
775 | |||
776 | niro | 10935 | # get the right prefix for newer systemd |
777 | [[ -x /bin/systemctl ]] && prefix="" | ||
778 | [[ -x /usr/bin/systemctl ]] && prefix="/usr" | ||
779 | |||
780 | niro | 7874 | # if no fullpath given use file from sourcedir |
781 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
782 | then | ||
783 | file="${SOURCEDIR}/$(mpname)/$1" | ||
784 | else | ||
785 | file="$1" | ||
786 | fi | ||
787 | |||
788 | if [[ -n "$2" ]] | ||
789 | then | ||
790 | unit="$2" | ||
791 | else | ||
792 | unit="$(basename ${file})" | ||
793 | fi | ||
794 | |||
795 | # needed directory | ||
796 | niro | 10935 | install -d ${BINDIR}${prefix}/lib/systemd/system || die |
797 | niro | 7874 | |
798 | # install our initscript | ||
799 | niro | 10935 | install -v -m 0644 -o root -g root ${file} ${BINDIR}${prefix}/lib/systemd/system/${unit} || die |
800 | niro | 7874 | } |
801 | |||
802 | # installs systemd tmp configs to /etc/tmpfiles.d | ||
803 | # minstalltmp /path/to/tmpdfile {destfilename} | ||
804 | minstalltmp() | ||
805 | { | ||
806 | local tmpdfile | ||
807 | local file | ||
808 | |||
809 | [[ -z "$1" ]] && die "No tmpd file given" | ||
810 | |||
811 | # if no fullpath given use file from sourcedir | ||
812 | if [[ -z $(dirname $1) ]] || [[ $(dirname $1) = . ]] | ||
813 | then | ||
814 | file="${SOURCEDIR}/$(mpname)/$1" | ||
815 | else | ||
816 | file="$1" | ||
817 | fi | ||
818 | |||
819 | if [[ -n "$2" ]] | ||
820 | then | ||
821 | tmpdfile="$2" | ||
822 | else | ||
823 | tmpdfile="$(basename ${file})" | ||
824 | fi | ||
825 | |||
826 | # needed directory | ||
827 | install -d ${BINDIR}/etc/tmpfiles.d || die | ||
828 | |||
829 | # install our tmpdfile | ||
830 | niro | 7876 | install -v -m 0644 -o root -g root ${file} ${BINDIR}/etc/tmpfiles.d/${tmpdfile} || die |
831 | niro | 7874 | } |
832 | niro | 8469 | |
833 | mclearconfig() | ||
834 | { | ||
835 | local confdir | ||
836 | local prefix="${BINDIR}" | ||
837 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" | ||
838 | |||
839 | # no bindir prefix if requested | ||
840 | case $1 in | ||
841 | -b|--no-bindir) prefix="";; | ||
842 | esac | ||
843 | |||
844 | confdir="$(dirname ${MCONFIG})" | ||
845 | if [[ ! -d ${prefix}/${confdir} ]] | ||
846 | then | ||
847 | install -d ${prefix}/${confdir} || die | ||
848 | fi | ||
849 | : > ${prefix}/${MCONFIG} | ||
850 | } | ||
851 | |||
852 | maddconfig() | ||
853 | { | ||
854 | local argv="$1" | ||
855 | local confdir | ||
856 | local prefix="${BINDIR}" | ||
857 | |||
858 | [[ -z ${MCONFIG} ]] && die "No \$MCONFIG given!" | ||
859 | |||
860 | # no bindir prefix if requested | ||
861 | case $1 in | ||
862 | -b|--no-bindir) prefix=""; argv="$2" ;; | ||
863 | esac | ||
864 | |||
865 | [[ -z ${argv} ]] && die "No argument given!" | ||
866 | |||
867 | confdir="$(dirname ${MCONFIG})" | ||
868 | if [[ ! -d ${prefix}/${confdir} ]] | ||
869 | then | ||
870 | install -d ${prefix}/${confdir} || die | ||
871 | fi | ||
872 | echo "${argv}" >> ${prefix}/${MCONFIG} || die | ||
873 | } |