diff options
author | Dave Reisner <dreisner@archlinux.org> | 2013-01-13 02:12:03 +0100 |
---|---|---|
committer | Dave Reisner <dreisner@archlinux.org> | 2013-01-13 02:12:03 +0100 |
commit | 1fb67220211a6b49870107bff052623c51ecbffb (patch) | |
tree | fc47d210c401b916a8985d4eb6b3c88d3ba4d129 /mkinitcpio | |
parent | be1e0c6506ed892a7e8031d69b1a7110a79070d4 (diff) | |
download | mkinitcpio-1fb67220211a6b49870107bff052623c51ecbffb.tar.gz mkinitcpio-1fb67220211a6b49870107bff052623c51ecbffb.tar.xz |
factor out kver detection to functions file
This leaves bash completion with a duplication, but this is intentional
to avoid pulling in the entire functions file and worrying about
pollution.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Diffstat (limited to 'mkinitcpio')
-rwxr-xr-x | mkinitcpio | 19 |
1 files changed, 1 insertions, 18 deletions
@@ -84,12 +84,6 @@ cleanup() { resolve_kernver() { local kernel=$1 offset kver - # this is intentionally very loose. only ensure that we're - # dealing with some sort of string that starts with something - # resembling dotted decimal notation. remember that there's no - # requirement for CONFIG_LOCALVERSION to be set. - local kver_validator='^[[:digit:]]+(\.[[:digit:]]+)+' - if [[ -z $kernel ]]; then uname -r return 0 @@ -105,18 +99,7 @@ resolve_kernver() { return 1 fi - # scrape the version out of the kernel image. locate the offset - # to the version string by reading 2 bytes out of image at at - # address 0x20E. this leads us to a string of, at most, 128 bytes. - # read the first word from this string as the kernel version. - offset=$(hexdump -s 526 -n 2 -e '"%0d"' "$kernel") - read kver _ < \ - <(dd if="$kernel" bs=1 count=127 skip=$(( offset + 0x200 )) 2>/dev/null) - - if [[ $kver =~ $kver_validator ]]; then - printf '%s' "$kver" - return 0 - fi + kver "$kernel" && return error "invalid kernel specified: \`%s'" "$_optkver" |