Commit cf0c773f authored by Vitaly Lipatov's avatar Vitaly Lipatov

drop a half of kernel detection dummy code, use aggregate tarball with source

parent 2b19c558
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
dkms_build_module dkms_build_module
else else
echo echo
echo "Building $MODULENAME $MODULEVERSION for $KERNELVERSION Linux kernel (headers in $KERNSRC)" echo "Building $MODULENAME $MODULEVERSION for $KERNELVERSION Linux kernel (use headers in $KERNSRC)"
compile_module compile_module
install_module install_module
fi fi
......
File mode changed from 100644 to 100755
#!/bin/sh #!/bin/sh
# 2007-2010 (c) Etersoft http://etersoft.ru # 2007-2010, 2017 (c) Etersoft http://etersoft.ru
# Vitaly Lipatov <lav@etersoft.ru> # Vitaly Lipatov <lav@etersoft.ru>
# Konstantin Baev <kipruss@etersoft.ru> # Konstantin Baev <kipruss@etersoft.ru>
# Pavel Shilovsky <piastry@etersoft.ru> # Pavel Shilovsky <piastry@etersoft.ru>
# Konstantin Artyushkin <akv@etersoft.ru>
# GNU Public License # GNU Public License
# Build kernel modules for all kernel and all platforms # Build kernel modules for all kernel and all platforms
PACKAGEINFO=@DATADIR@/package.conf
if [ -f "$PACKAGEINFO" ] ; then
. $PACKAGEINFO
else
fatal "Not found package information file $PACKAGEINFO"
fi
CONFIGFILE=@SYSCONFIGDIR@/etercifs.conf
if [ -f $CONFIGFILE ] ; then
. $CONFIGFILE
else
fatal "Not found configuration file $CONFIGFILE"
fi
fatal() fatal()
{ {
...@@ -28,13 +15,14 @@ fatal() ...@@ -28,13 +15,14 @@ fatal()
exit 1 exit 1
} }
exit_handler() PACKAGEINFO=@DATADIR@/package.conf
{ if [ -f "$PACKAGEINFO" ] ; then
local rc=$? . $PACKAGEINFO
trap - EXIT else
[ -z "$tmpdir" ] || rm -rf -- "$tmpdir" fatal "Not found package information file $PACKAGEINFO"
exit $rc fi
}
ETERCIFS_SOURCES_TARBALL=$DATADIR/etercifs-sources-$MODULEVERSION.tar.xz
kernel_release2() kernel_release2()
...@@ -62,14 +50,25 @@ split_kernel_version() ...@@ -62,14 +50,25 @@ split_kernel_version()
N3=`echo $KERNEL | cut -d"." -f 3 | cut -d"-" -f 1` N3=`echo $KERNEL | cut -d"." -f 3 | cut -d"-" -f 1`
N4=`echo $KERNEL | cut -d"-" -f 2 | cut -d"." -f 1` N4=`echo $KERNEL | cut -d"-" -f 2 | cut -d"." -f 1`
} }
list_source_versions()
{
tar --list --no-recursion -f $ETERCIFS_SOURCES_TARBALL --exclude '*/*' | sed -e "s|/||g"
}
# arg: version target
extract_source()
{
mkdir -p "$2" || return
tar -xJf $ETERCIFS_SOURCES_TARBALL -C "$2" --strip 1 "$1"
} }
check_for_openvz() check_for_openvz()
{ {
if echo "$KERNELVERSION" | egrep -q "2\.6\.18.*(stab|ovz-el|ovz-rhel)" ; then if echo "$KERNELVERSION" | egrep -q "2\.6\.18.*(stab|ovz-el|ovz-rhel)" ; then
OVZ_KERNEL="centos-ovz" KERNEL_STRING="centos-ovz"
elif echo "$KERNELVERSION" | egrep -q "2\.6\.32.*(stab|ovz-el|ovz-smp|ovz-rhel|openvz)" ; then elif echo "$KERNELVERSION" | egrep -q "2\.6\.32.*(stab|ovz-el|ovz-smp|ovz-rhel|openvz)" ; then
OVZ_KERNEL="centos60" KERNEL_STRING="centos60"
else else
return 1 return 1
fi fi
...@@ -78,6 +77,7 @@ check_for_openvz() ...@@ -78,6 +77,7 @@ check_for_openvz()
check_for_centos() check_for_centos()
{ {
# TODO: epm
if which lsb_release > /dev/null; then if which lsb_release > /dev/null; then
lsb_release -d | egrep -q 'GosLinux|CentOS|Red Hat|Scientific Linux|NauLinux|LinuxWizard Server|RERemix' || return lsb_release -d | egrep -q 'GosLinux|CentOS|Red Hat|Scientific Linux|NauLinux|LinuxWizard Server|RERemix' || return
fi fi
...@@ -88,74 +88,83 @@ check_for_centos() ...@@ -88,74 +88,83 @@ check_for_centos()
kernel_release4 kernel_release4
split_kernel_version split_kernel_version
CENTOS=0 if [ "$N1.$N2" = "2.6" ] ; then
if [ "$N1" -eq 2 ] && [ "$N2" -eq 6 ] ; then if [ "$N3" = "18" ] ; then
if [ "$N3" -eq 18 ] ; then if [ "$N4" = "274" ] ; then
if [ "$N4" -eq 274 ] ; then echo "Building from legacy sources with patch for kernels 2.6.18-274.x from CentOS 5.7."
echo "Your kernel is 2.6.18-274.x" KERNEL_STRING='centos56'
CENTOS=57
elif [ "$N4" -gt 274 ] ; then elif [ "$N4" -gt 274 ] ; then
echo "Warning! Your kernel is newer than 2.6.18-274.x" echo "Building from legacy sources with patch for kernels 2.6.18-238.x from CentOS 5.6."
CENTOS=56 KERNEL_STRING='centos56'
elif [ "$N4" -eq 238 ] ; then elif [ "$N4" -eq 238 ] ; then
echo "Your kernel is 2.6.18-238.x" echo "Your kernel is 2.6.18-238.x"
CENTOS=56 KERNEL_STRING='centos56'
elif [ "$N4" -gt 238 ] ; then elif [ "$N4" -gt 238 ] ; then
echo "Warning! Your kernel is newer than 2.6.18-238.x" echo "Warning! Your kernel is newer than 2.6.18-238.x"
CENTOS=56 KERNEL_STRING='centos56'
elif [ "$N4" -eq 194 ] ; then elif [ "$N4" -eq 194 ] ; then
echo "Your kernel is 2.6.18-194.x" echo "Your kernel is 2.6.18-194.x"
CENTOS=55 echo "Building from legacy sources with patch for kernels 2.6.18-194.x from CentOS 5.5."
KERNEL_STRING='centos55'
elif [ "$N4" -gt 194 ] ; then elif [ "$N4" -gt 194 ] ; then
echo "Warning! Your kernel is newer than 2.6.18-194.x and older than 2.6.18.238.x" echo "Warning! Your kernel is newer than 2.6.18-194.x and older than 2.6.18.238.x"
CENTOS=55 echo "Building from legacy sources with patch for kernels 2.6.18-194.x from CentOS 5.5."
KERNEL_STRING='centos55'
elif [ "$N4" -eq 164 ] ; then elif [ "$N4" -eq 164 ] ; then
echo "Your kernel is 2.6.18-164.x" echo "Building from legacy sources with patch for kernels 2.6.18-164.x from CentOS 5.4."
CENTOS=54 KERNEL_STRING='centos54'
elif [ "$N4" -gt 164 ] ; then elif [ "$N4" -gt 164 ] ; then
echo "Warning! Your kernel is newer than 2.6.18-164.x and older than 2.6.18.194.x" echo "Warning! Your kernel is newer than 2.6.18-164.x and older than 2.6.18.194.x"
CENTOS=54 echo "Building from legacy sources with patch for kernels 2.6.18-164.x from CentOS 5.4."
KERNEL_STRING='centos54'
elif [ "$N4" -eq 128 ] ; then elif [ "$N4" -eq 128 ] ; then
echo "Your kernel is 2.6.18-128.x" echo "Building from legacy sources with patch for kernels 2.6.18-128.x from CentOS 5.3."
CENTOS=53 KERNEL_STRING='centos53'
elif [ "$N4" -gt 128 ] ; then elif [ "$N4" -gt 128 ] ; then
echo "Warning! Your kernel is newer than 2.6.18-128.x and older than 2.6.18-164.x" echo "Warning! Your kernel is newer than 2.6.18-128.x and older than 2.6.18-164.x"
CENTOS=53 echo "Building from legacy sources with patch for kernels 2.6.18-128.x from CentOS 5.3."
KERNEL_STRING='centos53'
elif [ "$N4" -eq 92 ] ; then elif [ "$N4" -eq 92 ] ; then
echo "You kernel is 2.6.18-92.x" echo "Building from legacy sources with patch for kernels 2.6.18-92.x from CentOS 5.2."
CENTOS=52 KERNEL_STRING='centos52'
elif [ "$N4" -gt 92 ] ; then elif [ "$N4" -gt 92 ] ; then
echo "Warning! Your kernel is newer than 2.6.18-92.x and older than 2.6.18-128.x" echo "Warning! Your kernel is newer than 2.6.18-92.x and older than 2.6.18-128.x"
CENTOS=52 echo "Building from legacy sources with patch for kernels 2.6.18-92.x from CentOS 5.2."
KERNEL_STRING='centos52'
else else
echo "Warning! Your kernel is older than 2.6.18-92.x" echo "Warning! Your kernel is older than 2.6.18-92.x"
CENTOS=52 echo "Building from legacy sources."
KERNEL_STRING='legacy'
fi fi
elif [ "$N3" -gt 18 ] && [ "$N3" -lt 23 ] ; then elif [ "$N3" -gt 18 ] && [ "$N3" -lt 23 ] ; then
echo "Warning! Your kernel is newer than 2.6.18 and older than 2.6.23" echo "Building from legacy sources with patch for kernels 2.6.18-92.x from CentOS 5.2."
CENTOS=53 KERNEL_STRING='centos52'
elif [ "$N3" -eq 32 ] ; then elif [ "$N3" = "32" ] ; then
echo "Your kernel is 2.6.32-x.y" echo "Building from legacy sources with patch for kernels 2.6.32-x.y from CentOS 6.0."
CENTOS=60 KERNEL_STRING='centos60'
else else
echo "Warning! Your kernel is older than 2.6.18 or newer than 2.6.23" echo "Warning! Your RHEL kernel is older than 2.6.18 or newer than 2.6.23"
echo "Building from legacy sources."
KERNEL_STRING='legacy'
fi fi
elif [ "$N1" -eq 3 ] && [ "$N2" -eq 10 ] ; then elif [ "$N1.$N2" = "3.10" ] ; then
if [ "$N3" -eq 0 ] && [ "$N4" -eq 1 ] ; then if [ "$N3-$N4" = "0-1" ] ; then
echo "Your kernel is 3.10.0-1.x" # FIXME
CENTOS="GosLinux64" CENTOS="GosLinux64"
else else
echo "Your kernel is 3.10.x" echo "Building from legacy sources with patch for kernels 3.10.x from CentOS 7.0."
CENTOS=70 KERNEL_STRING='centos70'
fi fi
else else
echo "Warning! Your kernel in not 2.6.x" echo "Skipping RHEL specific kernel $KERNEL"
return 1
fi fi
return 0 return 0
} }
check_for_suse() check_for_suse()
{ {
# TODO epm
if which lsb_release > /dev/null; then if which lsb_release > /dev/null; then
lsb_release -d | egrep -q 'openSUSE' || return lsb_release -d | egrep -q 'openSUSE' || return
fi fi
...@@ -166,94 +175,66 @@ check_for_suse() ...@@ -166,94 +175,66 @@ check_for_suse()
kernel_release4 kernel_release4
split_kernel_version split_kernel_version
SUSE=0 if [ "$N1.$N2.$N3" = "3.16.7" ] ; then
if [ "$N1" -eq 3 ] && [ "$N2" -eq 16 ] ; then echo "Building from legacy sources with patch for kernels 3.16.7-21.x from SUSE 13.2"
if [ "$N3" -eq 7 ] ; then KERNEL_STRING='suse13_2'
SUSE="13_2" else
fi return 1
fi fi
return 0 return 0
} }
detect_etercifs_sources() detect_etercifs_sources()
{ {
# CentOS-RHEL specific part KERNEL_STRING=
if check_for_openvz ; then if check_for_openvz ; then
[ -n "$ETERCIFS_SOURCES_LIST" ] || ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs-* echo "Building from legacy sources with patch for OpenVZ kernel $KERNEL_STRING"
if [ "$OVZ_KERNEL" ] ; then
echo "Building from legacy sources with patch for OpenVZ kernels $OVZ_KERNEL"
KERNEL_STRING="$OVZ_KERNEL"
fi
elif check_for_centos ; then elif check_for_centos ; then
[ -n "$ETERCIFS_SOURCES_LIST" ] || ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs-* true
if [ "$CENTOS" -eq 70 ] ; then
echo "Building from legacy sources with patch for kernels 3.10.x from CentOS 7.0."
KERNEL_STRING='centos70'
elif [ "$CENTOS" -eq 60 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.32-x.y from CentOS 6.0."
KERNEL_STRING='centos60'
elif [ "$CENTOS" -eq 57 ] ; then
# The same as CentOS 5.6
echo "Building from legacy sources with patch for kernels 2.6.18-274.x from CentOS 5.7."
KERNEL_STRING='centos56'
elif [ "$CENTOS" -eq 56 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.18-238.x from CentOS 5.6."
KERNEL_STRING='centos56'
elif [ "$CENTOS" -eq 55 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.18-194.x from CentOS 5.5."
KERNEL_STRING='centos55'
elif [ "$CENTOS" -eq 54 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.18-164.x from CentOS 5.4."
KERNEL_STRING='centos54'
elif [ "$CENTOS" -eq 53 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.18-128.x from CentOS 5.3."
KERNEL_STRING='centos53'
elif [ "$CENTOS" -eq 52 ] ; then
echo "Building from legacy sources with patch for kernels 2.6.18-92.x from CentOS 5.2."
KERNEL_STRING='centos52'
else
echo "Building from legacy sources."
KERNEL_STRING='legacy'
fi # end of CentOS-RHEL specific part
# start opensuse specific part
elif check_for_suse; then elif check_for_suse; then
[ -n "$ETERCIFS_SOURCES_LIST" ] || ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs-* true
if [ "$SUSE" = "13_2" ] ; then
echo "Building from legacy sources with patch for kernels 3.16.7-21.x from SUSE 13.2"
KERNEL_STRING='suse13_2'
fi # end suse specific part
else else
kernel_release3 kernel_release3
split_kernel_version split_kernel_version
if [ "$N1" -eq 2 ] ; then if [ "$N1" -eq 2 ] ; then
[ -n "$ETERCIFS_SOURCES_LIST" ] || ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs-2* # 2.x.x regular kernel
KERNEL_STRING=$KERNEL KERNEL_STRING=$KERNEL
echo "Building for $KERNEL_STRING" echo "Building for $KERNEL_STRING"
else else
# some normal and modern kernel # some normal and modern kernel
[ -n "$ETERCIFS_SOURCES_LIST" ] || ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs-$N1*
kernel_release2 kernel_release2
KERNEL_STRING=$KERNEL KERNEL_STRING=$KERNEL
echo "Building for $KERNEL_STRING" echo "Building for $KERNEL_STRING"
fi fi
fi fi
[ -n "`ls $ETERCIFS_SOURCES_LIST`" ] || fatal "Etercifs kernel module sources does not installed (it is possible, etercifs package is obsoleted)!" # try get concrete version
KERNEL_SOURCE_ETERCIFS_LINK=`ls -1 $ETERCIFS_SOURCES_LIST | grep -F $KERNEL_STRING | sort -r | head -n 1` KERNEL_SOURCE_ETERCIFS=$(list_source_versions | grep -F "$KERNEL_STRING" | sort -r | head -n 1)
if [ -z "$KERNEL_SOURCE_ETERCIFS_LINK" ] ; then # try get like version
ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs-[0-9]* if [ -z "$KERNEL_SOURCE_ETERCIFS" ] ; then
KERNEL_SOURCE_ETERCIFS_LINK=`ls -1 $ETERCIFS_SOURCES_LIST | sort -r -V | head -n 1` KERNEL_SOURCE_ETERCIFS=$(list_source_versions | sort -r -V | head -n 1)
LATEST_SOURCES=`echo $KERNEL_SOURCE_ETERCIFS_LINK | cut -d"-" -f 4` LATEST_SOURCES=$(echo $KERNEL_SOURCE_ETERCIFS | cut -d"-" -f 4)
echo "Warning! Couldn't find module sources for the current kernel $KERNEL ($LATEST_SOURCES sources are selected)!" echo "Warning! Couldn't find module sources for the current kernel $KERNEL!"
echo "Using the latest supported sources - from v$LATEST_SOURCES kernel!" echo "Using the latest supported sources - from v$LATEST_SOURCES kernel!"
ETERCIFS_SOURCES_LIST=$DATADIR/sources/kernel-source-etercifs*
fi fi
KERNEL_SOURCE_ETERCIFS=`readlink -f $KERNEL_SOURCE_ETERCIFS_LINK` [ -n "$KERNEL_SOURCE_ETERCIFS" ] || fatal "Can't locate etercifs kernel module sources for current kernel!"
[ "$KERNEL_SOURCE_ETERCIFS" ] || fatal "Etercifs kernel module sources for current kernel does not installed!" }
exit_handler()
{
local rc=$?
trap - EXIT
if [ -n "$tmpdir" ] ; then
rm -rf -- "$tmpdir"
unset tmpdir
fi
exit $rc
} }
# can be used with external BUILDDIR
create_builddir() create_builddir()
{ {
if [ -n "$BUILDDIR" ] ; then if [ -n "$BUILDDIR" ] ; then
...@@ -261,11 +242,10 @@ create_builddir() ...@@ -261,11 +242,10 @@ create_builddir()
else else
tmpdir= tmpdir=
tmpdir="$(mktemp -dt "Etercifs.XXXXXXXX")" tmpdir="$(mktemp -dt "Etercifs.XXXXXXXX")"
fi
tar -xjf $KERNEL_SOURCE_ETERCIFS -C $tmpdir
trap exit_handler HUP PIPE INT QUIT TERM EXIT trap exit_handler HUP PIPE INT QUIT TERM EXIT
FILENAME=`basename $KERNEL_SOURCE_ETERCIFS` BUILDDIR=$tmpdir/$KERNEL_SOURCE_ETERCIFS
BUILDDIR=$tmpdir/${FILENAME%.tar.bz2} fi
extract_source $KERNEL_SOURCE_ETERCIFS $BUILDDIR
} }
# Heuristic # Heuristic
...@@ -314,18 +294,19 @@ check_headers() ...@@ -314,18 +294,19 @@ check_headers()
{ {
if [ ! -f $KERNSRC/include/linux/version.h ] && [ ! -f $KERNSRC/include/generated/uapi/linux/version.h ] ; then if [ ! -f $KERNSRC/include/linux/version.h ] && [ ! -f $KERNSRC/include/generated/uapi/linux/version.h ] ; then
# TODO: use distr_vendor # TODO: use distr_vendor
# TODO: use eepm, try install
cat >&2 <<EOF cat >&2 <<EOF
Error: no kernel headers found at $KERNSRC Error: no kernel headers found at $KERNSRC
Please install package Please install package
kernel-headers-modules-XXXX for ALT Linux kernel-headers-modules-XXXX for ALT Linux
kernel-devel for CentOS / Fedora kernel-devel for RHEL / CentOS / Fedora
linux-headers-XXXX for Debian / Ubuntu linux-headers-XXXX for Debian / Ubuntu
kernel-source-XXXX for SUSE Linux kernel-source-XXXX for SUSE Linux
kernel-source-XXXX for Slackware kernel-source-XXXX for Slackware
dkms-etercifs for Mandriva dkms-etercifs for Mandriva
where XXXX is your current version from uname -r: $(uname -r) where XXXX is your current version from \$ uname -r: $(uname -r)
or use KERNELVERSION variable to set correct version (for /lib/modules/KERNELVERSION/build) or use KERNELVERSION variable to set correct version (for /lib/modules/KERNELVERSION/build)
or use KERNSRC variable to set correct kernel headers location or set KERNSRC and KERNELVERSION variables to set correct kernel headers location
Exiting... Exiting...
EOF EOF
# FIXME: check detect # FIXME: check detect
...@@ -337,14 +318,15 @@ set_gcc() ...@@ -337,14 +318,15 @@ set_gcc()
{ {
if [ -f $KERNSRC/gcc_version.inc ] ; then if [ -f $KERNSRC/gcc_version.inc ] ; then
. $KERNSRC/gcc_version.inc . $KERNSRC/gcc_version.inc
echo "Use GCC $GCC_VERSION" echo "Use GCC $GCC_VERSION from $KERNSRC/gcc_version.inc"
export GCCNAME=gcc-$GCC_VERSION export GCCNAME=gcc-$GCC_VERSION
export USEGCC="CC=$GCCNAME" export USEGCC="CC=$GCCNAME"
else else
export GCCNAME=gcc export GCCNAME=gcc
fi fi
[ `which make` ] || fatal "GNU make utility have not found. Please, install make package." # TODO: epm assure make
which make >/dev/null || fatal "GNU make utility have not found. Please, install make package."
PATHGCC=`which $GCCNAME` PATHGCC=`which $GCCNAME`
[ $PATHGCC ] || fatal "GCC compiler have not found. Please, install gcc package." [ $PATHGCC ] || fatal "GCC compiler have not found. Please, install gcc package."
...@@ -355,19 +337,16 @@ dkms_build_module() ...@@ -355,19 +337,16 @@ dkms_build_module()
{ {
detect_etercifs_sources detect_etercifs_sources
STATUS=`dkms status -m $MODULENAME -v $MODULEVERSION` STATUS=`dkms status -m $MODULENAME -v $MODULEVERSION`
[ "$STATUS" ] || dkms add -m $MODULENAME -v $MODULEVERSION [ "$STATUS" ] || a= dkms add -m $MODULENAME -v $MODULEVERSION
tar -xjf $KERNEL_SOURCE_ETERCIFS -C $SRC_DIR
FILENAME=`basename $KERNEL_SOURCE_ETERCIFS`
DIRNAME=${FILENAME%.tar.bz2}
mv -f $SRC_DIR/$DIRNAME/* $SRC_DIR
BUILDDIR=$SRC_DIR BUILDDIR=$SRC_DIR
create_builddir
change_cifsversion change_cifsversion
rm -rf $SRC_DIR/$DIRNAME a= dkms uninstall -m $MODULENAME -v $MODULEVERSION --rpm_safe_upgrade
dkms uninstall -m $MODULENAME -v $MODULEVERSION --rpm_safe_upgrade a= dkms build -m $MODULENAME -v $MODULEVERSION --rpm_safe_upgrade
dkms build -m $MODULENAME -v $MODULEVERSION --rpm_safe_upgrade a= dkms install -m $MODULENAME -v $MODULEVERSION --rpm_safe_upgrade
dkms install -m $MODULENAME -v $MODULEVERSION --rpm_safe_upgrade
} }
# TODO: change it in the repo!
change_cifsversion() change_cifsversion()
{ {
if [ -f $BUILDDIR/cifsfs.h ] ; then if [ -f $BUILDDIR/cifsfs.h ] ; then
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment