From: Richard Weinberger <richard@sigma-star.at>
To: Richard Weinberger <richard@nod.at>,
xenomai@lists.linux.dev, upstream@sigma-star.at
Cc: upstream+xenomai@sigma-star.at, Jan Kiszka <jan.kiszka@siemens.com>
Subject: Re: [PATCH 02/14] prepare-kernel.sh: Add reverse mode
Date: Tue, 25 Jun 2024 18:44:09 +0200 [thread overview]
Message-ID: <13437395.lhuNh5TYOU@somecomputer> (raw)
In-Reply-To: <d96e1040-357a-40f2-b651-659c715af07f@siemens.com>
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
next prev parent reply other threads:[~2024-06-25 16:44 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
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-25 15:28 ` Jan Kiszka
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
2024-06-25 16:44 ` Richard Weinberger [this message]
2024-06-24 20:33 ` [PATCH 03/14] prepare-kernel.sh: Emit architecture agnostic changes Richard Weinberger
2024-06-24 20:33 ` [PATCH 04/14] prepare-kernel.sh: Improve kernel tree check Richard Weinberger
2024-06-24 20:33 ` [PATCH 05/14] prepare-kernel.sh: Disable SC2115 warning around $linux_tree Richard Weinberger
2024-06-24 20:33 ` [PATCH 06/14] prepare-kernel.sh: Remove --filterkvers= and --filterarch= Richard Weinberger
2024-06-24 20:33 ` [PATCH 07/14] prepare-kernel.sh: Remove interactivity Richard Weinberger
2024-06-24 20:33 ` [PATCH 08/14] prepare-kernel.sh: Don't depend on bash Richard Weinberger
2024-06-24 20:33 ` [PATCH 09/14] prepare-kernel.sh: Remove --forcelink Richard Weinberger
2024-06-24 20:33 ` [PATCH 10/14] prepare-kernel.sh: Fix dovetail check Richard Weinberger
2024-06-24 20:33 ` [PATCH 11/14] prepare-kernel.sh: Define command line variables Richard Weinberger
2024-06-24 20:33 ` [PATCH 12/14] prepare-kernel.sh: Remove dead code Richard Weinberger
2024-06-24 20:33 ` [PATCH 13/14] prepare-kernel.sh: Don't allow uninitialized variables 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
2024-06-25 15:58 ` Jan Kiszka
2024-06-25 16:10 ` Richard Weinberger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=13437395.lhuNh5TYOU@somecomputer \
--to=richard@sigma-star.at \
--cc=jan.kiszka@siemens.com \
--cc=richard@nod.at \
--cc=upstream+xenomai@sigma-star.at \
--cc=upstream@sigma-star.at \
--cc=xenomai@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.