Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
etercifs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
etercifs
Commits
2b19c558
Commit
2b19c558
authored
Mar 04, 2017
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
resort kernel version checking hell
parent
71b74214
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
34 deletions
+36
-34
functions.sh
etercifs/functions.sh
+36
-34
No files found.
etercifs/functions.sh
View file @
2b19c558
...
...
@@ -36,11 +36,32 @@ exit_handler()
exit
$rc
}
kernel_release2
()
{
# 3.0
KERNEL
=
`
echo
$KERNELVERSION
|
sed
's/\([0-9]\+\.[0-9]\+\).*/\1/'
`
}
kernel_release3
()
{
# 2.6.27
KERNEL
=
`
echo
$KERNELVERSION
|
sed
's/\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/'
`
}
kernel_release4
()
{
# 2.6.18-128 or 2.6.29.1
KERNEL
=
`
echo
$KERNELVERSION
|
sed
's/\([0-9]\+\.[0-9]\+\.[0-9]\+[\.-][0-9]\+\).*/\1/'
`
}
split_kernel_version
()
{
N1
=
`
echo
$KERNEL
|
cut
-d
"."
-f
1
`
N2
=
`
echo
$KERNEL
|
cut
-d
"."
-f
2
`
N3
=
`
echo
$KERNEL
|
cut
-d
"."
-f
3 |
cut
-d
"-"
-f
1
`
N4
=
`
echo
$KERNEL
|
cut
-d
"-"
-f
2 |
cut
-d
"."
-f
1
`
}
}
check_for_openvz
()
...
...
@@ -65,10 +86,7 @@ check_for_centos()
echo
"Found RHEL-like distribution."
kernel_release4
N1
=
`
echo
$KERNEL4
|
cut
-d
"."
-f
1
`
N2
=
`
echo
$KERNEL4
|
cut
-d
"."
-f
2
`
N3
=
`
echo
$KERNEL4
|
cut
-d
"."
-f
3 |
cut
-d
"-"
-f
1
`
N4
=
`
echo
$KERNEL4
|
cut
-d
"-"
-f
2 |
cut
-d
"."
-f
1
`
split_kernel_version
CENTOS
=
0
if
[
"
$N1
"
-eq
2
]
&&
[
"
$N2
"
-eq
6
]
;
then
...
...
@@ -146,10 +164,7 @@ check_for_suse()
echo
"Found openSUSE distribution."
kernel_release4
N1
=
`
echo
$KERNEL4
|
cut
-d
"."
-f
1
`
N2
=
`
echo
$KERNEL4
|
cut
-d
"."
-f
2
`
N3
=
`
echo
$KERNEL4
|
cut
-d
"."
-f
3 |
cut
-d
"-"
-f
1
`
N4
=
`
echo
$KERNEL4
|
cut
-d
"-"
-f
2 |
cut
-d
"."
-f
1
`
split_kernel_version
SUSE
=
0
if
[
"
$N1
"
-eq
3
]
&&
[
"
$N2
"
-eq
16
]
;
then
...
...
@@ -208,15 +223,17 @@ detect_etercifs_sources()
KERNEL_STRING
=
'suse13_2'
fi
# end suse specific part
else
FIRSTNUM
=
`
echo
$KERNEL
|
cut
-d
"."
-f
1
`
if
[
"
$FIRSTNUM
"
-eq
2
]
;
then
kernel_release3
split_kernel_version
if
[
"
$N1
"
-eq
2
]
;
then
[
-n
"
$ETERCIFS_SOURCES_LIST
"
]
||
ETERCIFS_SOURCES_LIST
=
$DATADIR
/sources/kernel-source-etercifs-2
*
KERNEL_STRING
=
$KERNEL
echo
"Building for
$KERNEL_STRING
"
elif
[
"
$FIRSTNUM
"
-eq
3
]
||
[
"
$FIRSTNUM
"
-eq
4
]
;
then
[
-n
"
$ETERCIFS_SOURCES_LIST
"
]
||
ETERCIFS_SOURCES_LIST
=
$DATADIR
/sources/kernel-source-etercifs-
$FIRSTNUM
*
else
# some normal and modern kernel
[
-n
"
$ETERCIFS_SOURCES_LIST
"
]
||
ETERCIFS_SOURCES_LIST
=
$DATADIR
/sources/kernel-source-etercifs-
$N1
*
kernel_release2
KERNEL_STRING
=
$KERNEL
2
KERNEL_STRING
=
$KERNEL
echo
"Building for
$KERNEL_STRING
"
fi
fi
...
...
@@ -228,7 +245,7 @@ detect_etercifs_sources()
ETERCIFS_SOURCES_LIST
=
$DATADIR
/sources/kernel-source-etercifs-[0-9]
*
KERNEL_SOURCE_ETERCIFS_LINK
=
`
ls
-1
$ETERCIFS_SOURCES_LIST
|
sort
-r
-V
|
head
-n
1
`
LATEST_SOURCES
=
`
echo
$KERNEL_SOURCE_ETERCIFS_LINK
|
cut
-d
"-"
-f
4
`
echo
"Warning! Couldn't find module sources for the current kernel
$KERNEL
2
(
$LATEST_SOURCES
sources are selected)!"
echo
"Warning! Couldn't find module sources for the current kernel
$KERNEL
(
$LATEST_SOURCES
sources are selected)!"
echo
"Using the latest supported sources - from v
$LATEST_SOURCES
kernel!"
ETERCIFS_SOURCES_LIST
=
$DATADIR
/sources/kernel-source-etercifs
*
fi
...
...
@@ -251,24 +268,6 @@ create_builddir()
BUILDDIR
=
$tmpdir
/
${
FILENAME
%.tar.bz2
}
}
kernel_release2
()
{
# 3.0
KERNEL2
=
`
echo
$KERNELVERSION
|
sed
's/\([0-9]\+\.[0-9]\+\).*/\1/'
`
}
kernel_release
()
{
# 2.6.27
KERNEL
=
`
echo
$KERNELVERSION
|
sed
's/\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/'
`
}
kernel_release4
()
{
# 2.6.18-128 or 2.6.29.1
KERNEL4
=
`
echo
$KERNELVERSION
|
sed
's/\([0-9]\+\.[0-9]\+\.[0-9]\+[\.-][0-9]\+\).*/\1/'
`
}
# Heuristic
detect_kernel
()
{
...
...
@@ -290,13 +289,14 @@ detect_kernel()
[
-n
"
$KERNELVERSION
"
]
&&
KERNELVERSION
=
$KERNELVERSION
-
`
basename
$KERNSRC
`
fi
fi
kernel_release
kernel_release
3
}
detect_host_kernel
()
{
local
KV
=
"
$KERNELVERSION
"
[
-n
"
$KERNELVERSION
"
]
||
KERNELVERSION
=
`
uname
-r
`
kernel_release
kernel_release
3
if
[
-z
"
$KERNSRC
"
]
;
then
KERNSRC
=
/lib/modules/
$KERNELVERSION
/build
...
...
@@ -305,6 +305,8 @@ detect_host_kernel()
local
KN
=
/usr/src/linux-headers-
$KERNELVERSION
[
-d
"
$KN
"
]
&&
KERNSRC
=
"
$KN
"
fi
else
[
-n
"
$KV
"
]
||
fatal
"Set both KERNSRC and KERNVERSION"
fi
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment