git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.1.0.x@3975 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Bart Van Assche
2011-12-10 13:52:02 +00:00
parent 26c783ac56
commit 9ca8fb0ba7
7 changed files with 501 additions and 79 deletions

View File

@@ -23,6 +23,9 @@ function categorize_line(line) {
is_blank = 0
is_trace_entry = 0
is_trace_exit = 0
is_label = 0
is_return_void = 0
is_brace_at_start_of_line = 0
if (line ~ "^+$")
is_blank = 1
else if (line ~ "^+\tTRACE_ENTRY\\(\\);$")
@@ -31,6 +34,12 @@ function categorize_line(line) {
|| line ~ "^+\tTRACE_EXIT_RES\\(.*\\);$" \
|| line ~ "^+\tTRACE_EXIT_HRES\\(.*\\);$")
is_trace_exit = 1
else if (line ~ ":$")
is_label = 1
else if (line ~ "^+\treturn;$")
is_return_void = 1
else if (line ~ "^+}$")
is_brace_at_start_of_line = 1
}
# Leave out TRACE_ENTRY() and the blank line below it and also TRACE_EXIT()
@@ -39,10 +48,14 @@ function print_conditionally() {
if (previous_is_trace_entry \
|| (before_previous_is_trace_entry && previous_is_blank) \
|| previous_is_trace_exit \
|| (previous_is_blank && is_trace_exit))
|| (previous_is_blank && is_trace_exit) \
|| (!before_previous_is_label \
&& previous_is_return_void \
&& is_brace_at_start_of_line))
{
# print "deleted", previous_line
lines_deleted++
reverse_shift_state_variables()
}
else
{
@@ -56,9 +69,19 @@ function shift_state_variables(line) {
before_previous_is_blank = previous_is_blank
before_previous_is_trace_entry = previous_is_trace_entry
before_previous_is_trace_exit = previous_is_trace_exit
before_previous_is_label = previous_is_label
previous_is_blank = is_blank
previous_is_trace_entry = is_trace_entry
previous_is_trace_exit = is_trace_exit
previous_is_label = is_label
previous_is_return_void = is_return_void
}
function reverse_shift_state_variables() {
previous_is_blank = before_previous_is_blank
previous_is_trace_entry = before_previous_is_trace_entry
previous_is_trace_exit = before_previous_is_trace_exit
previous_is_label = before_previous_is_label
}
function reset_hunk_state_variables() {
@@ -68,9 +91,12 @@ function reset_hunk_state_variables() {
before_previous_is_blank = 0
before_previous_is_trace_entry = 0
before_previous_is_trace_exit = 0
before_previous_is_label = 0
previous_is_blank = 0
previous_is_trace_entry = 0
previous_is_trace_exit = 0
previous_is_label = 0
previous_is_return_void = 0
}
function dump_lines() {
@@ -130,3 +156,8 @@ END {
print_conditionally()
dump_lines()
}
# Local variables:
# indent-tabs-mode: nil
# c-basic-offset: 2
# End:

View File

@@ -23,6 +23,8 @@
# Function definitions #
########################
source $(dirname $0)/kernel-version
function usage {
echo "Usage: $0 [-d] [-h] [-m] [-n] [-p <dir>] [-s] [-u] <kernel version>"
echo "where: "
@@ -45,8 +47,8 @@ function add_patch {
exit 1
fi
sed -e "s:^--- [^ ]*:--- orig/linux-${kernel_version}/$2:" \
-e "s:^+++ [^ ]*:+++ linux-${kernel_version}/$2:" \
sed -e "s:^--- [^ ]*:--- orig/linux-${kver}/$2:" \
-e "s:^+++ [^ ]*:+++ linux-${kver}/$2:" \
< "$1"
}
@@ -67,9 +69,9 @@ function add_file {
# -- skip *.mod.c.
if [ "$1" = "${1%.mod.c}" -a "$1" ]; then
cat <<EOF
diff -uprN orig/linux-${kernel_version}/$2 linux-${kernel_version}/$2
--- orig/linux-${kernel_version}/$2
+++ linux-${kernel_version}/$2
diff -uprN orig/linux-${kver}/$2 linux-${kver}/$2
--- orig/linux-${kver}/$2
+++ linux-${kver}/$2
@@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@
EOF
# Insert a '+'-sign at the start of each line.
@@ -93,9 +95,9 @@ function add_empty_file {
local a b
cat <<EOF
diff -uprN orig/linux-${kernel_version}/$1 linux-${kernel_version}/$1
--- orig/linux-${kernel_version}/$1
+++ linux-${kernel_version}/$1
diff -uprN orig/linux-${kver}/$1 linux-${kver}/$1
--- orig/linux-${kver}/$1
+++ linux-${kver}/$1
@@ -0,0 +1,1 @@
+
EOF
@@ -107,7 +109,7 @@ function specialize_patch {
if [ "${enable_specialize}" = "true" ]; then
"$(dirname $0)/specialize-patch" \
${specialize_patch_options} \
-v kernel_version="${kernel_version}" \
-v kernel_version="${kver}" \
-v SCSI_EXEC_REQ_FIFO_DEFINED="${scsi_exec_req_fifo_defined}" \
-v SCST_IO_CONTEXT="${scst_io_context}" \
| if [ "${generating_upstream_patch}" = "true" ]; then
@@ -120,7 +122,7 @@ function specialize_patch {
fi
}
# Read a patch from stdin, specialize it for kernel version ${kernel_version}
# Read a patch from stdin, specialize it for kernel version ${kver}
# and write the output either to stdout or to the file $1 (if not empty),
# depending on the value of the variable ${multiple_patches}.
function process_patch {
@@ -207,16 +209,11 @@ if [ $# != 1 ]; then
fi
# Strip patch level from the kernel version number.
if [ "${1#[0-9]*.[0-9]*.[0-9]*.[0-9]*}" != "$1" ]; then
kernel_version="${1%.[0-9]*}"
patch_level="${1#${kernel_version}.}"
else
kernel_version="$1"
fi
kver="$(kernel_version "$1")"
# Make sure that for kernel 2.6.33 and later the line
# "#define CONFIG_SCST_PROC" is removed from scst/include/scst.h.
if grep -qw scst_sysfs scst/kernel/in-tree/Makefile.scst-${kernel_version} \
if grep -qw scst_sysfs scst/kernel/in-tree/Makefile.scst-${kver} \
|| [ "${generating_upstream_patch}" = "true" ];
then
specialize_patch_options="${specialize_patch_options} -v config_scst_proc_undefined=1"
@@ -243,7 +240,7 @@ fi
# Patch Generation #
####################
for f in fcst/linux-patches/series-${kernel_version}*
for f in fcst/linux-patches/series-${kver}*
do
if [ -e "$f" ]; then
fcst_patch_series="$f"
@@ -255,8 +252,8 @@ done
scsi_exec_req_fifo_defined=0
scst_io_context=0
for p in scst/kernel/*-${kernel_version}.patch \
iscsi-scst/kernel/patches/*-${kernel_version}.patch
for p in scst/kernel/*-${kver}.patch \
iscsi-scst/kernel/patches/*-${kver}.patch
do
# Exclude the put_page_callback patch when command-line option -u has been
# specified since the current approach is not considered acceptable for
@@ -271,7 +268,7 @@ do
scst_io_context=1
fi
diffname="${p#scst/kernel/}"
diffname="${p%-${kernel_version}.patch}.diff"
diffname="${p%-${kver}.patch}.diff"
process_patch < "$p" "${diffname}"
fi
done
@@ -305,10 +302,10 @@ done
# Directory drivers/
(
add_patch "scst/kernel/in-tree/Kconfig.drivers.Linux-${kernel_version}.patch" \
add_patch "scst/kernel/in-tree/Kconfig.drivers.Linux-${kver}.patch" \
"drivers/Kconfig"
add_patch "scst/kernel/in-tree/Makefile.drivers.Linux-${kernel_version}.patch"\
add_patch "scst/kernel/in-tree/Makefile.drivers.Linux-${kver}.patch"\
"drivers/Makefile"
) \
| process_patch "scst_01_drivers_kbuild.diff"
@@ -320,7 +317,7 @@ add_patch "scst/kernel/in-tree/Makefile.drivers.Linux-${kernel_version}.patch"\
tmpdir="/tmp/scst-$$"
mkdir -p "${tmpdir}"
tmp_Kconfig="${tmpdir}/Kconfig.scst-${kernel_version}"
tmp_Kconfig="${tmpdir}/Kconfig.scst-${kver}"
cat "scst/kernel/in-tree/Kconfig.scst" | \
if [ -e "${fcst_patch_series}" ]; then
cat
@@ -329,8 +326,8 @@ else
fi >"${tmp_Kconfig}"
add_file "${tmp_Kconfig}" "drivers/scst/Kconfig"
tmp_Makefile="${tmpdir}/Makefile.scst-${kernel_version}"
cat "scst/kernel/in-tree/Makefile.scst-${kernel_version}" | \
tmp_Makefile="${tmpdir}/Makefile.scst-${kver}"
cat "scst/kernel/in-tree/Makefile.scst-${kver}" | \
if [ "${generating_upstream_patch}" = "true" ]; then
grep -v 'scst_proc'
else
@@ -371,7 +368,7 @@ done
# Directory drivers/scst/dev_handlers/
add_file "scst/kernel/in-tree/Makefile.dev_handlers-${kernel_version}" \
add_file "scst/kernel/in-tree/Makefile.dev_handlers-${kver}" \
"drivers/scst/dev_handlers/Makefile" \
| process_patch "scst_11_dev_handlers_makefile.diff"
@@ -460,7 +457,7 @@ if [ "${qla2x00t}" = "true" ]; then
add_file "qla2x00t/qla2x_tgt_def.h" \
"drivers/scsi/qla2xxx/qla2x_tgt_def.h"
add_file "qla2x00t/qla2x00-target/Makefile_in-tree-${kernel_version}" \
add_file "qla2x00t/qla2x00-target/Makefile_in-tree-${kver}" \
"drivers/scst/qla2xxx-target/Makefile"
add_file "qla2x00t/qla2x00-target/Kconfig" \
@@ -558,7 +555,7 @@ fi
add_file "scst_local/in-tree/Kconfig" "drivers/scst/scst_local/Kconfig"
add_file "scst_local/in-tree/Makefile-${kernel_version}" "drivers/scst/scst_local/Makefile"
add_file "scst_local/in-tree/Makefile-${kver}" "drivers/scst/scst_local/Makefile"
add_file "scst_local/scst_local.c" "drivers/scst/scst_local/scst_local.c"
) \
@@ -569,8 +566,8 @@ fi
# Directory drivers/scsi/ibmvstgt
{
( cd ibmvstgt && ./generate-in-tree-patches "${kernel_version}" )
if [ -e "ibmvstgt/in-tree-patches/${kernel_version}" ]; then
( cd ibmvstgt && ./generate-in-tree-patches "${kver}" )
if [ -e "ibmvstgt/in-tree-patches/${kver}" ]; then
if [ "${multiple_patches}" = "true" ]; then
cat <<EOF
[SCSI] ibmvstgt: Port from tgt to SCST
@@ -662,7 +659,7 @@ EOF
include/scsi/libsrp.h \
include/scsi/srp.h
do
patch="ibmvstgt/in-tree-patches/${kernel_version}/$(basename $f).patch"
patch="ibmvstgt/in-tree-patches/${kver}/$(basename $f).patch"
if [ -e "${patch}" ]; then
add_patch "${patch}" $f
fi
@@ -673,8 +670,8 @@ EOF
| process_patch "scst_18_ibmvstgt.diff"
{
( cd ibmvstgt && ./generate-in-tree-patches "${kernel_version}" )
if [ -e "ibmvstgt/in-tree-patches/${kernel_version}" ]; then
( cd ibmvstgt && ./generate-in-tree-patches "${kver}" )
if [ -e "ibmvstgt/in-tree-patches/${kver}" ]; then
if [ "${multiple_patches}" = "true" ]; then
cat <<EOF
[SCSI] tgt: Removal
@@ -741,7 +738,7 @@ EOF
include/scsi/scsi_tgt.h \
include/scsi/scsi_tgt_if.h
do
add_patch "ibmvstgt/in-tree-patches/${kernel_version}/$(basename $f).patch" $f
add_patch "ibmvstgt/in-tree-patches/${kver}/$(basename $f).patch" $f
done
fi
} \

View File

@@ -633,7 +633,7 @@ index ad178fa..1ae84db 100644
+++ b/include/scsi/srp.h
@@ -239,4 +239,42 @@ struct srp_rsp {
u8 data[0];
} __attribute__((packed));
} __packed;
+struct srp_cred_req {
+ u8 opcode;
@@ -665,7 +665,7 @@ index ad178fa..1ae84db 100644
+ __be32 sense_data_len;
+ u32 reserved3;
+ u8 sense_data[0];
+} __attribute__((packed));
+} __packed;
+
+struct srp_aer_rsp {
+ u8 opcode;

21
scripts/kernel-version Normal file
View File

@@ -0,0 +1,21 @@
# -*- mode: shell-script -*-
# Shell functions for parsing the Linux kernel version.
# Kernel version number.
function kernel_version {
if [ "${1#2.}" != "$1" ]; then
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/p'
else
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\).*$/\1/p'
fi
}
# Last component of the kernel version, or the empty string if $1 does
# not contain a patchlevel.
function patchlevel {
if [ "${1#2.}" != "$1" ]; then
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\)[.-]\(.*\)$/\2/p'
else
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\)[.-]\(.*\)$/\2/p'
fi
}

312
scripts/rebuild-rhel-kernel-rpm Executable file
View File

@@ -0,0 +1,312 @@
#!/bin/bash
############################################################################
#
# Copyright (C) 2008-2009 Bart Van Assche <bvanassche@acm.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation, version 2
# of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
############################################################################
############################################################################
#
# The recommended way to use this script is as follows:
# - Create an additional user, e.g. builder
# - Add a line to the sudoers file that allows that user to invoke yum and
# yum-builddep.
# - Add the source repositories in /etc/yum.repos.d.
# - One way to do that is by invoking the following shell commands as root:
# useradd builder
# echo 'builder ALL=(ALL) NOPASSWD: /usr/bin/yum, /usr/bin/yum-builddep' >>/etc/sudoers
# visudo -sc
#
# For more information about building a custom RHEL / CentOS / Scientific Linux
# kernel RPM, see also:
# * CentOS wiki, "I Need to Build a Custom Kernel"
# (http://wiki.centos.org/HowTos/Custom_Kernel).
# * Fedora wiki, "Building a custom kernel"
# (http://fedoraproject.org/wiki/Building_a_custom_kernel).
#
############################################################################
scst_dir="$(dirname "$(dirname "$0")")"
downloaddir=$HOME/software/downloads
rpmbuild_dir=$HOME/rpmbuild
if [ "$1" = "" ]; then
kernel="kernel-$(uname -r)"
else
kernel="$1"
fi
arch="$(uname -m)"
kernel="${kernel%.${arch}}"
kernel_src_rpm="${kernel}.src.rpm"
kver="${kernel#kernel-}"
distro="$(sed -n -e 's/^\(.*\) release .*$/\1/p' /etc/issue)"
releasever="$(sed -n -e 's/^.* release \([0-9.]*\) .*$/\1/p' /etc/issue)"
releasevermajor="$(echo $releasever | cut -f1 -d.)"
releaseverminor="$(echo $releasever | cut -f2 -d.)"
case "$distro" in
"CentOS"*)
if [ $releasevermajor = 5 ]; then
srpm_url=("http://vault.centos.org/${releasever}/os/SRPMS" "http://vault.centos.org/${releasever}/updates/SRPMS")
else
srpm_url=("http://mirror.centos.org/centos/${releasever}/os/SRPMS/Packages" "http://mirror.centos.org/centos/${releasever}/updates/SRPMS")
fi
;;
"Red Hat Enterprise Linux"*)
srpm_url=("http://ftp.redhat.com/pub/redhat/linux/enterprise/${releasevermajor}Server/en/os/SRPMS")
;;
"Scientific Linux")
if [ "$releasevermajor" = 6 ]; then
srpm_url=("http://ftp.scientificlinux.org/linux/scientific/$releasever/SRPMS/vendor")
else
srpm_url=("http://ftp.scientificlinux.org/linux/scientific/$releasevermajor$releaseverminor/SRPMS/vendor")
fi
;;
*)
echo "Unknown type of distribution: $distro"
exit 1
;;
esac
function log {
echo
echo "$@"
echo
}
function copy_patch {
local p="$1"
while [ ! -e "$p" ]
do
local q="$(echo "$p" | sed 's/[.-][a-z0-9]*\.patch$/.patch/')"
if [ "$q" = "$p" ]; then
break;
fi
p="$q"
done
if [ ! -e "$p" ]; then
echo "Error: patch $1 not found"
echo "Please report this on the scst-devel mailing list"
exit 1
fi
ln -s "$p" "$2"
}
if [ -e ${rpmbuild_dir} ]; then
echo "You have to remove the ${rpmbuild_dir} directory before starting $0"
exit 1
fi
if [ ! -e "${scst_dir}" ]; then
echo "Error: directory ${scst_dir} not found. Please modify scst_dir in $0."
exit 1
fi
log "Installing prerequisites"
sudo yum install -y -q asciidoc binutils-devel elfutils-libelf-devel hmaccalc ncurses-devel newt-devel patchutils 'perl(ExtUtils::Embed)' python-devel redhat-rpm-config rpmdevtools rng-tools rpm-build unifdef xmlto yum-utils zlib-devel
rc=$?; if [ $rc != 0 ]; then exit $rc; fi
log "Creating directory ${rpmbuild_dir}"
mkdir -p ${rpmbuild_dir}/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
log "Updating ~/.rpmmacros"
if [ -e ~/.rpmmacros ]; then
cp ~/.rpmmacros ~/.rpmmacros.tmp
else
touch ~/.rpmmacros.tmp
fi
{ cat ~/.rpmmacros.tmp | grep -v '^%_topdir '; \
echo "%_topdir ${rpmbuild_dir}"; } > ~/.rpmmacros
rm -f ~/.rpmmacros.tmp
log "Installing, unpacking and preparing kernel source files"
mkdir -p ${downloaddir}
if [ ! -e ${downloaddir}/${kernel_src_rpm} ]; then
cd ${downloaddir}
for dir in ${srpm_url[@]}
do
url="$dir/${kernel_src_rpm}"
echo "Trying $url ..."
if wget -q "$url"; then
break
fi
done
if [ ! -e ${downloaddir}/${kernel_src_rpm} ]; then
echo "Downloading kernel source failed. Has the yum source repository been configured in /etc/yum.repos.d ?"
exit 1
fi
fi
log "Installing kernel build prerequisites"
sudo yum-builddep -q -y ${downloaddir}/${kernel_src_rpm}
log "Installing kernel sources in ${rpmbuild_dir}"
cd ${rpmbuild_dir}
{ rpm -i ${downloaddir}/${kernel_src_rpm} 2>&1 \
| grep -v ' does not exist'; }
cd SPECS
{ rpmbuild -bp --target=${arch} kernel*.spec; \
rc=$?; if [ rc != 0 ]; then exit $rc; fi; } 2>&1 \
| tee prep-err.log
log "Copying SCST patches to the SOURCES directory"
cd ${rpmbuild_dir}/SOURCES
copy_patch $scst_dir/scst/kernel/rhel/scst_exec_req_fifo-${kver}.patch scst_exec_req_fifo.patch
copy_patch $scst_dir/iscsi-scst/kernel/patches/rhel/put_page_callback-${kver}.patch put_page_callback.patch
log "Adding SCST patches in kernel.spec"
if [ ${kver#2.6.18} != $kver ]; then
if [ -e ${rpmbuild_dir}/SPECS/kernel-2.6.spec ]; then
# RHEL/CentOS/SL 5.6
patch -p1 ${rpmbuild_dir}/SPECS/kernel-2.6.spec <<'EOF' || exit $?
diff -u SPECS/kernel-2.6.spec{.orig,}
--- SPECS/kernel-2.6.spec.orig
+++ SPECS/kernel-2.6.spec
@@ -6386,6 +6386,9 @@
# empty final patch file to facilitate testing of kernel patches
Patch99999: linux-kernel-test.patch
+Patch200: scst_exec_req_fifo.patch
+Patch201: put_page_callback.patch
+
# END OF PATCH DEFINITIONS
BuildRoot: %{_tmppath}/kernel-%{KVERREL}-root
@@ -12593,6 +12596,9 @@
rm -f kernel-%{kversion}-*-debug.config
%endif
+%patch200 -p1
+%patch201 -p1
+
# now run oldconfig over all the config files
for i in *.config
do
EOF
else
# RHEL/CentOS/SL 5.7
patch -p1 ${rpmbuild_dir}/SPECS/kernel.spec <<'EOF' || exit $?
--- SPECS/kernel.spec.orig
+++ SPECS/kernel.spec
@@ -425,6 +425,9 @@
Patch2: xen-config-2.6.18-redhat.patch
Patch3: xen-2.6.18-redhat.patch
+Patch200: scst_exec_req_fifo.patch
+Patch201: put_page_callback.patch
+
# empty final patch file to facilitate testing of kernel patches
Patch99999: linux-kernel-test.patch
@@ -733,6 +736,9 @@
rm -f kernel-%{version}-*-debug.config
%endif
+%patch200 -p1
+%patch201 -p1
+
# now run oldconfig over all the config files
for i in *.config
do
EOF
fi
elif [ ${kver#2.6.32-71} != $kver ]; then
# RHEL/CentOS/SL 6.0
patch -p1 ${rpmbuild_dir}/SPECS/kernel.spec <<'EOF' || exit $?
diff -u SPECS/kernel.spec{.orig,}
--- SPECS/kernel.spec.orig
+++ SPECS/kernel.spec
@@ -601,6 +601,9 @@
Source82: config-s390x-debug
Source83: config-s390x-debug-rhel
+Patch200: scst_exec_req_fifo.patch
+Patch201: put_page_callback.patch
+
# empty final patch file to facilitate testing of kernel patches
Patch999999: linux-kernel-test.patch
@@ -891,6 +894,9 @@
# Dynamically generate kernel .config files from config-* files
make -f %{SOURCE20} VERSION=%{version} configs
+ApplyPatch scst_exec_req_fifo.patch
+ApplyPatch put_page_callback.patch
+
ApplyOptionalPatch linux-kernel-test.patch
# Any further pre-build tree manipulations happen here.
@@ -917,6 +923,7 @@
for i in *.config
do
mv $i .config
+ echo "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION=y" >> .config
Arch=`head -1 .config | cut -b 3-`
make ARCH=$Arch %{oldconfig_target} > /dev/null
echo "# $Arch" > configs/$i
EOF
elif [ ${kver#2.6.32-131} != $kver ]; then
# RHEL/CentOS/SL 6.1
patch -p1 ${rpmbuild_dir}/SPECS/kernel.spec <<'EOF' || exit $?
# RHEL/CentOS/SL 6.x
diff -u SPECS/kernel.spec{.orig,}
--- SPECS/kernel.spec.orig
+++ SPECS/kernel.spec
@@ -601,6 +601,9 @@
Source82: config-generic
Source83: config-x86_64-debug-rhel
+Patch200: scst_exec_req_fifo.patch
+Patch201: put_page_callback.patch
+
# empty final patch file to facilitate testing of kernel patches
Patch999999: linux-kernel-test.patch
@@ -891,6 +894,9 @@
# Dynamically generate kernel .config files from config-* files
make -f %{SOURCE20} VERSION=%{version} configs
+ApplyPatch scst_exec_req_fifo.patch
+ApplyPatch put_page_callback.patch
+
ApplyOptionalPatch linux-kernel-test.patch
# Any further pre-build tree manipulations happen here.
@@ -917,6 +923,7 @@
for i in *.config
do
mv $i .config
+ echo "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION=y" >> .config
Arch=`head -1 .config | cut -b 3-`
make ARCH=$Arch %{oldconfig_target} > /dev/null
echo "# $Arch" > configs/$i
EOF
fi
log "Rebuilding kernel"
cd ${rpmbuild_dir}/SPECS
{ rpmbuild -bb --target=${arch} --with baseonly --with firmware --without kabichk kernel*.spec; rc=$?; if [ $rc != 0 ]; then exit $rc; fi; } 2>&1 \
| tee build.log
log "Ready. You can now install the freshly built kernel RPM as follows:\n"\
"sudo rpm -ivh --force $HOME/rpmbuild/RPMS/${arch}/kernel-*.rpm"

View File

@@ -27,7 +27,7 @@
# - Duplicates the entire source tree to the temporary directory and
# compiles the SCST source code.
# - Duplicates the entire source tree to the temporary directory, runs
# 'make debug2release' and again compiles the SCST source code.
# 'make 2release' and again compiles the SCST source code.
# - Checks whether the specified kernel version is present
# in the directory specified through option -c.
# - If the source code of the specified kernel version is not present,
@@ -54,6 +54,8 @@
# Function definitions #
########################
source $(dirname $0)/kernel-version
function usage {
echo "Usage: $0 [-c <dir>] [-d <dir>] [-f] [-h] [-j <jobs>] [-p <patchdir>] [-q] <kver1> <kver2> ..."
echo " -c - cache directory for Linux kernel tarballs."
@@ -65,17 +67,6 @@ function usage {
echo " <kver1> <kver2> ... - kernel versions to test."
}
# First three components of the kernel version number.
function kernel_version {
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\).*$/\1/p'
}
# Last component of the kernel version, or the empty string if $1 has only
# three components.
function patchlevel {
echo "$1" | sed -n 's/^\([0-9]*\.[0-9]*\.[0-9]*\)[.-]\(.*\)$/\2/p'
}
# Create a linux-$1 tree in the current directory, where $1 is a kernel
# version number with either three or four components.
function extract_kernel_tree {
@@ -184,9 +175,9 @@ EOF
function test_scst_tree_patches {
local rc=0
echo "Testing whether the SCST patches apply cleanly to the SCST tree ..."
for p in *.patch srpt/patches/scst_increase_max_tgt_cmds.patch
for p in *.patch srpt/patches/scst*.patch
do
if ! patch -p0 -f --dry-run -s <$p &>/dev/null; then
if [ -e "$p" ] && ! patch -p0 -f --dry-run -s <$p &>/dev/null; then
echo "ERROR: patch $p does not apply cleanly."
rc=1
fi
@@ -219,7 +210,8 @@ function compile_scst_unpatched {
if mkdir -p "${workingdirectory}" \
&& cd "${workingdirectory}" \
&& duplicate_scst_source_tree "${scst}" \
&& (make -s clean \
&& (export KCFLAGS=-DCONFIG_SCST_MEASURE_LATENCY; \
make -s clean \
&& make -s scst iscsi-scst \
&& if "${scst_local}" = "true" ; then make -C scst_local clean; fi \
&& if "${scst_local}" = "true" ; then make -C scst_local -s ; fi \
@@ -249,7 +241,8 @@ function compile_scst_patched {
&& cd "${workingdirectory}" \
&& duplicate_scst_source_tree "${scst}" \
&& make -s "$1" \
&& (make -s clean \
&& (export KCFLAGS=-DCONFIG_SCST_MEASURE_LATENCY; \
make -s clean \
&& make -s scst iscsi-scst \
&& if "${scst_local}" = "true" ; then make -C scst_local clean; fi \
&& if "${scst_local}" = "true" ; then make -C scst_local -s ; fi \
@@ -284,16 +277,22 @@ function download_file {
function download_kernel {
local kver="$(kernel_version $1)"
local plevel="$(patchlevel $1)"
local series="$1"
if [ "${series:0:2}" = "3." ]; then
series="3.x"
else
series="${series:0:3}"
fi
mkdir -p "${kernel_sources}" || return $?
test -w "${kernel_sources}" || return $?
(
cd "${kernel_sources}" || return $?
download_file "${kernel_mirror}/linux-$(kernel_version $1).tar.bz2" \
download_file "${kernel_mirror}/v$series/linux-$kver.tar.bz2" \
|| return $?
if [ "${plevel}" != "" ]; then
download_file "${kernel_mirror}/patch-$1.bz2" \
|| download_file "${kernel_longterm}/v$(kernel_version $1)/patch-$1.bz2" \
download_file "${kernel_mirror}/v$series/patch-$1.bz2" \
|| download_file "${kernel_longterm}/v$series/longterm/patch-$1.bz2" \
|| return $?
fi
)
@@ -547,8 +546,8 @@ fi
# Where to store persistenly downloaded kernel tarballs and kernel patches.
kernel_sources="$HOME/software/downloads"
# URL for downloading kernel tarballs and kernel patches.
kernel_mirror="ftp://ftp.eu.kernel.org/pub/linux/kernel/v2.6"
kernel_longterm="http://www.kernel.org/pub/linux/kernel/v2.6/longterm"
kernel_mirror="ftp://ftp.kernel.org/pub/linux/kernel"
kernel_longterm="http://www.kernel.org/pub/linux/kernel"
kernel_versions=""
# Directory in which the regression test output files will be stored. Must be
# an absolute path.
@@ -615,8 +614,8 @@ fi
test_scst_tree_patches || exit $?
if [ "${run_local_compilation}" = "true" ]; then
compile_scst_unpatched || exit $?
compile_scst_patched debug2release || exit $?
compile_scst_patched debug2perf || exit $?
compile_scst_patched 2release || exit $?
compile_scst_patched 2perf || exit $?
compile_scst_patched enable_proc || exit $?
fi

View File

@@ -31,7 +31,8 @@
# the KERNEL_VERSION() macro.
function version_code(kver, array) {
match(kver, "([0-9]+).([0-9]+).([0-9]+)", array)
if (!match(kver, "([0-9]+).([0-9]+).([0-9]+)", array))
match(kver, "([0-9]+).([0-9]+)", array)
return 65536*array[1] + 256*array[2] + array[3]
}
@@ -59,7 +60,7 @@ function evaluate(stmnt, pattern, arg, op, result) {
if (match(stmnt, "^+#ifndef (.*)$", arg))
{
stmnt = "+#if ! defined(" arg[1] ")"
stmnt = "+#if !defined(" arg[1] ")"
}
gsub("LINUX_VERSION_CODE", LINUX_VERSION_CODE, stmnt)
@@ -165,8 +166,8 @@ function evaluate(stmnt, pattern, arg, op, result) {
while (match(stmnt, pattern, op) != 0)
{
result="error"
if (op[2] == "+") result = op[1] * op[3]
else if (op[2] == "-") result = op[1] / op[3]
if (op[2] == "+") result = op[1] + op[3]
else if (op[2] == "-") result = op[1] - op[3]
sub(pattern, result, stmnt)
}
@@ -195,6 +196,18 @@ function evaluate(stmnt, pattern, arg, op, result) {
stmnt = "+#if " (op[1] != 0 ? op[2] : op[1])
}
pattern="^+#if[ ]*(!*[ ]*defined[ ]*\\([ ]*[A-Za-z_]*[ ]*\\))\\&\\&[ ]*([01])[ ]*$"
while (match(stmnt, pattern, op) != 0)
{
stmnt = "+#if " (op[2] != 0 ? op[1] : op[2])
}
pattern="^+#if[ ]*(!*[ ]*[A-Za-z_]*[ ]*)\\&\\&[ ]*([01])[ ]*$"
while (match(stmnt, pattern, op) != 0)
{
stmnt = "+#if " (op[2] != 0 ? op[1] : op[2])
}
pattern="(-*[0-9]+)[ ]*\\|\\|[ ]*(-*[0-9]+)"
while (match(stmnt, pattern, op) != 0)
{
@@ -228,9 +241,9 @@ function evaluate(stmnt, pattern, arg, op, result) {
}
# Evaluate ! stmnt
# Evaluate !stmnt
function invert(stmnt) {
return evaluate(gensub("^+#if (.*)$", "+#if ! (\\1)", "g", stmnt))
return evaluate(gensub("^+#if (.*)$", "+#if !(\\1)", "g", stmnt))
}
@@ -246,14 +259,13 @@ function handle_if(evaluated)
|| $0 ~ "RHEL_MAJOR" \
|| $0 ~ "RHEL_MINOR" \
|| $0 ~ "RHEL_RELEASE_CODE" \
|| $0 ~ "GENERATING_UPSTREAM_PATCH" \
|| generating_upstream_patch_defined \
&& $0 ~ "GENERATING_UPSTREAM_PATCH" \
|| $0 ~ "CONFIG_TCP_ZERO_COPY_TRANSFER_COMPLETION_NOTIFICATION" \
|| ($0 ~ "CONFIG_SCST_PROC" && config_scst_proc_undefined) \
|| ($0 ~ "SCSI_EXEC_REQ_FIFO_DEFINED" && SCSI_EXEC_REQ_FIFO_DEFINED!="") \
|| ($0 ~ "SCST_IO_CONTEXT" && SCST_IO_CONTEXT != ""))
{
#print $0 " -> " evaluated
$0 = evaluated
}
else
{
@@ -268,7 +280,7 @@ function handle_if(evaluated)
if_stmnt[if_nesting_level] = evaluated
any_section_output[if_nesting_level] = 0
decision[if_nesting_level] = evaluated
inv_decision[if_nesting_level] = evaluate(sprintf("+#if ! %s", substr(evaluated, 6)))
inv_decision[if_nesting_level] = evaluate(sprintf("+#if !%s", substr(evaluated, 6)))
if (debug)
printf "/* debug specialize-patch: (f) %s / %s */\n", \
decision[if_nesting_level], inv_decision[if_nesting_level]
@@ -283,7 +295,7 @@ function handle_if(evaluated)
evaluated = evaluate(evaluated)
decision[if_nesting_level] = evaluated
inv_decision[if_nesting_level] \
= evaluate(sprintf("+#if %s && ! %s", \
= evaluate(sprintf("+#if %s && !%s", \
substr(inv_decision[if_nesting_level], 6), \
substr(evaluated, 6)))
if (debug)
@@ -300,9 +312,11 @@ function handle_if(evaluated)
function process_preprocessor_statement(evaluated, condition) {
evaluated = evaluate($0)
condition = 1
ei = evaluated_if_stmnt[if_nesting_level];
if (evaluated ~ "^+#if")
{
if_nesting_level++
evaluated_if_stmnt[if_nesting_level] = evaluated
evaluated = handle_if(evaluated)
}
else if (evaluated ~ "^+#elif")
@@ -326,12 +340,17 @@ function process_preprocessor_statement(evaluated, condition) {
if (condition)
{
output = 1
for (i = if_nesting_level; i >= 0; i--)
{
output = output && decision[i] != "+#if 0"
for (i = if_nesting_level; i >= 0; i--) {
if (debug)
printf "/* debug specialize-patch: (g1) %s: decision[%d] = %s */\n", \
evaluated, i, decision[i]
output = output && decision[i] != "+#if 0" && decision[i] != "+#elif 0"
}
if (output)
any_section_output[if_nesting_level] = 1
if (debug)
printf "/* debug specialize-patch: (g2) %s: output = %d */\n", \
evaluated, output
}
if (evaluated ~ "^+#define SCSI_EXEC_REQ_FIFO_DEFINED$" \
&& SCSI_EXEC_REQ_FIFO_DEFINED != "" \
@@ -343,10 +362,48 @@ function process_preprocessor_statement(evaluated, condition) {
discard = 1
delete_next_blank_line = 1
}
else if (output && (! condition || condition && matching_if !~ "^+#if [01]"))
else if (output && (!condition \
|| condition && matching_if !~ "^+#if [01]" \
&& matching_if !~ "^+#elif [01]"))
{
for (i = 0; i < input_line_count; i++)
line[lines++] = input_line[i]
if (evaluated == "+#if undecided" \
|| (evaluated !~ "^+#if" \
&& evaluated !~ "^+#elif" \
&& evaluated !~ "^+#endif"))
{
for (i = 0; i < input_line_count; i++)
line[lines++] = input_line[i]
} else {
# If the statement being processed is an #else or #endif that is not a
# header file include guard and if that statement has a trailing comment,
# replace that comment by the partially evaluated matching #if expression.
if (evaluated ~ "^+#else" || evaluated ~ "^+#endif") {
if ($0 ~ "\\*/") {
if ($0 ~ "_H_* \\*/$") {
evaluated = $0
} else {
if (ei ~ "^+#if ")
ei = substr(ei, 6)
else if (ei ~ "^+#ifdef")
ei = substr(ei, 9)
evaluated = sprintf("%s /* %s */",
$0 ~ " " ? substr($0, 1, index($0, " ")) : $0,
ei);
if (match(evaluated, "([^/ ]*) */\\* defined\\(([^()]*)\\) \\*/",
arg))
{
evaluated = sprintf("%s /* %s */", arg[1], arg[2])
}
}
} else {
evaluated = $0
}
if (debug)
printf "/* debug specialize-patch: (h) %s */\n", evaluated
}
line[lines++] = evaluated
lines_less_added += input_line_count - 1
}
}
else
{
@@ -396,7 +453,7 @@ BEGIN {
exit 1
}
LINUX_VERSION_CODE = version_code(kernel_version)
if (LINUX_VERSION_CODE < 2*65536 || LINUX_VERSION_CODE > 3*65536)
if (LINUX_VERSION_CODE < 2*65536 || LINUX_VERSION_CODE > 4*65536)
{
printf "Error: kernel version (%s) is out of range.\n", kernel_version
exit 1
@@ -517,3 +574,8 @@ END {
# Dump processed contents of the last read hunk.
dump_lines()
}
# Local variables:
# indent-tabs-mode: nil
# c-basic-offset: 2
# End: