Skip to content

Instantly share code, notes, and snippets.

@Mic92
Last active December 22, 2015 10:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Mic92/d6e9e7f2ef9028c2790d to your computer and use it in GitHub Desktop.
Save Mic92/d6e9e7f2ef9028c2790d to your computer and use it in GitHub Desktop.
Install all dkms modules for a certain kernel version in archlinux
#!/usr/bin/env ruby
kernel_package = ARGV[0] || "linux"
content = ""
args = ["pacman", "-Ql", kernel_package]
puts("$ #{args.join(" ")}")
IO.popen(args) {|io| content = io.read }
kernel = /\/usr\/lib\/modules\/(?<version>.*)\/kernel/.match(content)
abort "no kernel version found in package" unless kernel
mods = Dir["/usr/src/*"].sort
mods.each do |mod|
match = /(?<name>[^\/-]+)-(?<version>.+)$/.match(mod)
unless match
puts "Skip module '#{mod}' (not following the name standard)"
next
end
args = ["dkms",
"install",
"-m", "#{match[:name]}/#{match[:version]}",
"-k", kernel[:version]]
puts "$ #{args.join(" ")}"
system(*args)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment