From 6df3bbbe2e0b189ca2a5bfae5625ceb552d7e26a Mon Sep 17 00:00:00 2001 From: Michael Marineau Date: Tue, 2 Sep 2014 15:49:33 -0700 Subject: [PATCH] sdk: assert host system is running Linux 3.7 or later Currently building images on older kernels will fail because mkfs.btrfs enables an incompatible feature 'extref' by default. We never really made this requirement explicit and the SDK in general has continued to maintain compatibility with older kernels. Make the requirement explicit so users will get errors quicker and there is a clear line for what kernel features can be used in the SDK. --- common.sh | 11 +++++++++++ sdk_lib/enter_chroot.sh | 1 + sdk_lib/make_chroot.sh | 1 + 3 files changed, 13 insertions(+) diff --git a/common.sh b/common.sh index 84b5bbee95..5693dc1464 100644 --- a/common.sh +++ b/common.sh @@ -464,6 +464,17 @@ assert_root_user() { fi } +# We depend on some relatively modern kernel features, in particular a +# reasonably recent btrfs version is required to generate images. +# Current requirement: 3.7 added btrfs' extref incompat feature +assert_kernel_version() { + local req_kv="3.7" + local cur_kv=$(uname -r) + if ! cmp_ver ge "${cur_kv}" "${req_kv}"; then + die_notrace "Detected kernel ${cur_kv}, ${req_kv} or later is required" + fi +} + # Check that all arguments are flags; that is, there are no remaining arguments # after parsing from shflags. Allow (with a warning) a single empty-string # argument. diff --git a/sdk_lib/enter_chroot.sh b/sdk_lib/enter_chroot.sh index ad310508b8..3e1603b897 100755 --- a/sdk_lib/enter_chroot.sh +++ b/sdk_lib/enter_chroot.sh @@ -12,6 +12,7 @@ SCRIPT_ROOT=$(readlink -f $(dirname "$0")/..) # Script must be run outside the chroot and as root. assert_outside_chroot assert_root_user +assert_kernel_version # Define command line flags # See http://code.google.com/p/shflags/wiki/Documentation10x diff --git a/sdk_lib/make_chroot.sh b/sdk_lib/make_chroot.sh index 29814f005d..60ed1edcba 100755 --- a/sdk_lib/make_chroot.sh +++ b/sdk_lib/make_chroot.sh @@ -29,6 +29,7 @@ fi # Script must be run outside the chroot and as root. assert_outside_chroot assert_root_user +assert_kernel_version # Define command line flags. # See http://code.google.com/p/shflags/wiki/Documentation10x