prepare-kernel.sh: Add reverse mode
RFC PATCH 1/1 prepare-kernel.sh: Add reverse mode
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 the script already does for symlinks in the linux tree.
--- scripts/prepare-kernel.sh | 73 +++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 14 deletions(-)
scripts/prepare-kernel.sh +59 -14
@@ -55,7 +55,9 @@ patch_append() { if test -L "$linux_tree/$file" ; then mv "$linux_tree/$file" "$linux_tree/$file.orig" cp "$linux_tree/$file.orig" "$linux_tree/$file" - fi + else + cp "$linux_tree/$file" "$linux_tree/$file.orig" + fi chmod +w "$linux_tree/$file" cat >> "$linux_tree/$file" else
@@ -66,6 +68,16 @@ patch_append() { fi } +patch_reverse() { + file="$1" + if test "x$output_patch" = "x"; then + if test -L "$linux_tree/$file" ; then + rm "$linux_tree/$file" + fi + mv "$linux_tree/$file.orig" "$linux_tree/$file" + fi +} + patch_link() { recursive="$1" # "r" or "n" link_file="$2" # "m", "n" or some file (basename) from $target_dir
@@ -106,11 +118,15 @@ patch_link() { f=`echo $f | cut -d/ -f2-` d=`dirname $f` if test "x$output_patch" = "x"; then - mkdir -p $linux_tree/$link_dir/$d - if test x$forcelink = x1 -o \ - ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f; - then - ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f + if test x$reverse = x1; then + rm -f $linux_tree/$link_dir/$f + else + mkdir -p $linux_tree/$link_dir/$d + if test x$forcelink = x1 -o \ + ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f; + then + ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f + fi fi else if test `check_filter $link_dir/$f` = "ok"; then
@@ -119,6 +135,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,7 +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
@@ -171,6 +192,9 @@ while test $# -gt 0; do --verbose) verbose=1 ;; + --reverse) + reverse=1 + ;; --help) echo "$usage" exit 0
@@ -220,8 +244,19 @@ if test \! -r $linux_tree/Makefile; then exit 2 fi +if test x$reverse = x1; then + if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then + echo "$me: $linux_tree is not prepared with Xenomai" >&2 + exit 2 + fi +fi + # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then + if test x$reverse = x1; then + echo "$me: --reverse and --outpatch are not compatible" + exit 1 + fi temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` if [ $? -ne 0 ]; then
@@ -359,15 +394,18 @@ case $linux_VERSION.$linux_PATCHLEVEL in -e "s,@SRCARCH@,$linux_arch,g" \ $xenomai_root/scripts/Kconfig.frag | patch_append init/Kconfig + elif test x$reverse = x1; then + patch_reverse init/Kconfig fi test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0 if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then - p="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai" - (echo; echo $p) | patch_append arch/$linux_arch/Makefile - p="core-\$(CONFIG_XENOMAI) += arch/$linux_arch/xenomai/" - echo $p | patch_append arch/$linux_arch/Makefile + p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai" + p2="core-\$(CONFIG_XENOMAI) += arch/$linux_arch/xenomai/" + (echo; echo $p1; echo $p2) | patch_append arch/$linux_arch/Makefile + elif test x$reverse = x1; then + patch_reverse arch/$linux_arch/Makefile fi patch_architecture_specific="n"
@@ -375,11 +413,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 ;;
@@ -388,13 +430,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
@@ -402,14 +446,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
Quoted 5 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.
I had this here locally:
rm -rf kernel/xenomai drivers/xenomai arch/*/include/asm/xenomai arch/*/xenomai include/xenomai include/linux/xenomai include/asm-generic/xenomai 2>/dev/null rm -rf drivers/xenomai 2>/dev/null
rm -rf include/trace/events/xn_*.h include/trace/events/cobalt-*.h 2>/dev/null
rm -rf arch/*/include/dovetail 2>/dev/null
git checkout -- arch/x86/Makefile arch/arm/Makefile arch/arm64/Makefile drivers/Makefile init/Kconfig kernel/Makefile
Quoted 15 lines
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 the script already does for symlinks in the linux tree.Signed-off-by Richard Weinberger <[email protected]>--- scripts/prepare-kernel.sh | 73 +++++++++++++++++++++++++++++++-------- 1 file changed, 59 insertions(+), 14 deletions(-)scripts/prepare-kernel.sh +0
-0
scripts/prepare-kernel.sh patch_append() { · line 60
Quoted 7 lines
scripts/prepare-kernel.sh +3
-1@@ -55,7 +55,9 @@ patch_append() { if test -L "$linux_tree/$file" ; then mv "$linux_tree/$file" "$linux_tree/$file.orig" cp "$linux_tree/$file.orig" "$linux_tree/$file" - fi + else + cp "$linux_tree/$file" "$linux_tree/$file.orig" + fi
Indention is inconsistent - to the degree the existing one of tabs+spaces in the script is considered consistent.
Quoted 73 lines
scripts/prepare-kernel.sh +28
-6chmod +w "$linux_tree/$file" cat >> "$linux_tree/$file" else@@ -66,6 +68,16 @@ patch_append() { fi } +patch_reverse() { + file="$1" + if test "x$output_patch" = "x"; then + if test -L "$linux_tree/$file" ; then + rm "$linux_tree/$file" + fi + mv "$linux_tree/$file.orig" "$linux_tree/$file" + fi +} + patch_link() { recursive="$1" # "r" or "n" link_file="$2" # "m", "n" or some file (basename) from $target_dir@@ -106,11 +118,15 @@ patch_link() { f=`echo $f | cut -d/ -f2-` d=`dirname $f` if test "x$output_patch" = "x"; then - mkdir -p $linux_tree/$link_dir/$d - if test x$forcelink = x1 -o \ - ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f; - then - ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f + if test x$reverse = x1; then + rm -f $linux_tree/$link_dir/$f + else + mkdir -p $linux_tree/$link_dir/$d + if test x$forcelink = x1 -o \ + ! $xenomai_root/$target_dir/$f -ef $linux_tree/$link_dir/$f; + then + ln -sf $xenomai_root/$target_dir/$f $linux_tree/$link_dir/$f + fi fi else if test `check_filter $link_dir/$f` = "ok"; then@@ -119,6 +135,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,7 +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@@ -171,6 +192,9 @@ while test $# -gt 0; do --verbose) verbose=1 ;; + --reverse) + reverse=1 + ;; --help) echo "$usage" exit 0
scripts/prepare-kernel.sh if test \! -r $linux_tree/Makefile; then · line 248
Quoted 5 lines
scripts/prepare-kernel.sh +2
-0@@ -220,8 +244,19 @@ if test \! -r $linux_tree/Makefile; then exit 2 fi +if test x$reverse = x1; then + if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then
Won't linux_arch soon be a list of archs?
Quoted 78 lines
scripts/prepare-kernel.sh +24
-6+ echo "$me: $linux_tree is not prepared with Xenomai" >&2 + exit 2 + fi +fi + # Create an empty output patch file, and initialize the temporary tree. if test "x$output_patch" != "x"; then + if test x$reverse = x1; then + echo "$me: --reverse and --outpatch are not compatible" + exit 1 + fi temp_tree=`mktemp -d prepare-kernel-XXX --tmpdir` if [ $? -ne 0 ]; then@@ -359,15 +394,18 @@ case $linux_VERSION.$linux_PATCHLEVEL in -e "s,@SRCARCH@,$linux_arch,g" \ $xenomai_root/scripts/Kconfig.frag | patch_append init/Kconfig + elif test x$reverse = x1; then + patch_reverse init/Kconfig fi test "x$CONFIG_XENO_REVISION_LEVEL" = "x" && CONFIG_XENO_REVISION_LEVEL=0 if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then - p="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai" - (echo; echo $p) | patch_append arch/$linux_arch/Makefile - p="core-\$(CONFIG_XENOMAI) += arch/$linux_arch/xenomai/" - echo $p | patch_append arch/$linux_arch/Makefile + p1="KBUILD_CFLAGS += -I\$(srctree)/arch/\$(SRCARCH)/xenomai/include -I\$(srctree)/include/xenomai" + p2="core-\$(CONFIG_XENOMAI) += arch/$linux_arch/xenomai/" + (echo; echo $p1; echo $p2) | patch_append arch/$linux_arch/Makefile + elif test x$reverse = x1; then + patch_reverse arch/$linux_arch/Makefile fi patch_architecture_specific="n"@@ -375,11 +413,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 ;;@@ -388,13 +430,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@@ -402,14 +446,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 460
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
I like this as it obsoletes my local script :). Just minor notes, and please make sure it goes will with the any-arch patching extension.
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
----- Ursprüngliche Mail -----
Quoted 3 lines
Von: "Jan Kiszka" <[email protected]> Indention is inconsistent - to the degree the existing one of tabs+spaces in the script is considered consistent.
Yeah, the whole script is a mess wrt. indention.
I have prepared a patch which converts the whole thing to tabs.
Quoted 4 lines
scripts/prepare-kernel.sh if test \! -r $linux_tree/Makefile; then · line 248
Quoted 2 lines
scripts/prepare-kernel.sh +2
-0+if test x$reverse = x1; then + if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; thenWon't
linux_archsoon be a list of archs?
Yes.
In my WIP branch I have glued everything together.
https://gitlab.com/Xenomai/xenomai-hacker-space/-/commits/rw/prepare_rework/?ref_type=heads
Quoted 2 lines
I like this as it obsoletes my local script :). Just minor notes, and please make sure it goes will with the any-arch patching extension.
Sure. Beside of other fixes I've managed also to get rid of /bin/bash and changed the script to POSIX shell.
shellcheck is now happy up to warning level.
Info level still gives tons of suggestions I have to review.
Beside of that, what's do you think about the --filterkvers, --filterarch, --default and --forcelink switches?
IMHO we can drop them. I don't see much use in them except of adding complexity.
Same for --dovetail, since no release patches are made anymore.
Also, do we really need interactivity?
Currently the script can ask the user for the paths to Linux and the dovetail patch. IMHO everything should be controlled by command line switches, no script chitchat needed.
Thanks,
//richard
Quoted 10 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 3 lines
Von: "Jan Kiszka" <[email protected]> Indention is inconsistent - to the degree the existing one of tabs+spaces in the script is considered consistent.
Yeah, the whole script is a mess wrt. indention.
I have prepared a patch which converts the whole thing to tabs.Quoted 3 lines
Quoted 2 lines
scripts/prepare-kernel.sh +2
-0+if test x$reverse = x1; then + if ! grep -q CONFIG_XENOMAI $linux_tree/arch/$linux_arch/Makefile; then
Quoted 7 lines
Quoted 1 line
Won't
linux_archsoon be a list of archs?Yes.
In my WIP branch I have glued everything together.
https://gitlab.com/Xenomai/xenomai-hacker-space/-/commits/rw/prepare_rework/?ref_type=heads
Just submit both in a single series next time so that it's clear for me which should be merged first.
Quoted 11 lines
Quoted 2 lines
I like this as it obsoletes my local script :). Just minor notes, and please make sure it goes will with the any-arch patching extension.
Sure. Beside of other fixes I've managed also to get rid of
/bin/bashand changed the script to POSIX shell.
shellcheck is now happy up to warning level.
Info level still gives tons of suggestions I have to review.Beside of that, what's do you think about the --filterkvers, --filterarch, --default and --forcelink switches?
IMHO we can drop them. I don't see much use in them except of adding complexity.
--filterkvers and --filterarch date back to 2006 and this commit:
https://source.denx.de/Xenomai/xenomai/-/commit/b1ef45e37c06a2e62d57cd139b410e02bc486898
Unfortunately, reasoning was not recorded, and we can't ask Gilles anymore. I tend to agree that this is not needed in practice.
--default seems to have become obsolete for the linux path with
https://source.denx.de/Xenomai/xenomai/-/commit/0886b75af74654682794102d080dfd4a16da1244
- I don't see that linux_tree could become empty anymore (unless you do "--linux= --default", but that would be strange). Adding your new default value for --arch (all), that switch could be dropped.
What would be your suggestion for --forcelink? Just drop it and skip over existing links or make it the new default? Enforcing the update is probably not as safe as using the new --reverse, followed by clean run of the script. This is at least what I would do.
Quoted 2 lines
Same for --dovetail, since no release patches are made anymore.
That switch is for integrating Xenomai + separate patch on top of a vanilla kernel. I would not drop that feature yet, even though we no longer distribute patches as releases.
Quoted 4 lines
Also, do we really need interactivity?
Currently the script can ask the user for the paths to Linux and the dovetail patch. IMHO everything should be controlled by command line switches, no script chitchat needed.
Where would interactivity still remain after the above cleanups?
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
----- Ursprüngliche Mail -----
Quoted 7 lines
Von: "Jan Kiszka" <[email protected]>
Quoted 3 lines
In my WIP branch I have glued everything together.
https://gitlab.com/Xenomai/xenomai-hacker-space/-/commits/rw/prepare_rework/?ref_type=headsJust submit both in a single series next time so that it's clear for me which should be merged first.
I have implement both features independently.
But now everything resides on the same branch, I'll send it out as patch series.
Quoted 13 lines
Quoted 8 lines
Quoted 2 lines
I like this as it obsoletes my local script :). Just minor notes, and please make sure it goes will with the any-arch patching extension.
Sure. Beside of other fixes I've managed also to get rid of
/bin/bashand changed the script to POSIX shell.
shellcheck is now happy up to warning level.
Info level still gives tons of suggestions I have to review.Quoted 4 lines
Beside of that, what's do you think about the --filterkvers, --filterarch, --default and --forcelink
switches?
IMHO we can drop them. I don't see much use in them except of adding complexity.
Quoted 6 lines
--filterkvers and --filterarch date back to 2006 and this commit:
https://source.denx.de/Xenomai/xenomai/-/commit/b1ef45e37c06a2e62d57cd139b410e02bc486898
Unfortunately, reasoning was not recorded, and we can't ask Gilles anymore. I tend to agree that this is not needed in practice.
Ok!
Quoted 5 lines
--default seems to have become obsolete for the linux path with
https://source.denx.de/Xenomai/xenomai/-/commit/0886b75af74654682794102d080dfd4a16da1244
- I don't see thatlinux_treecould become empty anymore (unless you do "--linux= --default", but that would be strange). Adding your new default value for --arch (all), that switch could be dropped.
Agreed.
Quoted 4 lines
What would be your suggestion for --forcelink? Just drop it and skip over existing links or make it the new default? Enforcing the update is probably not as safe as using the new --reverse, followed by clean run of the script. This is at least what I would do.
TBH, I have a hard time to understand the purpose of --forcelink
It is used in:
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 So, a symbolic link is forcefully created if either --forcelink is set or source and target files are not the same. "not the same" includes also that either of both is not present.
To put it the other way around, "ln -sf" is not called if --forcelink is not set and the link is already installed.
What's the use case?
Quoted 6 lines
Quoted 2 lines
Same for --dovetail, since no release patches are made anymore.
That switch is for integrating Xenomai + separate patch on top of a vanilla kernel. I would not drop that feature yet, even though we no longer distribute patches as releases.
Okay. Let's keep it.
Quoted 8 lines
Quoted 6 lines
Also, do we really need interactivity?
Currently the script can ask the user for the paths to Linux and the dovetail patch.
IMHO everything should be controlled by command line switches, no script chitchat needed.Where would interactivity still remain after the above cleanups?
If --linux points to a vanilla kernel, but --dovetail is not set, it will ask for the path to the patch.
Thanks,
//richard
Quoted 56 lines · Richard Weinberger
----- Ursprüngliche Mail -----
Quoted 7 lines
Von: "Jan Kiszka" <[email protected]>
Quoted 3 lines
In my WIP branch I have glued everything together.
https://gitlab.com/Xenomai/xenomai-hacker-space/-/commits/rw/prepare_rework/?ref_type=headsJust submit both in a single series next time so that it's clear for me which should be merged first.
I have implement both features independently.
But now everything resides on the same branch, I'll send it out as patch series.Quoted 13 lines
Quoted 8 lines
Quoted 2 lines
I like this as it obsoletes my local script :). Just minor notes, and please make sure it goes will with the any-arch patching extension.
Sure. Beside of other fixes I've managed also to get rid of
/bin/bashand changed the script to POSIX shell.
shellcheck is now happy up to warning level.
Info level still gives tons of suggestions I have to review.Quoted 4 lines
Beside of that, what's do you think about the --filterkvers, --filterarch, --default and --forcelink
switches?
IMHO we can drop them. I don't see much use in them except of adding complexity.Quoted 6 lines
--filterkvers and --filterarch date back to 2006 and this commit:
https://source.denx.de/Xenomai/xenomai/-/commit/b1ef45e37c06a2e62d57cd139b410e02bc486898
Unfortunately, reasoning was not recorded, and we can't ask Gilles anymore. I tend to agree that this is not needed in practice.
Ok!
Quoted 5 lines
--default seems to have become obsolete for the linux path with
https://source.denx.de/Xenomai/xenomai/-/commit/0886b75af74654682794102d080dfd4a16da1244
- I don't see thatlinux_treecould become empty anymore (unless you do "--linux= --default", but that would be strange). Adding your new default value for --arch (all), that switch could be dropped.Agreed.
Quoted 4 lines
What would be your suggestion for --forcelink? Just drop it and skip over existing links or make it the new default? Enforcing the update is probably not as safe as using the new --reverse, followed by clean run of the script. This is at least what I would do.
TBH, I have a hard time to understand the purpose of --forcelink
It is used in:
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
Quoted 9 lines
So, a symbolic link is forcefully created if either --forcelink is set or source and target files are not the same. "not the same" includes also that either of both is not present.
To put it the other way around, "ln -sf" is not called if --forcelink is not set and the link is already installed.
What's the use case?
The only difference of enforced linking might then be time updates in the metadata. But don't ask me about the pros and cons...
Quoted 16 lines
Quoted 6 lines
Quoted 2 lines
Same for --dovetail, since no release patches are made anymore.
That switch is for integrating Xenomai + separate patch on top of a vanilla kernel. I would not drop that feature yet, even though we no longer distribute patches as releases.
Okay. Let's keep it.
Quoted 7 lines
Quoted 6 lines
Also, do we really need interactivity?
Currently the script can ask the user for the paths to Linux and the dovetail patch.
IMHO everything should be controlled by command line switches, no script chitchat needed.
Quoted 4 lines
Quoted 1 line
Where would interactivity still remain after the above cleanups?
If --linux points to a vanilla kernel, but --dovetail is not set, it will ask for the path to the patch.
I agree that this should rather bail out with an error then.
Jan
Signature · 2 lines
Siemens AG, Technology Linux Expert Center
----- Ursprüngliche Mail -----
Quoted 3 lines
Von: "Jan Kiszka" <[email protected]>
The only difference of enforced linking might then be time updates in the metadata. But don't ask me about the pros and cons...
In 2006, Gilles changed the test from "-h" to "-ef" via7098866e0 ("Fix prepare-kernel.sh when it is run in order to change the xenomai directory to which the kernel is linked").
So, the script no longer checked just for the directory entry being a symlink, it checked also whether the symlink points to the right location.
The use case was, you have an already prepared kernel and move/update the Xenomai folder. As as consequence the symlinks are still present but point to the wrong location, but prepare-kernel.sh didn't update them.
To avoid this state, --forcelink should have been used.
But looks like Gilles didn't like that and made --forcelink more or less obsolete with his change.
Since make (and every other sane build system) follows symlinks, I don't see a reason to keep --forcelink.
Thanks,
//richard