]>
Commit | Line | Data |
---|---|---|
b21d5cb2 | 1 | #!/bin/bash --norc |
644c5241 | 2 | kver=$(uname -r) |
b21d5cb2 | 3 | |
644c5241 | 4 | error() { echo "$@" >&2; } |
b21d5cb2 LB |
5 | |
6 | usage () { | |
644c5241 | 7 | [[ $1 = '-n' ]] && cmd=echo || cmd=error |
b21d5cb2 | 8 | |
80bafe6d | 9 | $cmd "usage: ${0##*/} [--version] [--help] [-v] [-f] [--preload <module>]" |
b21d5cb2 | 10 | $cmd " [--image-version] [--with=<module>]" |
39f87ab2 | 11 | $cmd " [--nocompress]" |
b21d5cb2 LB |
12 | $cmd " <initrd-image> <kernel-version>" |
13 | $cmd "" | |
80bafe6d | 14 | $cmd " (ex: ${0##*/} /boot/initramfs-$kver.img $kver)" |
b21d5cb2 | 15 | |
644c5241 VL |
16 | [[ $1 = '-n' ]] && exit 0 |
17 | exit 1 | |
b21d5cb2 LB |
18 | } |
19 | ||
5bc545ed VL |
20 | # Little helper function for reading args from the commandline. |
21 | # it automatically handles -a b and -a=b variants, and returns 1 if | |
22 | # we need to shift $3. | |
23 | read_arg() { | |
24 | # $1 = arg name | |
25 | # $2 = arg value | |
26 | # $3 = arg parameter | |
27 | local rematch='^[^=]*=(.*)$' | |
28 | if [[ $2 =~ $rematch ]]; then | |
f8bc8990 | 29 | read "$1" <<< "${BASH_REMATCH[1]}" |
5bc545ed VL |
30 | elif [[ $3 != -* ]]; then |
31 | # Only read next arg if it not an arg itself. | |
f8bc8990 HH |
32 | read "$1" <<< "$3" |
33 | # There is no way to shift our callers args, so | |
34 | # return 1 to indicate they should do it instead. | |
35 | return 1 | |
5bc545ed VL |
36 | fi |
37 | } | |
b21d5cb2 | 38 | |
5bc545ed VL |
39 | while (($# > 0)); do |
40 | case ${1%%=*} in | |
41 | --with-usb) read_arg usbmodule "$@" || shift | |
42 | basicmodules="$basicmodules ${usbmodule:-usb-storage}" | |
43 | unset usbmodule;; | |
44 | --with-avail) read_arg modname "$@" || shift | |
45 | basicmodules="$basicmodules $modname";; | |
46 | --with) read_arg modname "$@" || shift | |
47 | basicmodules="$basicmodules $modname";; | |
b21d5cb2 LB |
48 | --version) |
49 | echo "mkinitrd: dracut compatibility wrapper" | |
5bc545ed VL |
50 | exit 0;; |
51 | -v|--verbose) dracut_args="${dracut_args} -v";; | |
79799c95 | 52 | -f|--force) dracut_args="${dracut_args} -f";; |
e74167bd | 53 | --preload) read_arg modname "$@" || shift |
5bc545ed VL |
54 | basicmodules="$basicmodules $modname";; |
55 | --image-version) img_vers=yes;; | |
e74167bd | 56 | --rootfs) read_arg rootfs "$@" || shift |
5bc545ed VL |
57 | dracut_args="${dracut_args} --filesystems $rootfs";; |
58 | --nocompress) dracut_args="$dracut_args --no-compress";; | |
59 | --help) usage -n;; | |
60 | --builtin) ;; | |
b21d5cb2 LB |
61 | --without*) ;; |
62 | --without-usb) ;; | |
63 | --fstab*) ;; | |
b21d5cb2 LB |
64 | --ifneeded) ;; |
65 | --omit-scsi-modules) ;; | |
66 | --omit-ide-modules) ;; | |
67 | --omit-raid-modules) ;; | |
68 | --omit-lvm-modules) ;; | |
69 | --omit-dmraid) ;; | |
70 | --allow-missing) ;; | |
71 | --net-dev*) ;; | |
72 | --noresume) ;; | |
f8bc8990 HH |
73 | --rootdev*) ;; |
74 | --thawdev*) ;; | |
75 | --rootopts*) ;; | |
76 | --root*) ;; | |
77 | --loopdev*) ;; | |
78 | --loopfs*) ;; | |
79 | --loopopts*) ;; | |
80 | --looppath*) ;; | |
81 | --dsdt*) ;; | |
b21d5cb2 | 82 | --bootchart) ;; |
5bc545ed VL |
83 | *) if [[ ! $target ]]; then |
84 | target=$1 | |
85 | elif [[ ! $kernel ]]; then | |
86 | kernel=$1 | |
b21d5cb2 | 87 | else |
5bc545ed VL |
88 | usage |
89 | fi;; | |
b21d5cb2 | 90 | esac |
b21d5cb2 LB |
91 | shift |
92 | done | |
93 | ||
5bc545ed VL |
94 | [[ $target && $kernel ]] || usage |
95 | [[ $img_vers ]] && target="$target-$kernel" | |
b21d5cb2 | 96 | |
5bc545ed | 97 | if [[ $basicmodules ]]; then |
f8bc8990 | 98 | dracut $dracut_args --add-drivers "$basicmodules" "$target" "$kernel" |
b21d5cb2 | 99 | else |
f8bc8990 | 100 | dracut $dracut_args "$target" "$kernel" |
b21d5cb2 | 101 | fi |