gummiboot: add new package
authorOskari Rauta <oskari.rauta@gmail.com>
Wed, 21 Apr 2021 00:58:42 +0000 (03:58 +0300)
committerRosen Penev <rosenp@gmail.com>
Sat, 24 Apr 2021 08:12:39 +0000 (01:12 -0700)
Signed-off-by: Oskari Rauta <oskari.rauta@gmail.com>
utils/gummiboot/Makefile [new file with mode: 0644]
utils/gummiboot/patches/010-fix-missing-includes.patch [new file with mode: 0644]
utils/gummiboot/patches/020-fix-dev-mapping.patch [new file with mode: 0644]

diff --git a/utils/gummiboot/Makefile b/utils/gummiboot/Makefile
new file mode 100644 (file)
index 0000000..01db866
--- /dev/null
@@ -0,0 +1,66 @@
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gummiboot
+PKG_VERSION:=45
+PKG_RELEASE:=$(AUTORELEASE)
+
+PKG_SOURCE_PROTO:=git
+PKG_SOURCE_URL:=https://github.com/rzr/gummiboot.git
+PKG_SOURCE_DATE:=2021-04-11
+PKG_SOURCE_VERSION:=eb3daf2ca4cb1657cf1f780957485d690a552bf6
+PKG_MIRROR_HASH:=4c57791693b57bbe36e85b49d70310728b8008c4c545006a71c5a5f71b8df501
+
+PKG_LICENSE:=LGPL-2.1-or-later
+PKG_LICENSE_FILES:=LICENSE
+PKG_BUILD_DEPENDS:=gnu-efi
+PKG_BUILD_PARALLEL:=1
+PKG_FIXUP:=autoreconf
+PKG_INSTALL:=1
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/gummiboot
+  SECTION:=boot
+  CATEGORY:=Boot Loaders
+  TITLE:=Simple UEFI boot manager
+  DEPENDS:=@TARGET_X86_64 +libblkid
+  URL:=https://github.com/rzr/gummiboot
+endef
+
+define Package/gummiboot/description
+  gummiboot Simple UEFI boot manager
+
+  gummiboot executes EFI images. The default entry is selected by a configured
+  pattern (glob) or an on-screen menu.
+endef
+
+CONFIGURE_ARGS += \
+       --with-efi-libdir=$(STAGING_DIR)/usr/lib \
+       --with-efi-ldsdir=$(STAGING_DIR)/usr/lib \
+       --with-efi-includedir=$(STAGING_DIR)/usr/include
+
+define Build/Compile
+       +$(MAKE_VARS) EFI_CFLAGS="-I$(TOOLCHAIN_DIR)/include $(TARGET_CFLAGS)" \
+       $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+               $(MAKE_FLAGS) \
+               $(1);
+endef
+
+define Build/Install
+       $(MAKE_VARS) EFI_CFLAGS="-I$(TOOLCHAIN_DIR)/include $(TARGET_CFLAGS)" \
+       $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+               $(MAKE_INSTALL_FLAGS) install
+endef
+
+define Package/gummiboot/install
+       $(INSTALL_DIR) $(1)/usr/sbin $(1)/usr/lib/gummiboot
+       $(INSTALL_DATA) $(PKG_INSTALL_DIR)/usr/lib/gummiboot/gummibootx64.efi $(1)/usr/lib/gummiboot/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gummiboot $(1)/usr/sbin/
+endef
+
+$(eval $(call BuildPackage,gummiboot))
diff --git a/utils/gummiboot/patches/010-fix-missing-includes.patch b/utils/gummiboot/patches/010-fix-missing-includes.patch
new file mode 100644 (file)
index 0000000..6036599
--- /dev/null
@@ -0,0 +1,10 @@
+--- a/src/setup/setup.c
++++ b/src/setup/setup.c
+@@ -37,6 +37,7 @@
+ #include <ftw.h>
+ #include <stdbool.h>
+ #include <blkid.h>
++#include <sys/sysmacros.h>
+ #include "efivars.h"
diff --git a/utils/gummiboot/patches/020-fix-dev-mapping.patch b/utils/gummiboot/patches/020-fix-dev-mapping.patch
new file mode 100644 (file)
index 0000000..0446aa2
--- /dev/null
@@ -0,0 +1,54 @@
+--- a/src/setup/setup.c
++++ b/src/setup/setup.c
+@@ -83,6 +83,9 @@ static int verify_esp(const char *p, uin
+         blkid_probe b = NULL;
+         int r;
+         const char *v;
++        char buf[1024];
++
++      memset(buf, 0, sizeof(buf));
+         if (statfs(p, &sfs) < 0) {
+                 fprintf(stderr, "Failed to check file system type of %s: %m\n", p);
+@@ -122,24 +125,38 @@ static int verify_esp(const char *p, uin
+                 return -ENODEV;
+         }
+-        r = asprintf(&t, "/dev/block/%u:%u", major(st.st_dev), minor(st.st_dev));
++        r = asprintf(&t, "/sys/dev/block/%u:%u", major(st.st_dev), minor(st.st_dev));
+         if (r < 0) {
+                 fprintf(stderr, "Out of memory.\n");
+                 return -ENOMEM;
+         }
++      r = readlink(t, buf, sizeof(buf) - 1);
++      if (r < 0) {
++              fprintf(stderr, "Failed to identify device node for block device %u:%u\n", major(st.st_dev), minor(st.st_dev));
++              return -ENOMEM;
++      }
++
++      r = asprintf(&t, "/dev/%s", basename(buf));
++      if (r < 0) {
++              fprintf(stderr, "Out of memory.\n");
++              return -ENOMEM;
++      }
++
+         errno = 0;
+         b = blkid_new_probe_from_filename(t);
+-        free(t);
+         if (!b) {
+                 if (errno != 0) {
+-                        fprintf(stderr, "Failed to open file system %s: %m\n", p);
++                        fprintf(stderr, "Failed to open file system %s on %s: %m\n", p, t);
++                      free(t);
+                         return -errno;
+                 }
++              free(t);
+                 fprintf(stderr, "Out of memory.\n");
+                 return -ENOMEM;
+         }
++      free(t);
+         blkid_probe_enable_superblocks(b, 1);
+         blkid_probe_set_superblocks_flags(b, BLKID_SUBLKS_TYPE);