package/fwupd-efi: new package

Backport some patches fixing the python shebang and allowing one
to disable the use of genpeimg since we use host-python-pefile.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
This commit is contained in:
James Hilliard
2024-07-19 00:32:34 -06:00
committed by Thomas Petazzoni
parent ab11a03899
commit 51f4451094
7 changed files with 178 additions and 0 deletions

View File

@@ -1491,6 +1491,7 @@ F: package/apcupsd/
F: package/bpftool/
F: package/cloudflared/
F: package/exfatprogs/
F: package/fwupd-efi/
F: package/fxdiv/
F: package/gensio/
F: package/lua-std-debug/

View File

@@ -519,6 +519,7 @@ endmenu
source "package/fmtools/Config.in"
source "package/freeipmi/Config.in"
source "package/freescale-imx/Config.in"
source "package/fwupd-efi/Config.in"
source "package/fxload/Config.in"
source "package/gcnano-binaries/Config.in"
source "package/gpm/Config.in"

View File

@@ -0,0 +1,41 @@
From fb1cf079346a2838cc44f7116cb4a790e40cc5bf Mon Sep 17 00:00:00 2001
From: James Hilliard <james.hilliard1@gmail.com>
Date: Tue, 2 Jul 2024 15:08:18 -0600
Subject: [PATCH] Allow enabling/disabling the use of genpeimg binary
In some cases we may want to force the use of python3-pefile instead
of genpeimg such as when cross compiling, add a feature option to
allow disabling genpeimg.
Upstream: https://github.com/fwupd/fwupd-efi/commit/fb1cf079346a2838cc44f7116cb4a790e40cc5bf
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
meson.build | 2 +-
meson_options.txt | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/meson.build b/meson.build
index a3ce068..a5612a6 100644
--- a/meson.build
+++ b/meson.build
@@ -17,7 +17,7 @@ prefix = get_option('prefix')
libdir = join_paths(prefix, get_option('libdir'))
libexecdir = join_paths(prefix, get_option('libexecdir'))
-genpeimg = find_program ('genpeimg', required: false)
+genpeimg = find_program ('genpeimg', required: get_option('genpeimg'))
efi_app_location = join_paths(libexecdir, 'fwupd', 'efi')
host_cpu = host_machine.cpu_family()
diff --git a/meson_options.txt b/meson_options.txt
index 26161e1..588ae29 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -7,3 +7,4 @@ option('efi_sbat_distro_summary', type : 'string', value : '', description : 'SB
option('efi_sbat_distro_pkgname', type : 'string', value : '', description : 'SBAT distribution package name, e.g. fwupd')
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')
--
2.34.1

View File

@@ -0,0 +1,95 @@
From 1cd1ff0216d5beb2a2523031398d4dba7d12729d Mon Sep 17 00:00:00 2001
From: James Hilliard <james.hilliard1@gmail.com>
Date: Tue, 2 Jul 2024 14:51:26 -0600
Subject: [PATCH] Fix python3 shebang paths and add python option.
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.
Upstream: https://github.com/fwupd/fwupd-efi/commit/1cd1ff0216d5beb2a2523031398d4dba7d12729d
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
---
contrib/reformat-code.py | 2 +-
efi/generate_binary.py | 2 +-
efi/generate_sbat.py | 2 +-
efi/meson.build | 4 ++--
meson.build | 7 +++++++
meson_options.txt | 1 +
6 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/contrib/reformat-code.py b/contrib/reformat-code.py
index 65a4ac4..ff6014d 100755
--- a/contrib/reformat-code.py
+++ b/contrib/reformat-code.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
#
# Copyright (C) 2017 Dell Inc.
#
diff --git a/efi/generate_binary.py b/efi/generate_binary.py
index 443472a..a4611bb 100755
--- a/efi/generate_binary.py
+++ b/efi/generate_binary.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
#
# Copyright (C) 2021 Javier Martinez Canillas <javierm@redhat.com>
# Copyright (C) 2021 Richard Hughes <richard@hughsie.com>
diff --git a/efi/generate_sbat.py b/efi/generate_sbat.py
index 6c904e5..b9b80ac 100755
--- a/efi/generate_sbat.py
+++ b/efi/generate_sbat.py
@@ -1,4 +1,4 @@
-#!/usr/bin/python3
+#!/usr/bin/env python3
#
# Copyright (C) 2021 Javier Martinez Canillas <javierm@redhat.com>
# Copyright (C) 2021 Richard Hughes <richard@hughsie.com>
diff --git a/efi/meson.build b/efi/meson.build
index 75ade7a..008ba3d 100644
--- a/efi/meson.build
+++ b/efi/meson.build
@@ -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)
diff --git a/meson.build b/meson.build
index a5612a6..5836213 100644
--- a/meson.build
+++ b/meson.build
@@ -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'
diff --git a/meson_options.txt b/meson_options.txt
index 588ae29..5f6f521 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -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')
--
2.34.1

View File

@@ -0,0 +1,9 @@
config BR2_PACKAGE_FWUPD_EFI
bool "fwupd-efi"
depends on BR2_PACKAGE_GNU_EFI_ARCH_SUPPORTS
select BR2_PACKAGE_GNU_EFI
select BR2_PACKAGE_HOST_PYTHON_USWID
help
EFI Application used by uefi-capsule plugin in fwupd.
https://github.com/fwupd/fwupd-efi

View File

@@ -0,0 +1,3 @@
# Locally calculated
sha256 afd0805a2ad081a7caff2ef5bc004ce3a0147b538015e8eca966341716b1260e fwupd-efi-1.6.tar.xz
sha256 dc626520dcd53a22f727af3ee42c770e56c97a64fe3adb063799d8ab032fe551 COPYING

View File

@@ -0,0 +1,28 @@
################################################################################
#
# fwupd-efi
#
################################################################################
FWUPD_EFI_VERSION = 1.6
FWUPD_EFI_SITE = https://github.com/fwupd/fwupd-efi/releases/download/$(FWUPD_EFI_VERSION)
FWUPD_EFI_SOURCE = fwupd-efi-$(FWUPD_EFI_VERSION).tar.xz
FWUPD_EFI_LICENSE = LGPL-2.1+
FWUPD_EFI_LICENSE_FILES = COPYING
FWUPD_EFI_INSTALL_STAGING = YES
FWUPD_EFI_DEPENDENCIES = host-python-pefile host-python-uswid gnu-efi
FWUPD_EFI_CONF_OPTS = \
-Defi-libdir=$(STAGING_DIR)/usr/lib \
-Defi-ldsdir=$(STAGING_DIR)/usr/lib \
-Defi-includedir=$(STAGING_DIR)/usr/include/efi \
-Defi_sbat_fwupd_generation=1 \
-Defi_sbat_distro_id=buildroot \
-Defi_sbat_distro_summary=Buildroot \
-Defi_sbat_distro_pkgname=fwupd-efi \
-Defi_sbat_distro_version=fwupd-efi-$(FWUPD_EFI_VERSION) \
-Defi_sbat_distro_url=https://gitlab.com/buildroot.org/buildroot/-/tree/master/package/fwupd-efi \
-Dgenpeimg=disabled \
-Dpython="$(HOST_DIR)/bin/python3"
FWUPD_EFI_MESON_EXTRA_BINARIES = objcopy='$(TARGET_OBJCOPY)'
$(eval $(meson-package))