Last active
December 22, 2015 10:38
-
-
Save Mic92/d6e9e7f2ef9028c2790d to your computer and use it in GitHub Desktop.
Install all dkms modules for a certain kernel version in archlinux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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