Skip to content

Commit

Permalink
Merge pull request #35 from jayofdoom/jay/OptionalFindExtrasPackage
Browse files Browse the repository at this point in the history
Use kernel release for package name on saucy and newer
  • Loading branch information
bflad committed Jan 2, 2014
2 parents 3fefb33 + 3cc505e commit 034dbfe
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions recipes/aufs.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 034dbfe

Please sign in to comment.