add dkms-update script for kernel

This commit is contained in:
Jörg Thalheim 2016-01-09 10:09:54 +00:00
parent c2801b8fc7
commit 3b3a2f4422
1 changed files with 23 additions and 0 deletions

23
dkms-update Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env ruby
kernel_package = ARGV[0] || "linux"
content = ""
IO.popen(["pacman", "-Ql", kernel_package]) {|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