Skip to content

Commit

Permalink
Fix python3 shebang paths and add python option.
Browse files Browse the repository at this point in the history
Using absolute paths can result in the wrong python3 binary being
used, such as when cross compiling using a non-system python3.

Use the normal python3 env shebang instead.

Also add a meson option to allow overriding the python path.

Signed-off-by: James Hilliard <[email protected]>
  • Loading branch information
jameshilliard authored and superm1 committed Jul 5, 2024
1 parent 7d67c7c commit 1cd1ff0
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion contrib/reformat-code.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Copyright (C) 2017 Dell Inc.
#
Expand Down
2 changes: 1 addition & 1 deletion efi/generate_binary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Copyright (C) 2021 Javier Martinez Canillas <[email protected]>
# Copyright (C) 2021 Richard Hughes <[email protected]>
Expand Down
2 changes: 1 addition & 1 deletion efi/generate_sbat.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/python3
#!/usr/bin/env python3
#
# Copyright (C) 2021 Javier Martinez Canillas <[email protected]>
# Copyright (C) 2021 Richard Hughes <[email protected]>
Expand Down
4 changes: 2 additions & 2 deletions efi/meson.build
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
generate_sbat = find_program('generate_sbat.py', native: true)
generate_binary = find_program('generate_binary.py', native: true)
generate_sbat = [python3, files('generate_sbat.py')]
generate_binary = [python3, files('generate_binary.py')]

# get source version, falling back
git = find_program('git', required : false)
Expand Down
7 changes: 7 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,13 @@ libexecdir = join_paths(prefix, get_option('libexecdir'))

genpeimg = find_program ('genpeimg', required: get_option('genpeimg'))

python3path = get_option('python')
if python3path == ''
python3 = import('python').find_installation('python3')
else
python3 = find_program(python3path)
endif

efi_app_location = join_paths(libexecdir, 'fwupd', 'efi')
host_cpu = host_machine.cpu_family()
if host_cpu == 'x86'
Expand Down
1 change: 1 addition & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ option('efi_sbat_distro_pkgname', type : 'string', value : '', description : 'SB
option('efi_sbat_distro_version', type : 'string', value : '', description : 'SBAT distribution version, e.g. fwupd-1.5.6.fc33')
option('efi_sbat_distro_url', type : 'string', value : '', description : 'SBAT distribution URL, e.g. https://src.fedoraproject.org/rpms/fwupd')
option('genpeimg', type : 'feature', description : 'Use genpeimg to add NX support to binaries')
option('python', type : 'string', description : 'the absolute path of the python3 binary')

0 comments on commit 1cd1ff0

Please sign in to comment.