Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kernel Bump v2 #14913

Merged
merged 11 commits into from Apr 12, 2024
Merged

Kernel Bump v2 #14913

merged 11 commits into from Apr 12, 2024

Conversation

oliv3r
Copy link
Contributor

@oliv3r oliv3r commented Mar 17, 2024

A bunch of fixes and improvements, also based on discussions in the first version, found in #14713.

  • scripts/kernel_bump: Delete merge commit
  • scripts/kernel_bump: Allow bumping sub-targets
  • scripts/kernel_bump: Use the git index to find the needed config files
  • scripts/kernel_bump: Use git to obtain the list of files
  • scripts/kernel_bump: Allow for migrating only configuration files
  • scripts/kernel_bump: Do no run on dirty repositories
  • scripts/kernel_bump: Drop unused function
  • scripts/kernel_bump: Avoid potential copyright claim

@github-actions github-actions bot added the build/scripts/tools pull request/issues for build, scripts and tools related changes label Mar 17, 2024
@rany2
Copy link
Contributor

rany2 commented Mar 17, 2024

@oliv3r Is there a reason why you aren't doing something like git ls-files 'target/*/config-6.1'?

@namiltd
Copy link
Contributor

namiltd commented Mar 17, 2024

Maybe add a change from patches-6.1 to patches-6.6 in this version?

find "${_target_dir}" -iname "patches-${source_version}" |
	sort -u |
	while read -r _patches; do
		_path="${_patches%%"/patches-${source_version}"}"
		git mv "${_patches}" "${_path}/patches-${target_version}"
	done

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 17, 2024 via email

@oliv3r oliv3r force-pushed the kernel_bump branch 2 times, most recently from febfcdc to 81e3773 Compare March 18, 2024 13:15
@oliv3r oliv3r changed the title Draft: Kernel Bump v2 Kernel Bump v2 Mar 18, 2024
@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 18, 2024

@rany2 so now it uses git ls-tree and git ls-files :D

@namiltd what made you say that, as this was the purpose of this script. Anyway, v2 should now do what you expected?
Also, I tested x86 and seemed to work fine! I used ./scripts/kernel_bump.sh -p x86 -s 6.1 -t 6.6 to see. I've also tested with -r generic which works, but then the root config file doesn't get migrated (as expected), so x86 might be a bit 'special' in that case. Though in the future, if updating only specific subtargets turns out to be a 'thing', this can be refined.

@robimarko so hopefully v2 improves, adds new features and makes things better!

@ehem this should address any concerns you have raised before! Thanks for your review, and hope to see more review here :)

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 18, 2024

One important note to make, I've added a 'hack' to drop the merge commit, just rebase the last commit. So now we have just our two clean commits. However, I don't know if there's any negative impact. It seems to work fine! So now we have just the two commits :)

Copy link
Contributor

@rany2 rany2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, great job!

@namiltd
Copy link
Contributor

namiltd commented Mar 18, 2024

change
while IFS=',' read -r
to
while read -d, -r

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 18, 2024

change while IFS=',' read -r to while read -d, -r

What would that change, other then causing:

^-- SC3045 (warning): In POSIX sh, read -d is undefined.

@robimarko
Copy link
Contributor

@hauke Your opinion would really help here

@ehem
Copy link
Contributor

ehem commented Mar 20, 2024

I see issues to point to in a review. I was rather hoping someone would at least test #14907 before I submit a review of #14913. Someone who cannot review is entirely capable of testing.

@ehem
Copy link
Contributor

ehem commented Mar 21, 2024

I am unsure I've quite replicated kernel_bump.sh's functionality exactly, but I am fairly confident I've got something which is mostly compatible based on invoking kernel_upgrade.pl from #14907.

@namiltd
Copy link
Contributor

namiltd commented Mar 21, 2024

I have three comments:
-The script does not work (err: Cannot find target linux directory.) if the name of the folder in which the branch is equal to the name of the platform
-On Windows systems (TartoiseGIT - GIT Bash here), finding the patches-version folder does not work. The script only copies .config files.
-When we run the script without parameters, the following is displayed: "err: Source () and target () versions need to be defined. In my opinion, the same text as with the -h option should be displayed here.

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 21, 2024

I have three comments: -The script does not work (err: Cannot find target linux directory.) if the name of the folder in which the branch is equal to the name of the platform

Let me re-validate this. After the git ls-files change I checked that it would work (produce output) from the target directory, but as I was checking multiple platforms, I actually only tested from the root. Valuable feedback, thank you.

However I can not replicate this. Might be a windows vs. linux thing. Not sure how 'supported' OpenWRT on windows is, but this should just work (tm). as it's just regular shell logic.

-On Windows systems (TartoiseGIT - GIT Bash here), finding the patches-version folder does not work. The script only copies .config files.

I don't have windows, so cannot validate this. I'd need your help to debug this. Can you set the environment variable export DEBUG_TRACE_SH=all and run the script again post the problematic output?

As I cannot reproduce it, I need more information to figure out what is happening here.

I've added a change, where we can now run the script from anywhere, by using the local script location. Which does require the script to always be, and always run, from the scripts subdir. Not a problem, but something to be aware of.

-When we run the script without parameters, the following is displayed: "err: Source () and target () versions need to be defined. In my opinion, the same text as with the -h option should be displayed here.

Since you are the second one to say this, I will add this (and improve the output a little). Since the idea was that if ONE parameter was missing, you get 'err: Source (v5.15) and target () versions need to be defined. e.g. it would be obvious. I see now it is not as obvious, and will improve the message and print the usage.

It will now print, for example:

./scripts/kernel_bump.sh -s v5.15
err: Source (5.15) and target (missing target version) versions need to be defined.

in addition to the 'usage'.

@oliv3r oliv3r force-pushed the kernel_bump branch 2 times, most recently from 0ca1726 to 4512f68 Compare March 21, 2024 09:47
@robimarko
Copy link
Contributor

robimarko commented Mar 21, 2024

@oliv3r The script is creating config--v6.6 and like folders instead of config-6.6

robimarko@fedora:~/Building/AX3600/qualcommax-6.6$ ls target/linux/qualcommax/
config-6.1     config--v6.6   files/         image/         ipq60xx/       ipq807x/       Makefile       patches-6.1/   patches--v6.6/

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 21, 2024

@oliv3r The script is creating config--v6.6 and like folders instead of config-6.6

robimarko@fedora:~/Building/AX3600/qualcommax-6.6$ ls target/linux/qualcommax/
config-6.1     config--v6.6   files/         image/         ipq60xx/       ipq807x/       Makefile       patches-6.1/   patches--v6.6/

Curious:

scripts/kernel_bump.sh -p at91 -s v5.15 -t 6.6
ls target/linux/at91/*
target/linux/at91/Makefile  target/linux/at91/modules.mk

target/linux/at91/base-files:
etc

target/linux/at91/files:
arch

target/linux/at91/image:
Config.in  dfboot  gen_at91_sdcard_img.sh  Makefile  sam9x.mk  sama5.mk  sama7.mk  uboot-env.txt

target/linux/at91/patches-5.15:
...

target/linux/at91/patches-6.6:
...

target/linux/at91/sam9x:
config-5.15  config-6.6  target.mk

target/linux/at91/sama5:
config-5.15  config-6.6  target.mk

target/linux/at91/sama7:
config-5.15  config-6.6  target.mk

and

scripts/kernel_bump.sh -p qualcommax -s v6.1 -t 6.6
ls target/linux/qualcommax/*
target/linux/qualcommax/config-6.1  target/linux/qualcommax/config-6.6  target/linux/qualcommax/Makefile

target/linux/qualcommax/files:
arch  include

target/linux/qualcommax/image:
ipq60xx.mk  ipq807x.mk  Makefile

target/linux/qualcommax/ipq60xx:
base-files  config-default  target.mk

target/linux/qualcommax/ipq807x:
base-files  config-default  target.mk

target/linux/qualcommax/patches-6.1:
...

target/linux/qualcommax/patches-6.6:
...

@namiltd
Copy link
Contributor

namiltd commented Mar 21, 2024

"-t 6.6" should be "-t v6.6"

But in fact the script should ignore this "v" because it is an unnecessary syntax complication.

@robimarko
Copy link
Contributor

"-t 6.6" should be "-t v6.6"

But in fact the script should ignore this "v" because it is an unnecessary syntax complication.

I agree, the v is just complication

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 21, 2024 via email

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 21, 2024 via email

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 22, 2024

@namiltd curious how you invoked the program however, and @robimarko that caused this weird double dash config--v6.6 to appear. A debug lug or command invocation would be very useful.

@robimarko
Copy link
Contributor

@oliv3r Well, fun fact is that today I cannot reproduce the dash bein added, it just worked as its supposed to :)

@namiltd
Copy link
Contributor

namiltd commented Mar 22, 2024

@oliv3r I downloaded the branch oliv3r:kernel_bump

@ehem
Copy link
Contributor

ehem commented Mar 22, 2024

Hmm, guess I should mention. The first of the patches for turning kernel_bump.sh into a wrapper for kernel_upgrade.pl seems suspiciously like a design suggestion. I created it strictly for the purpose of doing the wrapper, but does seem like it might be better for the script anyway.

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 23, 2024 via email

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 23, 2024 via email

@ehem
Copy link
Contributor

ehem commented Mar 23, 2024

Your script is doing most processing of variables (ensuring they're set, adding/removing prefixes, etc) in your main() function. Yet $platform_name is left mostly unprocessed by main() and instead adjusted inside bump_kernel().

For the conversion to wrapper I had to fix this. I suspect you might want to consider grabbing the first commit.

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 23, 2024

Your script is doing most processing of variables (ensuring they're set, adding/removing prefixes, etc) in your main() function. Yet $platform_name is left mostly unprocessed by main() and instead adjusted inside bump_kernel().

For the conversion to wrapper I had to fix this. I suspect you might want to consider grabbing the first commit.

The main function does just some argument setup, it's part of the arguments. You could argue it should be part of init maybe, but not main.

sort -u); do
if [ ! -s "${_path}" ] || \
[ "${_path}" = "${_path%%"-${source_version}"}" ]; then
continue
Copy link
Contributor

@namiltd namiltd Mar 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This testing doesn't work for Windows systems (TartoiseGIT - GIT Bash here).
For Windows, folders always have size 0.
Is it possible to check if the system is Windows by checking if the MINGW_CHOST constant is set.
You can also check: uname -s
MINGW64_NT-10.0-19045

@oliv3r
Copy link
Contributor Author

oliv3r commented Mar 24, 2024 via email

@ehem
Copy link
Contributor

ehem commented Mar 25, 2024

Your script is doing most processing of variables (ensuring they're set, adding/removing prefixes, etc) in your main() function. Yet $platform_name is left mostly unprocessed by main() and instead adjusted inside bump_kernel().
For the conversion to wrapper I had to fix this. I suspect you might want to consider grabbing the first commit.

The main function does just some argument setup, it's part of the arguments. You could argue it should be part of init maybe, but not main.

The section at the top of bump_kernel() looks suspiciously like argument setup.

I'll admit I'm more concerned about showing kernel_upgrade.pl can do everything this does. This isn't something I could reject as a reviewer (something about ethics and conflict of interest), but it does seem a bit odd.

Meanwhile there are some rather major issues waiting in a review submission, but I'm awaiting at least testing on another pull...

@ehem
Copy link
Contributor

ehem commented Apr 4, 2024

Uhm... No activity?

@oliv3r
Copy link
Contributor Author

oliv3r commented Apr 4, 2024 via email

@ehem
Copy link
Contributor

ehem commented Apr 4, 2024

I do have a review pretty well ready, but my theory was this was in exchange for assistance elsewhere (even if you cannot review, having someone simply state other things work has value).

@oliv3r
Copy link
Contributor Author

oliv3r commented Apr 4, 2024 via email

Due to potential fears of copyright infringement noted by Elliott
Mitchell [0], rewrite our message to belong to OpenWRT.

Note, AI was used to aid in construction of this sentence.

[0]: https://lists.openwrt.org/pipermail/openwrt-devel/2024-March/042422.html

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
No need to keep unused empty functions. A left over from early development.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Naivly and lazyly the leading v was only dropped from optarg, not from any
environment variable.

Lets do this properly and ensure a leading 'v' is always dropped.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
If a version string was not supplied, we currently print an empty
string. We can do better here. Also by popular demand, print the usage
information in case of error.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
We want to avoid starting a process when we know it will fail later.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Determine the target directory based on the script location, which might
work better in some cases, but at least also allows the script to be ran
from with any location in the OpenWRT repository.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
In some cases, we want to only migrate configuration files, e.g. if the
kernel was bumped already. Lets add a flag for this case to offer
flexibility. By default we will migrate configuration flags as before.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Instead of looping of a directory to find directories related to kernel
changes, use the git index instead.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
The current solution using `find` introduces a racecondition, where `find`
and `git mv` get in each others way. While this could be fixed with
more-utils sponge command (or even sort -u) to buffer the output of
find.

However, a much better approach, is to query the git index directly,
which will not change, and is far more accurate.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Some targets may need to bump specific sub-targets only. So lets offer
this as an option.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
While we have included the needed changes via a merge commit, there is
no need to keep it. Lets drop the merge commit, which we can do as we
haven't pushed anything.

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
@openwrt-bot openwrt-bot merged commit 98235e6 into openwrt:main Apr 12, 2024
2 checks passed
@robimarko
Copy link
Contributor

Thanks! Rebased on top of main and merged!

@oliv3r oliv3r deleted the kernel_bump branch April 12, 2024 16:47
@ehem
Copy link
Contributor

ehem commented May 7, 2024

I remember, but super busy with $work

Still listening to the crickets here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/scripts/tools pull request/issues for build, scripts and tools related changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants