server-scripts/dkms-update

24 lines
646 B
Plaintext
Raw Normal View History

2016-01-09 10:09:54 +00:00
#!/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