mirror of
https://github.com/flatcar/scripts.git
synced 2026-05-05 12:16:41 +02:00
sys-kernel/dracut: Sync with Gentoo
It's from Gentoo commit d041ff2a5eaf823fc98cb86bf8c6a27adf26258e. Signed-off-by: Flatcar Buildbot <buildbot@flatcar-linux.org>
This commit is contained in:
parent
38171642fe
commit
6d4db8eae0
@ -1,4 +1,4 @@
|
||||
DIST dracut-060_pre20240104.tar.gz 499965 BLAKE2B 935e0e5da348426d69c6dab6b91078f126cadd9ffc6a32378e79cd93b1dbadff35899efc3786fc12bf5a6741843d3637b0c98cc71fe4a96a8caf053ae887bac3 SHA512 f7818265f082e9c05ebb81a91b67fb9b1d3bf8b2433b7e6ea9be6bee43d28cd1ee48577648e1d9b3729c17608b028d294c13bf5d4db4cc5a18e3b007eb2cd67e
|
||||
DIST dracut-103.tar.gz 567713 BLAKE2B 7781c0b7fc83a2c0c461f6398687e053226b489fb5405b3132b30d8e7a4f3cea2bb73aa0fe6e4c4b27187d6270ba623f403916ec38025a912930ae347a7e25ce SHA512 ba0dbefbcbecb09c44ce240664bc4f4ee25dfb8be7bc060028ae3b1ccf7d70410491c105e64fcef3d6f44d2794cb6162bcea9404125906be46bf3dff098e0277
|
||||
DIST dracut-106.tar.gz 527743 BLAKE2B 837621da329500b88b0c81a724990702a9f4e816a4818c26622b2bc5e3885c908f0bbba682a262f967d9a08a912cfd63a33270143560a30e3d067dc4217c5262 SHA512 ab17f9440129e2db7c2902115459309132ce7f7b29bbb3172002b7a8ea8ab54799d62d89fbf3f84581a5c14196f6754d33669b583b9d758ab4686a3443a3c4ad
|
||||
DIST dracut-107.tar.gz 536435 BLAKE2B 8ff85073853f874b31b659b73abfafe27bb0da59c8e77039bd1739d266dffe26616f6c96eceb2cb36319801d0fb3df53ea4153bf426f081e7e5b73c11522018b SHA512 3f8e79fbfd40c0d384e856cbabe9257c5cbafbb4a3fe4b56da27832c36844dbbf9c59f12155d165d9343bc7341eda2b90c215148eb46ae873c219fbc93992944
|
||||
DIST dracut-108.tar.gz 552724 BLAKE2B fa5efd4039be8d2d30564a0768d2dec8c3d72b3721391d3a02bde8445cd7a5766d4b119594ebbca86dbd59bd71b64353febaaa7e2257f02d0075333dc29e9047 SHA512 ed06844b65003c1f75373309dbdc10a3036958f413b05b608510142fa78bb34dd9fb1e622242b02b2e9e4063bfa916fd755f5131a77fb3249f77d3f08eca2283
|
||||
|
||||
@ -54,7 +54,10 @@ DEPEND="
|
||||
"
|
||||
|
||||
BDEPEND="
|
||||
app-text/asciidoc
|
||||
|| (
|
||||
dev-ruby/asciidoctor
|
||||
app-text/asciidoc
|
||||
)
|
||||
app-text/docbook-xml-dtd:4.5
|
||||
>=app-text/docbook-xsl-stylesheets-1.75.2
|
||||
>=dev-libs/libxslt-1.1.26
|
||||
@ -99,9 +102,13 @@ QA_MULTILIB_PATHS="usr/lib/dracut/.*"
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/gentoo-ldconfig-paths-r1.patch
|
||||
# Gentoo specific acct-user and acct-group conf adjustments
|
||||
"${FILESDIR}"/${PN}-106-acct-user-group-gentoo.patch
|
||||
# https://github.com/dracut-ng/dracut-ng/pull/1322
|
||||
"${FILESDIR}"/${PN}-107-hostonly-regression-fix-1322.patch
|
||||
"${FILESDIR}"/${PN}-108-acct-user-group-gentoo.patch
|
||||
# https://github.com/dracut-ng/dracut-ng/pull/1447
|
||||
"${FILESDIR}"/${PN}-108-respect-objcopy-and-objdump.patch
|
||||
# https://github.com/dracut-ng/dracut-ng/pull/1538
|
||||
"${FILESDIR}"/${PN}-108-elf-parsing-fixes.patch
|
||||
# https://github.com/dracut-ng/dracut-ng/pull/1122#issuecomment-3192110686
|
||||
"${FILESDIR}"/${PN}-108-disable-ukify-magic.patch
|
||||
)
|
||||
|
||||
pkg_setup() {
|
||||
@ -117,6 +124,10 @@ src_configure() {
|
||||
--disable-dracut-cpio
|
||||
)
|
||||
|
||||
if ! has_version dev-ruby/asciidoctor; then
|
||||
myconf+=( --disable-asciidoctor )
|
||||
fi
|
||||
|
||||
# this emulates what the build system would be doing without us
|
||||
append-cflags -D_FILE_OFFSET_BITS=64
|
||||
|
||||
@ -167,6 +178,9 @@ src_install() {
|
||||
exeinto /usr/lib/dracut
|
||||
doexe "src/dracut-cpio/$(cargo_target_dir)/dracut-cpio"
|
||||
fi
|
||||
|
||||
# Use our own from sys-kernel/installkernel[dracut]
|
||||
rm -r "${ED}/usr/lib/kernel" || die
|
||||
}
|
||||
|
||||
pkg_preinst() {
|
||||
@ -54,7 +54,10 @@ DEPEND="
|
||||
"
|
||||
|
||||
BDEPEND="
|
||||
app-text/asciidoc
|
||||
|| (
|
||||
dev-ruby/asciidoctor
|
||||
app-text/asciidoc
|
||||
)
|
||||
app-text/docbook-xml-dtd:4.5
|
||||
>=app-text/docbook-xsl-stylesheets-1.75.2
|
||||
>=dev-libs/libxslt-1.1.26
|
||||
@ -99,7 +102,7 @@ QA_MULTILIB_PATHS="usr/lib/dracut/.*"
|
||||
PATCHES=(
|
||||
"${FILESDIR}"/gentoo-ldconfig-paths-r1.patch
|
||||
# Gentoo specific acct-user and acct-group conf adjustments
|
||||
"${FILESDIR}"/${PN}-106-acct-user-group-gentoo.patch
|
||||
"${FILESDIR}"/${PN}-108-acct-user-group-gentoo.patch
|
||||
)
|
||||
|
||||
pkg_setup() {
|
||||
@ -115,6 +118,10 @@ src_configure() {
|
||||
--disable-dracut-cpio
|
||||
)
|
||||
|
||||
if ! has_version dev-ruby/asciidoctor; then
|
||||
myconf+=( --disable-asciidoctor )
|
||||
fi
|
||||
|
||||
# this emulates what the build system would be doing without us
|
||||
append-cflags -D_FILE_OFFSET_BITS=64
|
||||
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
diff --git a/modules.d/73tpm2-tss/module-setup.sh b/modules.d/73tpm2-tss/module-setup.sh
|
||||
index 4441f5528..4b5654d56 100755
|
||||
--- a/modules.d/73tpm2-tss/module-setup.sh
|
||||
+++ b/modules.d/73tpm2-tss/module-setup.sh
|
||||
@@ -30,7 +30,7 @@ installkernel() {
|
||||
|
||||
# Install the required file(s) and directories for the module in the initramfs.
|
||||
install() {
|
||||
- inst_sysusers tpm2-tss.conf
|
||||
+ inst_sysusers tss.conf
|
||||
|
||||
inst_multiple -o \
|
||||
"$tmpfilesdir"/tpm2-tss-fapi.conf \
|
||||
@ -0,0 +1,13 @@
|
||||
diff --git a/dracut.sh b/dracut.sh
|
||||
index e6d2d9f25..792ab3d34 100755
|
||||
--- a/dracut.sh
|
||||
+++ b/dracut.sh
|
||||
@@ -2732,7 +2732,7 @@ if [[ $uefi == yes ]]; then
|
||||
cp "$uefi_stub" "$tmp_uefi_stub"
|
||||
"${OBJCOPY:-objcopy}" --remove-section .sbat "$tmp_uefi_stub" &> /dev/null
|
||||
|
||||
- if command -v ukify &> /dev/null; then
|
||||
+ if false; then
|
||||
dinfo "*** Using ukify to create UKI ***"
|
||||
if ukify build \
|
||||
--linux "$kernel_image" \
|
||||
@ -0,0 +1,332 @@
|
||||
From 88e375f89c11c989737f6d00b0cfe6309f7447d7 Mon Sep 17 00:00:00 2001
|
||||
From: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
Date: Fri, 8 Aug 2025 12:50:12 +0100
|
||||
Subject: [PATCH 1/3] fix(dracut-install): the -n short option for --dry-run
|
||||
|
||||
I forgot to update the getopt call.
|
||||
|
||||
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
--- a/src/install/dracut-install.c
|
||||
+++ b/src/install/dracut-install.c
|
||||
@@ -1638,7 +1638,7 @@ static int parse_argv(int argc, char *argv[])
|
||||
{NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
- while ((c = getopt_long(argc, argv, "madfhlL:oD:Hr:Rp:P:s:S:N:v", options, NULL)) != -1) {
|
||||
+ while ((c = getopt_long(argc, argv, "madfhlL:oD:Hr:Rp:P:s:S:N:vn", options, NULL)) != -1) {
|
||||
switch (c) {
|
||||
case ARG_VERSION:
|
||||
puts(PROGRAM_VERSION_STRING);
|
||||
--
|
||||
2.50.1
|
||||
|
||||
|
||||
From 06e95cc602d0c6df99f4a54b2ade7deb59343a40 Mon Sep 17 00:00:00 2001
|
||||
From: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
Date: Fri, 8 Aug 2025 12:52:23 +0100
|
||||
Subject: [PATCH 2/3] fix(dracut-install): the RUNPATH expansion returning
|
||||
empty strings
|
||||
|
||||
The input was not initially copied into the result, so the result would
|
||||
start with a null pointer and be treated as an empty string. Expansion
|
||||
will not occur in most cases, leading to a straight copy of input being
|
||||
returned, so just do that in the first place.
|
||||
|
||||
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
--- a/src/install/dracut-install.c
|
||||
+++ b/src/install/dracut-install.c
|
||||
@@ -770,7 +770,7 @@ static char *search_via_ldconf(const char *conf_pattern, const char *soname, con
|
||||
expands to the directory of the given src path. $LIB expands to lib if
|
||||
match64 is NULL or lib64 otherwise. Returns a newly allocated string even if
|
||||
no expansion was necessary. */
|
||||
-static char *expand_runpath(char *input, const char *src, const Elf64_Ehdr *match64)
|
||||
+static char *expand_runpath(const char *input, const char *src, const Elf64_Ehdr *match64)
|
||||
{
|
||||
regex_t regex;
|
||||
regmatch_t rmatch[3]; /* 0: full match, 1: without brackets, 2: with brackets */
|
||||
@@ -780,11 +780,15 @@ static char *expand_runpath(char *input, const char *src, const Elf64_Ehdr *matc
|
||||
return NULL;
|
||||
}
|
||||
|
||||
- char *result = NULL, *current = input;
|
||||
+ char *result = strdup(input);
|
||||
+ if (!result)
|
||||
+ goto oom;
|
||||
+
|
||||
+ const char *current = input;
|
||||
int offset = 0;
|
||||
|
||||
while (regexec(®ex, current + offset, 3, rmatch, 0) == 0) {
|
||||
- char *varname = NULL;
|
||||
+ const char *varname = NULL;
|
||||
_cleanup_free_ char *varval = NULL;
|
||||
size_t varname_len, varval_len;
|
||||
|
||||
@@ -823,7 +827,7 @@ static char *expand_runpath(char *input, const char *src, const Elf64_Ehdr *matc
|
||||
}
|
||||
|
||||
regfree(®ex);
|
||||
- return result ?: strdup(current);
|
||||
+ return result;
|
||||
|
||||
oom:
|
||||
log_error("Out of memory");
|
||||
--
|
||||
2.50.1
|
||||
|
||||
|
||||
From 9f2f306fa971ee00cee0ae307479bc8a8dbc5263 Mon Sep 17 00:00:00 2001
|
||||
From: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
Date: Fri, 8 Aug 2025 13:18:07 +0100
|
||||
Subject: [PATCH 3/3] fix(dracut-install): the handling of absolute paths in
|
||||
sonames
|
||||
|
||||
If the soname is an absolute path, expand it like the RUNPATH, and
|
||||
return it (with the sysroot) without further checks like glibc and musl
|
||||
do.
|
||||
|
||||
They also support relative paths, but we cannot feasibly support them.
|
||||
Such paths are relative to the current directory of the calling process
|
||||
at runtime, which we cannot know in this context.
|
||||
|
||||
This was observed with Neovim.
|
||||
|
||||
Bug: https://bugs.gentoo.org/961101
|
||||
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
--- a/src/install/dracut-install.c
|
||||
+++ b/src/install/dracut-install.c
|
||||
@@ -894,6 +894,21 @@ oom:
|
||||
static char *find_library(const char *soname, const char *src, size_t src_len, const Elf64_Ehdr *match64,
|
||||
const Elf32_Ehdr *match32)
|
||||
{
|
||||
+ /* If the soname is an absolute path, expand it like the RUNPATH, and
|
||||
+ return it (with the sysroot) without further checks like glibc and
|
||||
+ musl do. They also support relative paths, but we cannot feasibly
|
||||
+ support them. Such paths are relative to the current directory of the
|
||||
+ calling process at runtime, which we cannot know in this context. */
|
||||
+ if (soname[0] == '/') {
|
||||
+ _cleanup_free_ char *expanded = expand_runpath(soname, src, match64);
|
||||
+ if (!expanded)
|
||||
+ return NULL;
|
||||
+
|
||||
+ char *sysroot_expanded = NULL;
|
||||
+ _asprintf(&sysroot_expanded, "%s%s", sysrootdir ?: "", expanded);
|
||||
+ return sysroot_expanded;
|
||||
+ }
|
||||
+
|
||||
if (match64)
|
||||
FIND_LIBRARY_RUNPATH_FOR_BITS(64, match64);
|
||||
else if (match32)
|
||||
--
|
||||
2.50.1
|
||||
|
||||
|
||||
From 7186fa47fee7060a70fa6698748c4f4793edadf8 Mon Sep 17 00:00:00 2001
|
||||
From: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
Date: Mon, 11 Aug 2025 10:12:59 +0100
|
||||
Subject: [PATCH 4/6] fix(dracut-install): handling of multiple sonames in
|
||||
dlopen JSON
|
||||
|
||||
We should not try to install every library referenced in the soname
|
||||
array, only the first one present. The array is intended to be an
|
||||
ordered preference list.
|
||||
|
||||
Closes: https://github.com/dracut-ng/dracut-ng/issues/1552
|
||||
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
--- a/src/install/dracut-install.c
|
||||
+++ b/src/install/dracut-install.c
|
||||
@@ -951,9 +951,10 @@ static void resolve_deps_dlopen_parse_json(Hashmap *pdeps, Hashmap *deps, const
|
||||
for (size_t entry_idx = 0; entry_idx < sd_json_variant_elements(dlopen_json); entry_idx++) {
|
||||
sd_json_variant *entry = sd_json_variant_by_index(dlopen_json, entry_idx);
|
||||
sd_json_variant *feature_json = sd_json_variant_by_key(entry, "feature");
|
||||
+ const char *feature = NULL;
|
||||
|
||||
if (feature_json && sd_json_variant_is_string(feature_json)) {
|
||||
- const char *feature = sd_json_variant_string(feature_json);
|
||||
+ feature = sd_json_variant_string(feature_json);
|
||||
const char *name = src_soname ?: basename(fullsrcpath);
|
||||
|
||||
Iterator i;
|
||||
@@ -988,12 +989,15 @@ static void resolve_deps_dlopen_parse_json(Hashmap *pdeps, Hashmap *deps, const
|
||||
|
||||
const char *soname = sd_json_variant_string(soname_json);
|
||||
if (hashmap_get(pdeps, soname))
|
||||
- continue;
|
||||
+ goto skip;
|
||||
|
||||
char *library = find_library(soname, fullsrcpath, src_len, match64, match32);
|
||||
- if (!library || hashmap_put_strdup_key(deps, soname, library) < 0)
|
||||
- log_warning("WARNING: could not locate dlopen dependency %s requested by '%s'", soname, fullsrcpath);
|
||||
+ if (library && hashmap_put_strdup_key(deps, soname, library) == 0)
|
||||
+ goto skip;
|
||||
}
|
||||
+
|
||||
+ log_warning("WARNING: could not locate dlopen dependency for %s feature requested by '%s'", feature ?: "unnamed",
|
||||
+ fullsrcpath);
|
||||
skip:
|
||||
}
|
||||
}
|
||||
--
|
||||
2.50.1
|
||||
|
||||
|
||||
From 5c69be7d20af599cc6dd94d451a16d8639139bce Mon Sep 17 00:00:00 2001
|
||||
From: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
Date: Mon, 11 Aug 2025 10:51:51 +0100
|
||||
Subject: [PATCH 5/6] fix(dracut-install): cache resolve_deps calls for speed
|
||||
and less noise
|
||||
|
||||
The dlopen dependency failure warning was particularly noisy and likely
|
||||
to trigger. We were already caching the processed items in resolve_lazy,
|
||||
but resolve_deps recurses many times, so it was necessary to move the
|
||||
cache down a level. I didn't reuse "items" here because it would have
|
||||
clashed with its usage elsewhere.
|
||||
|
||||
I had to think about whether the cache would function correctly with
|
||||
changing values of pdeps. If a dependency is not found on the first
|
||||
attempt, it does not prevent its consumer from being installed, so it
|
||||
does not matter that it might be found via a RUNPATH on a subsequent
|
||||
attempt.
|
||||
|
||||
Closes: https://github.com/dracut-ng/dracut-ng/issues/1552
|
||||
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
--- a/src/install/dracut-install.c
|
||||
+++ b/src/install/dracut-install.c
|
||||
@@ -93,6 +93,7 @@ static Hashmap *items_failed = NULL;
|
||||
static Hashmap *modules_loaded = NULL;
|
||||
static Hashmap *modules_suppliers = NULL;
|
||||
static Hashmap *processed_suppliers = NULL;
|
||||
+static Hashmap *processed_deps = NULL;
|
||||
static Hashmap *modalias_to_kmod = NULL;
|
||||
static Hashmap *add_dlopen_features = NULL;
|
||||
static Hashmap *omit_dlopen_features = NULL;
|
||||
@@ -1132,13 +1133,21 @@ skip:
|
||||
Both ELF binaries and scripts with shebangs are handled. */
|
||||
static int resolve_deps(const char *src, Hashmap *pdeps)
|
||||
{
|
||||
- _cleanup_free_ char *fullsrcpath = NULL;
|
||||
-
|
||||
- fullsrcpath = get_real_file(src, true);
|
||||
+ char *fullsrcpath = get_real_file(src, true);
|
||||
log_debug("resolve_deps('%s') -> get_real_file('%s', true) = '%s'", src, src, fullsrcpath);
|
||||
if (!fullsrcpath)
|
||||
return 0;
|
||||
|
||||
+ switch (hashmap_put(processed_deps, fullsrcpath, fullsrcpath)) {
|
||||
+ case -EEXIST:
|
||||
+ free(fullsrcpath);
|
||||
+ return 0;
|
||||
+ case -ENOMEM:
|
||||
+ log_error("Out of memory");
|
||||
+ free(fullsrcpath);
|
||||
+ return -ENOMEM;
|
||||
+ }
|
||||
+
|
||||
_cleanup_close_ int fd = open(fullsrcpath, O_RDONLY | O_CLOEXEC);
|
||||
if (fd < 0) {
|
||||
log_error("ERROR: cannot open '%s': %m", fullsrcpath);
|
||||
@@ -1838,27 +1847,10 @@ static int parse_argv(int argc, char *argv[])
|
||||
static int resolve_lazy(int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
- size_t destrootdirlen = strlen(destrootdir);
|
||||
int ret = 0;
|
||||
- char *item;
|
||||
for (i = 0; i < argc; i++) {
|
||||
- const char *src = argv[i];
|
||||
- char *p = argv[i];
|
||||
-
|
||||
- log_debug("resolve_deps('%s')", src);
|
||||
-
|
||||
- if (strstr(src, destrootdir)) {
|
||||
- p = &argv[i][destrootdirlen];
|
||||
- }
|
||||
-
|
||||
- if (check_hashmap(items, p)) {
|
||||
- continue;
|
||||
- }
|
||||
-
|
||||
- item = strdup(p);
|
||||
- hashmap_put(items, item, item);
|
||||
-
|
||||
- ret += resolve_deps(src, NULL);
|
||||
+ log_debug("resolve_deps('%s')", argv[i]);
|
||||
+ ret += resolve_deps(argv[i], NULL);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -3008,13 +3000,14 @@ int main(int argc, char **argv)
|
||||
items = hashmap_new(string_hash_func, string_compare_func);
|
||||
items_failed = hashmap_new(string_hash_func, string_compare_func);
|
||||
processed_suppliers = hashmap_new(string_hash_func, string_compare_func);
|
||||
+ processed_deps = hashmap_new(string_hash_func, string_compare_func);
|
||||
modalias_to_kmod = hashmap_new(string_hash_func, string_compare_func);
|
||||
|
||||
dlopen_features[0] = add_dlopen_features = hashmap_new(string_hash_func, string_compare_func);
|
||||
dlopen_features[1] = omit_dlopen_features = hashmap_new(string_hash_func, string_compare_func);
|
||||
|
||||
if (!items || !items_failed || !processed_suppliers || !modules_loaded ||
|
||||
- !add_dlopen_features || !omit_dlopen_features) {
|
||||
+ !processed_deps || !add_dlopen_features || !omit_dlopen_features) {
|
||||
log_error("Out of memory");
|
||||
r = EXIT_FAILURE;
|
||||
goto finish1;
|
||||
@@ -3093,6 +3086,9 @@ finish2:
|
||||
while ((i = hashmap_steal_first(processed_suppliers)))
|
||||
item_free(i);
|
||||
|
||||
+ while ((i = hashmap_steal_first(processed_deps)))
|
||||
+ item_free(i);
|
||||
+
|
||||
for (size_t j = 0; j < 2; j++) {
|
||||
char ***array;
|
||||
Iterator it;
|
||||
@@ -3118,6 +3114,7 @@ finish2:
|
||||
hashmap_free(modules_loaded);
|
||||
hashmap_free(modules_suppliers);
|
||||
hashmap_free(processed_suppliers);
|
||||
+ hashmap_free(processed_deps);
|
||||
hashmap_free(modalias_to_kmod);
|
||||
|
||||
if (arg_mod_filter_path)
|
||||
--
|
||||
2.50.1
|
||||
|
||||
|
||||
From edb94a1b2c7d11a29eb055a28fa598e8fd317fe4 Mon Sep 17 00:00:00 2001
|
||||
From: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
Date: Tue, 12 Aug 2025 10:15:58 +0100
|
||||
Subject: [PATCH 6/6] fix(dracut-install): broken calls to mmap with 0 length
|
||||
|
||||
This results in an invalid argument error, so check for 0 length first.
|
||||
|
||||
Fixes: https://bugs.gentoo.org/961340
|
||||
Signed-off-by: James Le Cuirot <jlecuirot@microsoft.com>
|
||||
--- a/src/install/dracut-install.c
|
||||
+++ b/src/install/dracut-install.c
|
||||
@@ -632,7 +632,11 @@ static char *check_lib_match(const char *dirname, const char *basename, const ch
|
||||
if (fstat(fd, &sb) < 0)
|
||||
goto finish2;
|
||||
|
||||
- void *map = mmap(NULL, sb.st_size, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
+ size_t lib_len = sb.st_size;
|
||||
+ if (lib_len == 0)
|
||||
+ goto finish2;
|
||||
+
|
||||
+ void *map = mmap(NULL, lib_len, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (map == MAP_FAILED)
|
||||
goto finish2;
|
||||
|
||||
@@ -1161,6 +1165,9 @@ static int resolve_deps(const char *src, Hashmap *pdeps)
|
||||
}
|
||||
|
||||
size_t src_len = sb.st_size;
|
||||
+ if (src_len == 0)
|
||||
+ return 0;
|
||||
+
|
||||
void *map = mmap(NULL, src_len, PROT_READ, MAP_PRIVATE, fd, 0);
|
||||
if (map == MAP_FAILED) {
|
||||
log_error("ERROR: cannot mmap '%s': %m", fullsrcpath);
|
||||
--
|
||||
2.50.1
|
||||
|
||||
@ -0,0 +1,89 @@
|
||||
diff --git a/dracut-functions.sh b/dracut-functions.sh
|
||||
index 84a34fafd..617ccf91c 100755
|
||||
--- a/dracut-functions.sh
|
||||
+++ b/dracut-functions.sh
|
||||
@@ -1042,7 +1042,7 @@ get_dev_module() {
|
||||
pe_file_format() {
|
||||
if [[ $# -eq 1 ]]; then
|
||||
local magic
|
||||
- magic=$(objdump -p "$1" \
|
||||
+ magic=$("${OBJDUMP:-objdump}" -p "$1" \
|
||||
| awk '{if ($1 == "Magic"){print $2}}')
|
||||
# 010b (PE32), 020b (PE32+)
|
||||
[[ $magic == "020b" || $magic == "010b" ]] && return 0
|
||||
@@ -1055,7 +1055,7 @@ pe_get_header_data() {
|
||||
local data_header
|
||||
[[ $# -ne "2" ]] && return 1
|
||||
[[ $(pe_file_format "$1") -eq 1 ]] && return 1
|
||||
- data_header=$(objdump -p "$1" \
|
||||
+ data_header=$("${OBJDUMP:-objdump}" -p "$1" \
|
||||
| awk -v data="$2" '{if ($1 == data){print $2}}')
|
||||
echo "$data_header"
|
||||
}
|
||||
diff --git a/dracut.sh b/dracut.sh
|
||||
index 45373efb7..b53d72924 100755
|
||||
--- a/dracut.sh
|
||||
+++ b/dracut.sh
|
||||
@@ -1649,7 +1649,7 @@ if [[ ! $print_cmdline ]]; then
|
||||
fi
|
||||
|
||||
if [[ $uefi == yes ]]; then
|
||||
- if ! command -v objcopy &> /dev/null; then
|
||||
+ if ! command -v "${OBJCOPY:-objcopy}" &> /dev/null; then
|
||||
dfatal "Need 'objcopy' to create a UEFI executable"
|
||||
exit 1
|
||||
fi
|
||||
@@ -2638,7 +2638,7 @@ clean_sbat_string() {
|
||||
get_sbat_string() {
|
||||
local inp=$1
|
||||
local out=$uefi_outdir/$2
|
||||
- objcopy -O binary --only-section=.sbat "$inp" "$out"
|
||||
+ "${OBJCOPY:-objcopy}" -O binary --only-section=.sbat "$inp" "$out"
|
||||
clean_sbat_string "$out"
|
||||
}
|
||||
|
||||
@@ -2656,7 +2656,7 @@ if [[ $uefi == yes ]]; then
|
||||
fi
|
||||
fi
|
||||
|
||||
- offs=$(($(objdump -h "$uefi_stub" 2> /dev/null | awk 'NF==7 {size=$3;
|
||||
+ offs=$(($("${OBJDUMP:-objdump}" -h "$uefi_stub" 2> /dev/null | awk 'NF==7 {size=$3;
|
||||
offset=$4} END {print "16#"size" + 16#"offset}')))
|
||||
if [[ $offs -eq 0 ]]; then
|
||||
dfatal "Failed to get the size of $uefi_stub to create UEFI image file"
|
||||
@@ -2719,7 +2719,7 @@ if [[ $uefi == yes ]]; then
|
||||
|
||||
tmp_uefi_stub=$uefi_outdir/elf.stub
|
||||
cp "$uefi_stub" "$tmp_uefi_stub"
|
||||
- objcopy --remove-section .sbat "$tmp_uefi_stub" &> /dev/null
|
||||
+ "${OBJCOPY:-objcopy}" --remove-section .sbat "$tmp_uefi_stub" &> /dev/null
|
||||
|
||||
if command -v ukify &> /dev/null; then
|
||||
dinfo "*** Using ukify to create UKI ***"
|
||||
@@ -2749,7 +2749,7 @@ if [[ $uefi == yes ]]; then
|
||||
exit 1
|
||||
fi
|
||||
else
|
||||
- if objcopy \
|
||||
+ if "${OBJCOPY:-objcopy}" \
|
||||
${SOURCE_DATE_EPOCH:+--enable-deterministic-archives --preserve-dates} \
|
||||
${uefi_osrelease:+--add-section .osrel="$uefi_osrelease" --change-section-vma .osrel=$(printf 0x%x "$uefi_osrelease_offs")} \
|
||||
${uefi_cmdline:+--add-section .cmdline="$uefi_cmdline" --change-section-vma .cmdline=$(printf 0x%x "$uefi_cmdline_offs")} \
|
||||
diff --git a/lsinitrd.sh b/lsinitrd.sh
|
||||
index 86b2c5a67..fd0633dfa 100755
|
||||
--- a/lsinitrd.sh
|
||||
+++ b/lsinitrd.sh
|
||||
@@ -358,11 +358,11 @@ unpack_files() {
|
||||
|
||||
read -r -N 2 bin < "$image"
|
||||
if [ "$bin" = "MZ" ]; then
|
||||
- command -v objcopy > /dev/null || {
|
||||
+ command -v "${OBJCOPY:-objcopy}" > /dev/null || {
|
||||
echo "Need 'objcopy' to unpack an UEFI executable."
|
||||
exit 1
|
||||
}
|
||||
- objcopy \
|
||||
+ "${OBJCOPY:-objcopy}" \
|
||||
--dump-section .linux="$TMPDIR/vmlinuz" \
|
||||
--dump-section .initrd="$TMPDIR/initrd.img" \
|
||||
--dump-section .cmdline="$TMPDIR/cmdline.txt" \
|
||||
Loading…
x
Reference in New Issue
Block a user