ClangBuiltLinux / boot-utils

Collection of files for booting Linux kernels
26 stars 7 forks source link

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

Closed nathanchance closed 2 years ago

nathanchance commented 2 years ago

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.