diff --git a/files/0001-Exclude-unwanted-paths-from-libdirs-for-initrd-creat.patch b/files/0001-Exclude-unwanted-paths-from-libdirs-for-initrd-creat.patch new file mode 100644 --- /dev/null +++ b/files/0001-Exclude-unwanted-paths-from-libdirs-for-initrd-creat.patch @@ -0,0 +1,216 @@ +From 49c08094f81d684de71f5b61bf4a381cdf7b2c1e Mon Sep 17 00:00:00 2001 +From: Peter O'Connor +Date: Sun, 3 Jun 2018 16:06:19 +1000 +Subject: [PATCH] Exclude unwanted paths from libdirs for initrd creation + +libdirs aregenerated from generic libs (/lib[64] /usr/lib[64]) but uses +ldconfig to detect further paths. In Solus, this means 3 extra directories +that are unwanted can be detected: + +- lib32 paths can be installed outside of solbuild +- /usr/lib[64]/fakeroot inside solbuild +- /usr/lib[64]/haswell once avx2 libs are included in builds + +By adding usr/lib32, fakeroot and haswell to be removed from the search, these +3 directories will no longer be used to search for library paths in initrd +creation excluding duplicate unused libraries, keeping the initrd as small +and compatible as possible. + +"haswell" and "haswell/avx512" from lookup paths as we only want a single +version for each library (one that works on all systems). + +Signed-off-by: Peter O'Connor +--- + dracut-functions.sh | 2 +- + install/dracut-install.c | 81 +++++++++++++++++++++++++++++----------- + 2 files changed, 60 insertions(+), 23 deletions(-) + +diff --git a/dracut-functions.sh b/dracut-functions.sh +index ccc4897..bd3f8df 100755 +--- a/dracut-functions.sh ++++ b/dracut-functions.sh +@@ -52,7 +52,7 @@ find_binary() { + + ldconfig_paths() + { +- ldconfig -pN 2>/dev/null | grep -E -v '/(lib|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq ++ ldconfig -pN 2>/dev/null | grep -E -v '/(libfakeroot|haswell|lib|lib32|lib64|usr/lib|usr/lib64)/[^/]*$' | sed -n 's,.* => \(.*\)/.*,\1,p' | sort | uniq + } + + # Version comparision function. Assumes Linux style version scheme. +diff --git a/install/dracut-install.c b/install/dracut-install.c +index 4b2ff89..bb034ec 100644 +--- a/install/dracut-install.c ++++ b/install/dracut-install.c +@@ -598,6 +598,43 @@ static bool check_hashmap(Hashmap *hm, const char *item) + + static int dracut_install(const char *src, const char *dst, bool isdir, bool resolvedeps, bool hashdst) + { ++ char *srctmp = NULL, *srcn = NULL; ++ char *dsttmp = NULL, *dstn = NULL; ++ ++ void * strip_avx2(const char *fullpath, const char *avxpath) ++ { ++ int length; ++ char *spntr = NULL, *fpath = NULL, *apath = NULL; ++ char npath[120] = "/usr/lib64/"; ++ ++ fpath = strdup(fullpath); ++ apath = strdup(avxpath); ++ ++ if(strstr(fpath, apath)) ++ { ++ // Get pointer to found path ++ char *qpntr = strstr(fpath, apath); ++ ++ // Remove leading path from the pointer ++ length = strlen(apath); ++ spntr = strdup(qpntr + length); ++ ++ // Join path to /usr/lib64 (dracut default) ++ strcat(npath, spntr); ++ char *resultpath = strdup(npath); ++ return resultpath; ++ } ++ return fpath; ++ } ++ srctmp = strip_avx2(src, "haswell/avx512_1/"); ++ srcn = strip_avx2(srctmp, "haswell/"); ++ dsttmp = strip_avx2(dst, "haswell/avx512_1/"); ++ dstn = strip_avx2(dsttmp, "haswell/"); ++ printf("%s\n", src); ++ printf("%s\n", srcn); ++ printf("%s\n", dst); ++ printf("%s\n", dstn); ++ + struct stat sb, db; + _cleanup_free_ char *fulldstpath = NULL; + _cleanup_free_ char *fulldstdir = NULL; +@@ -605,35 +642,35 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + bool src_exists = true; + char *i = NULL; + +- log_debug("dracut_install('%s', '%s')", src, dst); ++ log_debug("dracut_install('%s', '%s')", srcn, dstn); + +- if (check_hashmap(items_failed, src)) { +- log_debug("hash hit items_failed for '%s'", src); ++ if (check_hashmap(items_failed, srcn)) { ++ log_debug("hash hit items_failed for '%s'", srcn); + return 1; + } + +- if (hashdst && check_hashmap(items, dst)) { +- log_debug("hash hit items for '%s'", dst); ++ if (hashdst && check_hashmap(items, dstn)) { ++ log_debug("hash hit items for '%s'", dstn); + return 0; + } + +- if (lstat(src, &sb) < 0) { ++ if (lstat(srcn, &sb) < 0) { + src_exists = false; + if (!isdir) { +- i = strdup(src); ++ i = strdup(srcn); + hashmap_put(items_failed, i, i); +- /* src does not exist */ ++ /* srcn does not exist */ + return 1; + } + } + +- i = strdup(dst); ++ i = strdup(dstn); + if (!i) + return -ENOMEM; + + hashmap_put(items, i, i); + +- ret = asprintf(&fulldstpath, "%s/%s", destrootdir, (dst[0]=='/' ? (dst+1) : dst)); ++ ret = asprintf(&fulldstpath, "%s/%s", destrootdir, (dstn[0]=='/' ? (dstn+1) : dstn)); + if (ret < 0) { + log_error("Out of memory!"); + exit(EXIT_FAILURE); +@@ -649,11 +686,11 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + if (ret == 0) { + if (resolvedeps && S_ISREG(sb.st_mode) && (sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) { + log_debug("'%s' already exists, but checking for any deps", fulldstpath); +- ret = resolve_deps(src); ++ ret = resolve_deps(srcn); + } else + log_debug("'%s' already exists", fulldstpath); + +- /* dst does already exist */ ++ /* dstn does already exist */ + return ret; + } + +@@ -672,7 +709,7 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + } + /* create destination directory */ + log_debug("dest dir '%s' does not exist", fulldstdir); +- dname = strdup(dst); ++ dname = strdup(dstn); + if (!dname) + return 1; + +@@ -691,7 +728,7 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + return ret; + } + +- /* ready to install src */ ++ /* ready to install srcn */ + + if (S_ISDIR(sb.st_mode)) { + log_info("mkdir '%s'", fulldstpath); +@@ -702,7 +739,7 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + if (S_ISLNK(sb.st_mode)) { + _cleanup_free_ char *abspath = NULL; + +- abspath = realpath(src, NULL); ++ abspath = realpath(srcn, NULL); + + if (abspath == NULL) + return 1; +@@ -731,7 +768,7 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + + if (arg_hmac) { + /* copy .hmac files also */ +- hmac_install(src, dst, NULL); ++ hmac_install(srcn, dstn, NULL); + } + + return 0; +@@ -739,22 +776,22 @@ static int dracut_install(const char *src, const char *dst, bool isdir, bool res + + if (sb.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { + if (resolvedeps) +- ret += resolve_deps(src); ++ ret += resolve_deps(srcn); + if (arg_hmac) { + /* copy .hmac files also */ +- hmac_install(src, dst, NULL); ++ hmac_install(srcn, dstn, NULL); + } + } + + log_debug("dracut_install ret = %d", ret); +- log_info("cp '%s' '%s'", src, fulldstpath); ++ log_info("cp '%s' '%s'", srcn, fulldstpath); + + if (arg_hostonly && !arg_module) +- mark_hostonly(dst); ++ mark_hostonly(dstn); + +- ret += cp(src, fulldstpath); ++ ret += cp(srcn, fulldstpath); + if (ret == 0 && logfile_f) +- dracut_log_cp(src); ++ dracut_log_cp(srcn); + + log_debug("dracut_install ret = %d", ret); + +-- +2.18.0 + diff --git a/files/series b/files/series --- a/files/series +++ b/files/series @@ -1,3 +1,4 @@ 0001-Support-stateless-glibc-ldconfig-configuration.patch 0002-multipath-Use-stateless-configuration-for-non-host-o.patch 0003-Support-an-alternative-bash-build-than-the-default.patch +0001-Exclude-unwanted-paths-from-libdirs-for-initrd-creat.patch diff --git a/package.yml b/package.yml --- a/package.yml +++ b/package.yml @@ -1,6 +1,6 @@ name : dracut version : '047' -release : 40 +release : 41 source : - https://www.kernel.org/pub/linux/utils/boot/dracut/dracut-047.tar.xz : b0afd3bdd886b2f756743c91a00a155da9df0644625b1c565c3d5ef78cd76ab2 homepage : http://dracut.wiki.kernel.org/index.php/Main_Page diff --git a/pspec_x86_64.xml b/pspec_x86_64.xml --- a/pspec_x86_64.xml +++ b/pspec_x86_64.xml @@ -3,8 +3,8 @@ dracut http://dracut.wiki.kernel.org/index.php/Main_Page - daper - david@daper.email + Peter O'Connor + peter@solus-project.com GPL-2.0 system.boot @@ -22,7 +22,10 @@ /etc/dracut.conf /etc/dracut.conf.d - /usr/bin + /usr/bin/dracut + /usr/bin/dracut-catimages + /usr/bin/lsinitrd + /usr/bin/mkinitrd /usr/lib/kernel/install.d/50-dracut.install /usr/lib/kernel/install.d/51-dracut-rescue.install /usr/lib64/dracut/dracut-functions @@ -332,17 +335,34 @@ /usr/lib64/dracut/skipcpio /usr/share/bash-completion/completions/dracut /usr/share/bash-completion/completions/lsinitrd - /usr/share/man + /usr/share/man/man1/lsinitrd.1 + /usr/share/man/man5/dracut.conf.5 + /usr/share/man/man7/dracut.bootup.7 + /usr/share/man/man7/dracut.cmdline.7 + /usr/share/man/man7/dracut.kernel.7 + /usr/share/man/man7/dracut.modules.7 + /usr/share/man/man8/dracut-catimages.8 + /usr/share/man/man8/dracut-cmdline.service.8 + /usr/share/man/man8/dracut-initqueue.service.8 + /usr/share/man/man8/dracut-mount.service.8 + /usr/share/man/man8/dracut-pre-mount.service.8 + /usr/share/man/man8/dracut-pre-pivot.service.8 + /usr/share/man/man8/dracut-pre-trigger.service.8 + /usr/share/man/man8/dracut-pre-udev.service.8 + /usr/share/man/man8/dracut-shutdown.service.8 + /usr/share/man/man8/dracut.8 + /usr/share/man/man8/mkinitrd-suse.8 + /usr/share/man/man8/mkinitrd.8 /usr/share/pkgconfig/dracut.pc - - 2018-02-21 + + 2018-08-03 047 Packaging update - daper - david@daper.email + Peter O'Connor + peter@solus-project.com \ No newline at end of file