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

boot-utils.py: Fix searching for Linux kernel version numbers #69

Merged

Conversation

nathanchance
Copy link
Member

CI reported a crash when attempting to boot arm64 kernels:

  Traceback (most recent call last):
    File ".../boot-qemu.py", line 727, in <module>
      cfg = get_qemu_args(cfg)
    File ".../boot-qemu.py", line 451, in get_qemu_args
      linux_ver_code = get_linux_ver_code(gzip_kernel_cmd)
    File ".../boot-qemu.py", line 338, in get_linux_ver_code
      return create_version_code(linux_version)
    File ".../boot-qemu.py", line 262, in create_version_code
      major, minor, patch = [int(version[i]) for i in (0, 1, 2)]
    File ".../boot-qemu.py", line 262, in <listcomp>
      major, minor, patch = [int(version[i]) for i in (0, 1, 2)]
  ValueError: invalid literal for int() with base 10: '%s'

Looking at the strings output reveals:

  $ gzip -d -c Image.gz &| strings &| grep "Linux version "
  Linux version %s (%s)
  Linux version 4.19.254 (tuxmake@tuxmake) (Debian clang version 14.0.6-++20220622053050+f28c006a5895-1~exp1~20220622173135.152, Debian LLD 14.0.6) #1 SMP PREEMPT @1659593940

Use re.search() plus a regular expression for a more precise match. I
had originally tried to do this but I could not get it to work for some
reason. I tested this against all the kernels that had issues in CI with
no further issues.

CI reported a crash when attempting to boot arm64 kernels:

  Traceback (most recent call last):
    File ".../boot-qemu.py", line 727, in <module>
      cfg = get_qemu_args(cfg)
    File ".../boot-qemu.py", line 451, in get_qemu_args
      linux_ver_code = get_linux_ver_code(gzip_kernel_cmd)
    File ".../boot-qemu.py", line 338, in get_linux_ver_code
      return create_version_code(linux_version)
    File ".../boot-qemu.py", line 262, in create_version_code
      major, minor, patch = [int(version[i]) for i in (0, 1, 2)]
    File ".../boot-qemu.py", line 262, in <listcomp>
      major, minor, patch = [int(version[i]) for i in (0, 1, 2)]
  ValueError: invalid literal for int() with base 10: '%s'

Looking at the strings output reveals:

  $ gzip -d -c Image.gz &| strings &| grep "Linux version "
  Linux version %s (%s)
  Linux version 4.19.254 (tuxmake@tuxmake) (Debian clang version 14.0.6-++20220622053050+f28c006a5895-1~exp1~20220622173135.152, Debian LLD 14.0.6) ClangBuiltLinux#1 SMP PREEMPT @1659593940

Use re.search() plus a regular expression for a more precise match. I
had originally tried to do this but I could not get it to work for some
reason. I tested this against all the kernels that had issues in CI with
no further issues.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@nathanchance
Copy link
Member Author

Thanks for the review!

@nathanchance nathanchance merged commit 7cad9a3 into ClangBuiltLinux:main Aug 4, 2022
@nathanchance nathanchance deleted the fix-linux-version-code branch August 4, 2022 15:52
nathanchance added a commit to nathanchance/continuous-integration2 that referenced this pull request Aug 4, 2022
See ClangBuiltLinux/boot-utils#69 for more
information.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants