diff options
author | Dave Reisner <d@falconindy.com> | 2011-06-06 07:38:49 +0200 |
---|---|---|
committer | Dave Reisner <d@falconindy.com> | 2011-06-16 20:27:02 +0200 |
commit | 031c99d6d1fd44bf6cc28395867b8adf432b9115 (patch) | |
tree | 4435e9081b6b3e9165cdc7fe0bbd9bac3bfb13a9 | |
parent | c178ddde535dddce27fb230cdd1f501f8eb3ba9b (diff) | |
download | mkinitcpio-031c99d6d1fd44bf6cc28395867b8adf432b9115.tar.gz mkinitcpio-031c99d6d1fd44bf6cc28395867b8adf432b9115.tar.xz |
mkinitcpio: allow specifying kernel ver as path to image
update the example.preset to show this syntax as an alternative
Signed-off-by: Dave Reisner <d@falconindy.com>
-rwxr-xr-x | mkinitcpio | 29 | ||||
-rw-r--r-- | mkinitcpio.d/example.preset | 2 |
2 files changed, 29 insertions, 2 deletions
@@ -80,6 +80,25 @@ sighandler() { exit 1 } +get_kernver() { + local kernel=$1 + + if [[ "${kernel:0:1}" != / ]]; then + echo $kernel + return 0 + fi + + [[ -r "$kernel" ]] || return 1 + + read _ kernver < <(file -b "$BASEDIR$kernel" | grep -o 'version [^ ]\+') + if [[ "$kernver" && -e "$BASEDIR/lib/modules/$kernver" ]]; then + echo "$kernver" + return 0 + fi + + return 1 +} + trap sighandler TERM INT while getopts ':c:k:sb:g:p:m:vH:LMhS:' arg; do @@ -90,7 +109,7 @@ while getopts ':c:k:sb:g:p:m:vH:LMhS:' arg; do fi case "${arg}" in c) CONFIG="${OPTARG}" ;; - k) KERNELVERSION="${OPTARG}" ;; + k) optkver=$OPTARG ;; s) SAVELIST="y"; ;; b) BASEDIR="${OPTARG}" ;; g) GENIMG="${OPTARG}" ;; @@ -122,6 +141,14 @@ while getopts ':c:k:sb:g:p:m:vH:LMhS:' arg; do done shift $((${OPTIND} - 1)) +if [[ $optkver ]]; then + if ! KERNELVERSION=$(get_kernver "$optkver"); then + echo "error: '$optkver' is an invalid kernel specifier" + cleanup + exit 1 + fi +fi + # use preset $PRESET if [ -n "${PRESET}" ]; then if [ -f "${PRESETDIR}/${PRESET}.preset" ]; then diff --git a/mkinitcpio.d/example.preset b/mkinitcpio.d/example.preset index 3fb32f1..93a8f92 100644 --- a/mkinitcpio.d/example.preset +++ b/mkinitcpio.d/example.preset @@ -7,7 +7,7 @@ PRESETS=('default' 'fallback') # note for distribution kernels: this should be in a separate file # and read like this: # . /etc/mkinitcpio.d/exmaple.kver -ALL_kver='2.6.24-ARCH' +ALL_kver='/boot/vmlinuz26' ALL_config='/etc/mkinitcpio.conf' # presetname_kver - the kernel version (omit if ALL_kver should be used) |