Files
scst/scripts/generate-kernel-patch
Vladislav Bolkhovitin 00bca6ce75 Patch from Bart Van Assche <bart.vanassche@gmail.com>:
By this time I have reworked the update of scripts/generate-kernel-patch'>scripts/generate-kernel-patch. 
These are the changes that were already present in version 1 of this patch 
and that have been kept in this patch:
- The SCST code has been moved from drivers/scsi/scsi_tgt to drivers/scst.
- Moved SCST header files from include/scsi_tgt to include/scst.
- Added iscsi-scst in drivers/scst/iscsi-scst.

For the time being the generate-kernel-patch does no longer try to add the 
qla2x00t driver in drivers/scst/qla2x00-target -- I have not yet been able to 
figure out how to get qla2x00t/qla2x00-target compiled without the initiator 
code.

Just as in version 1 of this patch, the following files in the Subversion 
repository have been renamed to reflect the above changes:
- Renamed scst/kernel/in-tree/Makefile.scsi.Linux-2.6.24.patch'>scst/kernel/in-tree/Makefile.scsi.Linux-2.6.24.patch to
scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch'>scst/kernel/in-tree/Makefile.drivers.Linux-2.6.24.patch.
- Renamed Kconfig'>scst/kernel/in-tree/Kconfig.scsi.Linux-2.6.24.patch to
scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch'>scst/kernel/in-tree/Kconfig.drivers.Linux-2.6.24.patch.
- Renamed scst/kernel/in-tree/Makefile.scsi_tgt'>scst/kernel/in-tree/Makefile.scsi_tgt to
scst/kernel/in-tree/Makefile.scst'>scst/kernel/in-tree/Makefile.scst.
- Renamed scst/kernel/in-tree/Kconfig.scsi_tgt'>scst/kernel/in-tree/Kconfig.scsi_tgt to
scst/kernel/in-tree/Kconfig.scst'>scst/kernel/in-tree/Kconfig.scst.

Because of the above changes the include path specified in the following
Makefiles had to be changed:
- scst/kernel/in-tree/Makefile.dev_handlers'>scst/kernel/in-tree/Makefile.dev_handlers
- srpt/src/Makefile.in_kernel'>srpt/src/Makefile.in_kernel

Other changes:
- I have added menu/endmenu entries in file scst/kernel/in-tree/Kconfig.scst
such that the SCST entries become visible when running make xconfig or make
menuconfig.
- Elaborated the SCST help texts a little bit (in file
scst/kernel/in-tree/Kconfig.scst).

New in version 2 of this patch:
- Moved remaining patches in the generate-kernel-patch script to separate 
files.
- Added support for the 2.6.25 kernel.

This patch has been tested as follows:

mkdir -p tmp
cd tmp
rm -rf linux-2.6.25.3 /lib/modules/2.6.25.3-scst
tar xjf ~vanasscb/software/downloads/linux-2.6.25.3.tar.bz2
cd linux-2.6.25.3
cp ../.config-2.6.25 .
(cd ~vanasscb/software/scst
&& ~vanasscb/software/scst/scripts/generate-kernel-patch \
2.6.25) | patch -p1
make oldconfig
diff ../.config .
make xconfig
make menuconfig
make -j5 bzImage modules
make modules_install install
cp -r /lib/firmware/$(uname -r) /lib/firmware/2.6.25.3-scst
update-initramfs -k 2.6.25.3-scst -c
reboot
modprobe iscsi-scst
modprobe ib_srpt
lsmod | grep -E 'scst|ib_srpt'
dmesg

Signed-off-by: bart.vanassche@gmail.com 


git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@373 d57e44dd-8a1f-0410-8b47-8ef2f437770f
2008-05-15 15:00:21 +00:00

225 lines
5.5 KiB
Bash
Executable File

#!/bin/bash
############################################################################
#
# Script for converting the SCST source tree as it exists in the Subversion
# repository to a Linux kernel patch.
#
# Copyright (C) 2008 Bart Van Assche <bart.vanassche@gmail.com>
#
# 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.
#
############################################################################
########################
# Function definitions #
########################
# Convert an existing patch.
# $1: path of patch to be added.
# $2: path in kernel tree of file to be patched.
function add_patch {
if [ ! -e "$1" ]; then
echo "Error: could not find $1." >&2
exit 1
fi
sed -e "s:^--- [^ ]*:--- orig/$2:" -e "s:^+++ [^ ]*:+++ $2:" < "$1"
}
# Generate a patch for a file to be added to the kernel source tree, and strip
# trailing whitespace from C source files while converting the file to patch
# format.
# $1: path of file to be added.
# $2: path in kernel tree where file should be added.
function add_file {
local a b
if [ ! -e "$1" ]; then
echo "Error: could not find $1." >&2
exit 1
fi
# Skip any files generated by the kernel build process (*.mod.c).
if [ "${1%.mod.c}" != "$1" ]; then
return 0;
fi
cat <<EOF
diff -uprN orig/$2 $2
--- orig/$2
+++ $2
@@ -0,0 +1,$(wc -l "$1" | { read a b; echo $a; }) @@
EOF
if [ "${2%.[ch]}" != "$2" ]; then
sed -e 's/^/+/' -e 's/[ ]*$//g' < "$1"
else
sed -e 's/^/+/' < "$1"
fi
}
#########################
# Argument verification #
#########################
if [ ! -e scst -o ! -e iscsi-scst -o ! -e srpt ]; then
echo "Please run this script from inside the SCST subversion source tree."
exit 1
fi
if [ $# != 1 ]; then
echo "Usage: $0 <kernel version>."
exit 1
fi
####################
# Patch Generation #
####################
kernel_version="$1"
kpatch=( \
"scst/kernel/scst_exec_req_fifo-${kernel_version}.patch" \
"iscsi-scst/kernel/patches/put_page_callback-${kernel_version}.patch" \
)
for p in "${kpatch[@]}"
do
if [ ! -e "$p" ]; then
echo "Error: kernel version ${kernel_version} is not supported by SCST."
echo "(could not find file $p)."
exit 1
fi >&2
done
# General kernel patches.
for p in "${kpatch[@]}"
do
cat "$p"
echo ''
echo ''
done
# Directory include/scst/
for f in scst/include/*h
do
add_file "${f}" "linux-${kernel_version}/include/scst/${f#scst/include/}"
done
for f in iscsi-scst/include/*h
do
add_file "${f}" "linux-${kernel_version}/include/scst/${f#iscsi-scst/include/}"
done
# Directory drivers/
add_patch "scst/kernel/in-tree/Kconfig.drivers.Linux-${kernel_version}.patch" \
"linux-${kernel_version}/drivers/Kconfig"
add_patch "scst/kernel/in-tree/Makefile.drivers.Linux-${kernel_version}.patch"\
"linux-${kernel_version}/drivers/Makefile"
# Directory drivers/scst/
add_file "scst/kernel/in-tree/Kconfig.scst" \
"linux-${kernel_version}/drivers/scst/Kconfig"
add_file "scst/kernel/in-tree/Makefile.scst" \
"linux-${kernel_version}/drivers/scst/Makefile"
for f in scst/src/*.[ch]
do
add_file ${f} linux-${kernel_version}/drivers/scst/${f#scst/src/}
echo ''
echo ''
done
# Directory drivers/scst/dev_handlers/
add_file "scst/kernel/in-tree/Makefile.dev_handlers" \
"linux-${kernel_version}/drivers/scst/dev_handlers/Makefile"
for f in scst/src/dev_handlers/*.[ch]
do
add_file ${f} linux-${kernel_version}/drivers/scst/dev_handlers/${f#scst/src/dev_handlers/}
echo ''
echo ''
done
# Directory drivers/scst/iscsi-scst/
add_file "iscsi-scst/kernel/Makefile.in-kernel" \
"linux-${kernel_version}/drivers/scst/iscsi-scst/Makefile"
add_file "iscsi-scst/kernel/Kconfig" \
"linux-${kernel_version}/drivers/scst/iscsi-scst/Kconfig"
for f in iscsi-scst/kernel/*.[ch]
do
add_file "${f}" \
"linux-${kernel_version}/drivers/scst/iscsi-scst/${f#iscsi-scst/kernel/}"
echo ''
echo ''
done
# Directory drivers/scst/qla2x00-target/
if false; then
add_file "qla2x00t/qla2x00-target/Makefile.in-kernel" \
"linux-${kernel_version}/drivers/scst/qla2x00-target/Makefile"
add_file "qla2x00t/qla2x00-target/Kconfig" \
"linux-${kernel_version}/drivers/scst/qla2x00-target/Kconfig"
add_file "qla2x00t/qla2x_tgt_def.h" \
"linux-${kernel_version}/drivers/scst/qla2x00-target/qla2x_tgt_def.h"
for f in qla2x00t/qla2x00-target/*.[ch]
do
add_file "${f}" \
"linux-${kernel_version}/drivers/scst/qla2x00-target/${f#qla2x00t/qla2x00-target/}"
echo ''
echo ''
done
fi
# Directory drivers/infiniband/ulp/srpt/
add_patch "srpt/src/Kconfig.infiniband.Linux-${kernel_version}.patch" \
"linux-${kernel_version}/drivers/infiniband/Kconfig"
add_patch "srpt/src/Makefile.infiniband.Linux-${kernel_version}.patch" \
"linux-${kernel_version}/drivers/infiniband/Makefile"
add_file "srpt/src/Kconfig" "drivers/infiniband/ulp/srpt/Kconfig"
add_file "srpt/src/Makefile.in_kernel" "drivers/infiniband/ulp/srpt/Makefile"
for f in srpt/src/*.[ch]
do
add_file ${f} linux-${kernel_version}/drivers/infiniband/ulp/srpt/${f#srpt/src/}
echo ''
echo ''
done