mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-19 21:56:31 +00:00
scripts: Merge r8007:8277 from trunk
git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/3.3.x@8281 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
+66
-18
@@ -3,7 +3,8 @@
|
||||
# from kernel.org.
|
||||
|
||||
kernel_mirror="http://cdn.kernel.org/pub/linux/kernel"
|
||||
kernel_sources="$HOME/software/downloads"
|
||||
kernel_downloads="$HOME/software/downloads"
|
||||
kernel_tree="$HOME/software/linux-kernel"
|
||||
|
||||
# Whether or not kernel version $1 is lower than or equal kernel version $2.
|
||||
function kernel_version_le {
|
||||
@@ -42,7 +43,7 @@ function download_file {
|
||||
}
|
||||
|
||||
# Make sure the kernel tarball and patch file are present in directory
|
||||
# ${kernel_sources}. Download any missing files from ${kernel_mirror}.
|
||||
# ${kernel_downloads}. Download any missing files from ${kernel_mirror}.
|
||||
function download_kernel {
|
||||
local kver="$(kernel_version $1)"
|
||||
local plevel="$(patchlevel $1)"
|
||||
@@ -52,10 +53,10 @@ function download_kernel {
|
||||
[12].*) series="${series:0:3}";;
|
||||
*) series="${series/.*/}.x";;
|
||||
esac
|
||||
mkdir -p "${kernel_sources}" || return $?
|
||||
test -w "${kernel_sources}" || return $?
|
||||
mkdir -p "${kernel_downloads}" || return $?
|
||||
test -w "${kernel_downloads}" || return $?
|
||||
(
|
||||
cd "${kernel_sources}" || return $?
|
||||
cd "${kernel_downloads}" || return $?
|
||||
if [ "$plevel" = "" -o "$plevel" = "0" ] ||
|
||||
download_file "${kernel_mirror}/v$series/patch-$1.xz"
|
||||
then
|
||||
@@ -73,15 +74,15 @@ function extract_kernel_archive {
|
||||
local plevel="$(patchlevel $1)"
|
||||
local series="$1"
|
||||
|
||||
if [ -e "${kernel_sources}/linux-$1.tar.xz" ]; then
|
||||
xz -cd "${kernel_sources}/linux-$1.tar.xz" | tar xf -
|
||||
elif [ -e "${kernel_sources}/linux-$kver.tar.xz" ]; then
|
||||
xz -cd "${kernel_sources}/linux-$kver.tar.xz" | tar xf - &&
|
||||
if [ -e "${kernel_downloads}/linux-$1.tar.xz" ]; then
|
||||
xz -cd "${kernel_downloads}/linux-$1.tar.xz" | tar xf -
|
||||
elif [ -e "${kernel_downloads}/linux-$kver.tar.xz" ]; then
|
||||
xz -cd "${kernel_downloads}/linux-$kver.tar.xz" | tar xf - &&
|
||||
mv linux-$kver linux-$1
|
||||
elif [ -e "${kernel_sources}/linux-$1.tar.bz2" ]; then
|
||||
tar xjf "${kernel_sources}/linux-$1.tar.bz2"
|
||||
elif [ -e "${kernel_sources}/linux-$kver.tar.bz2" ]; then
|
||||
tar xjf "${kernel_sources}/linux-$kver.tar.bz2" &&
|
||||
elif [ -e "${kernel_downloads}/linux-$1.tar.bz2" ]; then
|
||||
tar xjf "${kernel_downloads}/linux-$1.tar.bz2"
|
||||
elif [ -e "${kernel_downloads}/linux-$kver.tar.bz2" ]; then
|
||||
tar xjf "${kernel_downloads}/linux-$kver.tar.bz2" &&
|
||||
mv linux-$kver linux-$1
|
||||
else
|
||||
return 1
|
||||
@@ -100,10 +101,10 @@ function extract_kernel_tree {
|
||||
(
|
||||
cd "${tmpdir}" || return $?
|
||||
if [ "$plevel" != "" -a "$plevel" != "0" -a \
|
||||
-e "${kernel_sources}/patch-$1.xz" ]; then
|
||||
-e "${kernel_downloads}/patch-$1.xz" ]; then
|
||||
extract_kernel_archive $kver || return $?
|
||||
mv linux-$kver linux-$1
|
||||
( cd linux-$1 && xz -cd "${kernel_sources}/patch-$1.xz" \
|
||||
( cd linux-$1 && xz -cd "${kernel_downloads}/patch-$1.xz" \
|
||||
| patch -p1 -f -s; ) \
|
||||
|| return $?
|
||||
else
|
||||
@@ -113,6 +114,12 @@ function extract_kernel_tree {
|
||||
fi
|
||||
mv "linux-$1" ".." || return $?
|
||||
cd "../linux-$1" || return $?
|
||||
)
|
||||
rmdir "${tmpdir}"
|
||||
}
|
||||
|
||||
# Patch a kernel tree where $1 is the kernel version.
|
||||
function patch_kernel {
|
||||
if [ "$1" = "2.6.29" -o "$1" = "2.6.29.1" -o "$1" = "2.6.29.2" -o "$1" = "2.6.29.3" ]
|
||||
then
|
||||
patch -f -s -p1 <<'EOF'
|
||||
@@ -321,7 +328,7 @@ index d6d65537b0d9..6aad8308a0ac 100644
|
||||
EOF
|
||||
fi
|
||||
case "$1" in
|
||||
3.[0-9].*|3.1[01345].*|3.17.*|3.19.*|4.[023567].*)
|
||||
2.6.3[6-9]*|3.[0-9]|3.[0-9].*|3.1[01345]|3.1[01345].*|3.17|3.17.*|3.19|3.19.*|4.[023567]|4.[023567].*)
|
||||
patch -p1 <<'EOF'
|
||||
From c6a385539175ebc603da53aafb7753d39089f32e Mon Sep 17 00:00:00 2001
|
||||
From: Borislav Petkov <bp@suse.de>
|
||||
@@ -383,9 +390,38 @@ index 0ed6ce300543..c324b43712f0 100644
|
||||
KBUILD_AFLAGS_MODULE := -DMODULE
|
||||
KBUILD_CFLAGS_MODULE := -DMODULE
|
||||
KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds
|
||||
EOF
|
||||
;;
|
||||
2.6.3[1-5]*)
|
||||
patch -p1 <<'EOF'
|
||||
diff --git a/Makefile b/Makefile
|
||||
index 141da26fda4b..343ec388ae2e 100644
|
||||
--- a/Makefile
|
||||
+++ b/Makefile
|
||||
@@ -349,12 +349,13 @@ LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
|
||||
|
||||
KBUILD_CPPFLAGS := -D__KERNEL__
|
||||
|
||||
-KBUILD_CFLAGS := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
|
||||
+KBUILD_CFLAGS := $(call cc-option,-fno-PIE) \
|
||||
+ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
|
||||
-fno-strict-aliasing -fno-common \
|
||||
-Werror-implicit-function-declaration \
|
||||
-Wno-format-security \
|
||||
-fno-delete-null-pointer-checks
|
||||
-KBUILD_AFLAGS := -D__ASSEMBLY__
|
||||
+KBUILD_AFLAGS := -D__ASSEMBLY__ $(call cc-option,-fno-PIE)
|
||||
|
||||
# Read KERNELRELEASE from include/config/kernel.release (if it exists)
|
||||
KERNELRELEASE = $(shell cat include/config/kernel.release 2> /dev/null)
|
||||
EOF
|
||||
;;
|
||||
esac
|
||||
|
||||
# Use sed to patch the ____ilog2_NaN() prototype.
|
||||
sed -i 's/__attribute__((const, noreturn))/__attribute__((noreturn))/' \
|
||||
include/linux/log2.h tools/include/linux/log2.h 2>/dev/null
|
||||
|
||||
# After patch-v4.14.1[12] has been applied, the execute bit has to be
|
||||
# set for sync-check.sh since patch can't do that.
|
||||
for f in "tools/objtool/sync-check.sh"; do
|
||||
@@ -393,7 +429,19 @@ EOF
|
||||
chmod a+x "$f"
|
||||
fi
|
||||
done
|
||||
)
|
||||
rmdir "${tmpdir}"
|
||||
}
|
||||
|
||||
function download_and_extract_kernel_tree {
|
||||
if [ -e "${kernel_tree}" ]; then
|
||||
rm -rf "linux-$1"
|
||||
mkdir "linux-$1"
|
||||
(
|
||||
cd "${kernel_tree}" &&
|
||||
{ git tag -l "v$1" >/dev/null || git fetch stable; } &&
|
||||
git archive "v$1"
|
||||
) | tar -C "linux-$1" -xf-
|
||||
else
|
||||
download_kernel "$1" && extract_kernel_tree "$1"
|
||||
fi &&
|
||||
(cd linux-$1 && patch_kernel "$1")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user