* [PATCH 01/16] prepare-kernel.sh: Add reverse mode
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-25 11:57 ` [PATCH 02/16] prepare-kernel.sh: Emit architecture agnostic changes Richard Weinberger
` (15 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
There is currently no way to undo preparing of a kernel, except using
--outpatch and reverting the resulting patch later.
But in link mode the kernel tree needs manual cleaning,
which can be tedious if a git clean -f -d -x is not possible.
The new --reverse flag offers this feature, it removes all previously
created symlinks and directories.
To be able to undo effects by patch_append(), keep a .orig file link
as the script already does for symlinks in the linux tree.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 73 +++++++++++++++++++++++++++++++--------
1 file changed, 59 insertions(+), 14 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index faf3e7235..f0f81471f 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -55,7 +55,9 @@ patch_append() {
if test -L "$linux_tree/$file" ; then
mv "$linux_tree/$file" "$linux_tree/$file.orig"
cp "$linux_tree/$file.orig" "$linux_tree/$file"
- fi
+ else
+ cp "$linux_tree/$file" "$linux_tree/$file.orig"
+ fi
chmod +w "$linux_tree/$file"
cat >> "$linux_tree/$file"
else
@@ -66,6 +68,16 @@ patch_append() {
fi
}
+patch_reverse() {
+ file="$1"
+ if test "x$output_patch" = "x"; then
+ if test -L "$linux_tree/$file" ; then
+ rm "$linux_tree/$file"
+ fi
+ mv "$linux_tree/$file.orig" "$linux_tree/$file"
+ fi
+}
+
patch_link() {
recursive="$1" # "r" or "n"
link_file="$2" # "m", "n" or some file (basename) from $target_dir
@@ -106,11 +118,15 @@ patch_link() {
f=`echo $f | cut -d/ -f2-`
d=`dirname $f`
if test "x$output_patch" = "x"; then
- mkdir -p $linux_tree/$link_dir/$d
- if test x$forcelink = x1 -o \
- ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f;
- then
- ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f
+ if test x$reverse = x1; then
+ rm -f $linux_tree/$link_dir/$f
+ else
+ mkdir -p $linux_tree/$link_dir/$d
+ if test x$forcelink = x1 -o \
+ ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f;
+ then
+ ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f
+ fi
fi
else
if test `check_filter $link_dir/$f` = "ok"; then
@@ -122,6 +138,11 @@ patch_link() {
fi
fi
done
+ if test x$reverse = x1; then
+ if ! find $linux_tree/$link_dir -not -type d | grep -q . ; then
+ rm -rf $linux_tree/$link_dir
+ fi
+ fi
)
}
@@ -138,7 +159,7 @@ generate_patch() {
}
-usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--filterkvers=y|n] [--filterarch=y|n]] [--forcelink] [--default] [--verbose]'
+usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--filterkvers=y|n] [--filterarch=y|n]] [--forcelink] [--default] [--verbose] [--reverse]'
me=`basename $0`
while test $# -gt 0; do
@@ -174,6 +195,9 @@ while test $# -gt 0; do
--verbose)
verbose=1
;;
+ --reverse)
+ reverse=1
+ ;;
--help)
echo "$usage"
exit 0
@@ -223,8 +247,19 @@ if test \! -r $linux_tree/Makefile; then
exit 2
fi
+if test x$reverse = x1; then
+ if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then
+ echo "$me: $linux_tree is not prepared with Xenomai" >&2
+ exit 2
+ fi
+fi
+
# Create an empty output patch file, and initialize the temporary tree.
if test "x$output_patch" != "x"; then
+ if test x$reverse = x1; then
+ echo "$me: --reverse and --outpatch are not compatible"
+ exit 1
+ fi
temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
if [ $? -ne 0 ]; then
@@ -362,15 +397,18 @@ case $linux_VERSION.$linux_PATCHLEVEL in
-e "s,@SRCARCH@,$linux_arch,g" \
$xenomai_root/scripts/Kconfig.frag |
patch_append init/Kconfig
+ elif test x$reverse = x1; then
+ patch_reverse init/Kconfig
fi
test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0
if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then
- p="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
- (echo; echo $p) | patch_append arch/$linux_arch/Makefile
- p="core-\$(CONFIG_XENOMAI) += arch/$linux_arch/xenomai/"
- echo $p | patch_append arch/$linux_arch/Makefile
+ p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
+ p2="core-\$(CONFIG_XENOMAI) += arch/$linux_arch/xenomai/"
+ (echo; echo $p1; echo $p2) | patch_append arch/$linux_arch/Makefile
+ elif test x$reverse = x1; then
+ patch_reverse arch/$linux_arch/Makefile
fi
patch_architecture_specific="n"
@@ -378,11 +416,15 @@ test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0
if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
p="obj-\$(CONFIG_XENOMAI) += xenomai/"
( echo ; echo $p ) | patch_append drivers/Makefile
+ elif test x$reverse = x1; then
+ patch_reverse drivers/Makefile
fi
if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
p="obj-\$(CONFIG_XENOMAI) += xenomai/"
( echo ; echo $p ) | patch_append kernel/Makefile
+ elif test x$reverse = x1; then
+ patch_reverse kernel/Makefile
fi
;;
@@ -391,13 +433,15 @@ esac
# Create local directories then symlink to the source files from
# there, so that we don't pollute the Xenomai source tree with
# compilation files.
+#
+# Keep link dirs (4th parameter) descending, otherwise --reverse
+# is not able to cleanup these directories!
patch_kernelversion_specific="n"
patch_architecture_specific="y"
patch_link r m kernel/cobalt/arch/$linux_arch arch/$linux_arch/xenomai
patch_link n n kernel/cobalt/include/dovetail arch/$linux_arch/include/dovetail
patch_architecture_specific="n"
-patch_link n m kernel/cobalt kernel/xenomai
patch_link n cobalt-core.h kernel/cobalt/trace include/trace/events
patch_link n cobalt-rtdm.h kernel/cobalt/trace include/trace/events
patch_link n cobalt-posix.h kernel/cobalt/trace include/trace/events
@@ -405,14 +449,15 @@ patch_link r n kernel/cobalt/include/asm-generic/xenomai include/asm-generic/xen
patch_link n m kernel/cobalt/posix kernel/xenomai/posix
patch_link n m kernel/cobalt/rtdm kernel/xenomai/rtdm
patch_link n m kernel/cobalt/dovetail kernel/xenomai/pipeline
+patch_link n m kernel/cobalt kernel/xenomai
patch_link r m kernel/drivers drivers/xenomai
patch_link n n include/cobalt/kernel include/xenomai/cobalt/kernel
-patch_link r n include/cobalt/kernel/rtdm include/xenomai/rtdm
patch_link r n include/cobalt/kernel/dovetail/pipeline include/xenomai/pipeline
patch_link r n include/cobalt/uapi include/xenomai/cobalt/uapi
patch_link r n include/rtdm/uapi include/xenomai/rtdm/uapi
-patch_link n version.h include/xenomai include/xenomai
+patch_link r n include/cobalt/kernel/rtdm include/xenomai/rtdm
patch_link n stdarg.h kernel/cobalt/include/linux include/xenomai/linux
+patch_link n version.h include/xenomai include/xenomai
if test "x$output_patch" != "x"; then
if test x$verbose = x1; then
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 02/16] prepare-kernel.sh: Emit architecture agnostic changes
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
2024-05-25 11:57 ` [PATCH 01/16] prepare-kernel.sh: Add reverse mode Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-25 11:57 ` [PATCH 03/16] prepare-kernel.sh: Convert to tabs Richard Weinberger
` (14 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
If --arch= is not passed, emit changes that work on all architectures
supported by Xenomai, currently arm, arm64 and x86.
This is especially useful with --outpatch=, the resulting patch can be
used for any architecture later and makes maintaining and building
a Xenomai enabled kernel easier.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/Kconfig.frag | 2 +-
scripts/prepare-kernel.sh | 97 +++++++++++++++++----------------------
2 files changed, 44 insertions(+), 55 deletions(-)
diff --git a/scripts/Kconfig.frag b/scripts/Kconfig.frag
index b76d25e53..3c9ad2b9f 100644
--- a/scripts/Kconfig.frag
+++ b/scripts/Kconfig.frag
@@ -16,7 +16,7 @@ menuconfig XENOMAI
Please visit http://xenomai.org for more information.
if XENOMAI
-source "arch/@SRCARCH@/xenomai/Kconfig"
+source "arch/$(SRCARCH)/xenomai/Kconfig"
endif
if MIGRATION
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index f0f81471f..826236c34 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -247,13 +247,6 @@ if test \! -r $linux_tree/Makefile; then
exit 2
fi
-if test x$reverse = x1; then
- if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then
- echo "$me: $linux_tree is not prepared with Xenomai" >&2
- exit 2
- fi
-fi
-
# Create an empty output patch file, and initialize the temporary tree.
if test "x$output_patch" != "x"; then
if test x$reverse = x1; then
@@ -274,42 +267,33 @@ if test "x$output_patch" != "x"; then
fi
-# Infer the default architecture if unspecified.
-
if test x$linux_arch = x; then
- build_arch=`$xenomai_root/config/config.guess`
- default_linux_arch=`echo $build_arch|cut -f1 -d-`
+ target_linux_archs="x86 arm arm64"
+else
+ case "$linux_arch" in
+ x86*|i*86|amd*)
+ target_linux_archs="x86"
+ ;;
+ arm)
+ target_linux_archs="arm"
+ ;;
+ arm64|aarch64)
+ target_linux_archs="arm64"
+ ;;
+ *)
+ echo "$me: unsupported architecture: $linux_arch" >&2
+ exit 1
+ ;;
+ esac
fi
-while : ; do
- if test x$linux_arch = x; then
- if test x$usedefault = x; then
- echo -n "Target architecture [default $default_linux_arch]: "
- read linux_arch
- fi
- if test "x$linux_arch" = x; then
- linux_arch=$default_linux_arch
- fi
- fi
- case "$linux_arch" in
- x86*|i*86|amd*)
- linux_arch=x86
- ;;
- arm)
- linux_arch=arm
- ;;
- arm64|aarch64)
- linux_arch=arm64
- ;;
- *)
- echo "$me: unsupported architecture: $linux_arch" >&2
- linux_arch=
- usedefault=
- ;;
- esac
- if test \! x$linux_arch = x; then
- break
- fi
+for a in $target_linux_archs; do
+ if test x$reverse = x1; then
+ if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
+ echo "$me: $linux_tree is not prepared with Xenomai" >&2
+ exit 2
+ fi
+ fi
done
foo=`grep '^KERNELSRC := ' $linux_tree/Makefile | cut -d= -f2`
@@ -358,10 +342,12 @@ else
cd $curdir
fi
-if test \! -r $linux_tree/arch/$linux_arch/$arch_probe_header; then
- echo "$me: $linux_tree has no IRQ pipeline support for $linux_arch" >&2
- exit 2
-fi
+for a in $target_linux_archs; do
+ if test \! -r $linux_tree/arch/$a/$arch_probe_header; then
+ echo "$me: $linux_tree has no IRQ pipeline support for $a" >&2
+ exit 2
+ fi
+done
if test x$verbose = x1; then
echo "IRQ pipeline installed."
@@ -394,7 +380,6 @@ case $linux_VERSION.$linux_PATCHLEVEL in
-e "s,@VERSION_MINOR@,$version_minor,g" \
-e "s,@REVISION_LEVEL@,$revision_level,g" \
-e "s,@VERSION_STRING@,$version_string,g" \
- -e "s,@SRCARCH@,$linux_arch,g" \
$xenomai_root/scripts/Kconfig.frag |
patch_append init/Kconfig
elif test x$reverse = x1; then
@@ -403,13 +388,15 @@ case $linux_VERSION.$linux_PATCHLEVEL in
test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0
- if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then
- p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
- p2="core-\$(CONFIG_XENOMAI) += arch/$linux_arch/xenomai/"
- (echo; echo $p1; echo $p2) | patch_append arch/$linux_arch/Makefile
- elif test x$reverse = x1; then
- patch_reverse arch/$linux_arch/Makefile
- fi
+ for a in $target_linux_archs; do
+ if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
+ p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
+ p2="core-\$(CONFIG_XENOMAI) += arch/$a/xenomai/"
+ (echo; echo $p1; echo $p2) | patch_append arch/$a/Makefile
+ elif test x$reverse = x1; then
+ patch_reverse arch/$a/Makefile
+ fi
+ done
patch_architecture_specific="n"
@@ -439,8 +426,10 @@ esac
patch_kernelversion_specific="n"
patch_architecture_specific="y"
-patch_link r m kernel/cobalt/arch/$linux_arch arch/$linux_arch/xenomai
-patch_link n n kernel/cobalt/include/dovetail arch/$linux_arch/include/dovetail
+for a in $target_linux_archs; do
+ patch_link r m kernel/cobalt/arch/$a arch/$a/xenomai
+ patch_link n n kernel/cobalt/include/dovetail arch/$a/include/dovetail
+done
patch_architecture_specific="n"
patch_link n cobalt-core.h kernel/cobalt/trace include/trace/events
patch_link n cobalt-rtdm.h kernel/cobalt/trace include/trace/events
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 03/16] prepare-kernel.sh: Convert to tabs
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
2024-05-25 11:57 ` [PATCH 01/16] prepare-kernel.sh: Add reverse mode Richard Weinberger
2024-05-25 11:57 ` [PATCH 02/16] prepare-kernel.sh: Emit architecture agnostic changes Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-27 7:19 ` Florian Bezdeka
2024-05-25 11:57 ` [PATCH 04/16] prepare-kernel.sh: Improve kernel tree check Richard Weinberger
` (13 subsequent siblings)
16 siblings, 1 reply; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
Currently the script used a mix of spaces of various lengths and tabs.
Let's use tabs everywhere.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 529 +++++++++++++++++++-------------------
1 file changed, 262 insertions(+), 267 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 826236c34..534531e2b 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -29,133 +29,128 @@ patch_architecture_filter="b"
linux_tree=.
patch_copytempfile() {
- file="$1"
- if ! test -f "$temp_tree/$file"; then
- subdir=`dirname "$file"`
- mkdir -p "$temp_tree/$subdir"
- cp "$linux_tree/$file" "$temp_tree/$file"
- fi
+ file="$1"
+ if ! test -f "$temp_tree/$file"; then
+ subdir=`dirname "$file"`
+ mkdir -p "$temp_tree/$subdir"
+ cp "$linux_tree/$file" "$temp_tree/$file"
+ fi
}
check_filter() {
- if test "$patch_kernelversion_specific" != "$patch_kernelversion_filter" \
- -a "$patch_architecture_specific" != "$patch_architecture_filter"; then
- echo ok
- elif test -e "$temp_tree/$1"; then
- echo "$me: inconsistent multiple changes to $1 in Linux kernel tree" >&2
- echo error
- else
- echo ignore
- fi
+ if test "$patch_kernelversion_specific" != "$patch_kernelversion_filter" \
+ -a "$patch_architecture_specific" != "$patch_architecture_filter"; then
+ echo ok
+ elif test -e "$temp_tree/$1"; then
+ echo "$me: inconsistent multiple changes to $1 in Linux kernel tree" >&2
+ echo error
+ else
+ echo ignore
+ fi
}
patch_append() {
- file="$1"
- if test "x$output_patch" = "x"; then
- if test -L "$linux_tree/$file" ; then
- mv "$linux_tree/$file" "$linux_tree/$file.orig"
- cp "$linux_tree/$file.orig" "$linux_tree/$file"
- else
- cp "$linux_tree/$file" "$linux_tree/$file.orig"
- fi
- chmod +w "$linux_tree/$file"
- cat >> "$linux_tree/$file"
- else
- if test `check_filter $file` = "ok"; then
- patch_copytempfile "$file"
- cat >> "$temp_tree/$file"
- fi
- fi
+ file="$1"
+ if test "x$output_patch" = "x"; then
+ if test -L "$linux_tree/$file" ; then
+ mv "$linux_tree/$file" "$linux_tree/$file.orig"
+ cp "$linux_tree/$file.orig" "$linux_tree/$file"
+ else
+ cp "$linux_tree/$file" "$linux_tree/$file.orig"
+ fi
+ chmod +w "$linux_tree/$file"
+ cat >> "$linux_tree/$file"
+ else
+ if test `check_filter $file` = "ok"; then
+ patch_copytempfile "$file"
+ cat >> "$temp_tree/$file"
+ fi
+ fi
}
patch_reverse() {
- file="$1"
- if test "x$output_patch" = "x"; then
- if test -L "$linux_tree/$file" ; then
- rm "$linux_tree/$file"
- fi
- mv "$linux_tree/$file.orig" "$linux_tree/$file"
- fi
+ file="$1"
+ if test "x$output_patch" = "x"; then
+ if test -L "$linux_tree/$file" ; then
+ rm "$linux_tree/$file"
+ fi
+ mv "$linux_tree/$file.orig" "$linux_tree/$file"
+ fi
}
patch_link() {
- recursive="$1" # "r" or "n"
- link_file="$2" # "m", "n" or some file (basename) from $target_dir
- target_dir="$3"
- link_dir="$4"
-
- (
- if test \! \( x$link_file = xm -o x$link_file = xn \); then
- find_clean_opt="-name $link_file"
- find_link_opt=$find_clean_opt
+ recursive="$1" # "r" or "n"
+ link_file="$2" # "m", "n" or some file (basename) from $target_dir
+ target_dir="$3"
+ link_dir="$4"
+
+ (
+ if test \! \( x$link_file = xm -o x$link_file = xn \); then
+ find_clean_opt="-name $link_file"
+ find_link_opt=$find_clean_opt
else
- link_makefiles_opt=""
- if test x$link_file = xm; then
- link_makefiles_opt="-name Makefile -o"
- fi
- if test x$recursive = xr; then
- recursive_opt="-mindepth 1"
- dir_opt="-type d -o"
- else
- recursive_opt="-maxdepth 1"
- dir_opt=""
- fi
- find_clean_opt="$recursive_opt \( $dir_opt $link_makefiles_opt -name Kconfig -o -name '*.[chS]' -o -name '*.sh' \)"
- find_link_opt="$recursive_opt \( $link_makefiles_opt -name Kconfig -o -name '*.[chS]' -o -name '*.sh' \)"
+ link_makefiles_opt=""
+ if test x$link_file = xm; then
+ link_makefiles_opt="-name Makefile -o"
+ fi
+ if test x$recursive = xr; then
+ recursive_opt="-mindepth 1"
+ dir_opt="-type d -o"
+ else
+ recursive_opt="-maxdepth 1"
+ dir_opt=""
+ fi
+ find_clean_opt="$recursive_opt \( $dir_opt $link_makefiles_opt -name Kconfig -o -name '*.[chS]' -o -name '*.sh' \)"
+ find_link_opt="$recursive_opt \( $link_makefiles_opt -name Kconfig -o -name '*.[chS]' -o -name '*.sh' \)"
+ fi
+
+ if test "x$output_patch" = "x" -a -e $linux_tree/$link_dir; then
+ cd $linux_tree/$link_dir && eval find . $find_clean_opt | while read f; do
+ if test -L $f -a ! -e $xenomai_root/$target_dir/$f; then rm -Rf $f; fi
+ done
fi
- if test "x$output_patch" = "x" -a -e $linux_tree/$link_dir; then
- cd $linux_tree/$link_dir &&
- eval find . $find_clean_opt |
- while read f; do
- if test -L $f -a ! -e $xenomai_root/$target_dir/$f; then rm -Rf $f; fi
- done
- fi
-
- cd $xenomai_root/$target_dir &&
- eval find . $find_link_opt |
- while read f; do
- f=`echo $f | cut -d/ -f2-`
- d=`dirname $f`
- if test "x$output_patch" = "x"; then
- if test x$reverse = x1; then
- rm -f $linux_tree/$link_dir/$f
- else
- mkdir -p $linux_tree/$link_dir/$d
- if test x$forcelink = x1 -o \
- ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f;
- then
- ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f
- fi
- fi
- else
- if test `check_filter $link_dir/$f` = "ok"; then
- if test -e $linux_tree/$link_dir/$f; then
- echo "$me: warning: $link_dir/$f already present in Linux kernel tree, output patch might be defective" >&2
- fi
- mkdir -p $temp_tree/$link_dir/$d
- cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
- fi
- fi
- done
- if test x$reverse = x1; then
- if ! find $linux_tree/$link_dir -not -type d | grep -q . ; then
- rm -rf $linux_tree/$link_dir
- fi
- fi
- )
+ cd $xenomai_root/$target_dir && eval find . $find_link_opt | while read f; do
+ f=`echo $f | cut -d/ -f2-`
+ d=`dirname $f`
+ if test "x$output_patch" = "x"; then
+ if test x$reverse = x1; then
+ rm -f $linux_tree/$link_dir/$f
+ else
+ mkdir -p $linux_tree/$link_dir/$d
+ if test x$forcelink = x1 -o ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f; then
+ ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f
+ fi
+ fi
+ else
+ if test `check_filter $link_dir/$f` = "ok"; then
+ if test -e $linux_tree/$link_dir/$f; then
+ echo "$me: warning: $link_dir/$f already present in Linux kernel tree, output patch might be defective" >&2
+ fi
+ mkdir -p $temp_tree/$link_dir/$d
+ cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
+ fi
+ fi
+ done
+
+ if test x$reverse = x1; then
+ if ! find $linux_tree/$link_dir -not -type d | grep -q . ; then
+ rm -rf $linux_tree/$link_dir
+ fi
+ fi
+ )
}
generate_patch() {
- (
- cd "$temp_tree"
- find . -type f |
- while read f; do
- diff -Naurd "$linux_tree/$f" "$f" |
- sed -e "s,^--- ${linux_tree}/\.\(/.*\)$,--- linux\1," \
- -e "s,^+++ \.\(/.*\)$,+++ linux-patched\1,"
- done
- )
+ (
+ cd "$temp_tree"
+ find . -type f |
+ while read f; do
+ diff -Naurd "$linux_tree/$f" "$f" |
+ sed -e "s,^--- ${linux_tree}/\.\(/.*\)$,--- linux\1," \
+ -e "s,^+++ \.\(/.*\)$,+++ linux-patched\1,"
+ done
+ )
}
@@ -163,52 +158,52 @@ usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>]
me=`basename $0`
while test $# -gt 0; do
- case "$1" in
- --linux=*)
- linux_tree=`echo $1|sed -e 's,^--linux=\\(.*\\)$,\\1,g'`
- linux_tree=`eval "echo $linux_tree"`
+ case "$1" in
+ --linux=*)
+ linux_tree=`echo $1|sed -e 's,^--linux=\\(.*\\)$,\\1,g'`
+ linux_tree=`eval "echo $linux_tree"`
;;
- --dovetail=*)
- pipeline_patch=`echo $1|sed -e 's,^--dovetail=\\(.*\\)$,\\1,g'`
- pipeline_patch=`eval "echo $pipeline_patch"`
- probe_header=include/linux/dovetail.h
- arch_probe_header=include/asm/dovetail.h
+ --dovetail=*)
+ pipeline_patch=`echo $1|sed -e 's,^--dovetail=\\(.*\\)$,\\1,g'`
+ pipeline_patch=`eval "echo $pipeline_patch"`
+ probe_header=include/linux/dovetail.h
+ arch_probe_header=include/asm/dovetail.h
;;
- --arch=*)
- linux_arch=`echo $1|sed -e 's,^--arch=\\(.*\\)$,\\1,g'`
+ --arch=*)
+ linux_arch=`echo $1|sed -e 's,^--arch=\\(.*\\)$,\\1,g'`
;;
- --outpatch=*)
- output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
+ --outpatch=*)
+ output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
;;
- --filterkvers=*)
- patch_kernelversion_filter=`echo $1|sed -e 's,^--filterkvers=\\(.*\\)$,\\1,g'`
- ;;
- --filterarch=*)
- patch_architecture_filter=`echo $1|sed -e 's,^--filterarch=\\(.*\\)$,\\1,g'`
- ;;
- --forcelink)
- forcelink=1
- ;;
- --default)
- usedefault=1
- ;;
- --verbose)
- verbose=1
+ --filterkvers=*)
+ patch_kernelversion_filter=`echo $1|sed -e 's,^--filterkvers=\\(.*\\)$,\\1,g'`
+ ;;
+ --filterarch=*)
+ patch_architecture_filter=`echo $1|sed -e 's,^--filterarch=\\(.*\\)$,\\1,g'`
+ ;;
+ --forcelink)
+ forcelink=1
+ ;;
+ --default)
+ usedefault=1
+ ;;
+ --verbose)
+ verbose=1
;;
- --reverse)
- reverse=1
+ --reverse)
+ reverse=1
;;
- --help)
- echo "$usage"
- exit 0
+ --help)
+ echo "$usage"
+ exit 0
;;
- *)
- echo "$me: unknown flag: $1" >&2
- echo "$usage" >&2
- exit 1
+ *)
+ echo "$me: unknown flag: $1" >&2
+ echo "$usage" >&2
+ exit 1
;;
- esac
- shift
+ esac
+ shift
done
# Infere the location of the Xenomai source tree from
@@ -223,47 +218,47 @@ xenomai_root=`cd $xenomai_root && pwd`
default_linux_tree=/lib/modules/`uname -r`/source
while test x$linux_tree = x; do
- if test x$usedefault = x; then
- echo -n "Linux tree [default $default_linux_tree]: "
- read linux_tree
- fi
- if test x$linux_tree = x; then
- linux_tree=$default_linux_tree
- fi
- if test \! -x "$linux_tree"; then
- echo "$me: cannot access Linux tree in $linux_tree"
- linux_tree=
- usedefault=
- default_linux_tree=/usr/src
- else
- break
- fi
+ if test x$usedefault = x; then
+ echo -n "Linux tree [default $default_linux_tree]: "
+ read linux_tree
+ fi
+ if test x$linux_tree = x; then
+ linux_tree=$default_linux_tree
+ fi
+ if test \! -x "$linux_tree"; then
+ echo "$me: cannot access Linux tree in $linux_tree"
+ linux_tree=
+ usedefault=
+ default_linux_tree=/usr/src
+ else
+ break
+ fi
done
linux_tree=`cd $linux_tree && pwd`
if test \! -r $linux_tree/Makefile; then
- echo "$me: $linux_tree is not a valid Linux kernel tree" >&2
- exit 2
+ echo "$me: $linux_tree is not a valid Linux kernel tree" >&2
+ exit 2
fi
# Create an empty output patch file, and initialize the temporary tree.
if test "x$output_patch" != "x"; then
- if test x$reverse = x1; then
- echo "$me: --reverse and --outpatch are not compatible"
- exit 1
- fi
-
- temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
- if [ $? -ne 0 ]; then
- echo Temporary directory could not be created.
- exit 1
- fi
-
- patchdir=`dirname $output_patch`
- patchdir=`cd $patchdir && pwd`
- output_patch=$patchdir/`basename $output_patch`
- echo > "$output_patch"
+ if test x$reverse = x1; then
+ echo "$me: --reverse and --outpatch are not compatible"
+ exit 1
+ fi
+
+ temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
+ if [ $? -ne 0 ]; then
+ echo Temporary directory could not be created.
+ exit 1
+ fi
+
+ patchdir=`dirname $output_patch`
+ patchdir=`cd $patchdir && pwd`
+ output_patch=$patchdir/`basename $output_patch`
+ echo > "$output_patch"
fi
@@ -296,9 +291,9 @@ for a in $target_linux_archs; do
fi
done
-foo=`grep '^KERNELSRC := ' $linux_tree/Makefile | cut -d= -f2`
+foo=`grep '^KERNELSRC := ' $linux_tree/Makefile | cut -d= -f2`
if [ ! -z $foo ] ; then
- linux_tree=$foo
+ linux_tree=$foo
fi
unset foo
@@ -310,110 +305,110 @@ eval linux_`grep '^VERSION =' $linux_tree/Makefile | sed -e 's, ,,g'`
linux_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL"
if test x$verbose = x1; then
-echo "Preparing kernel $linux_version$linux_EXTRAVERSION in $linux_tree..."
+ echo "Preparing kernel $linux_version$linux_EXTRAVERSION in $linux_tree..."
fi
if test -r $linux_tree/$probe_header; then
- if test x$verbose = x1; then
- echo "IRQ pipeline found - bypassing patch."
- fi
+ if test x$verbose = x1; then
+ echo "IRQ pipeline found - bypassing patch."
+ fi
else
- if test x$verbose = x1; then
- echo "$me: no IRQ pipeline support found." >&2
- fi
- while test x$pipeline_patch = x; do
- echo -n "IRQ pipeline patch: "
- read pipeline_patch
- if test \! -r "$pipeline_patch" -o x$pipeline_patch = x; then
- echo "$me: cannot read IRQ pipeline support from $pipeline_patch" >&2
- pipeline_patch=
- fi
- done
- patchdir=`dirname $pipeline_patch`;
- patchdir=`cd $patchdir && pwd`
- pipeline_patch=$patchdir/`basename $pipeline_patch`
- curdir=$PWD
- cd $linux_tree && patch --dry-run -p1 -f < $pipeline_patch || {
- cd $curdir;
- echo "$me: Unable to patch kernel $linux_version$linux_EXTRAVERSION with `basename $pipeline_patch`." >&2
- exit 2;
- }
- patch -p1 -f -s < $pipeline_patch
- cd $curdir
+ if test x$verbose = x1; then
+ echo "$me: no IRQ pipeline support found." >&2
+ fi
+ while test x$pipeline_patch = x; do
+ echo -n "IRQ pipeline patch: "
+ read pipeline_patch
+ if test \! -r "$pipeline_patch" -o x$pipeline_patch = x; then
+ echo "$me: cannot read IRQ pipeline support from $pipeline_patch" >&2
+ pipeline_patch=
+ fi
+ done
+ patchdir=`dirname $pipeline_patch`;
+ patchdir=`cd $patchdir && pwd`
+ pipeline_patch=$patchdir/`basename $pipeline_patch`
+ curdir=$PWD
+ cd $linux_tree && patch --dry-run -p1 -f < $pipeline_patch || {
+ cd $curdir;
+ echo "$me: Unable to patch kernel $linux_version$linux_EXTRAVERSION with `basename $pipeline_patch`." >&2
+ exit 2;
+ }
+ patch -p1 -f -s < $pipeline_patch
+ cd $curdir
fi
for a in $target_linux_archs; do
- if test \! -r $linux_tree/arch/$a/$arch_probe_header; then
- echo "$me: $linux_tree has no IRQ pipeline support for $a" >&2
- exit 2
- fi
+ if test \! -r $linux_tree/arch/$a/$arch_probe_header; then
+ echo "$me: $linux_tree has no IRQ pipeline support for $a" >&2
+ exit 2
+ fi
done
if test x$verbose = x1; then
- echo "IRQ pipeline installed."
+ echo "IRQ pipeline installed."
fi
patch_kernelversion_specific="y"
case $linux_VERSION.$linux_PATCHLEVEL in
- 2.*)
+ 2.*)
- echo "$me: Unsupported kernel version $linux_VERSION.$linux_PATCHLEVEL.x" >&2
- exit 2
- ;;
+ echo "$me: Unsupported kernel version $linux_VERSION.$linux_PATCHLEVEL.x" >&2
+ exit 2
+ ;;
- *)
+ *)
- patch_architecture_specific="y"
+ patch_architecture_specific="y"
- if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
- version_stamp=`cat $xenomai_root/config/version-code`
- version_major=`expr $version_stamp : '\([[0-9]]*\)' || true`
- version_minor=`expr $version_stamp : '[[0-9]]*\.\([[0-9]*]*\)' || true`
- revision_level=`expr $version_stamp : '[[0-9]]*\.[[0-9]*]*\.\([[0-9]*]*\)' || true`
+ if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
+ version_stamp=`cat $xenomai_root/config/version-code`
+ version_major=`expr $version_stamp : '\([[0-9]]*\)' || true`
+ version_minor=`expr $version_stamp : '[[0-9]]*\.\([[0-9]*]*\)' || true`
+ revision_level=`expr $version_stamp : '[[0-9]]*\.[[0-9]*]*\.\([[0-9]*]*\)' || true`
if [ -z "$revision_level" ]; then
- revision_level=0
+ revision_level=0
fi
version_string=`cat $xenomai_root/config/version-label`
sed -e "s,@VERSION_MAJOR@,$version_major,g" \
- -e "s,@VERSION_MINOR@,$version_minor,g" \
- -e "s,@REVISION_LEVEL@,$revision_level,g" \
- -e "s,@VERSION_STRING@,$version_string,g" \
- $xenomai_root/scripts/Kconfig.frag |
- patch_append init/Kconfig
- elif test x$reverse = x1; then
- patch_reverse init/Kconfig
- fi
+ -e "s,@VERSION_MINOR@,$version_minor,g" \
+ -e "s,@REVISION_LEVEL@,$revision_level,g" \
+ -e "s,@VERSION_STRING@,$version_string,g" \
+ $xenomai_root/scripts/Kconfig.frag |
+ patch_append init/Kconfig
+ elif test x$reverse = x1; then
+ patch_reverse init/Kconfig
+ fi
test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0
- for a in $target_linux_archs; do
- if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
- p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
- p2="core-\$(CONFIG_XENOMAI) += arch/$a/xenomai/"
- (echo; echo $p1; echo $p2) | patch_append arch/$a/Makefile
- elif test x$reverse = x1; then
- patch_reverse arch/$a/Makefile
- fi
- done
-
- patch_architecture_specific="n"
-
- if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
- p="obj-\$(CONFIG_XENOMAI) += xenomai/"
- ( echo ; echo $p ) | patch_append drivers/Makefile
- elif test x$reverse = x1; then
- patch_reverse drivers/Makefile
- fi
-
- if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
- p="obj-\$(CONFIG_XENOMAI) += xenomai/"
- ( echo ; echo $p ) | patch_append kernel/Makefile
- elif test x$reverse = x1; then
- patch_reverse kernel/Makefile
- fi
- ;;
+ for a in $target_linux_archs; do
+ if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
+ p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
+ p2="core-\$(CONFIG_XENOMAI) += arch/$a/xenomai/"
+ (echo; echo $p1; echo $p2) | patch_append arch/$a/Makefile
+ elif test x$reverse = x1; then
+ patch_reverse arch/$a/Makefile
+ fi
+ done
+
+ patch_architecture_specific="n"
+
+ if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
+ p="obj-\$(CONFIG_XENOMAI) += xenomai/"
+ ( echo ; echo $p ) | patch_append drivers/Makefile
+ elif test x$reverse = x1; then
+ patch_reverse drivers/Makefile
+ fi
+
+ if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
+ p="obj-\$(CONFIG_XENOMAI) += xenomai/"
+ ( echo ; echo $p ) | patch_append kernel/Makefile
+ elif test x$reverse = x1; then
+ patch_reverse kernel/Makefile
+ fi
+ ;;
esac
@@ -427,8 +422,8 @@ esac
patch_kernelversion_specific="n"
patch_architecture_specific="y"
for a in $target_linux_archs; do
- patch_link r m kernel/cobalt/arch/$a arch/$a/xenomai
- patch_link n n kernel/cobalt/include/dovetail arch/$a/include/dovetail
+ patch_link r m kernel/cobalt/arch/$a arch/$a/xenomai
+ patch_link n n kernel/cobalt/include/dovetail arch/$a/include/dovetail
done
patch_architecture_specific="n"
patch_link n cobalt-core.h kernel/cobalt/trace include/trace/events
@@ -449,16 +444,16 @@ patch_link n stdarg.h kernel/cobalt/include/linux include/xenomai/linux
patch_link n version.h include/xenomai include/xenomai
if test "x$output_patch" != "x"; then
- if test x$verbose = x1; then
- echo 'Generating patch.'
- fi
- generate_patch > "$output_patch"
- rm -rf $temp_tree
+ if test x$verbose = x1; then
+ echo 'Generating patch.'
+ fi
+ generate_patch > "$output_patch"
+ rm -rf $temp_tree
fi
if test x$verbose = x1; then
-echo 'Links installed.'
-echo 'Build system ready.'
+ echo 'Links installed.'
+ echo 'Build system ready.'
fi
exit 0
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 03/16] prepare-kernel.sh: Convert to tabs
2024-05-25 11:57 ` [PATCH 03/16] prepare-kernel.sh: Convert to tabs Richard Weinberger
@ 2024-05-27 7:19 ` Florian Bezdeka
2024-05-27 7:27 ` Jan Kiszka
2024-05-27 8:14 ` Richard Weinberger
0 siblings, 2 replies; 28+ messages in thread
From: Florian Bezdeka @ 2024-05-27 7:19 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
Hi Richard!
On Sat, 2024-05-25 at 13:57 +0200, Richard Weinberger wrote:
> patch_reverse() {
> - file="$1"
> - if test "x$output_patch" = "x"; then
> - if test -L "$linux_tree/$file" ; then
> - rm "$linux_tree/$file"
> - fi
> - mv "$linux_tree/$file.orig" "$linux_tree/$file"
> - fi
> + file="$1"
> + if test "x$output_patch" = "x"; then
> + if test -L "$linux_tree/$file" ; then
> + rm "$linux_tree/$file"
> + fi
> + mv "$linux_tree/$file.orig" "$linux_tree/$file"
> + fi
> }
>
This part is introduced in patch 1 and completely rewritten in this
patch (patch 3).
We could avoid that by applying patch 3 fist, so basically reordering
the patches so that patch 3 becomes the first one. Could help if
someone has to bisect later...
Best regards,
Florian
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH 03/16] prepare-kernel.sh: Convert to tabs
2024-05-27 7:19 ` Florian Bezdeka
@ 2024-05-27 7:27 ` Jan Kiszka
2024-05-27 8:14 ` Richard Weinberger
1 sibling, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2024-05-27 7:27 UTC (permalink / raw)
To: Florian Bezdeka, Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 27.05.24 09:19, Florian Bezdeka wrote:
> Hi Richard!
>
> On Sat, 2024-05-25 at 13:57 +0200, Richard Weinberger wrote:
>> patch_reverse() {
>> - file="$1"
>> - if test "x$output_patch" = "x"; then
>> - if test -L "$linux_tree/$file" ; then
>> - rm "$linux_tree/$file"
>> - fi
>> - mv "$linux_tree/$file.orig" "$linux_tree/$file"
>> - fi
>> + file="$1"
>> + if test "x$output_patch" = "x"; then
>> + if test -L "$linux_tree/$file" ; then
>> + rm "$linux_tree/$file"
>> + fi
>> + mv "$linux_tree/$file.orig" "$linux_tree/$file"
>> + fi
>> }
>>
>
> This part is introduced in patch 1 and completely rewritten in this
> patch (patch 3).
>
> We could avoid that by applying patch 3 fist, so basically reordering
> the patches so that patch 3 becomes the first one. Could help if
> someone has to bisect later...
>
Yep, that would indeed be nicer.
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 28+ messages in thread* Re: [PATCH 03/16] prepare-kernel.sh: Convert to tabs
2024-05-27 7:19 ` Florian Bezdeka
2024-05-27 7:27 ` Jan Kiszka
@ 2024-05-27 8:14 ` Richard Weinberger
1 sibling, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-27 8:14 UTC (permalink / raw)
To: Richard Weinberger, xenomai, upstream+xenomai, Florian Bezdeka
Florian,
Am Montag, 27. Mai 2024, 09:19:44 CEST schrieb 'Florian Bezdeka' via upstream:
> Hi Richard!
>
> On Sat, 2024-05-25 at 13:57 +0200, Richard Weinberger wrote:
> > patch_reverse() {
> > - file="$1"
> > - if test "x$output_patch" = "x"; then
> > - if test -L "$linux_tree/$file" ; then
> > - rm "$linux_tree/$file"
> > - fi
> > - mv "$linux_tree/$file.orig" "$linux_tree/$file"
> > - fi
> > + file="$1"
> > + if test "x$output_patch" = "x"; then
> > + if test -L "$linux_tree/$file" ; then
> > + rm "$linux_tree/$file"
> > + fi
> > + mv "$linux_tree/$file.orig" "$linux_tree/$file"
> > + fi
> > }
> >
>
> This part is introduced in patch 1 and completely rewritten in this
> patch (patch 3).
>
> We could avoid that by applying patch 3 fist, so basically reordering
> the patches so that patch 3 becomes the first one. Could help if
> someone has to bisect later...
How does it hurt bisecing beside of adding an extra step?
But sure, I can reorder.
So, I assume you're fine with tabs? :-)
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 04/16] prepare-kernel.sh: Improve kernel tree check
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (2 preceding siblings ...)
2024-05-25 11:57 ` [PATCH 03/16] prepare-kernel.sh: Convert to tabs Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-27 10:51 ` Jan Kiszka
2024-05-25 11:57 ` [PATCH 05/16] prepare-kernel.sh: Fix shellcheck SC2046 warnings wrt. check_filter Richard Weinberger
` (12 subsequent siblings)
16 siblings, 1 reply; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
Currently any directory that contains a Makefile is treated as kernel tree.
This causes strange errors when calling the script without parameters
within the Xenomai tree.
$ ./scripts/prepare-kernel.sh
./scripts/prepare-kernel.sh: line 298: linux_: command not found
Fix it by checking for a more specific file in the kernel tree.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 534531e2b..800528058 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -237,7 +237,7 @@ done
linux_tree=`cd $linux_tree && pwd`
-if test \! -r $linux_tree/Makefile; then
+if test \! -r $linux_tree/kernel/kallsyms.c; then
echo "$me: $linux_tree is not a valid Linux kernel tree" >&2
exit 2
fi
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 04/16] prepare-kernel.sh: Improve kernel tree check
2024-05-25 11:57 ` [PATCH 04/16] prepare-kernel.sh: Improve kernel tree check Richard Weinberger
@ 2024-05-27 10:51 ` Jan Kiszka
2024-05-27 15:42 ` Richard Weinberger
0 siblings, 1 reply; 28+ messages in thread
From: Jan Kiszka @ 2024-05-27 10:51 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 25.05.24 13:57, Richard Weinberger wrote:
> Currently any directory that contains a Makefile is treated as kernel tree.
> This causes strange errors when calling the script without parameters
> within the Xenomai tree.
>
> $ ./scripts/prepare-kernel.sh
> ./scripts/prepare-kernel.sh: line 298: linux_: command not found
>
> Fix it by checking for a more specific file in the kernel tree.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> scripts/prepare-kernel.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> index 534531e2b..800528058 100755
> --- a/scripts/prepare-kernel.sh
> +++ b/scripts/prepare-kernel.sh
> @@ -237,7 +237,7 @@ done
>
> linux_tree=`cd $linux_tree && pwd`
>
> -if test \! -r $linux_tree/Makefile; then
> +if test \! -r $linux_tree/kernel/kallsyms.c; then
Fine with checking for a real kernel, but this here is not my favorite
method. How about
test "$(head -1 README)" = "Linux kernel"
instead?
> echo "$me: $linux_tree is not a valid Linux kernel tree" >&2
> exit 2
> fi
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 04/16] prepare-kernel.sh: Improve kernel tree check
2024-05-27 10:51 ` Jan Kiszka
@ 2024-05-27 15:42 ` Richard Weinberger
0 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-27 15:42 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai, upstream+xenomai
----- Ursprüngliche Mail -----
>> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
>> index 534531e2b..800528058 100755
>> --- a/scripts/prepare-kernel.sh
>> +++ b/scripts/prepare-kernel.sh
>> @@ -237,7 +237,7 @@ done
>>
>> linux_tree=`cd $linux_tree && pwd`
>>
>> -if test \! -r $linux_tree/Makefile; then
>> +if test \! -r $linux_tree/kernel/kallsyms.c; then
>
> Fine with checking for a real kernel, but this here is not my favorite
> method. How about
>
> test "$(head -1 README)" = "Linux kernel"
>
> instead?
My idea was that kernel/kallsyms.c is an old file which is unlikely to
get renamed soon.
It came via:
commit e42f617ecdfc68e68b0108cd337d30224b541352
Author: Ingo Molnar <mingo@elte.hu>
Date: Thu Sep 26 03:31:07 2002 -0700
[PATCH] kksymoops-2.5.38-C9
Make the kernel print out symbolic bactraces if symbol table information
is available (CONFIG_KALLSYMS)
and was never renamed since.
README, one other hand, saw more changes.
In it's current form it looks more stable, though.
So, I don't have a strong opinion on this.
Thanks,
//richard
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 05/16] prepare-kernel.sh: Fix shellcheck SC2046 warnings wrt. check_filter
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (3 preceding siblings ...)
2024-05-25 11:57 ` [PATCH 04/16] prepare-kernel.sh: Improve kernel tree check Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-27 10:52 ` Jan Kiszka
2024-05-25 11:57 ` [PATCH 06/16] prepare-kernel.sh: Disable SC2115 warning around $linux_tree Richard Weinberger
` (11 subsequent siblings)
16 siblings, 1 reply; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
Fixes:
In scripts/prepare-kernel.sh line 64:
if test `check_filter $file` = "ok"; then
^------------------^ SC2046 (warning): Quote this to prevent word splitting.
In scripts/prepare-kernel.sh line 126:
if test `check_filter $link_dir/$f` = "ok"; then
^-------------------------^ SC2046 (warning): Quote this to prevent word splitting.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 800528058..d8d63397d 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -61,7 +61,7 @@ patch_append() {
chmod +w "$linux_tree/$file"
cat >> "$linux_tree/$file"
else
- if test `check_filter $file` = "ok"; then
+ if test "`check_filter $file`" = "ok"; then
patch_copytempfile "$file"
cat >> "$temp_tree/$file"
fi
@@ -123,7 +123,7 @@ patch_link() {
fi
fi
else
- if test `check_filter $link_dir/$f` = "ok"; then
+ if test "`check_filter $link_dir/$f`" = "ok"; then
if test -e $linux_tree/$link_dir/$f; then
echo "$me: warning: $link_dir/$f already present in Linux kernel tree, output patch might be defective" >&2
fi
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 05/16] prepare-kernel.sh: Fix shellcheck SC2046 warnings wrt. check_filter
2024-05-25 11:57 ` [PATCH 05/16] prepare-kernel.sh: Fix shellcheck SC2046 warnings wrt. check_filter Richard Weinberger
@ 2024-05-27 10:52 ` Jan Kiszka
0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2024-05-27 10:52 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 25.05.24 13:57, Richard Weinberger wrote:
> Fixes:
> In scripts/prepare-kernel.sh line 64:
> if test `check_filter $file` = "ok"; then
> ^------------------^ SC2046 (warning): Quote this to prevent word splitting.
>
> In scripts/prepare-kernel.sh line 126:
> if test `check_filter $link_dir/$f` = "ok"; then
> ^-------------------------^ SC2046 (warning): Quote this to prevent word splitting.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> scripts/prepare-kernel.sh | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> index 800528058..d8d63397d 100755
> --- a/scripts/prepare-kernel.sh
> +++ b/scripts/prepare-kernel.sh
> @@ -61,7 +61,7 @@ patch_append() {
> chmod +w "$linux_tree/$file"
> cat >> "$linux_tree/$file"
> else
> - if test `check_filter $file` = "ok"; then
> + if test "`check_filter $file`" = "ok"; then
> patch_copytempfile "$file"
> cat >> "$temp_tree/$file"
> fi
> @@ -123,7 +123,7 @@ patch_link() {
> fi
> fi
> else
> - if test `check_filter $link_dir/$f` = "ok"; then
> + if test "`check_filter $link_dir/$f`" = "ok"; then
> if test -e $linux_tree/$link_dir/$f; then
> echo "$me: warning: $link_dir/$f already present in Linux kernel tree, output patch might be defective" >&2
> fi
`command` is legacy. Can we switch to $(command) at this chance? Applies
to succeeding patches as well.
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 06/16] prepare-kernel.sh: Disable SC2115 warning around $linux_tree
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (4 preceding siblings ...)
2024-05-25 11:57 ` [PATCH 05/16] prepare-kernel.sh: Fix shellcheck SC2046 warnings wrt. check_filter Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-25 11:57 ` [PATCH 07/16] prepare-kernel.sh: Don't use eval Richard Weinberger
` (10 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
The script makes sure that $linux_tree is valid, it cannot be empty.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index d8d63397d..e78c48e61 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -135,7 +135,8 @@ patch_link() {
if test x$reverse = x1; then
if ! find $linux_tree/$link_dir -not -type d | grep -q . ; then
- rm -rf $linux_tree/$link_dir
+ # shellcheck disable=SC2115
+ rm -rf ${linux_tree}/$link_dir
fi
fi
)
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 07/16] prepare-kernel.sh: Don't use eval
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (5 preceding siblings ...)
2024-05-25 11:57 ` [PATCH 06/16] prepare-kernel.sh: Disable SC2115 warning around $linux_tree Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-25 11:57 ` [PATCH 08/16] prepare-kernel.sh: Don't depend on bash Richard Weinberger
` (9 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
eval is evil and confuses shellcheck.
Fixes:
In scripts/prepare-kernel.sh line 302:
linux_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL"
^------------^ SC2154 (warning): linux_VERSION is referenced but not assigned (did you mean 'linux_version'?).
^---------------^ SC2154 (warning): linux_PATCHLEVEL is referenced but not assigned.
^-------------^ SC2154 (warning): linux_SUBLEVEL is referenced but not assigned.
In scripts/prepare-kernel.sh line 305:
echo "Preparing kernel $linux_version$linux_EXTRAVERSION in $linux_tree..."
^-----------------^ SC2154 (warning): linux_EXTRAVERSION is referenced but not assigned.
Instead of using eval plus grep and sed, just use good old awk.
Tested also with busybox awk.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index e78c48e61..3c13d471f 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -298,10 +298,10 @@ if [ ! -z $foo ] ; then
fi
unset foo
-eval linux_`grep '^EXTRAVERSION =' $linux_tree/Makefile | sed -e 's, ,,g'`
-eval linux_`grep '^PATCHLEVEL =' $linux_tree/Makefile | sed -e 's, ,,g'`
-eval linux_`grep '^SUBLEVEL =' $linux_tree/Makefile | sed -e 's, ,,g'`
-eval linux_`grep '^VERSION =' $linux_tree/Makefile | sed -e 's, ,,g'`
+linux_EXTRAVERSION=`awk -F= '/^EXTRAVERSION =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
+linux_PATCHLEVEL=`awk -F= '/^PATCHLEVEL =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
+linux_SUBLEVEL=`awk -F= '/^SUBLEVEL =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
+linux_VERSION=`awk -F= '/^VERSION =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
linux_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL"
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 08/16] prepare-kernel.sh: Don't depend on bash
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (6 preceding siblings ...)
2024-05-25 11:57 ` [PATCH 07/16] prepare-kernel.sh: Don't use eval Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-27 10:56 ` Jan Kiszka
2024-05-25 11:57 ` [PATCH 09/16] prepare-kernel.sh: Remove --filterkvers= and --filterarch= Richard Weinberger
` (8 subsequent siblings)
16 siblings, 1 reply; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
- type -p is not POSIX, so use realpath(1), I think it is safe
to assume this tool.
- echo -n is also not POSIX, but if some echo command does not support
omitting the trailing newline, so what...
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 3c13d471f..f7aca804f 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/sh
set -e
unset CDPATH
@@ -210,7 +210,7 @@ done
# Infere the location of the Xenomai source tree from
# the path of the current script.
-script_path=`type -p $0`
+script_path=`realpath $0`
xenomai_root=`dirname $script_path`/..
xenomai_root=`cd $xenomai_root && pwd`
@@ -220,6 +220,7 @@ default_linux_tree=/lib/modules/`uname -r`/source
while test x$linux_tree = x; do
if test x$usedefault = x; then
+ # shellcheck disable=SC3037
echo -n "Linux tree [default $default_linux_tree]: "
read linux_tree
fi
@@ -318,6 +319,7 @@ else
echo "$me: no IRQ pipeline support found." >&2
fi
while test x$pipeline_patch = x; do
+ # shellcheck disable=SC3037
echo -n "IRQ pipeline patch: "
read pipeline_patch
if test \! -r "$pipeline_patch" -o x$pipeline_patch = x; then
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 08/16] prepare-kernel.sh: Don't depend on bash
2024-05-25 11:57 ` [PATCH 08/16] prepare-kernel.sh: Don't depend on bash Richard Weinberger
@ 2024-05-27 10:56 ` Jan Kiszka
2024-05-27 16:00 ` Richard Weinberger
0 siblings, 1 reply; 28+ messages in thread
From: Jan Kiszka @ 2024-05-27 10:56 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 25.05.24 13:57, Richard Weinberger wrote:
> - type -p is not POSIX, so use realpath(1), I think it is safe
> to assume this tool.
>
> - echo -n is also not POSIX, but if some echo command does not support
> omitting the trailing newline, so what...
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> scripts/prepare-kernel.sh | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> index 3c13d471f..f7aca804f 100755
> --- a/scripts/prepare-kernel.sh
> +++ b/scripts/prepare-kernel.sh
> @@ -1,4 +1,4 @@
> -#! /bin/bash
> +#!/bin/sh
> set -e
>
> unset CDPATH
> @@ -210,7 +210,7 @@ done
> # Infere the location of the Xenomai source tree from
> # the path of the current script.
>
> -script_path=`type -p $0`
> +script_path=`realpath $0`
> xenomai_root=`dirname $script_path`/..
> xenomai_root=`cd $xenomai_root && pwd`
>
> @@ -220,6 +220,7 @@ default_linux_tree=/lib/modules/`uname -r`/source
>
> while test x$linux_tree = x; do
> if test x$usedefault = x; then
> + # shellcheck disable=SC3037
> echo -n "Linux tree [default $default_linux_tree]: "
Better use printf instead.
> read linux_tree
> fi
> @@ -318,6 +319,7 @@ else
> echo "$me: no IRQ pipeline support found." >&2
> fi
> while test x$pipeline_patch = x; do
> + # shellcheck disable=SC3037
> echo -n "IRQ pipeline patch: "
> read pipeline_patch
> if test \! -r "$pipeline_patch" -o x$pipeline_patch = x; then
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 08/16] prepare-kernel.sh: Don't depend on bash
2024-05-27 10:56 ` Jan Kiszka
@ 2024-05-27 16:00 ` Richard Weinberger
2024-05-27 16:02 ` Jan Kiszka
0 siblings, 1 reply; 28+ messages in thread
From: Richard Weinberger @ 2024-05-27 16:00 UTC (permalink / raw)
To: Jan Kiszka; +Cc: xenomai, upstream+xenomai
----- Ursprüngliche Mail -----
> Von: "Jan Kiszka" <jan.kiszka@siemens.com>
>> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
>> index 3c13d471f..f7aca804f 100755
>> --- a/scripts/prepare-kernel.sh
>> +++ b/scripts/prepare-kernel.sh
>> @@ -1,4 +1,4 @@
>> -#! /bin/bash
>> +#!/bin/sh
>> set -e
>>
>> unset CDPATH
>> @@ -210,7 +210,7 @@ done
>> # Infere the location of the Xenomai source tree from
>> # the path of the current script.
>>
>> -script_path=`type -p $0`
>> +script_path=`realpath $0`
>> xenomai_root=`dirname $script_path`/..
>> xenomai_root=`cd $xenomai_root && pwd`
>>
>> @@ -220,6 +220,7 @@ default_linux_tree=/lib/modules/`uname -r`/source
>>
>> while test x$linux_tree = x; do
>> if test x$usedefault = x; then
>> + # shellcheck disable=SC3037
>> echo -n "Linux tree [default $default_linux_tree]: "
>
> Better use printf instead.
Good point.
If you agree with "[PATCH 10/16] prepare-kernel.sh: Remove interactivity", we can drop this anyway.
Thanks,
//richard
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 08/16] prepare-kernel.sh: Don't depend on bash
2024-05-27 16:00 ` Richard Weinberger
@ 2024-05-27 16:02 ` Jan Kiszka
0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2024-05-27 16:02 UTC (permalink / raw)
To: Richard Weinberger; +Cc: xenomai, upstream+xenomai
On 27.05.24 18:00, Richard Weinberger wrote:
> ----- Ursprüngliche Mail -----
>> Von: "Jan Kiszka" <jan.kiszka@siemens.com>
>>> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
>>> index 3c13d471f..f7aca804f 100755
>>> --- a/scripts/prepare-kernel.sh
>>> +++ b/scripts/prepare-kernel.sh
>>> @@ -1,4 +1,4 @@
>>> -#! /bin/bash
>>> +#!/bin/sh
>>> set -e
>>>
>>> unset CDPATH
>>> @@ -210,7 +210,7 @@ done
>>> # Infere the location of the Xenomai source tree from
>>> # the path of the current script.
>>>
>>> -script_path=`type -p $0`
>>> +script_path=`realpath $0`
>>> xenomai_root=`dirname $script_path`/..
>>> xenomai_root=`cd $xenomai_root && pwd`
>>>
>>> @@ -220,6 +220,7 @@ default_linux_tree=/lib/modules/`uname -r`/source
>>>
>>> while test x$linux_tree = x; do
>>> if test x$usedefault = x; then
>>> + # shellcheck disable=SC3037
>>> echo -n "Linux tree [default $default_linux_tree]: "
>>
>> Better use printf instead.
>
> Good point.
> If you agree with "[PATCH 10/16] prepare-kernel.sh: Remove interactivity", we can drop this anyway.
>
Absence of comments signals agreement in this case - ack.
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH 09/16] prepare-kernel.sh: Remove --filterkvers= and --filterarch=
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (7 preceding siblings ...)
2024-05-25 11:57 ` [PATCH 08/16] prepare-kernel.sh: Don't depend on bash Richard Weinberger
@ 2024-05-25 11:57 ` Richard Weinberger
2024-05-25 11:58 ` [PATCH 10/16] prepare-kernel.sh: Remove interactivity Richard Weinberger
` (7 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:57 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
These days (not) applying kernel version or architecture specific changes
is no longer needed for development.
Let's simplify the code and remove this feature.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 65 ++++++---------------------------------
1 file changed, 9 insertions(+), 56 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index f7aca804f..53ff89abd 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -3,28 +3,6 @@ set -e
unset CDPATH
-# At all time, this variable must be set to either:
-# "y" if the changes to the Linux tree are specific to the kernel version;
-# "n" otherwise.
-patch_kernelversion_specific="n"
-
-# At all time, this variable must be set to either:
-# "y" if the changes to the Linux tree are specific to the architecture;
-# "n" otherwise.
-patch_architecture_specific="n"
-
-# At all time, this variable must be set to either:
-# "y": ignore kernel-version-specific changes;
-# "n": ignore non-kernel-version-specific changes;
-# "b": don't filter according to the kernel version.
-patch_kernelversion_filter="b"
-
-# At all time, this variable must be set to either:
-# "y": ignore architecture-specific changes;
-# "n": ignore non-architecture-specific changes;
-# "b": don't filter according to the architecture.
-patch_architecture_filter="b"
-
# Default path to kernel tree
linux_tree=.
@@ -37,18 +15,6 @@ patch_copytempfile() {
fi
}
-check_filter() {
- if test "$patch_kernelversion_specific" != "$patch_kernelversion_filter" \
- -a "$patch_architecture_specific" != "$patch_architecture_filter"; then
- echo ok
- elif test -e "$temp_tree/$1"; then
- echo "$me: inconsistent multiple changes to $1 in Linux kernel tree" >&2
- echo error
- else
- echo ignore
- fi
-}
-
patch_append() {
file="$1"
if test "x$output_patch" = "x"; then
@@ -61,10 +27,8 @@ patch_append() {
chmod +w "$linux_tree/$file"
cat >> "$linux_tree/$file"
else
- if test "`check_filter $file`" = "ok"; then
- patch_copytempfile "$file"
- cat >> "$temp_tree/$file"
- fi
+ patch_copytempfile "$file"
+ cat >> "$temp_tree/$file"
fi
}
@@ -123,13 +87,11 @@ patch_link() {
fi
fi
else
- if test "`check_filter $link_dir/$f`" = "ok"; then
- if test -e $linux_tree/$link_dir/$f; then
- echo "$me: warning: $link_dir/$f already present in Linux kernel tree, output patch might be defective" >&2
- fi
- mkdir -p $temp_tree/$link_dir/$d
- cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
+ if test -e $linux_tree/$link_dir/$f; then
+ echo "$me: warning: $link_dir/$f already present in Linux kernel tree, output patch might be defective" >&2
fi
+ mkdir -p $temp_tree/$link_dir/$d
+ cp $xenomai_root/$target_dir/$f $temp_tree/$link_dir/$f
fi
done
@@ -155,7 +117,7 @@ generate_patch() {
}
-usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--filterkvers=y|n] [--filterarch=y|n]] [--forcelink] [--default] [--verbose] [--reverse]'
+usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--forcelink] [--default] [--verbose] [--reverse]'
me=`basename $0`
while test $# -gt 0; do
@@ -177,10 +139,10 @@ while test $# -gt 0; do
output_patch=`echo $1|sed -e 's,^--outpatch=\\(.*\\)$,\\1,g'`
;;
--filterkvers=*)
- patch_kernelversion_filter=`echo $1|sed -e 's,^--filterkvers=\\(.*\\)$,\\1,g'`
+ echo "$me: warning: --filterkvers= is deprecated and now a no-op" >&2
;;
--filterarch=*)
- patch_architecture_filter=`echo $1|sed -e 's,^--filterarch=\\(.*\\)$,\\1,g'`
+ echo "$me: warning: --filterarch= is deprecated and now a no-op" >&2
;;
--forcelink)
forcelink=1
@@ -351,8 +313,6 @@ if test x$verbose = x1; then
echo "IRQ pipeline installed."
fi
-patch_kernelversion_specific="y"
-
case $linux_VERSION.$linux_PATCHLEVEL in
2.*)
@@ -363,8 +323,6 @@ case $linux_VERSION.$linux_PATCHLEVEL in
*)
- patch_architecture_specific="y"
-
if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
version_stamp=`cat $xenomai_root/config/version-code`
version_major=`expr $version_stamp : '\([[0-9]]*\)' || true`
@@ -396,8 +354,6 @@ test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0
fi
done
- patch_architecture_specific="n"
-
if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
p="obj-\$(CONFIG_XENOMAI) += xenomai/"
( echo ; echo $p ) | patch_append drivers/Makefile
@@ -422,13 +378,10 @@ esac
# Keep link dirs (4th parameter) descending, otherwise --reverse
# is not able to cleanup these directories!
-patch_kernelversion_specific="n"
-patch_architecture_specific="y"
for a in $target_linux_archs; do
patch_link r m kernel/cobalt/arch/$a arch/$a/xenomai
patch_link n n kernel/cobalt/include/dovetail arch/$a/include/dovetail
done
-patch_architecture_specific="n"
patch_link n cobalt-core.h kernel/cobalt/trace include/trace/events
patch_link n cobalt-rtdm.h kernel/cobalt/trace include/trace/events
patch_link n cobalt-posix.h kernel/cobalt/trace include/trace/events
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 10/16] prepare-kernel.sh: Remove interactivity
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (8 preceding siblings ...)
2024-05-25 11:57 ` [PATCH 09/16] prepare-kernel.sh: Remove --filterkvers= and --filterarch= Richard Weinberger
@ 2024-05-25 11:58 ` Richard Weinberger
2024-05-25 11:58 ` [PATCH 11/16] prepare-kernel.sh: Remove --forcelink Richard Weinberger
` (6 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:58 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
Let's reduce complexity and remove user interaction, all parameters
shall get set using command line switches instead.
This makes also --default obsolete, if someone passes --linux= (empty)
to the script, it will from now on automatically fall back to /lib/modules/`uname -r`/source.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 38 +++++++++-----------------------------
1 file changed, 9 insertions(+), 29 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 53ff89abd..2b74e9f7b 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -117,7 +117,7 @@ generate_patch() {
}
-usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--forcelink] [--default] [--verbose] [--reverse]'
+usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--forcelink] [--verbose] [--reverse]'
me=`basename $0`
while test $# -gt 0; do
@@ -148,7 +148,7 @@ while test $# -gt 0; do
forcelink=1
;;
--default)
- usedefault=1
+ echo "$me: warning: --default is deprecated and now always on" >&2
;;
--verbose)
verbose=1
@@ -180,24 +180,9 @@ xenomai_root=`cd $xenomai_root && pwd`
default_linux_tree=/lib/modules/`uname -r`/source
-while test x$linux_tree = x; do
- if test x$usedefault = x; then
- # shellcheck disable=SC3037
- echo -n "Linux tree [default $default_linux_tree]: "
- read linux_tree
- fi
- if test x$linux_tree = x; then
- linux_tree=$default_linux_tree
- fi
- if test \! -x "$linux_tree"; then
- echo "$me: cannot access Linux tree in $linux_tree"
- linux_tree=
- usedefault=
- default_linux_tree=/usr/src
- else
- break
- fi
-done
+if test x$linux_tree = x; then
+ linux_tree=$default_linux_tree
+fi
linux_tree=`cd $linux_tree && pwd`
@@ -280,15 +265,10 @@ else
if test x$verbose = x1; then
echo "$me: no IRQ pipeline support found." >&2
fi
- while test x$pipeline_patch = x; do
- # shellcheck disable=SC3037
- echo -n "IRQ pipeline patch: "
- read pipeline_patch
- if test \! -r "$pipeline_patch" -o x$pipeline_patch = x; then
- echo "$me: cannot read IRQ pipeline support from $pipeline_patch" >&2
- pipeline_patch=
- fi
- done
+ if test x$pipeline_patch = x; then
+ echo "$me: no IRQ pipeline support found in $linux_tree and --dovetail= not set" >&2
+ exit 2
+ fi
patchdir=`dirname $pipeline_patch`;
patchdir=`cd $patchdir && pwd`
pipeline_patch=$patchdir/`basename $pipeline_patch`
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 11/16] prepare-kernel.sh: Remove --forcelink
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (9 preceding siblings ...)
2024-05-25 11:58 ` [PATCH 10/16] prepare-kernel.sh: Remove interactivity Richard Weinberger
@ 2024-05-25 11:58 ` Richard Weinberger
2024-05-25 11:58 ` [PATCH 12/16] prepare-kernel.sh: Fix dovetail check Richard Weinberger
` (5 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:58 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
To my best knowledge, the idea behind --forcelink was forcing
the script to recreate the symlinks if the xenomai tree has changed.
But since 7098866e0 ("Fix prepare-kernel.sh when it is run in order to change the xenomai directory to which the kernel is linked").
the script is smart enough to figure whether links need an update.
So, --forcelink is essentially in vain and can be removed.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 2b74e9f7b..214a008e3 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -82,7 +82,7 @@ patch_link() {
rm -f $linux_tree/$link_dir/$f
else
mkdir -p $linux_tree/$link_dir/$d
- if test x$forcelink = x1 -o ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f; then
+ if test ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f; then
ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f
fi
fi
@@ -117,7 +117,7 @@ generate_patch() {
}
-usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--forcelink] [--verbose] [--reverse]'
+usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--verbose] [--reverse]'
me=`basename $0`
while test $# -gt 0; do
@@ -145,7 +145,7 @@ while test $# -gt 0; do
echo "$me: warning: --filterarch= is deprecated and now a no-op" >&2
;;
--forcelink)
- forcelink=1
+ echo "$me: warning: --forcelink is deprecated and now a no-op" >&2
;;
--default)
echo "$me: warning: --default is deprecated and now always on" >&2
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 12/16] prepare-kernel.sh: Fix dovetail check
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (10 preceding siblings ...)
2024-05-25 11:58 ` [PATCH 11/16] prepare-kernel.sh: Remove --forcelink Richard Weinberger
@ 2024-05-25 11:58 ` Richard Weinberger
2024-05-25 11:58 ` [PATCH 13/16] prepare-kernel.sh: Define command line variables Richard Weinberger
` (4 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:58 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
$probe_header and $arch_probe_header are only set when --dovetail= is used,
otherwise they are unset and checking whether the kernel has dovetail
always succeeds.
Fix by remove the variables and use the header files directly.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 214a008e3..a8179518b 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -129,8 +129,6 @@ while test $# -gt 0; do
--dovetail=*)
pipeline_patch=`echo $1|sed -e 's,^--dovetail=\\(.*\\)$,\\1,g'`
pipeline_patch=`eval "echo $pipeline_patch"`
- probe_header=include/linux/dovetail.h
- arch_probe_header=include/asm/dovetail.h
;;
--arch=*)
linux_arch=`echo $1|sed -e 's,^--arch=\\(.*\\)$,\\1,g'`
@@ -257,7 +255,7 @@ if test x$verbose = x1; then
echo "Preparing kernel $linux_version$linux_EXTRAVERSION in $linux_tree..."
fi
-if test -r $linux_tree/$probe_header; then
+if test -r $linux_tree/include/linux/dovetail.h; then
if test x$verbose = x1; then
echo "IRQ pipeline found - bypassing patch."
fi
@@ -283,7 +281,7 @@ else
fi
for a in $target_linux_archs; do
- if test \! -r $linux_tree/arch/$a/$arch_probe_header; then
+ if test \! -r $linux_tree/arch/$a/include/asm/dovetail.h; then
echo "$me: $linux_tree has no IRQ pipeline support for $a" >&2
exit 2
fi
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 13/16] prepare-kernel.sh: Define command line variables
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (11 preceding siblings ...)
2024-05-25 11:58 ` [PATCH 12/16] prepare-kernel.sh: Fix dovetail check Richard Weinberger
@ 2024-05-25 11:58 ` Richard Weinberger
2024-05-25 11:58 ` [PATCH 14/16] prepare-kernel.sh: Remove dead code Richard Weinberger
` (3 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:58 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
To use "set -u" later, define all variables that can be set via the command line.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index a8179518b..43883ded3 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -3,9 +3,6 @@ set -e
unset CDPATH
-# Default path to kernel tree
-linux_tree=.
-
patch_copytempfile() {
file="$1"
if ! test -f "$temp_tree/$file"; then
@@ -120,6 +117,14 @@ generate_patch() {
usage='usage: prepare-kernel --linux=<linux-tree> [--dovetail=<dovetail-patch>] [--arch=<arch>] [--outpatch=<file> [--verbose] [--reverse]'
me=`basename $0`
+# Default path to kernel tree
+linux_tree=.
+output_patch=""
+linux_arch=""
+reverse=0
+pipeline_patch=""
+verbose=0
+
while test $# -gt 0; do
case "$1" in
--linux=*)
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 14/16] prepare-kernel.sh: Remove dead code
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (12 preceding siblings ...)
2024-05-25 11:58 ` [PATCH 13/16] prepare-kernel.sh: Define command line variables Richard Weinberger
@ 2024-05-25 11:58 ` Richard Weinberger
2024-05-25 11:58 ` [PATCH 15/16] prepare-kernel.sh: Don't allow uninitialized variables Richard Weinberger
` (2 subsequent siblings)
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:58 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
CONFIG_XENO_REVISION_LEVEL was added via
b370b7d54 ("build: introduce core API revision level in userland"),
to my best knowledge it was dead code since ever.
Let's remove it.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 2 --
1 file changed, 2 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 43883ded3..fe9dd5de5 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -325,8 +325,6 @@ case $linux_VERSION.$linux_PATCHLEVEL in
patch_reverse init/Kconfig
fi
-test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0
-
for a in $target_linux_archs; do
if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 15/16] prepare-kernel.sh: Don't allow uninitialized variables
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (13 preceding siblings ...)
2024-05-25 11:58 ` [PATCH 14/16] prepare-kernel.sh: Remove dead code Richard Weinberger
@ 2024-05-25 11:58 ` Richard Weinberger
2024-05-25 11:58 ` [PATCH 16/16] prepare-kernel.sh: Remove kernel version check Richard Weinberger
2024-06-21 14:42 ` [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Jan Kiszka
16 siblings, 0 replies; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:58 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
Use "set -u" to detect subtle breakage in future.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 1 +
1 file changed, 1 insertion(+)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index fe9dd5de5..f6eedc1a0 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -1,5 +1,6 @@
#!/bin/sh
set -e
+set -u
unset CDPATH
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* [PATCH 16/16] prepare-kernel.sh: Remove kernel version check
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (14 preceding siblings ...)
2024-05-25 11:58 ` [PATCH 15/16] prepare-kernel.sh: Don't allow uninitialized variables Richard Weinberger
@ 2024-05-25 11:58 ` Richard Weinberger
2024-05-27 11:06 ` Jan Kiszka
2024-06-21 14:42 ` [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Jan Kiszka
16 siblings, 1 reply; 28+ messages in thread
From: Richard Weinberger @ 2024-05-25 11:58 UTC (permalink / raw)
To: xenomai; +Cc: upstream+xenomai, Richard Weinberger
The kernel version is only used to test whether the kernel is extremely old
and verbose logging.
IMHO it's worth the complexity of reading it from the kernel tree.
Signed-off-by: Richard Weinberger <richard@nod.at>
---
scripts/prepare-kernel.sh | 98 ++++++++++++++++-----------------------
1 file changed, 39 insertions(+), 59 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index f6eedc1a0..b5644a4a9 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -250,15 +250,8 @@ if [ ! -z $foo ] ; then
fi
unset foo
-linux_EXTRAVERSION=`awk -F= '/^EXTRAVERSION =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
-linux_PATCHLEVEL=`awk -F= '/^PATCHLEVEL =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
-linux_SUBLEVEL=`awk -F= '/^SUBLEVEL =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
-linux_VERSION=`awk -F= '/^VERSION =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
-
-linux_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL"
-
if test x$verbose = x1; then
- echo "Preparing kernel $linux_version$linux_EXTRAVERSION in $linux_tree..."
+ echo "Preparing kernel $linux_tree..."
fi
if test -r $linux_tree/include/linux/dovetail.h; then
@@ -279,7 +272,7 @@ else
curdir=$PWD
cd $linux_tree && patch --dry-run -p1 -f < $pipeline_patch || {
cd $curdir;
- echo "$me: Unable to patch kernel $linux_version$linux_EXTRAVERSION with `basename $pipeline_patch`." >&2
+ echo "$me: Unable to patch kernel $linux_tree with `basename $pipeline_patch`." >&2
exit 2;
}
patch -p1 -f -s < $pipeline_patch
@@ -297,61 +290,48 @@ if test x$verbose = x1; then
echo "IRQ pipeline installed."
fi
-case $linux_VERSION.$linux_PATCHLEVEL in
-
- 2.*)
-
- echo "$me: Unsupported kernel version $linux_VERSION.$linux_PATCHLEVEL.x" >&2
- exit 2
- ;;
-
- *)
-
- if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
- version_stamp=`cat $xenomai_root/config/version-code`
- version_major=`expr $version_stamp : '\([[0-9]]*\)' || true`
- version_minor=`expr $version_stamp : '[[0-9]]*\.\([[0-9]*]*\)' || true`
- revision_level=`expr $version_stamp : '[[0-9]]*\.[[0-9]*]*\.\([[0-9]*]*\)' || true`
- if [ -z "$revision_level" ]; then
- revision_level=0
- fi
- version_string=`cat $xenomai_root/config/version-label`
- sed -e "s,@VERSION_MAJOR@,$version_major,g" \
- -e "s,@VERSION_MINOR@,$version_minor,g" \
- -e "s,@REVISION_LEVEL@,$revision_level,g" \
- -e "s,@VERSION_STRING@,$version_string,g" \
- $xenomai_root/scripts/Kconfig.frag |
- patch_append init/Kconfig
- elif test x$reverse = x1; then
- patch_reverse init/Kconfig
- fi
-
- for a in $target_linux_archs; do
- if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
- p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
- p2="core-\$(CONFIG_XENOMAI) += arch/$a/xenomai/"
- (echo; echo $p1; echo $p2) | patch_append arch/$a/Makefile
- elif test x$reverse = x1; then
- patch_reverse arch/$a/Makefile
- fi
- done
+if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
+ version_stamp=`cat $xenomai_root/config/version-code`
+ version_major=`expr $version_stamp : '\([[0-9]]*\)' || true`
+ version_minor=`expr $version_stamp : '[[0-9]]*\.\([[0-9]*]*\)' || true`
+ revision_level=`expr $version_stamp : '[[0-9]]*\.[[0-9]*]*\.\([[0-9]*]*\)' || true`
+if [ -z "$revision_level" ]; then
+ revision_level=0
+fi
+version_string=`cat $xenomai_root/config/version-label`
+sed -e "s,@VERSION_MAJOR@,$version_major,g" \
+ -e "s,@VERSION_MINOR@,$version_minor,g" \
+ -e "s,@REVISION_LEVEL@,$revision_level,g" \
+ -e "s,@VERSION_STRING@,$version_string,g" \
+ $xenomai_root/scripts/Kconfig.frag |
+ patch_append init/Kconfig
+elif test x$reverse = x1; then
+ patch_reverse init/Kconfig
+fi
- if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
- p="obj-\$(CONFIG_XENOMAI) += xenomai/"
- ( echo ; echo $p ) | patch_append drivers/Makefile
+for a in $target_linux_archs; do
+ if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
+ p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
+ p2="core-\$(CONFIG_XENOMAI) += arch/$a/xenomai/"
+ (echo; echo $p1; echo $p2) | patch_append arch/$a/Makefile
elif test x$reverse = x1; then
- patch_reverse drivers/Makefile
+ patch_reverse arch/$a/Makefile
fi
+done
- if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
- p="obj-\$(CONFIG_XENOMAI) += xenomai/"
- ( echo ; echo $p ) | patch_append kernel/Makefile
- elif test x$reverse = x1; then
- patch_reverse kernel/Makefile
- fi
- ;;
+if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
+ p="obj-\$(CONFIG_XENOMAI) += xenomai/"
+ ( echo ; echo $p ) | patch_append drivers/Makefile
+elif test x$reverse = x1; then
+ patch_reverse drivers/Makefile
+fi
-esac
+if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
+ p="obj-\$(CONFIG_XENOMAI) += xenomai/"
+ ( echo ; echo $p ) | patch_append kernel/Makefile
+elif test x$reverse = x1; then
+ patch_reverse kernel/Makefile
+fi
# Create local directories then symlink to the source files from
# there, so that we don't pollute the Xenomai source tree with
--
2.35.3
^ permalink raw reply related [flat|nested] 28+ messages in thread* Re: [PATCH 16/16] prepare-kernel.sh: Remove kernel version check
2024-05-25 11:58 ` [PATCH 16/16] prepare-kernel.sh: Remove kernel version check Richard Weinberger
@ 2024-05-27 11:06 ` Jan Kiszka
0 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2024-05-27 11:06 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 25.05.24 13:58, Richard Weinberger wrote:
> The kernel version is only used to test whether the kernel is extremely old
> and verbose logging.
> IMHO it's worth the complexity of reading it from the kernel tree.
>
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
> scripts/prepare-kernel.sh | 98 ++++++++++++++++-----------------------
> 1 file changed, 39 insertions(+), 59 deletions(-)
>
> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> index f6eedc1a0..b5644a4a9 100755
> --- a/scripts/prepare-kernel.sh
> +++ b/scripts/prepare-kernel.sh
> @@ -250,15 +250,8 @@ if [ ! -z $foo ] ; then
> fi
> unset foo
>
> -linux_EXTRAVERSION=`awk -F= '/^EXTRAVERSION =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
> -linux_PATCHLEVEL=`awk -F= '/^PATCHLEVEL =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
> -linux_SUBLEVEL=`awk -F= '/^SUBLEVEL =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
> -linux_VERSION=`awk -F= '/^VERSION =/{ gsub(/ /, "", $2); print $2}' $linux_tree/Makefile`
> -
Oh, that's the nice awk code I was about to comment on earlier. If we
agree on removing, that earlier refactoring should not be done, rather
this patch pulled to the front if needed.
> -linux_version="$linux_VERSION.$linux_PATCHLEVEL.$linux_SUBLEVEL"
> -
> if test x$verbose = x1; then
> - echo "Preparing kernel $linux_version$linux_EXTRAVERSION in $linux_tree..."
> + echo "Preparing kernel $linux_tree..."
> fi
>
> if test -r $linux_tree/include/linux/dovetail.h; then
> @@ -279,7 +272,7 @@ else
> curdir=$PWD
> cd $linux_tree && patch --dry-run -p1 -f < $pipeline_patch || {
> cd $curdir;
> - echo "$me: Unable to patch kernel $linux_version$linux_EXTRAVERSION with `basename $pipeline_patch`." >&2
> + echo "$me: Unable to patch kernel $linux_tree with `basename $pipeline_patch`." >&2
> exit 2;
> }
> patch -p1 -f -s < $pipeline_patch
> @@ -297,61 +290,48 @@ if test x$verbose = x1; then
> echo "IRQ pipeline installed."
> fi
>
> -case $linux_VERSION.$linux_PATCHLEVEL in
> -
> - 2.*)
> -
> - echo "$me: Unsupported kernel version $linux_VERSION.$linux_PATCHLEVEL.x" >&2
> - exit 2
> - ;;
> -
> - *)
> -
> - if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
> - version_stamp=`cat $xenomai_root/config/version-code`
> - version_major=`expr $version_stamp : '\([[0-9]]*\)' || true`
> - version_minor=`expr $version_stamp : '[[0-9]]*\.\([[0-9]*]*\)' || true`
> - revision_level=`expr $version_stamp : '[[0-9]]*\.[[0-9]*]*\.\([[0-9]*]*\)' || true`
> - if [ -z "$revision_level" ]; then
> - revision_level=0
> - fi
> - version_string=`cat $xenomai_root/config/version-label`
> - sed -e "s,@VERSION_MAJOR@,$version_major,g" \
> - -e "s,@VERSION_MINOR@,$version_minor,g" \
> - -e "s,@REVISION_LEVEL@,$revision_level,g" \
> - -e "s,@VERSION_STRING@,$version_string,g" \
> - $xenomai_root/scripts/Kconfig.frag |
> - patch_append init/Kconfig
> - elif test x$reverse = x1; then
> - patch_reverse init/Kconfig
> - fi
> -
> - for a in $target_linux_archs; do
> - if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
> - p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
> - p2="core-\$(CONFIG_XENOMAI) += arch/$a/xenomai/"
> - (echo; echo $p1; echo $p2) | patch_append arch/$a/Makefile
> - elif test x$reverse = x1; then
> - patch_reverse arch/$a/Makefile
> - fi
> - done
> +if ! grep -q XENOMAI $linux_tree/init/Kconfig; then
> + version_stamp=`cat $xenomai_root/config/version-code`
> + version_major=`expr $version_stamp : '\([[0-9]]*\)' || true`
> + version_minor=`expr $version_stamp : '[[0-9]]*\.\([[0-9]*]*\)' || true`
> + revision_level=`expr $version_stamp : '[[0-9]]*\.[[0-9]*]*\.\([[0-9]*]*\)' || true`
> +if [ -z "$revision_level" ]; then
> + revision_level=0
> +fi
> +version_string=`cat $xenomai_root/config/version-label`
> +sed -e "s,@VERSION_MAJOR@,$version_major,g" \
> + -e "s,@VERSION_MINOR@,$version_minor,g" \
> + -e "s,@REVISION_LEVEL@,$revision_level,g" \
> + -e "s,@VERSION_STRING@,$version_string,g" \
> + $xenomai_root/scripts/Kconfig.frag |
> + patch_append init/Kconfig
> +elif test x$reverse = x1; then
> + patch_reverse init/Kconfig
> +fi
>
> - if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
> - p="obj-\$(CONFIG_XENOMAI) += xenomai/"
> - ( echo ; echo $p ) | patch_append drivers/Makefile
> +for a in $target_linux_archs; do
> + if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$a/Makefile; then
> + p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai"
> + p2="core-\$(CONFIG_XENOMAI) += arch/$a/xenomai/"
> + (echo; echo $p1; echo $p2) | patch_append arch/$a/Makefile
> elif test x$reverse = x1; then
> - patch_reverse drivers/Makefile
> + patch_reverse arch/$a/Makefile
> fi
> +done
>
> - if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
> - p="obj-\$(CONFIG_XENOMAI) += xenomai/"
> - ( echo ; echo $p ) | patch_append kernel/Makefile
> - elif test x$reverse = x1; then
> - patch_reverse kernel/Makefile
> - fi
> - ;;
> +if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
> + p="obj-\$(CONFIG_XENOMAI) += xenomai/"
> + ( echo ; echo $p ) | patch_append drivers/Makefile
> +elif test x$reverse = x1; then
> + patch_reverse drivers/Makefile
> +fi
>
> -esac
> +if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
> + p="obj-\$(CONFIG_XENOMAI) += xenomai/"
> + ( echo ; echo $p ) | patch_append kernel/Makefile
> +elif test x$reverse = x1; then
> + patch_reverse kernel/Makefile
> +fi
>
> # Create local directories then symlink to the source files from
> # there, so that we don't pollute the Xenomai source tree with
I agree that the current check is complex and in this form useless. I
just wonder if we should remove or modernize it. No clear opinion yet,
but it was you who raised that question just the other week, no?
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh
2024-05-25 11:57 [PATCH 00/16] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (15 preceding siblings ...)
2024-05-25 11:58 ` [PATCH 16/16] prepare-kernel.sh: Remove kernel version check Richard Weinberger
@ 2024-06-21 14:42 ` Jan Kiszka
16 siblings, 0 replies; 28+ messages in thread
From: Jan Kiszka @ 2024-06-21 14:42 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 25.05.24 13:57, Richard Weinberger wrote:
> This series contains the following improvements and cleanups.
>
> - Implement --reverse to undo the effects of the script
> - Emit changes that work on any architecture, renders --arch= optional
> - Switch from /bin/bash to /bin/sh
> - Make shellcheck happy up to warning level, info level is still a lot of work
> - Convert the whole script to tabs
> - Remove dead and in vain code
> - Various fixes
>
> Richard Weinberger (16):
> prepare-kernel.sh: Add reverse mode
> prepare-kernel.sh: Emit architecture agnostic changes
> prepare-kernel.sh: Convert to tabs
> prepare-kernel.sh: Improve kernel tree check
> prepare-kernel.sh: Fix shellcheck SC2046 warnings wrt. check_filter
> prepare-kernel.sh: Disable SC2115 warning around $linux_tree
> prepare-kernel.sh: Don't use eval
> prepare-kernel.sh: Don't depend on bash
> prepare-kernel.sh: Remove --filterkvers= and --filterarch=
> prepare-kernel.sh: Remove interactivity
> prepare-kernel.sh: Remove --forcelink
> prepare-kernel.sh: Fix dovetail check
> prepare-kernel.sh: Define command line variables
> prepare-kernel.sh: Remove dead code
> prepare-kernel.sh: Don't allow uninitialized variables
> prepare-kernel.sh: Remove kernel version check
>
> scripts/Kconfig.frag | 2 +-
> scripts/prepare-kernel.sh | 585 +++++++++++++++++---------------------
> 2 files changed, 267 insertions(+), 320 deletions(-)
>
We still need some v2 of this before 3.3-rc1...
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 28+ messages in thread