* [PATCH 01/14] prepare-kernel.sh: Convert to tabs
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-25 15:28 ` Jan Kiszka
2024-06-24 20:33 ` [PATCH 02/14] prepare-kernel.sh: Add reverse mode Richard Weinberger
` (13 subsequent siblings)
14 siblings, 1 reply; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 | 510 +++++++++++++++++++-------------------
1 file changed, 253 insertions(+), 257 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index faf3e7235..9299aaa97 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -29,112 +29,110 @@ 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"
+ 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"
+ 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
- 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_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
-
- 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
- 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
- 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$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
+ 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
+ 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
+ )
}
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
+ )
}
@@ -142,49 +140,49 @@ 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
;;
- --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
@@ -199,87 +197,86 @@ 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
+ temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
+ if [ $? -ne 0 ]; then
+ echo Temporary directory could not be created.
+ 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"
+ patchdir=`dirname $output_patch`
+ patchdir=`cd $patchdir && pwd`
+ output_patch=$patchdir/`basename $output_patch`
+ echo > "$output_patch"
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-`
+ build_arch=`$xenomai_root/config/config.guess`
+ default_linux_arch=`echo $build_arch|cut -f1 -d-`
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
+ 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
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
@@ -291,101 +288,100 @@ 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
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
+ echo "$me: $linux_tree has no IRQ pipeline support for $linux_arch" >&2
+ exit 2
fi
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" \
- -e "s,@SRCARCH@,$linux_arch,g" \
- $xenomai_root/scripts/Kconfig.frag |
- patch_append init/Kconfig
- fi
+ -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
+ 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
- fi
-
- patch_architecture_specific="n"
+ 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
+ fi
- if ! grep -q CONFIG_XENOMAI $linux_tree/drivers/Makefile; then
- p="obj-\$(CONFIG_XENOMAI) += xenomai/"
- ( echo ; echo $p ) | patch_append drivers/Makefile
- fi
+ patch_architecture_specific="n"
- if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
- p="obj-\$(CONFIG_XENOMAI) += xenomai/"
- ( echo ; echo $p ) | patch_append 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
+ fi
+ if ! grep -q CONFIG_XENOMAI $linux_tree/kernel/Makefile; then
+ p="obj-\$(CONFIG_XENOMAI) += xenomai/"
+ ( echo ; echo $p ) | patch_append kernel/Makefile
+ fi
+ ;;
esac
# Create local directories then symlink to the source files from
@@ -415,16 +411,16 @@ patch_link n version.h include/xenomai include/xenomai
patch_link n stdarg.h kernel/cobalt/include/linux include/xenomai/linux
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] 23+ messages in thread* Re: [PATCH 01/14] prepare-kernel.sh: Convert to tabs
2024-06-24 20:33 ` [PATCH 01/14] prepare-kernel.sh: Convert to tabs Richard Weinberger
@ 2024-06-25 15:28 ` Jan Kiszka
0 siblings, 0 replies; 23+ messages in thread
From: Jan Kiszka @ 2024-06-25 15:28 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 24.06.24 22:33, Richard Weinberger wrote:
> 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 | 510 +++++++++++++++++++-------------------
> 1 file changed, 253 insertions(+), 257 deletions(-)
>
> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> index faf3e7235..9299aaa97 100755
> --- a/scripts/prepare-kernel.sh
> +++ b/scripts/prepare-kernel.sh
> @@ -29,112 +29,110 @@ 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"
> + 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"
> + 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
> - 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_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
> -
> - 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
> - 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
> - 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$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
> + 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
> + 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
> + )
> }
>
> 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
> + )
> }
>
>
> @@ -142,49 +140,49 @@ 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
> ;;
> - --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
> @@ -199,87 +197,86 @@ 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
> + temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
> + if [ $? -ne 0 ]; then
> + echo Temporary directory could not be created.
> + 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"
> + patchdir=`dirname $output_patch`
> + patchdir=`cd $patchdir && pwd`
> + output_patch=$patchdir/`basename $output_patch`
> + echo > "$output_patch"
>
> 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-`
> + build_arch=`$xenomai_root/config/config.guess`
> + default_linux_arch=`echo $build_arch|cut -f1 -d-`
> 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
> + 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
> 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
>
> @@ -291,101 +288,100 @@ 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
>
> 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
> + echo "$me: $linux_tree has no IRQ pipeline support for $linux_arch" >&2
> + exit 2
> fi
>
> 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" \
> - -e "s,@SRCARCH@,$linux_arch,g" \
> - $xenomai_root/scripts/Kconfig.frag |
> - patch_append init/Kconfig
> - fi
> + -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
> + fi
This leaves the two if-blocks improperly indented behind (noticed
because the next patch fails to cover it properly as well).
I'm trying to fix up while merging.
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 02/14] prepare-kernel.sh: Add reverse mode
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
2024-06-24 20:33 ` [PATCH 01/14] prepare-kernel.sh: Convert to tabs Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-25 15:44 ` Jan Kiszka
2024-06-25 16:20 ` Jan Kiszka
2024-06-24 20:33 ` [PATCH 03/14] prepare-kernel.sh: Emit architecture agnostic changes Richard Weinberger
` (12 subsequent siblings)
14 siblings, 2 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 | 71 +++++++++++++++++++++++++++++++--------
1 file changed, 57 insertions(+), 14 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 9299aaa97..f294ef0fa 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -55,6 +55,8 @@ 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"
+ else
+ cp "$linux_tree/$file" "$linux_tree/$file.orig"
fi
chmod +w "$linux_tree/$file"
cat >> "$linux_tree/$file"
@@ -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
@@ -104,11 +116,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
@@ -120,6 +136,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
)
}
@@ -135,8 +156,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
@@ -172,6 +192,9 @@ while test $# -gt 0; do
--verbose)
verbose=1
;;
+ --reverse)
+ reverse=1
+ ;;
--help)
echo "$usage"
exit 0
@@ -221,6 +244,13 @@ 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
temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
@@ -229,6 +259,11 @@ if test "x$output_patch" != "x"; then
exit 1
fi
+ if test x$reverse = x1; then
+ echo "$me: --reverse and --outpatch are not compatible"
+ exit 1
+ fi
+
patchdir=`dirname $output_patch`
patchdir=`cd $patchdir && pwd`
output_patch=$patchdir/`basename $output_patch`
@@ -364,10 +399,11 @@ 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
- 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"
@@ -375,11 +411,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
;;
esac
@@ -387,13 +427,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
@@ -401,14 +443,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] 23+ messages in thread* Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
2024-06-24 20:33 ` [PATCH 02/14] prepare-kernel.sh: Add reverse mode Richard Weinberger
@ 2024-06-25 15:44 ` Jan Kiszka
2024-06-25 15:48 ` Richard Weinberger
2024-06-25 16:20 ` Jan Kiszka
1 sibling, 1 reply; 23+ messages in thread
From: Jan Kiszka @ 2024-06-25 15:44 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 24.06.24 22:33, Richard Weinberger wrote:
> 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 | 71 +++++++++++++++++++++++++++++++--------
> 1 file changed, 57 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> index 9299aaa97..f294ef0fa 100755
> --- a/scripts/prepare-kernel.sh
> +++ b/scripts/prepare-kernel.sh
> @@ -55,6 +55,8 @@ 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"
> + else
> + cp "$linux_tree/$file" "$linux_tree/$file.orig"
> fi
> chmod +w "$linux_tree/$file"
> cat >> "$linux_tree/$file"
> @@ -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
> @@ -104,11 +116,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
> @@ -120,6 +136,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
> )
> }
>
> @@ -135,8 +156,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
> @@ -172,6 +192,9 @@ while test $# -gt 0; do
> --verbose)
> verbose=1
> ;;
> + --reverse)
> + reverse=1
> + ;;
> --help)
> echo "$usage"
> exit 0
> @@ -221,6 +244,13 @@ 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
> temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
> @@ -229,6 +259,11 @@ if test "x$output_patch" != "x"; then
> exit 1
> fi
>
> + if test x$reverse = x1; then
> + echo "$me: --reverse and --outpatch are not compatible"
> + exit 1
> + fi
> +
> patchdir=`dirname $output_patch`
> patchdir=`cd $patchdir && pwd`
> output_patch=$patchdir/`basename $output_patch`
> @@ -364,10 +399,11 @@ 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
> - 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"
> @@ -375,11 +411,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
> ;;
> esac
> @@ -387,13 +427,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
> @@ -401,14 +443,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
The reverse mode is missing coverage for init/Kconfig. Only patch 14
introduces it. Fixing up while merging.
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
2024-06-25 15:44 ` Jan Kiszka
@ 2024-06-25 15:48 ` Richard Weinberger
0 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-25 15:48 UTC (permalink / raw)
To: Richard Weinberger, xenomai, upstream+xenomai; +Cc: Jan Kiszka
Am Dienstag, 25. Juni 2024, 17:44:47 CEST schrieb 'Jan Kiszka' via upstream:
> > if test "x$output_patch" != "x"; then
> > if test x$verbose = x1; then
>
> The reverse mode is missing coverage for init/Kconfig. Only patch 14
> introduces it. Fixing up while merging.
Hm, must have happened while reordering patches.
Sorry for that.
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
2024-06-24 20:33 ` [PATCH 02/14] prepare-kernel.sh: Add reverse mode Richard Weinberger
2024-06-25 15:44 ` Jan Kiszka
@ 2024-06-25 16:20 ` Jan Kiszka
2024-06-25 16:44 ` Richard Weinberger
1 sibling, 1 reply; 23+ messages in thread
From: Jan Kiszka @ 2024-06-25 16:20 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 24.06.24 22:33, Richard Weinberger wrote:
> 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 | 71 +++++++++++++++++++++++++++++++--------
> 1 file changed, 57 insertions(+), 14 deletions(-)
>
> diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> index 9299aaa97..f294ef0fa 100755
> --- a/scripts/prepare-kernel.sh
> +++ b/scripts/prepare-kernel.sh
> @@ -55,6 +55,8 @@ 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"
> + else
> + cp "$linux_tree/$file" "$linux_tree/$file.orig"
> fi
> chmod +w "$linux_tree/$file"
> cat >> "$linux_tree/$file"
> @@ -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
> @@ -104,11 +116,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
> @@ -120,6 +136,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
> )
> }
>
> @@ -135,8 +156,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
> @@ -172,6 +192,9 @@ while test $# -gt 0; do
> --verbose)
> verbose=1
> ;;
> + --reverse)
> + reverse=1
> + ;;
> --help)
> echo "$usage"
> exit 0
> @@ -221,6 +244,13 @@ 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
> temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
> @@ -229,6 +259,11 @@ if test "x$output_patch" != "x"; then
> exit 1
> fi
>
> + if test x$reverse = x1; then
> + echo "$me: --reverse and --outpatch are not compatible"
> + exit 1
> + fi
> +
> patchdir=`dirname $output_patch`
> patchdir=`cd $patchdir && pwd`
> output_patch=$patchdir/`basename $output_patch`
> @@ -364,10 +399,11 @@ 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
> - 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"
> @@ -375,11 +411,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
> ;;
> esac
> @@ -387,13 +427,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
> @@ -401,14 +443,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
This breaks rtdm/uapi/rtdm.h, at least. Didn't debug yet, just bisected.
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
2024-06-25 16:20 ` Jan Kiszka
@ 2024-06-25 16:44 ` Richard Weinberger
0 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-25 16:44 UTC (permalink / raw)
To: Richard Weinberger, xenomai, upstream; +Cc: upstream+xenomai, Jan Kiszka
Am Dienstag, 25. Juni 2024, 18:20:45 CEST schrieb 'Jan Kiszka' via upstream:
> On 24.06.24 22:33, Richard Weinberger wrote:
> > 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 | 71 +++++++++++++++++++++++++++++++--------
> > 1 file changed, 57 insertions(+), 14 deletions(-)
> >
> > diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
> > index 9299aaa97..f294ef0fa 100755
> > --- a/scripts/prepare-kernel.sh
> > +++ b/scripts/prepare-kernel.sh
> > @@ -55,6 +55,8 @@ 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"
> > + else
> > + cp "$linux_tree/$file" "$linux_tree/$file.orig"
> > fi
> > chmod +w "$linux_tree/$file"
> > cat >> "$linux_tree/$file"
> > @@ -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
> > @@ -104,11 +116,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
> > @@ -120,6 +136,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
> > )
> > }
> >
> > @@ -135,8 +156,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
> > @@ -172,6 +192,9 @@ while test $# -gt 0; do
> > --verbose)
> > verbose=1
> > ;;
> > + --reverse)
> > + reverse=1
> > + ;;
> > --help)
> > echo "$usage"
> > exit 0
> > @@ -221,6 +244,13 @@ 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
> > temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
> > @@ -229,6 +259,11 @@ if test "x$output_patch" != "x"; then
> > exit 1
> > fi
> >
> > + if test x$reverse = x1; then
> > + echo "$me: --reverse and --outpatch are not compatible"
> > + exit 1
> > + fi
> > +
> > patchdir=`dirname $output_patch`
> > patchdir=`cd $patchdir && pwd`
> > output_patch=$patchdir/`basename $output_patch`
> > @@ -364,10 +399,11 @@ 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
> > - 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"
> > @@ -375,11 +411,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
> > ;;
> > esac
> > @@ -387,13 +427,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
> > @@ -401,14 +443,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
>
> This breaks rtdm/uapi/rtdm.h, at least. Didn't debug yet, just bisected.
I found the problem.
The order of calls to patch_link() matters in wicked ways. :-/
It used to work before I have further "cleaned up".
I'll look into a fix after dinner.
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 23+ messages in thread
* [PATCH 03/14] prepare-kernel.sh: Emit architecture agnostic changes
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
2024-06-24 20:33 ` [PATCH 01/14] prepare-kernel.sh: Convert to tabs Richard Weinberger
2024-06-24 20:33 ` [PATCH 02/14] prepare-kernel.sh: Add reverse mode Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 04/14] prepare-kernel.sh: Improve kernel tree check Richard Weinberger
` (11 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 | 77 +++++++++++++++++----------------------
2 files changed, 34 insertions(+), 45 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 f294ef0fa..aa845e65e 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -244,13 +244,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
temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir`
@@ -271,41 +264,32 @@ 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-`
-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
+ target_linux_archs="x86 arm arm64"
+else
case "$linux_arch" in
x86*|i*86|amd*)
- linux_arch=x86
+ target_linux_archs="x86"
;;
arm)
- linux_arch=arm
+ target_linux_archs="arm"
;;
arm64|aarch64)
- linux_arch=arm64
+ target_linux_archs="arm64"
;;
*)
echo "$me: unsupported architecture: $linux_arch" >&2
- linux_arch=
- usedefault=
+ exit 1
;;
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
@@ -355,10 +339,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."
@@ -391,20 +377,21 @@ 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
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
- 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"
@@ -433,8 +420,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] 23+ messages in thread* [PATCH 04/14] prepare-kernel.sh: Improve kernel tree check
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (2 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 03/14] prepare-kernel.sh: Emit architecture agnostic changes Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 05/14] prepare-kernel.sh: Disable SC2115 warning around $linux_tree Richard Weinberger
` (10 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 the kernel README file.
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 aa845e65e..5712f760d 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -239,7 +239,7 @@ done
linux_tree=`cd $linux_tree && pwd`
-if test \! -r $linux_tree/Makefile; then
+if test "$(head -1 $linux_tree/README 2> /dev/null)" != "Linux kernel"; 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] 23+ messages in thread* [PATCH 05/14] prepare-kernel.sh: Disable SC2115 warning around $linux_tree
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (3 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 04/14] prepare-kernel.sh: Improve kernel tree check Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 06/14] prepare-kernel.sh: Remove --filterkvers= and --filterarch= Richard Weinberger
` (9 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 5712f760d..30c5be2aa 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -138,7 +138,8 @@ patch_link() {
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
+ # shellcheck disable=SC2115
+ rm -rf ${linux_tree}/$link_dir
fi
fi
)
--
2.35.3
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 06/14] prepare-kernel.sh: Remove --filterkvers= and --filterarch=
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (4 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 05/14] prepare-kernel.sh: Disable SC2115 warning around $linux_tree Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 07/14] prepare-kernel.sh: Remove interactivity Richard Weinberger
` (8 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 30c5be2aa..ad2cacd4e 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
}
@@ -127,13 +91,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
if test x$reverse = x1; then
@@ -157,7 +119,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
@@ -179,10 +141,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`
@@ -394,8 +352,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
@@ -419,13 +375,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] 23+ messages in thread* [PATCH 07/14] prepare-kernel.sh: Remove interactivity
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (5 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 06/14] prepare-kernel.sh: Remove --filterkvers= and --filterarch= Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 08/14] prepare-kernel.sh: Don't depend on bash Richard Weinberger
` (7 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 | 36 +++++++++---------------------------
1 file changed, 9 insertions(+), 27 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index ad2cacd4e..a6eb6c1e0 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -119,7 +119,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
@@ -150,7 +150,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
@@ -182,23 +182,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
- 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`
@@ -281,14 +267,10 @@ 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
+ 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] 23+ messages in thread* [PATCH 08/14] prepare-kernel.sh: Don't depend on bash
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (6 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 07/14] prepare-kernel.sh: Remove interactivity Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 09/14] prepare-kernel.sh: Remove --forcelink Richard Weinberger
` (6 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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.
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 a6eb6c1e0..26333c419 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/sh
set -e
unset CDPATH
@@ -174,7 +174,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`
--
2.35.3
^ permalink raw reply related [flat|nested] 23+ messages in thread* [PATCH 09/14] prepare-kernel.sh: Remove --forcelink
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (7 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 08/14] prepare-kernel.sh: Don't depend on bash Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 10/14] prepare-kernel.sh: Fix dovetail check Richard Weinberger
` (5 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 26333c419..d16e3feab 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -84,9 +84,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
@@ -119,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
@@ -147,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] 23+ messages in thread* [PATCH 10/14] prepare-kernel.sh: Fix dovetail check
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (8 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 09/14] prepare-kernel.sh: Remove --forcelink Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 11/14] prepare-kernel.sh: Define command line variables Richard Weinberger
` (4 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 d16e3feab..cc1907b63 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] 23+ messages in thread* [PATCH 11/14] prepare-kernel.sh: Define command line variables
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (9 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 10/14] prepare-kernel.sh: Fix dovetail check Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 12/14] prepare-kernel.sh: Remove dead code Richard Weinberger
` (3 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 cc1907b63..e1d1c318d 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] 23+ messages in thread* [PATCH 12/14] prepare-kernel.sh: Remove dead code
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (10 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 11/14] prepare-kernel.sh: Define command line variables Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 13/14] prepare-kernel.sh: Don't allow uninitialized variables Richard Weinberger
` (2 subsequent siblings)
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 e1d1c318d..37be3a3b0 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -323,8 +323,6 @@ case $linux_VERSION.$linux_PATCHLEVEL in
patch_append 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] 23+ messages in thread* [PATCH 13/14] prepare-kernel.sh: Don't allow uninitialized variables
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (11 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 12/14] prepare-kernel.sh: Remove dead code Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-24 20:33 ` [PATCH 14/14] prepare-kernel.sh: Remove kernel version check Richard Weinberger
2024-06-25 15:46 ` [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Jan Kiszka
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 37be3a3b0..276273a96 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] 23+ messages in thread* [PATCH 14/14] prepare-kernel.sh: Remove kernel version check
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (12 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 13/14] prepare-kernel.sh: Don't allow uninitialized variables Richard Weinberger
@ 2024-06-24 20:33 ` Richard Weinberger
2024-06-25 15:46 ` [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Jan Kiszka
14 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-24 20:33 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 | 95 ++++++++++++++++-----------------------
1 file changed, 39 insertions(+), 56 deletions(-)
diff --git a/scripts/prepare-kernel.sh b/scripts/prepare-kernel.sh
index 276273a96..20c384f13 100755
--- a/scripts/prepare-kernel.sh
+++ b/scripts/prepare-kernel.sh
@@ -250,15 +250,8 @@ 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_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,58 +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 |
+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
- 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
+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
- ;;
-esac
+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
# 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] 23+ messages in thread* Re: [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh
2024-06-24 20:33 [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Richard Weinberger
` (13 preceding siblings ...)
2024-06-24 20:33 ` [PATCH 14/14] prepare-kernel.sh: Remove kernel version check Richard Weinberger
@ 2024-06-25 15:46 ` Jan Kiszka
2024-06-25 15:58 ` Jan Kiszka
14 siblings, 1 reply; 23+ messages in thread
From: Jan Kiszka @ 2024-06-25 15:46 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 24.06.24 22:33, 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
>
> Changes since v1[0]:
> - Rebased to current next branch
> - Reorganized patch series
> - Worked in feedback from Jan and Florian
>
> Richard Weinberger (14):
> prepare-kernel.sh: Convert to tabs
> prepare-kernel.sh: Add reverse mode
> prepare-kernel.sh: Emit architecture agnostic changes
> prepare-kernel.sh: Improve kernel tree check
> prepare-kernel.sh: Disable SC2115 warning around $linux_tree
> prepare-kernel.sh: Remove --filterkvers= and --filterarch=
> prepare-kernel.sh: Remove interactivity
> prepare-kernel.sh: Don't depend on bash
> 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 | 587 +++++++++++++++++---------------------
> 2 files changed, 268 insertions(+), 321 deletions(-)
>
> [0]: https://lore.kernel.org/xenomai/20240525115806.12101-1-richard@nod.at/
>
Thanks, series with smaller adjustments in next now. The final diff is
limited to whitespaces, though.
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 23+ messages in thread* Re: [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh
2024-06-25 15:46 ` [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh Jan Kiszka
@ 2024-06-25 15:58 ` Jan Kiszka
2024-06-25 16:10 ` Richard Weinberger
0 siblings, 1 reply; 23+ messages in thread
From: Jan Kiszka @ 2024-06-25 15:58 UTC (permalink / raw)
To: Richard Weinberger, xenomai; +Cc: upstream+xenomai
On 25.06.24 17:46, Jan Kiszka wrote:
> On 24.06.24 22:33, 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
>>
>> Changes since v1[0]:
>> - Rebased to current next branch
>> - Reorganized patch series
>> - Worked in feedback from Jan and Florian
>>
>> Richard Weinberger (14):
>> prepare-kernel.sh: Convert to tabs
>> prepare-kernel.sh: Add reverse mode
>> prepare-kernel.sh: Emit architecture agnostic changes
>> prepare-kernel.sh: Improve kernel tree check
>> prepare-kernel.sh: Disable SC2115 warning around $linux_tree
>> prepare-kernel.sh: Remove --filterkvers= and --filterarch=
>> prepare-kernel.sh: Remove interactivity
>> prepare-kernel.sh: Don't depend on bash
>> 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 | 587 +++++++++++++++++---------------------
>> 2 files changed, 268 insertions(+), 321 deletions(-)
>>
>> [0]: https://lore.kernel.org/xenomai/20240525115806.12101-1-richard@nod.at/
>>
>
> Thanks, series with smaller adjustments in next now. The final diff is
> limited to whitespaces, though.
>
Does not look good yet, at least regarding backward compatibility (we
didn't change our CI rules, so...):
https://source.denx.de/Xenomai/xenomai/-/pipelines/21335
Jan
--
Siemens AG, Technology
Linux Expert Center
^ permalink raw reply [flat|nested] 23+ messages in thread
* Re: [PATCH v2 00/14] Assorted Cleanups For prepare-kernel.sh
2024-06-25 15:58 ` Jan Kiszka
@ 2024-06-25 16:10 ` Richard Weinberger
0 siblings, 0 replies; 23+ messages in thread
From: Richard Weinberger @ 2024-06-25 16:10 UTC (permalink / raw)
To: Richard Weinberger, xenomai, upstream; +Cc: upstream+xenomai, Jan Kiszka
Am Dienstag, 25. Juni 2024, 17:58:01 CEST schrieb 'Jan Kiszka' via upstream:
> On 25.06.24 17:46, Jan Kiszka wrote:
> > On 24.06.24 22:33, 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
> >>
> >> Changes since v1[0]:
> >> - Rebased to current next branch
> >> - Reorganized patch series
> >> - Worked in feedback from Jan and Florian
> >>
> >> Richard Weinberger (14):
> >> prepare-kernel.sh: Convert to tabs
> >> prepare-kernel.sh: Add reverse mode
> >> prepare-kernel.sh: Emit architecture agnostic changes
> >> prepare-kernel.sh: Improve kernel tree check
> >> prepare-kernel.sh: Disable SC2115 warning around $linux_tree
> >> prepare-kernel.sh: Remove --filterkvers= and --filterarch=
> >> prepare-kernel.sh: Remove interactivity
> >> prepare-kernel.sh: Don't depend on bash
> >> 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 | 587 +++++++++++++++++---------------------
> >> 2 files changed, 268 insertions(+), 321 deletions(-)
> >>
> >> [0]: https://lore.kernel.org/xenomai/20240525115806.12101-1-richard@nod.at/
> >>
> >
> > Thanks, series with smaller adjustments in next now. The final diff is
> > limited to whitespaces, though.
> >
>
> Does not look good yet, at least regarding backward compatibility (we
> didn't change our CI rules, so...):
>
> https://source.denx.de/Xenomai/xenomai/-/pipelines/21335
I'm checking right now what is causing this.
Thanks,
//richard
--
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT
UID/VAT Nr: ATU 66964118 | FN: 374287y
^ permalink raw reply [flat|nested] 23+ messages in thread