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
ecf40bee
Commit
ecf40bee
authored
Mar 05, 2017
by
Vitaly Lipatov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
move single used functions from functions.sh
parent
586688a8
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
83 additions
and
89 deletions
+83
-89
buildmodule.sh
etercifs/buildmodule.sh
+21
-2
checkmodule.sh
etercifs/checkmodule.sh
+37
-0
etercifs
etercifs/etercifs
+6
-22
functions.sh
etercifs/functions.sh
+19
-65
No files found.
etercifs/buildmodule.sh
View file @
ecf40bee
...
...
@@ -10,7 +10,26 @@
.
./functions.sh
detect_host_kernel
detect_kernel_source
()
{
KERNELMANUAL
=
"
$KERNSRC$KERNELVERSION
"
[
-n
"
$KERNELVERSION
"
]
||
KERNELVERSION
=
`
uname
-r
`
if
[
-z
"
$KERNSRC
"
]
;
then
KERNSRC
=
/lib/modules/
$KERNELVERSION
/build
# workaround for missed link on deb-based systems
if
[
!
-d
"
$KERNSRC
"
]
;
then
local
KN
=
/usr/src/linux-headers-
$KERNELVERSION
[
-d
"
$KN
"
]
&&
KERNSRC
=
"
$KN
"
fi
else
# [ -n "$KV" ] || fatal "Set both KERNSRC and KERNVERSION"
KERNELVERSION
=
$(
basename
$(
dirname
"
$KERNSRC
"
))
fi
}
detect_kernel_source
if
[
-r
$SRC_DIR
/dkms.conf
]
&&
which dkms 2>/dev/null
>
/dev/null
]
;
then
echo
echo
"Building
$MODULENAME
$MODULEVERSION
for
$KERNELVERSION
Linux kernel with dkms"
...
...
@@ -18,7 +37,7 @@
else
echo
echo
"Building
$MODULENAME
$MODULEVERSION
for
$KERNELVERSION
Linux kernel (use headers in
$KERNSRC
)"
compile_module
compile_module
||
fatal
install_module
fi
etercifs/checkmodule.sh
View file @
ecf40bee
...
...
@@ -6,6 +6,43 @@
.
./functions.sh
# Heuristic
detect_kernel
()
{
# Detect kernel version
if
[
-f
$KERNSRC
/.kernelrelease
]
;
then
KERNELVERSION
=
`
head
-n
1
$KERNSRC
/.kernelrelease
`
elif
[
-f
$KERNSRC
/include/config/kernel.release
]
;
then
KERNELVERSION
=
`
head
-n
1
$KERNSRC
/include/config/kernel.release
`
elif
[
-f
$KERNSRC
/include/linux/version.h
]
;
then
KERNELVERSION
=
`
head
-n
1
$KERNSRC
/include/linux/version.h |
grep
UTS_RELEASE |
cut
-d
" "
-f
3 |
sed
-e
's|"||g'
`
fi
if
[
-z
"
$KERNELVERSION
"
]
;
then
head
-n
5
$KERNSRC
/Makefile |
sed
-e
"s| ||g"
>
get_version
.
./get_version
KERNELVERSION
=
$VERSION
.
$PATCHLEVEL
.
$SUBLEVEL$EXTRAVERSION
# Hack for strange SUSE 10.2
if
[
-z
"
$EXTRAVERSION
"
]
;
then
KERNELVERSION
=
`
grep
KERNELSRC
$KERNSRC
/Makefile |
head
-n
1 |
sed
-e
"s|.*linux-||g"
`
[
-n
"
$KERNELVERSION
"
]
&&
KERNELVERSION
=
$KERNELVERSION
-
`
basename
$KERNSRC
`
fi
fi
}
check_build_module
()
{
if
[
-r
"
$BUILDDIR
/
$MODULEFILENAME
"
]
;
then
echo
"
$KERNELVERSION
- OK"
BUILTLIST
=
"
$BUILTLIST
---DONE"
else
echo
"can't locate built module
$MODULEFILENAME
"
echo
"
$KERNELVERSION
- FAIL"
BUILTLIST
=
"
$BUILTLIST
---FAILURE"
fi
}
echo
echo
"====================================================================="
echo
"Check build etercifs module for all found kernels"
...
...
etercifs/etercifs
View file @
ecf40bee
...
...
@@ -137,22 +137,6 @@ is_origmoduled()
lsmod |
grep
"^
$ORIGMODULENAME
"
>
/dev/null
}
check_for_old_kernel
()
{
detect_host_kernel
split_kernel_version
if
[
"
$N1
"
-eq
2
]
&&
[
"
$N2
"
-eq
6
]
;
then
if
[
"
$N3
"
-ge
29
]
;
then
return
0
fi
fi
check_for_centos
>
/dev/null
if
[
-n
"
$SPECIFIC_CENTOS
"
]
&&
[
"
$CENTOS
"
-ge
54
]
;
then
return
0
fi
return
1
}
umount_cifs
()
{
WASCIFS
=
...
...
@@ -189,10 +173,10 @@ load_module()
if
[
"
$?
"
-eq
1
]
;
then
return
fi
check_for_old_kernel
if
[
"
$?
"
-eq
1
]
;
then
#
check_for_old_kernel
#
if [ "$?" -eq 1 ]; then
sleep
2s
fi
#
fi
echo
-n
"Removing vanilla kernel module
$ORIGMODULENAME
... "
$RMMOD
$ORIGMODULENAME
--wait
success
...
...
@@ -233,10 +217,10 @@ stop()
if
[
"
$?
"
-eq
1
]
;
then
return
fi
check_for_old_kernel
if
[
"
$?
"
-eq
1
]
;
then
#
check_for_old_kernel
#
if [ "$?" -eq 1 ]; then
sleep
2s
fi
#
fi
echo
-n
"Unloading kernel module
$MODULENAME
... "
is_moduled
||
{
passed
;
return
;
}
$RMMOD
$MODULENAME
...
...
etercifs/functions.sh
View file @
ecf40bee
...
...
@@ -71,6 +71,7 @@ detect_etercifs_sources()
if
[
-z
"
$KERNEL_STRING
"
]
||
[
"
$KERNEL_STRING
"
=
"fixme"
]
;
then
# build fake source table from source list
KERNEL_STRING
=
$(
echo
-e
"[Generic]
\n
$(
list_source_versions |
grep
'^[0-9]'
| sort_dn
)
"
| ./source.sh
"Generic"
"
$KERNELVERSION
"
)
# hack for mc colorifer: "
fi
if
[
-n
"
$KERNEL_STRING
"
]
;
then
...
...
@@ -125,47 +126,6 @@ list_kernel_headers()
done
}
# Heuristic
detect_kernel
()
{
# Detect kernel version
if
[
-f
$KERNSRC
/.kernelrelease
]
;
then
KERNELVERSION
=
`
head
-n
1
$KERNSRC
/.kernelrelease
`
elif
[
-f
$KERNSRC
/include/config/kernel.release
]
;
then
KERNELVERSION
=
`
head
-n
1
$KERNSRC
/include/config/kernel.release
`
elif
[
-f
$KERNSRC
/include/linux/version.h
]
;
then
KERNELVERSION
=
`
head
-n
1
$KERNSRC
/include/linux/version.h |
grep
UTS_RELEASE |
cut
-d
" "
-f
3 |
sed
-e
's|"||g'
`
fi
if
[
-z
"
$KERNELVERSION
"
]
;
then
head
-n
5
$KERNSRC
/Makefile |
sed
-e
"s| ||g"
>
get_version
.
./get_version
KERNELVERSION
=
$VERSION
.
$PATCHLEVEL
.
$SUBLEVEL$EXTRAVERSION
# Hack for strange SUSE 10.2
if
[
-z
"
$EXTRAVERSION
"
]
;
then
KERNELVERSION
=
`
grep
KERNELSRC
$KERNSRC
/Makefile |
head
-n
1 |
sed
-e
"s|.*linux-||g"
`
[
-n
"
$KERNELVERSION
"
]
&&
KERNELVERSION
=
$KERNELVERSION
-
`
basename
$KERNSRC
`
fi
fi
}
detect_host_kernel
()
{
KERNELMANUAL
=
"
$KERNSRC$KERNELVERSION
"
[
-n
"
$KERNELVERSION
"
]
||
KERNELVERSION
=
`
uname
-r
`
if
[
-z
"
$KERNSRC
"
]
;
then
KERNSRC
=
/lib/modules/
$KERNELVERSION
/build
# workaround for missed link on deb-based systems
if
[
!
-d
"
$KERNSRC
"
]
;
then
local
KN
=
/usr/src/linux-headers-
$KERNELVERSION
[
-d
"
$KN
"
]
&&
KERNSRC
=
"
$KN
"
fi
else
# [ -n "$KV" ] || fatal "Set both KERNSRC and KERNVERSION"
KERNELVERSION
=
$(
basename
$(
dirname
"
$KERNSRC
"
))
fi
}
check_headers
()
{
if
[
!
-f
$KERNSRC
/include/linux/version.h
]
&&
[
!
-f
$KERNSRC
/include/generated/uapi/linux/version.h
]
;
then
...
...
@@ -188,7 +148,7 @@ or set KERNELVERSION variable to set correct version (for /lib/modules/KERNELVER
Exiting...
EOF
# FIXME: check detect
exit
1
return
1
fi
}
...
...
@@ -241,17 +201,8 @@ change_cifsversion()
fi
}
c
ompile_module
()
c
heck_kernel_conf
()
{
detect_etercifs_sources
check_headers
||
return
create_builddir
||
return
set_gcc
# SMP build
[
-z
"
$RPM_BUILD_NCPUS
"
]
&&
RPM_BUILD_NCPUS
=
`
/usr/bin/getconf _NPROCESSORS_ONLN
`
[
"
$RPM_BUILD_NCPUS
"
-gt
1
]
&&
MAKESMP
=
"-j
$RPM_BUILD_NCPUS
"
||
MAKESMP
=
""
echo
"Checking the kernel configuration..."
if
[
-r
"
$KERNSRC
/.config"
]
;
then
CONF_STRING
=
`
cat
$KERNSRC
/.config |
grep
CONFIG_CIFS
=
`
...
...
@@ -269,6 +220,21 @@ compile_module()
else
echo
"WARNING: the .config file in kernel source directory does not exist!"
fi
return
0
}
compile_module
()
{
detect_etercifs_sources
check_headers
||
return
create_builddir
||
return
set_gcc
# SMP build
[
-z
"
$RPM_BUILD_NCPUS
"
]
&&
RPM_BUILD_NCPUS
=
`
/usr/bin/getconf _NPROCESSORS_ONLN
`
[
"
$RPM_BUILD_NCPUS
"
-gt
1
]
&&
MAKESMP
=
"-j
$RPM_BUILD_NCPUS
"
||
MAKESMP
=
""
check_kernel_conf
||
return
change_cifsversion
make
$USEGCC
-C
$KERNSRC
here
=
$BUILDDIR
SUBDIRS
=
$BUILDDIR
clean
...
...
@@ -289,18 +255,6 @@ install_module()
install
-m
644
-o
root
-g
root
$BUILDDIR
/
$MODULEFILENAME
$INSTALL_MOD_PATH
/
||
exit
1
echo
"Do depmod -Ae for
$KERNELVERSION
kernel"
depmod
-Ae
$KERNELVERSION
||
exit
1
}
check_build_module
()
{
if
[
-r
"
$BUILDDIR
/
$MODULEFILENAME
"
]
;
then
echo
"
$KERNELVERSION
- OK"
BUILTLIST
=
"
$BUILTLIST
---DONE"
else
echo
"can't locate built module
$MODULEFILENAME
"
echo
"
$KERNELVERSION
- FAIL"
BUILTLIST
=
"
$BUILTLIST
---FAILURE"
fi
depmod
-Ae
$KERNELVERSION
}
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