24 lines
646 B
Ruby
Executable File
24 lines
646 B
Ruby
Executable File
#!/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
|