nvidia-drivers: set SYSSRC for other kernels than current using. find_fetched_version: tries string as pathname and as version.

This commit is contained in:
Denis Knauf 2013-04-21 17:24:01 +02:00
parent 777cfce5a3
commit 49e5ade7f5
2 changed files with 48 additions and 20 deletions

View file

@ -108,8 +108,18 @@ module LinuxUpdate
class Fetched class Fetched
attr_reader :dir attr_reader :dir
def initialize dir def initialize( dir) @dir = Pathname.new dir end
@dir = Pathname.new dir def config() dir + '.config' end
def <=>( other) version <=> other.version end
def info( text) STDERR.puts "[#{version}] #{text}" end
def linux_sources?
begin
version
true
rescue Base::MakeFailed
false
end
end end
def make *opts, &block def make *opts, &block
@ -138,17 +148,11 @@ module LinuxUpdate
end end
end end
def config
dir + '.config'
end
def configured? def configured?
return @configured if @configured return @configured if @configured
@configured = config.exist? @configured = config.exist?
end end
def <=>( other) version <=> other.version end
def to_s def to_s
r = "#{dir}" r = "#{dir}"
r += " #{version}" if @version r += " #{version}" if @version
@ -165,7 +169,9 @@ module LinuxUpdate
end end
end end
def import_config_from_io( io) open_config('w') {|c| io.each_line {|l| c.print l } } end def import_config_from_io io
open_config('w') {|c| io.each_line {|l| c.print l } }
end
def import_config file_or_io_or_fetched def import_config file_or_io_or_fetched
info "Import config #{file_or_io_or_fetched}" info "Import config #{file_or_io_or_fetched}"
@ -194,12 +200,8 @@ module LinuxUpdate
end end
def install def install
info 'make modules_install install' info 'make firmware_install modules_install install'
make 'modules_install', 'install' make 'firmware_install', 'modules_install', 'install'
end
def info text
STDERR.puts "[#{version}] #{text}"
end end
end end
@ -207,6 +209,18 @@ module LinuxUpdate
class Error <Exception class Error <Exception
end end
class InvalidVersionType <Error class InvalidVersionType <Error
attr_reader :get
def initialize get
@get = get
super "I know Fetched, Versionomy, Release and String, but what is #{get.class}?"
end
end
class NoLinuxSource <Error
attr_reader :get
def initialize get
@get = get
super "Linux sources in #{get} not found."
end
end end
class MakeFailed <Error class MakeFailed <Error
end end
@ -254,20 +268,33 @@ module LinuxUpdate
@fetched ||= Dir[ @sources_base_dir + 'linux-*']. @fetched ||= Dir[ @sources_base_dir + 'linux-*'].
map( &Pathname.method( :new)). map( &Pathname.method( :new)).
select( &:directory?). select( &:directory?).
map {|d| Fetched.new d } map {|d| Fetched.new d }.
select( &:linux_sources?)
end end
def configured() fetched.select &:configured? end def configured() fetched.select &:configured? end
def unconfigured() fetched.reject &:configured? end def unconfigured() fetched.reject &:configured? end
def find_fetched_version version def find_fetched_version version
try =
lambda do |&e|
begin e.call
rescue NoLinuxSource
false
end
end
case version case version
when Fetched then version when Fetched
raise NoLinuxSource, version unless version.linux_sources?
version
when Versionomy::Value then fetched.find {|f| version == f.version } when Versionomy::Value then fetched.find {|f| version == f.version }
when Release then find_fetched_version version.version when Release then find_fetched_version version.version
when String then find_fetched_version Versionomy.parse( version) when Pathname then find_fetched_version Fetched.new( version)
when String
try.() { find_fetched_version Pathname.new version } or
find_fetched_version Versionomy.parse( version)
when nil, false then fetched.max when nil, false then fetched.max
else raise InvalidVersionType, "I know Fetched, Versionomy, Release and String, but what is #{version.class}?" else raise InvalidVersionType, version
end end
end end

View file

@ -5,7 +5,8 @@ NVDSRC="${NVDSRC:-/usr/src/nvidia-drivers}"
which make >/dev/null 2>&1 || exit 0 which make >/dev/null 2>&1 || exit 0
[ -d "${NVDSRC}" ] || exit 0 [ -d "${NVDSRC}" ] || exit 0
V="${1:-`uname -r`}" V="${1:-`uname -r`}"
SYSSRC="/lib/modules/${V}/source"
echo "Build NVIDIA module..." >&2 echo "Build NVIDIA module..." >&2
cd "${NVDSRC}" cd "${NVDSRC}"
exec make module-install PWD="${NVDSRC}" exec make module-install SYSSRC="${SYSSRC}" PWD="${NVDSRC}"