Initial commit

This commit is contained in:
2026-03-21 12:43:00 -05:00
commit 83bf16823c
438 changed files with 33617 additions and 0 deletions
+125
View File
@@ -0,0 +1,125 @@
diff --git a/Makefile b/Makefile
index 5f1dc88..1ef6fcd 100644
--- a/Makefile
+++ b/Makefile
@@ -35,12 +35,12 @@ brick : all
done
a :
- @if [ $${EUID} != 0 ]; then \
+ @if [ "$$(id -u)" != 0 ]; then \
echo no 1>&2 ; \
exit 1 ; \
fi
-GITTAG = $(shell bash -c "echo $$(($(VERSION) + 1))")
+GITTAG = $(shell printf '%s\n' $$(( $(VERSION) + 1 )))
efivar.spec : | Makefile src/include/version.mk
diff --git a/src/include/defaults.mk b/src/include/defaults.mk
index 4da0cde..40f4d51 100644
--- a/src/include/defaults.mk
+++ b/src/include/defaults.mk
@@ -11,13 +11,15 @@ PKGS ?=
CROSS_COMPILE ?=
COMPILER ?= gcc
-ifeq ($(origin CC),command line)
-override COMPILER := $(CC)
-override CC := $(CROSS_COMPILE)$(COMPILER)
-endif
+
+tool-if-exists = $(strip $(shell command -v $(1) >/dev/null 2>&1 && printf '%s' '$(1)'))
+cc-command = $(firstword $(filter-out ccache sccache distcc,$(foreach word,$(1),$(notdir $(word)))))
+cc-name = $(patsubst $(CROSS_COMPILE)%,%,$(call cc-command,$(1)))
+
$(call set-if-undefined,CC,$(CROSS_COMPILE)$(COMPILER))
+override COMPILER := $(or $(call cc-name,$(CC)),$(COMPILER))
$(call set-if-undefined,CCLD,$(CC))
-$(call set-if-undefined,HOSTCC,$(COMPILER))
+$(call set-if-undefined,HOSTCC,$(call cc-name,$(CC)))
$(call set-if-undefined,HOSTCCLD,$(HOSTCC))
# temporary, see https://sourceware.org/bugzilla/show_bug.cgi?id=28264
@@ -107,11 +109,11 @@ override HOST_LDFLAGS = $(HOST_CFLAGS) -L. \
$(call pkg-config-ccldflags)
override HOST_CCLDFLAGS = $(HOST_LDFLAGS)
-PKG_CONFIG ?= $(shell if [ -e "$$(env $(CROSS_COMPILE)pkg-config 2>&1)" ]; then echo $(CROSS_COMPILE)pkg-config ; else echo pkg-config ; fi)
+PKG_CONFIG ?= $(or $(call tool-if-exists,$(CROSS_COMPILE)pkg-config),pkg-config)
INSTALL ?= install
-AR := $(CROSS_COMPILE)$(COMPILER)-ar
-NM := $(CROSS_COMPILE)$(COMPILER)-nm
-RANLIB := $(CROSS_COMPILE)$(COMPILER)-ranlib
+$(call set-if-undefined,AR,$(or $(call tool-if-exists,$(CROSS_COMPILE)$(call cc-name,$(CC))-ar),$(if $(findstring clang,$(call cc-name,$(CC))),$(call tool-if-exists,$(CROSS_COMPILE)llvm-ar),$(call tool-if-exists,$(CROSS_COMPILE)gcc-ar)),$(call tool-if-exists,$(CROSS_COMPILE)ar),ar))
+$(call set-if-undefined,NM,$(or $(call tool-if-exists,$(CROSS_COMPILE)$(call cc-name,$(CC))-nm),$(if $(findstring clang,$(call cc-name,$(CC))),$(call tool-if-exists,$(CROSS_COMPILE)llvm-nm),$(call tool-if-exists,$(CROSS_COMPILE)gcc-nm)),$(call tool-if-exists,$(CROSS_COMPILE)nm),nm))
+$(call set-if-undefined,RANLIB,$(or $(call tool-if-exists,$(CROSS_COMPILE)$(call cc-name,$(CC))-ranlib),$(if $(findstring clang,$(call cc-name,$(CC))),$(call tool-if-exists,$(CROSS_COMPILE)llvm-ranlib),$(call tool-if-exists,$(CROSS_COMPILE)gcc-ranlib)),$(call tool-if-exists,$(CROSS_COMPILE)ranlib),ranlib))
ABIDW := abidw
ABIDIFF := abidiff
MANDOC := mandoc
diff --git a/src/include/coverity.mk b/src/include/coverity.mk
index 2e7024b..f852097 100644
--- a/src/include/coverity.mk
+++ b/src/include/coverity.mk
@@ -4,11 +4,11 @@ COV_URL=$(call get-config,coverity.url)
COV_FILE=$(NAME)-coverity-$(VERSION)-$(COMMIT_ID).tar.bz2
cov-int : clean
- cov-build --dir cov-int make all
+ cov-build --dir cov-int $(MAKE) all
cov-clean :
@rm -vf $(NAME)-coverity-*.tar.*
- @if [[ -d cov-int ]]; then rm -rf cov-int && echo "removed 'cov-int'"; fi
+ @if [ -d cov-int ]; then rm -rf cov-int && echo "removed 'cov-int'"; fi
cov-file : | $(COV_FILE)
@@ -16,9 +16,9 @@ $(COV_FILE) : cov-int
tar caf $@ cov-int
cov-upload :
- @if [[ -n "$(COV_URL)" ]] && \
- [[ -n "$(COV_TOKEN)" ]] && \
- [[ -n "$(COV_EMAIL)" ]] ; \
+ @if [ -n "$(COV_URL)" ] && \
+ [ -n "$(COV_TOKEN)" ] && \
+ [ -n "$(COV_EMAIL)" ] ; \
then \
echo curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \
curl --form token=$(COV_TOKEN) --form email="$(COV_EMAIL)" --form file=@"$(COV_FILE)" --form version=$(VERSION).1 --form description="$(COMMIT_ID)" "$(COV_URL)" ; \
@@ -31,7 +31,7 @@ coverity : cov-file cov-upload
clean : | cov-clean
-COV_BUILD ?= $(shell x=$$(which --skip-alias --skip-functions cov-build 2>/dev/null) ; [ -n "$$x" ] && echo 1)
+COV_BUILD ?= $(shell command -v cov-build >/dev/null 2>&1 && printf '%s' 1)
ifeq ($(COV_BUILD),)
COV_BUILD_ERROR = $(error cov-build not found)
endif
diff --git a/src/include/scan-build.mk b/src/include/scan-build.mk
index 19da90c..125c85c 100644
--- a/src/include/scan-build.mk
+++ b/src/include/scan-build.mk
@@ -1,4 +1,4 @@
-SCAN_BUILD ?= $(shell x=$$(which --skip-alias --skip-functions scan-build 2>/dev/null) ; [ -n "$$x" ] && echo 1)
+SCAN_BUILD ?= $(shell command -v scan-build >/dev/null 2>&1 && printf '%s' 1)
ifeq ($(SCAN_BUILD),)
SCAN_BUILD_ERROR = $(error scan-build not found)
endif
@@ -6,12 +6,12 @@ endif
scan-test : ; $(SCAN_BUILD_ERROR)
scan-clean : clean
- @if [[ -d scan-results ]]; then rm -rf scan-results && echo "removed 'scan-results'"; fi
+ @if [ -d scan-results ]; then rm -rf scan-results && echo "removed 'scan-results'"; fi
scan-build : | scan-test
scan-build : clean
$(MAKE) -C src makeguids
- scan-build -o scan-results make $(DASHJ) CC=clang all
+ scan-build -o scan-results $(MAKE) $(DASHJ) CC=clang all
scan-build-all: | scan-build
scan : | scan-build
@@ -0,0 +1,162 @@
Submitted by: Bruce Dubbs <bdubbs@linuxfromscratch.org>
Date: 2026-02-23
Initial Package Version: 39
Upstream Status: Submitted
Origin: https://github.com/rhboot/efivar/pull/292/changes/12060aa29dac86169b0ed8929e33e10644917dba
Description: Allows to build efivar-39 with glibc-2.43
From 12060aa29dac86169b0ed8929e33e10644917dba Mon Sep 17 00:00:00 2001
From: Xi Ruoyao <xry111@xry111.site>
Date: Sat, 14 Feb 2026 02:06:51 +0800
Subject: [PATCH] Fix build failure with glibc 2.43
In glibc 2.43, some _Generic macros have been added to preserve the
constness of pointers. They are following C23 but also available when
_GNU_SOURCE is defined (as we are doing). The preserved constness can
trigger some -Wdiscarded-qualifiers warnings, which are turned to errors
with -Werror (that we enable by default).
The find_parent_devpath function really modifies the buffer so we have
to drop the const qualifer for it. For other cases, simply add the
missed const qualifer.
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
---
src/guid.c | 12 ++++++------
src/linux-acpi-root.c | 2 +-
src/linux-ata.c | 4 ++--
src/linux-i2o.c | 2 +-
src/linux.c | 2 +-
src/linux.h | 2 +-
6 files changed, 12 insertions(+), 12 deletions(-)
diff --git a/src/guid.c b/src/guid.c
index f999fc4e..1f4a6605 100644
--- a/src/guid.c
+++ b/src/guid.c
@@ -78,13 +78,13 @@ cmpnamep(const void *p1, const void *p2)
}
static int NONNULL(1, 2)
-_get_common_guidname(const efi_guid_t *guid, struct efivar_guidname **result)
+_get_common_guidname(const efi_guid_t *guid, const struct efivar_guidname **result)
{
struct efivar_guidname key;
memset(&key, '\0', sizeof(key));
memcpy(&key.guid, guid, sizeof(*guid));
- struct efivar_guidname *tmp;
+ const struct efivar_guidname *tmp;
tmp = bsearch(&key,
&efi_well_known_guids[0],
efi_n_well_known_guids,
@@ -104,7 +104,7 @@ _get_common_guidname(const efi_guid_t *guid, struct efivar_guidname **result)
int NONNULL(1, 2) PUBLIC
efi_guid_to_name(efi_guid_t *guid, char **name)
{
- struct efivar_guidname *result;
+ const struct efivar_guidname *result;
int rc = _get_common_guidname(guid, &result);
if (rc >= 0) {
*name = strndup(result->name, sizeof(result->name) -1);
@@ -119,7 +119,7 @@ efi_guid_to_name(efi_guid_t *guid, char **name)
int NONNULL(1, 2) PUBLIC
efi_guid_to_symbol(efi_guid_t *guid, char **symbol)
{
- struct efivar_guidname *result;
+ const struct efivar_guidname *result;
int rc = _get_common_guidname(guid, &result);
if (rc >= 0) {
*symbol = strndup(result->symbol, sizeof(result->symbol) -1);
@@ -133,7 +133,7 @@ efi_guid_to_symbol(efi_guid_t *guid, char **symbol)
int NONNULL(1) PUBLIC
efi_guid_to_id_guid(const efi_guid_t *guid, char **sp)
{
- struct efivar_guidname *result = NULL;
+ const struct efivar_guidname *result = NULL;
char *ret = NULL;
int rc;
@@ -201,7 +201,7 @@ efi_name_to_guid(const char *name, efi_guid_t *guid)
key.name[sizeof(key.name) - 1] = '\0';
- struct efivar_guidname *result;
+ const struct efivar_guidname *result;
result = bsearch(&key,
&efi_well_known_names[0],
efi_n_well_known_names,
diff --git a/src/linux-acpi-root.c b/src/linux-acpi-root.c
index c4c00e7d..a45f0c9d 100644
--- a/src/linux-acpi-root.c
+++ b/src/linux-acpi-root.c
@@ -35,7 +35,7 @@ parse_acpi_root(struct device *dev, const char *path, const char *root UNUSED)
uint16_t pad0;
uint8_t pad1;
char *acpi_header = NULL;
- char *colon;
+ const char *colon;
debug("entry");
diff --git a/src/linux-ata.c b/src/linux-ata.c
index 064a4247..d8c98060 100644
--- a/src/linux-ata.c
+++ b/src/linux-ata.c
@@ -95,7 +95,7 @@ parse_ata(struct device *dev, const char *path, const char *root UNUSED)
return 0;
}
- char *host = strstr(path, "/host");
+ const char *host = strstr(path, "/host");
if (!host)
return -1;
@@ -113,7 +113,7 @@ parse_ata(struct device *dev, const char *path, const char *root UNUSED)
dev->ata_info.scsi_target = scsi_target;
dev->ata_info.scsi_lun = scsi_lun;
- char *block = strstr(current, "/block/");
+ const char *block = strstr(current, "/block/");
if (block)
current += block + 1 - current;
debug("current:'%s' sz:%zd", current, current - path);
diff --git a/src/linux-i2o.c b/src/linux-i2o.c
index 3aea7d35..2cd1b48a 100644
--- a/src/linux-i2o.c
+++ b/src/linux-i2o.c
@@ -32,7 +32,7 @@ parse_i2o(struct device *dev, const char *current, const char *root UNUSED)
return 0;
}
- char *block = strstr(current, "/block/");
+ const char *block = strstr(current, "/block/");
ssize_t sz = block ? block + 1 - current : -1;
debug("current:'%s' sz:%zd", current, sz);
return sz;
diff --git a/src/linux.c b/src/linux.c
index 4344986e..a0a04079 100644
--- a/src/linux.c
+++ b/src/linux.c
@@ -31,7 +31,7 @@
#include "efiboot.h"
int HIDDEN
-find_parent_devpath(const char * const child, char **parent)
+find_parent_devpath(char * const child, char **parent)
{
int ret;
char *node;
diff --git a/src/linux.h b/src/linux.h
index 3489e9c1..de3b5b01 100644
--- a/src/linux.h
+++ b/src/linux.h
@@ -161,7 +161,7 @@ extern int HIDDEN eb_nvme_ns_id(int fd, uint32_t *ns_id);
int HIDDEN get_sector_size(int filedes);
-extern int HIDDEN find_parent_devpath(const char * const child,
+extern int HIDDEN find_parent_devpath(char * const child,
char **parent);
extern ssize_t HIDDEN make_mac_path(uint8_t *buf, ssize_t size,
+30
View File
@@ -0,0 +1,30 @@
[build]
type = "makefile"
[build.flags]
makefile_commands = ["make ENABLE_DOCS=0"]
makefile_install_commands = [
"make install DESTDIR=$DESTDIR ENABLE_DOCS=0 LIBDIR=/usr/lib",
"install -Dvm644 docs/efivar.1 $DESTDIR/usr/share/man/man1/efivar.1",
"install -d $DESTDIR/usr/share/man/man3 && install -vm644 docs/*.3 $DESTDIR/usr/share/man/man3/"
]
skip_tests = true
[dependencies]
runtime = ["glibc"]
[[manual_sources]]
files = [ "efivar-39-upstream_fixes-1.patch", "efivar-39-posixify-build.patch" ]
[package]
description = "tools and libraries to manipulate EFI variables"
homepage = "https://github.com/rhboot/efivar"
license = "LGPL-2.1-or-later"
name = "efivar"
version = "39"
[[source]]
extract_dir = "$name-$version"
patches = [ "efivar-39-upstream_fixes-1.patch", "efivar-39-posixify-build.patch" ]
sha256 = "c9edd15f2eeeea63232f3e669a48e992c7be9aff57ee22672ac31f5eca1609a6"
url = "https://github.com/rhboot/efivar/archive/$version/efivar-$version.tar.gz"