Skip to contentSkip to conversation

efivar: new package

PATCH Superseded Erico Nunes 2 participants 4 messages Mar 26, 2016 – Apr 21, 2016

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 efivar: new package

efivar contains tools and libraries to manipulate EFI variables.

This package has some restrictions to build. First, it needs uchar.h which apparently does not come in uclibc, so it has been disabled for uclibc.
It has also been found that in some systems it failed to build due to not generating the .pc files. This has been tracked to the use of make 3.81, so a patch was prepared for it. I have also sent this patch to the upstream development.
And then there's the linux/nvme.h header, which is somewhat conturbed, as it has appeared in user space linux headers 3.12 and in 4.4 it was renamed. This has been solved by restricting it to build with linux headers >= 3.12 and a patch from upstream was picked which fixes it for linux headers >= 4.4.

---
 package/Config.in                                  |  1 +
 .../0001-Workaround-rename-of-linux-nvme.h.patch   | 32 +++++++++++++++
 .../0002-Make.rules-fix-build-with-make-3.81.patch | 45 ++++++++++++++++++++++
 package/efivar/Config.in                           | 14 +++++++
 package/efivar/efivar.hash                         |  2 +
 package/efivar/efivar.mk                           | 43 +++++++++++++++++++++
 6 files changed, 137 insertions(+)
 create mode 100644 package/efivar/0001-Workaround-rename-of-linux-nvme.h.patch
 create mode 100644 package/efivar/0002-Make.rules-fix-build-with-make-3.81.patch
 create mode 100644 package/efivar/Config.in
 create mode 100644 package/efivar/efivar.hash
 create mode 100644 package/efivar/efivar.mk
package/Config.in +1 -0
index 1467f33..b8d142f 100644
@@ -1612,6 +1612,7 @@ if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 endif
 	source "package/cgroupfs-mount/Config.in"
 	source "package/dsp-tools/Config.in"
+	source "package/efivar/Config.in"
 	source "package/emlog/Config.in"
 	source "package/ftop/Config.in"
 	source "package/getent/Config.in"
package/efivar/0001-Workaround-rename-of-linux-nvme.h.patch new file +32 -0
new file mode 100644
index 0000000..c12a2d9
@@ -0,0 +1,32 @@
+From 75a73111371526a12712bb7211da2116c0bf40f7 Mon Sep 17 00:00:00 2001
+From: Mike Gilbert <[email protected]>
+Date: Thu, 14 Jan 2016 17:02:31 -0500
+Subject: [PATCH] Workaround rename of linux/nvme.h
+
+Bug: https://bugs.gentoo.org/571548
+
+Signed-off-by: Erico Nunes <[email protected]>
+---
+ src/linux.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/src/linux.c b/src/linux.c
+index b618cfd..9388cd3 100644
+--- a/src/linux.c
++++ b/src/linux.c
+@@ -22,7 +22,12 @@
+ #include <inttypes.h>
+ #include <limits.h>
+ #include <linux/ethtool.h>
++#include <linux/version.h>
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 0)
++#include <linux/nvme_ioctl.h>
++#else
+ #include <linux/nvme.h>
++#endif
+ #include <linux/sockios.h>
+ #include <net/if.h>
+ #include <scsi/scsi.h>
+-- 
+2.7.4
+
package/efivar/0002-Make.rules-fix-build-with-make-3.81.patch new file +45 -0

45 lines not on this page · raw message

package/efivar/Config.in new file +14 -0
new file mode 100644
index 0000000..baddddd
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_EFIVAR
+	bool "efivar"
+	depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12 # linux/nvme.h
+	depends on BR2_TOOLCHAIN_USES_GLIBC || \
+		BR2_TOOLCHAIN_USES_MUSL # uchar.h
+	select BR2_PACKAGE_POPT
+	help
+	  Tools and libraries to manipulate EFI variables
+
+	  https://github.com/rhinstaller/efivar
+
+comment "efivar requires an (e)glibc/musl toolchain w/ headers >= 3.12"
+	depends on !BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_12 || \
+		!(BR2_TOOLCHAIN_USES_GLIBC || BR2_TOOLCHAIN_USES_MUSL)
package/efivar/efivar.hash new file +2 -0
new file mode 100644
index 0000000..6619229
@@ -0,0 +1,2 @@
+# locally computed hash
+sha256 f807f5f0846323bc21b18043542b296f5ad81514f91f13c74a4b8da30c965c94 efivar-0.23.tar.gz
package/efivar/efivar.mk new file +43 -0

43 lines not on this page · raw message

Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/2 efibootmgr: new package

A Linux user-space application to modify the Intel Extensible Firmware Interface (EFI) Boot Manager. This application can create and destroy boot entries, change the boot order, change the next running boot option, and more.

The only issue found was that it was trying to include headers from the host, so $(STAGING_DIR) has been prepended to the include path so that the package finds the right headers.

efibootmgr depends on the libraries provided by efivar.

---
 package/Config.in                  |  1 +
 package/efibootmgr/Config.in       | 10 ++++++++++
 package/efibootmgr/efibootmgr.hash |  2 ++
 package/efibootmgr/efibootmgr.mk   | 23 +++++++++++++++++++++++
 4 files changed, 36 insertions(+)
 create mode 100644 package/efibootmgr/Config.in
 create mode 100644 package/efibootmgr/efibootmgr.hash
 create mode 100644 package/efibootmgr/efibootmgr.mk
package/Config.in +1 -0
index b8d142f..bd30c07 100644
@@ -1612,6 +1612,7 @@ if BR2_PACKAGE_BUSYBOX_SHOW_OTHERS
 endif
 	source "package/cgroupfs-mount/Config.in"
 	source "package/dsp-tools/Config.in"
+	source "package/efibootmgr/Config.in"
 	source "package/efivar/Config.in"
 	source "package/emlog/Config.in"
 	source "package/ftop/Config.in"
package/efibootmgr/Config.in new file +10 -0
new file mode 100644
index 0000000..a784d8c
@@ -0,0 +1,10 @@
+config BR2_PACKAGE_EFIBOOTMGR
+	bool "efibootmgr"
+	depends on BR2_PACKAGE_EFIVAR
+	help
+	  A Linux user-space application to modify the Intel Extensible
+	  Firmware Interface (EFI) Boot Manager. This application can create
+	  and destroy boot entries, change the boot order, change the next
+	  running boot option, and more.
+
+	  https://github.com/rhinstaller/efibootmgr
package/efibootmgr/efibootmgr.hash new file +2 -0
new file mode 100644
index 0000000..a789942
@@ -0,0 +1,2 @@
+# locally computed hash
+sha256 b180d7d6b377d24b0872869f2571e2700b618e4d7ebdc2133134a918efe2623b efibootmgr-efibootmgr-0.12.tar.gz
package/efibootmgr/efibootmgr.mk new file +23 -0
new file mode 100644
index 0000000..9156499
@@ -0,0 +1,23 @@
+################################################################################
+#
+# efibootmgr
+#
+################################################################################
+
+EFIBOOTMGR_VERSION = efibootmgr-0.12
+EFIBOOTMGR_SITE = $(call github,rhinstaller,efibootmgr,$(EFIBOOTMGR_VERSION))
+EFIBOOTMGR_LICENSE = GPLv2
+EFIBOOTMGR_LICENSE_FILES = COPYING
+EFIBOOTMGR_DEPENDENCIES = efivar
+
+define EFIBOOTMGR_BUILD_CMDS
+	$(SED) 's,-I/,-I$(STAGING_DIR)/,' $(@D)/Makefile
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE1) -C $(@D)
+endef
+
+define EFIBOOTMGR_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/src/efibootmgr/efibootmgr \
+		$(TARGET_DIR)/usr/bin/efibootmgr
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.7.4
#2 lore raw

PATCH 1/2 efivar: new package

In reply to Erico Nunes

Hello,

This patch looks mostly good. There are only a few nits, see below.

Quoted 9 lines · Erico Nunes

efivar contains tools and libraries to manipulate EFI variables.

This package has some restrictions to build. First, it needs uchar.h which apparently does not come in uclibc, so it has been disabled for uclibc.
It has also been found that in some systems it failed to build due to not generating the .pc files. This has been tracked to the use of make 3.81, so a patch was prepared for it. I have also sent this patch to the upstream development.

We try to avoid first person sentences in commit log. Can you rephrase
as: "so a patch was prepared for it, and was submitted upstream".

package/efivar/Config.in line 2

Quoted 8 lines
package/efivar/Config.in new file +2 -0
new file mode 100644
index 0000000..baddddd
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_EFIVAR
+	bool "efivar"

Does it build on all architectures, or is it somehow x86/x86-64 specific ?

Quoted 6 lines
package/efivar/efivar.mk new file +0 -0
new file mode 100644
index 0000000..9775777

package/efivar/efivar.mk line 9

Quoted 9 lines
package/efivar/efivar.mk new file +9 -0
@@ -0,0 +1,43 @@
+################################################################################
+#
+# efivar
+#
+################################################################################
+
+EFIVAR_VERSION = 0.23
+EFIVAR_SITE = $(call github,rhinstaller,efivar,$(EFIVAR_VERSION))
+EFIVAR_LICENSE = GPLv2.1

GPLv2.1 doesn't exist. It's either GPLv2 or LGPLv2.1. Looking at the code, it seems to be LGPLv2.1.

package/efivar/efivar.mk line 18

Quoted 9 lines
package/efivar/efivar.mk new file +9 -0
+EFIVAR_LICENSE_FILES = COPYING
+EFIVAR_DEPENDENCIES = popt
+EFIVAR_INSTALL_STAGING = YES
+
+define EFIVAR_BUILD_CMDS
+	# makeguids is an internal host tool and must be built separately with
+	# $(HOST_CC), otherwise it gets cross-built.
+	$(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) CFLAGS+=-std=c99 \
+		$(MAKE1) -C $(@D)/src makeguids

Please use CFLAGS="$(HOST_CFLAGS) -std=c99" instead of CFLAGS+=

package/efivar/efivar.mk line 22

Quoted 4 lines
package/efivar/efivar.mk new file +4 -0
+
+	# skip efivar-static build, otherwise we always require static popt
+	$(SED) 's/^BINTARGETS=.*/BINTARGETS=efivar/g' \
+		$(@D)/src/Makefile

This should be done in a post-patch hook, or maybe even by a patch itself? Or maybe you don't need any patch at all, by just passing BINTARGETS=efivar when building/installing ?

Since you also need libdir at each step, shall I suggest that you do something like:

EFIVAR_MAKE_OPTS = \
	BINTARGETS=efivar \
	libdir=/usr/lib

and then use $(EFIVAR_MAKE_OPTS) at build and install time ?

Could you address those issues and send an updated version?

Thanks!

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#3 lore raw

PATCH 1/2 efivar: new package

Hi Thomas,

Thanks for the review.

Quoted 11 lines · Thomas Petazzoni
Quoted 9 lines · Erico Nunes

efivar contains tools and libraries to manipulate EFI variables.

This package has some restrictions to build. First, it needs uchar.h which apparently does not come in uclibc, so it has been disabled for uclibc.
It has also been found that in some systems it failed to build due to not generating the .pc files. This has been tracked to the use of make 3.81, so a patch was prepared for it. I have also sent this patch to the upstream development.

Quoted 2 lines

We try to avoid first person sentences in commit log. Can you rephrase
as: "so a patch was prepared for it, and was submitted upstream".

Sure, will change it.

Quoted 11 lines

package/efivar/Config.in line 2

Quoted 8 lines
package/efivar/Config.in new file +2 -0
new file mode 100644
index 0000000..baddddd
@@ -0,0 +1,14 @@
+config BR2_PACKAGE_EFIVAR
+     bool "efivar"

Does it build on all architectures, or is it somehow x86/x86-64 specific ?

This package can be useful at least on x86, x86-64 and aarch64. There are no limitations to build it in other architectures though, so I don't think we need to restrict it. I have build tested it on a few other architectures that have glibc support (mips, MicroBlaze, ppc64, sparc64 at least).

Quoted 10 lines
Quoted 10 lines
package/efivar/efivar.mk new file +4 -0
new file mode 100644
index 0000000..9775777
@@ -0,0 +1,43 @@
+################################################################################
+#
+# efivar
+#
Quoted 8 lines

package/efivar/efivar.mk line 9

Quoted 5 lines
package/efivar/efivar.mk new file +5 -0
+################################################################################
+
+EFIVAR_VERSION = 0.23
+EFIVAR_SITE = $(call github,rhinstaller,efivar,$(EFIVAR_VERSION))
+EFIVAR_LICENSE = GPLv2.1

GPLv2.1 doesn't exist. It's either GPLv2 or LGPLv2.1. Looking at the code, it seems to be LGPLv2.1.

It's LGPLv2.1, will fix in v2.

Quoted 11 lines

package/efivar/efivar.mk line 18

Quoted 9 lines
package/efivar/efivar.mk new file +9 -0
+EFIVAR_LICENSE_FILES = COPYING
+EFIVAR_DEPENDENCIES = popt
+EFIVAR_INSTALL_STAGING = YES
+
+define EFIVAR_BUILD_CMDS
+     # makeguids is an internal host tool and must be built separately with
+     # $(HOST_CC), otherwise it gets cross-built.
+     $(HOST_MAKE_ENV) $(HOST_CONFIGURE_OPTS) CFLAGS+=-std=c99 \
+             $(MAKE1) -C $(@D)/src makeguids

Please use CFLAGS="$(HOST_CFLAGS) -std=c99" instead of CFLAGS+=

Will fix it.

Quoted 9 lines

package/efivar/efivar.mk line 22

Quoted 4 lines
package/efivar/efivar.mk new file +4 -0
+
+     # skip efivar-static build, otherwise we always require static popt
+     $(SED) 's/^BINTARGETS=.*/BINTARGETS=efivar/g' \
+             $(@D)/src/Makefile

This should be done in a post-patch hook, or maybe even by a patch itself? Or maybe you don't need any patch at all, by just passing BINTARGETS=efivar when building/installing ?

Quoted 8 lines

Since you also need libdir at each step, shall I suggest that you do something like:

EFIVAR_MAKE_OPTS = \
        BINTARGETS=efivar \
        libdir=/usr/lib

and then use $(EFIVAR_MAKE_OPTS) at build and install time ?

The EFIVAR_MAKE_OPTS suggestion works and is much better than the previous approach, will change it.

?rico