#!/usr/bin/env ruby kernel_package = ARGV[0] || "linux" content = "" IO.popen(["pacman", "-Ql", kernel_package]) {|io| content = io.read } kernel = /\/usr\/lib\/modules\/(?.*)\/kernel/.match(content) abort "no kernel version found in package" unless kernel mods = Dir["/usr/src/*"].sort mods.each do |mod| match = /(?[^\/-]+)-(?.+)$/.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