linux-update.rb update: tries to determine sources version name and compile version.

This commit is contained in:
Denis Knauf 2013-04-20 21:40:45 +02:00
parent 0c74272f88
commit de8785d5ba
2 changed files with 14 additions and 11 deletions

View file

@ -222,7 +222,7 @@ module LinuxUpdate
end end
attr_reader :releases_uri, :sources_base_dir, :cache_dir attr_reader :releases_uri, :sources_base_dir, :cache_dir
ReleasesURI = 'https://www.kernel.org/releases.json' ReleasesURI = 'https://www.kernel.org/releases.json'
SourcesBaseDir = '/usr/src' SourcesBaseDir = '/usr/src/linux'
CacheDir = '/var/cache/linux-update' CacheDir = '/var/cache/linux-update'
def releases_uri=( uri) @releases_uri = URI.parse uri.to_s end def releases_uri=( uri) @releases_uri = URI.parse uri.to_s end
@ -288,7 +288,7 @@ module LinuxUpdate
def _download uri, file def _download uri, file
dest = Pathname.new "#{file}.download" dest = Pathname.new "#{file}.download"
info "Download #{uri} => #{tarball}" info "Download #{uri} => #{file}"
if true if true
raise DownloadFailed, uri unless Kernel.system( 'wget', '-c', '-O', dest.to_s, uri.to_s) raise DownloadFailed, uri unless Kernel.system( 'wget', '-c', '-O', dest.to_s, uri.to_s)
else else
@ -317,6 +317,8 @@ module LinuxUpdate
end end
end end
# returns tarballs-filename (e.g. linux-3.1.0.tar.xz)
# unpack-path will be @sources_base_dir, but sources dir is unknown.
def download release_or_uri def download release_or_uri
uri = uri =
case release_or_uri case release_or_uri
@ -329,6 +331,7 @@ module LinuxUpdate
tarball = @cache_dir + File.basename( uri.path) tarball = @cache_dir + File.basename( uri.path)
_download uri, tarball unless tarball.exist? _download uri, tarball unless tarball.exist?
_unpack tarball, @sources_base_dir _unpack tarball, @sources_base_dir
tarball.basename
end end
def oldconfig_prepare version = nil, config = nil def oldconfig_prepare version = nil, config = nil
@ -453,8 +456,10 @@ module LinuxUpdate
option :mainline, type: :boolean, aliases: '-m', desc: 'Select mainline versions.' option :mainline, type: :boolean, aliases: '-m', desc: 'Select mainline versions.'
desc 'update [VERSION]', 'Download, compile and install linux-kernel' desc 'update [VERSION]', 'Download, compile and install linux-kernel'
def update version = nil def update version = nil
fetch version tarball = fetch version
all version /^linux-(.*)\.tar\./ =~ tarball.basename.to_s
# try it with version in tarball's name:
all $1
end end
no_commands do no_commands do

View file

@ -1,13 +1,11 @@
#!/usr/bin/env sh #!/usr/bin/env sh
NVDSRC="${NVDSRC:-/usr/src/nvidia-drivers}" NVDSRC="${NVDSRC:-/usr/src/nvidia-drivers}"
[ -e "$0.disabled" ] && exit 0 [ -e "${0}.disabled" ] && exit 0
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"
SYSOUT="/lib/modules/$V/build"
echo Build NVIDIA module... >&2 echo "Build NVIDIA module..." >&2
cd "$SYSSRC" cd "${NVDSRC}"
exec make -C "$NVDSRC" SYSOUT="$SYSOUT" SYSSRC="$SYSSRC" module-install exec make module-install PWD="${NVDSRC}"