3 # Copyright (c) 2009-2016 Andreas Beckmann <anbe@debian.org>
4 # 2010-2016 Russ Allbery <rra@debian.org>
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this script. If not, see <http://www.gnu.org/licenses/>.
19 # This program comes from:
20 # https://anonscm.debian.org/viewvc/pkg-nvidia/packages/nvidia-graphics-drivers/trunk/debian/module/debian/kernel-version?view=markup
21 # The original copyright and license (GPL2+) can be found at:
22 # https://anonscm.debian.org/viewvc/pkg-nvidia/packages/nvidia-graphics-drivers/trunk/debian/copyright?view=markup
24 # Extract the kernel version from the kernel version header file. Takes the
25 # kernel source path as its only argument. If the version header couldn't be
26 # found, print nothing and exit quietly.
31 unless ($ksrc && (-f "$ksrc/include/linux/version.h" || -f "$ksrc/include/generated/uapi/linux/version.h")) {
36 if (open (VERSION, "$ksrc/include/linux/version.h")) {
37 if (defined(VERSION) && ($line = <VERSION>)) {
38 if ($line =~ /"(.+)"/) {
45 if (open (VERSION, "$ksrc/include/generated/utsrelease.h")) {
46 if (defined(VERSION) && ($line = <VERSION>)) {
47 if ($line =~ /UTS_RELEASE *"(.+)"/) {
54 # kernel.release is no longer useful since 3.1.0
55 unless (open (VERSION, "$ksrc/include/config/kernel.release")) {
58 if (defined(VERSION) && ($line = <VERSION>)) {