diff --git a/recipes/aufs.rb b/recipes/aufs.rb index 554998f104..e450264c50 100644 --- a/recipes/aufs.rb +++ b/recipes/aufs.rb @@ -1,16 +1,19 @@ case node['platform'] when 'ubuntu' - # - # The below code copied from: https://github.com/thoward/docker-cookbook/blob/master/recipes/default.rb - # It's not pretty, but gets the job done! - # - # If aufs isn't available, do our best to install the correct - # linux-image-extra package. This is somewhat messy because the - # naming of these packages is very inconsistent across kernel - # versions - extra_package = Mixlib::ShellOut.new("apt-cache search linux-image-extra-`uname -r | grep --only-matching -e [0-9]\.[0-9]\.[0-9]-[0-9]*` | cut -d ' ' -f 1").run_command.stdout.strip + # If aufs isn't available, do our best to install the correct linux-image-extra package. + # Use kernel release for saucy and newer, otherwise use older, more compatible regexp match + if Gem::Version.new(node['platform_version']) < Gem::Version('13.10') + # Original method copied from https://github.com/thoward/docker-cookbook/blob/master/recipes/default.rb + package_name = 'linux-image-extra-' + Mixlib::ShellOut.new("uname -r | grep --only-matching -e [0-9]\.[0-9]\.[0-9]-[0-9]*").run_command.stdout.strip + else + # In modern ubuntu versions, kernel release matches the kernel package name + package_name = 'linux-image-extra-' + node['kernel']['release'] + end + + extra_package = Mixlib::ShellOut.new('apt-cache search ' + package_name).run_command.stdout.split(' ').first + # Wait to strip until after checking for empty, to protect against nil errors unless extra_package.empty? - package extra_package do + package extra_package.strip do not_if 'modprobe -l | grep aufs' end end