Assorted Cleanups For prepare-kernel.sh
v2 cover Assorted Cleanups For prepare-kernel.sh
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/[email protected]/
Signature · 1 line
2.35.3
PATCH v2 1/14 prepare-kernel.sh: Convert to tabs
Currently the script used a mix of spaces of various lengths and tabs. Let's use tabs everywhere.
--- scripts/prepare-kernel.sh | 510 +++++++++++++++++++------------------- 1 file changed, 253 insertions(+), 257 deletions(-)
scripts/prepare-kernel.sh +253 -257
@@ -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
Signature · 1 line
2.35.3
Re: [PATCH 01/14] prepare-kernel.sh: Convert to tabs
Quoted 559 lines · 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 <[email protected]>--- scripts/prepare-kernel.sh | 510 +++++++++++++++++++------------------- 1 file changed, 253 insertions(+), 257 deletions(-)scripts/prepare-kernel.sh +223
-230@@ -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" \
scripts/prepare-kernel.sh eval linux_`grep '^VERSION =' $linux_tree/Makefile | sed -e 's, ,,g'` · line 362
Quoted 10 lines
scripts/prepare-kernel.sh +7
-3- $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
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
PATCH v2 2/14 prepare-kernel.sh: Add reverse mode
In reply to Richard WeinbergerThere 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.
--- scripts/prepare-kernel.sh | 71 +++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 14 deletions(-)
scripts/prepare-kernel.sh +57 -14
@@ -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
Signature · 1 line
2.35.3
Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
Quoted 181 lines · 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 bypatch_append(), keep a .orig file link as the script already does for symlinks in the linux tree.Signed-off-by Richard Weinberger <[email protected]>--- scripts/prepare-kernel.sh | 71 +++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 14 deletions(-)scripts/prepare-kernel.sh +55
-13@@ -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
scripts/prepare-kernel.sh patch_link r n kernel/cobalt/include/asm-generic/xenomai include/asm-generic/xen · line 457
Quoted 10 lines
scripts/prepare-kernel.sh +2
-1patch_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
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
Am Dienstag, 25. Juni 2024, 17:44:47 CEST schrieb 'Jan Kiszka' via upstream:
Quoted 5 lines
Quoted 2 lines
if test "x$output_patch" != "x"; then
if test x$verbose = x1; thenThe 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
Signature · 2 lines
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr: ATU 66964118 | FN: 374287y
Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
In reply to Richard WeinbergerQuoted 181 lines · 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 bypatch_append(), keep a .orig file link as the script already does for symlinks in the linux tree.Signed-off-by Richard Weinberger <[email protected]>--- scripts/prepare-kernel.sh | 71 +++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 14 deletions(-)scripts/prepare-kernel.sh +55
-13@@ -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
scripts/prepare-kernel.sh patch_link r n kernel/cobalt/include/asm-generic/xenomai include/asm-generic/xen · line 457
Quoted 10 lines
scripts/prepare-kernel.sh +2
-1patch_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
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
Am Dienstag, 25. Juni 2024, 18:20:45 CEST schrieb 'Jan Kiszka' via upstream:
Quoted 190 lines · Richard Weinberger
Quoted 189 lines
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 bypatch_append(), keep a .orig file link as the script already does for symlinks in the linux tree.Signed-off-by Richard Weinberger <[email protected]>--- scripts/prepare-kernel.sh | 71 +++++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 14 deletions(-)scripts/prepare-kernel.sh +57
-14@@ -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
Quoted 4 lines
scripts/prepare-kernel.sh patch_link r n kernel/cobalt/include/asm-generic/xenomai include/asm-generic/xen · line 457
Quoted 2 lines
scripts/prepare-kernel.sh +0
-0if test "x$output_patch" != "x"; then if test x$verbose = x1; thenThis 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
Signature · 2 lines
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr: ATU 66964118 | FN: 374287y
PATCH v2 3/14 prepare-kernel.sh: Emit architecture agnostic changes
In reply to Richard WeinbergerIf --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.
--- scripts/Kconfig.frag | 2 +- scripts/prepare-kernel.sh | 77 +++++++++++++++++---------------------- 2 files changed, 34 insertions(+), 45 deletions(-)
scripts/Kconfig.frag +1 -1
@@ -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
scripts/prepare-kernel.sh +33 -44
125 lines not on this page · raw message
Signature · 1 line
2.35.3
PATCH v2 4/14 prepare-kernel.sh: Improve kernel tree check
In reply to Richard WeinbergerCurrently 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.
--- scripts/prepare-kernel.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/prepare-kernel.sh +1 -1
@@ -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
Signature · 1 line
2.35.3
PATCH v2 5/14 prepare-kernel.sh: Disable SC2115 warning around $linux_tree
In reply to Richard WeinbergerThe script makes sure that $linux_tree is valid, it cannot be empty.
--- scripts/prepare-kernel.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
scripts/prepare-kernel.sh +2 -1
@@ -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 )
Signature · 1 line
2.35.3
PATCH v2 6/14 prepare-kernel.sh: Remove --filterkvers= and --filterarch=
In reply to Richard WeinbergerThese days (not) applying kernel version or architecture specific changes is no longer needed for development.
Let's simplify the code and remove this feature.
--- scripts/prepare-kernel.sh | 65 ++++++--------------------------------- 1 file changed, 9 insertions(+), 56 deletions(-)
scripts/prepare-kernel.sh +9 -56
@@ -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
Signature · 1 line
2.35.3
PATCH v2 7/14 prepare-kernel.sh: Remove interactivity
In reply to Richard WeinbergerLet'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.
--- scripts/prepare-kernel.sh | 36 +++++++++--------------------------- 1 file changed, 9 insertions(+), 27 deletions(-)
scripts/prepare-kernel.sh +9 -27
@@ -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`
Signature · 1 line
2.35.3
PATCH v2 8/14 prepare-kernel.sh: Don't depend on bash
In reply to Richard Weinbergertype -p is not POSIX, so use realpath(1), I think it is safe to assume this tool.
--- scripts/prepare-kernel.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
scripts/prepare-kernel.sh +2 -2
@@ -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`
Signature · 1 line
2.35.3
PATCH v2 9/14 prepare-kernel.sh: Remove --forcelink
In reply to Richard WeinbergerTo 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.
--- scripts/prepare-kernel.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-)
scripts/prepare-kernel.sh +3 -5
@@ -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
Signature · 1 line
2.35.3
PATCH v2 10/14 prepare-kernel.sh: Fix dovetail check
In reply to 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.
--- scripts/prepare-kernel.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
scripts/prepare-kernel.sh +2 -4
@@ -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
Signature · 1 line
2.35.3
PATCH v2 11/14 prepare-kernel.sh: Define command line variables
In reply to Richard WeinbergerTo use "set -u" later, define all variables that can be set via the command line.
--- scripts/prepare-kernel.sh | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
scripts/prepare-kernel.sh +8 -3
@@ -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=*)
Signature · 1 line
2.35.3
PATCH v2 12/14 prepare-kernel.sh: Remove dead code
In reply to Richard WeinbergerCONFIG_XENO_REVISION_LEVEL was added viab370b7d54 ("build: introduce core API revision level in userland"), to my best knowledge it was dead code since ever.
Let's remove it.
--- scripts/prepare-kernel.sh | 2 -- 1 file changed, 2 deletions(-)
scripts/prepare-kernel.sh +0 -2
@@ -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"
Signature · 1 line
2.35.3
PATCH v2 13/14 prepare-kernel.sh: Don't allow uninitialized variables
In reply to Richard WeinbergerUse "set -u" to detect subtle breakage in future.
--- scripts/prepare-kernel.sh | 1 + 1 file changed, 1 insertion(+)
scripts/prepare-kernel.sh +1 -0
@@ -1,5 +1,6 @@ #!/bin/sh set -e +set -u unset CDPATH
Signature · 1 line
2.35.3
PATCH v2 14/14 prepare-kernel.sh: Remove kernel version check
In reply to Richard WeinbergerThe 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.
--- scripts/prepare-kernel.sh | 95 ++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 56 deletions(-)
scripts/prepare-kernel.sh +39 -56
@@ -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
Signature · 1 line
2.35.3
Quoted 31 lines · Richard Weinberger
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/bashto/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 fixesChanges since v1[0]:
- Rebased to current next branch
- Reorganized patch series
- Worked in feedback from Jan and FlorianRichard Weinberger (14):
prepare-kernel.sh: Convert to tabsprepare-kernel.sh: Add reverse modeprepare-kernel.sh: Emit architecture agnostic changesprepare-kernel.sh: Improve kernel tree checkprepare-kernel.sh: Disable SC2115 warning around $linux_treeprepare-kernel.sh: Remove --filterkvers= and --filterarch=prepare-kernel.sh: Remove interactivityprepare-kernel.sh: Don't depend on bashprepare-kernel.sh: Remove --forcelinkprepare-kernel.sh: Fix dovetail checkprepare-kernel.sh: Define command line variablesprepare-kernel.sh: Remove dead codeprepare-kernel.sh: Don't allow uninitialized variablesprepare-kernel.sh: Remove kernel version check
Quoted 6 lines
scripts/Kconfig.frag | 2 +- scripts/prepare-kernel.sh | 587 +++++++++++++++++--------------------- 2 files changed, 268 insertions(+), 321 deletions(-)
Thanks, series with smaller adjustments in next now. The final diff is limited to whitespaces, though.
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
Quoted 36 lines · Jan Kiszka
Quoted 35 lines · Richard Weinberger
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/bashto/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 fixesChanges since v1[0]:
- Rebased to current next branch
- Reorganized patch series
- Worked in feedback from Jan and FlorianRichard Weinberger (14):
prepare-kernel.sh: Convert to tabsprepare-kernel.sh: Add reverse modeprepare-kernel.sh: Emit architecture agnostic changesprepare-kernel.sh: Improve kernel tree checkprepare-kernel.sh: Disable SC2115 warning around $linux_treeprepare-kernel.sh: Remove --filterkvers= and --filterarch=prepare-kernel.sh: Remove interactivityprepare-kernel.sh: Don't depend on bashprepare-kernel.sh: Remove --forcelinkprepare-kernel.sh: Fix dovetail checkprepare-kernel.sh: Define command line variablesprepare-kernel.sh: Remove dead codeprepare-kernel.sh: Don't allow uninitialized variablesprepare-kernel.sh: Remove kernel version checkscripts/Kconfig.frag | 2 +- scripts/prepare-kernel.sh | 587 +++++++++++++++++--------------------- 2 files changed, 268 insertions(+), 321 deletions(-)
Quoted 6 lines
Quoted 2 lines
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
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
Am Dienstag, 25. Juni 2024, 17:58:01 CEST schrieb 'Jan Kiszka' via upstream:
Quoted 40 lines · Jan Kiszka
Quoted 39 lines · Richard Weinberger
Quoted 37 lines
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/bashto/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 fixesChanges since v1[0]:
- Rebased to current next branch
- Reorganized patch series
- Worked in feedback from Jan and FlorianRichard Weinberger (14):
prepare-kernel.sh: Convert to tabsprepare-kernel.sh: Add reverse modeprepare-kernel.sh: Emit architecture agnostic changesprepare-kernel.sh: Improve kernel tree checkprepare-kernel.sh: Disable SC2115 warning around $linux_treeprepare-kernel.sh: Remove --filterkvers= and --filterarch=prepare-kernel.sh: Remove interactivityprepare-kernel.sh: Don't depend on bashprepare-kernel.sh: Remove --forcelinkprepare-kernel.sh: Fix dovetail checkprepare-kernel.sh: Define command line variablesprepare-kernel.sh: Remove dead codeprepare-kernel.sh: Don't allow uninitialized variablesprepare-kernel.sh: Remove kernel version checkscripts/Kconfig.frag | 2 +- scripts/prepare-kernel.sh | 587 +++++++++++++++++--------------------- 2 files changed, 268 insertions(+), 321 deletions(-)
Quoted 8 lines
Quoted 3 lines
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...):
I'm checking right now what is causing this.
Thanks,
//richard
Signature · 2 lines
sigma star gmbh | Eduard-Bodem-Gasse 6, 6020 Innsbruck, AUT UID/VAT Nr: ATU 66964118 | FN: 374287y