Skip to content

boot-qemu.py: Fix get_linux_ver_code() when CONFIG_LOCALVERSION_AUTO is not set#74

Merged
nathanchance merged 1 commit into
ClangBuiltLinux:mainfrom
nathanchance:fix-get_linux_ver_code-without-CONFIG_LOCALVERSION_AUTO
Oct 5, 2022
Merged

boot-qemu.py: Fix get_linux_ver_code() when CONFIG_LOCALVERSION_AUTO is not set#74
nathanchance merged 1 commit into
ClangBuiltLinux:mainfrom
nathanchance:fix-get_linux_ver_code-without-CONFIG_LOCALVERSION_AUTO

Conversation

@nathanchance

@nathanchance nathanchance commented Oct 4, 2022

Copy link
Copy Markdown
Member

When CONFIG_LOCALVERSION_AUTO is not set, the Linux version string may be
"Linux version x.y.z+", which is not handled gracefully by the script:

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

Use re.search() for a more specific match, which ends up simplifying the
logic to the point of not needing a comment.

@nathanchance nathanchance force-pushed the fix-get_linux_ver_code-without-CONFIG_LOCALVERSION_AUTO branch from a90b5ae to 2be5b3e Compare October 4, 2022 19:12
Comment thread boot-qemu.py Outdated
Comment thread boot-qemu.py Outdated
…is not set

When CONFIG_LOCALVERSION_AUTO is not set, the Linux version string may be
"Linux version x.y.z+", which is not handled gracefully by the script:

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

Use re.search() for a more specific match, which ends up simplifying the
logic to the point of not needing a comment.

Signed-off-by: Nathan Chancellor <nathan@kernel.org>
@nathanchance nathanchance force-pushed the fix-get_linux_ver_code-without-CONFIG_LOCALVERSION_AUTO branch from f293df5 to 604db5b Compare October 4, 2022 20:55
@nathanchance nathanchance merged commit 309c67a into ClangBuiltLinux:main Oct 5, 2022
@nathanchance nathanchance deleted the fix-get_linux_ver_code-without-CONFIG_LOCALVERSION_AUTO branch October 5, 2022 00:47
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.

3 participants