0002-Fix-python3-shebang-paths-and-add-python-option.patch 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. From 1cd1ff0216d5beb2a2523031398d4dba7d12729d Mon Sep 17 00:00:00 2001
  2. From: James Hilliard <james.hilliard1@gmail.com>
  3. Date: Tue, 2 Jul 2024 14:51:26 -0600
  4. Subject: [PATCH] Fix python3 shebang paths and add python option.
  5. Using absolute paths can result in the wrong python3 binary being
  6. used, such as when cross compiling using a non-system python3.
  7. Use the normal python3 env shebang instead.
  8. Also add a meson option to allow overriding the python path.
  9. Upstream: https://github.com/fwupd/fwupd-efi/commit/1cd1ff0216d5beb2a2523031398d4dba7d12729d
  10. Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
  11. ---
  12. contrib/reformat-code.py | 2 +-
  13. efi/generate_binary.py | 2 +-
  14. efi/generate_sbat.py | 2 +-
  15. efi/meson.build | 4 ++--
  16. meson.build | 7 +++++++
  17. meson_options.txt | 1 +
  18. 6 files changed, 13 insertions(+), 5 deletions(-)
  19. diff --git a/contrib/reformat-code.py b/contrib/reformat-code.py
  20. index 65a4ac4..ff6014d 100755
  21. --- a/contrib/reformat-code.py
  22. +++ b/contrib/reformat-code.py
  23. @@ -1,4 +1,4 @@
  24. -#!/usr/bin/python3
  25. +#!/usr/bin/env python3
  26. #
  27. # Copyright (C) 2017 Dell Inc.
  28. #
  29. diff --git a/efi/generate_binary.py b/efi/generate_binary.py
  30. index 443472a..a4611bb 100755
  31. --- a/efi/generate_binary.py
  32. +++ b/efi/generate_binary.py
  33. @@ -1,4 +1,4 @@
  34. -#!/usr/bin/python3
  35. +#!/usr/bin/env python3
  36. #
  37. # Copyright (C) 2021 Javier Martinez Canillas <javierm@redhat.com>
  38. # Copyright (C) 2021 Richard Hughes <richard@hughsie.com>
  39. diff --git a/efi/generate_sbat.py b/efi/generate_sbat.py
  40. index 6c904e5..b9b80ac 100755
  41. --- a/efi/generate_sbat.py
  42. +++ b/efi/generate_sbat.py
  43. @@ -1,4 +1,4 @@
  44. -#!/usr/bin/python3
  45. +#!/usr/bin/env python3
  46. #
  47. # Copyright (C) 2021 Javier Martinez Canillas <javierm@redhat.com>
  48. # Copyright (C) 2021 Richard Hughes <richard@hughsie.com>
  49. diff --git a/efi/meson.build b/efi/meson.build
  50. index 75ade7a..008ba3d 100644
  51. --- a/efi/meson.build
  52. +++ b/efi/meson.build
  53. @@ -1,5 +1,5 @@
  54. -generate_sbat = find_program('generate_sbat.py', native: true)
  55. -generate_binary = find_program('generate_binary.py', native: true)
  56. +generate_sbat = [python3, files('generate_sbat.py')]
  57. +generate_binary = [python3, files('generate_binary.py')]
  58. # get source version, falling back
  59. git = find_program('git', required : false)
  60. diff --git a/meson.build b/meson.build
  61. index a5612a6..5836213 100644
  62. --- a/meson.build
  63. +++ b/meson.build
  64. @@ -19,6 +19,13 @@ libexecdir = join_paths(prefix, get_option('libexecdir'))
  65. genpeimg = find_program ('genpeimg', required: get_option('genpeimg'))
  66. +python3path = get_option('python')
  67. +if python3path == ''
  68. + python3 = import('python').find_installation('python3')
  69. +else
  70. + python3 = find_program(python3path)
  71. +endif
  72. +
  73. efi_app_location = join_paths(libexecdir, 'fwupd', 'efi')
  74. host_cpu = host_machine.cpu_family()
  75. if host_cpu == 'x86'
  76. diff --git a/meson_options.txt b/meson_options.txt
  77. index 588ae29..5f6f521 100644
  78. --- a/meson_options.txt
  79. +++ b/meson_options.txt
  80. @@ -8,3 +8,4 @@ option('efi_sbat_distro_pkgname', type : 'string', value : '', description : 'SB
  81. option('efi_sbat_distro_version', type : 'string', value : '', description : 'SBAT distribution version, e.g. fwupd-1.5.6.fc33')
  82. option('efi_sbat_distro_url', type : 'string', value : '', description : 'SBAT distribution URL, e.g. https://src.fedoraproject.org/rpms/fwupd')
  83. option('genpeimg', type : 'feature', description : 'Use genpeimg to add NX support to binaries')
  84. +option('python', type : 'string', description : 'the absolute path of the python3 binary')
  85. --
  86. 2.34.1