1From 7cc1c8cfcc620dec284204be0ae4416fd9fed95d Mon Sep 17 00:00:00 2001 2From: Alexander Kanavin <alex.kanavin@gmail.com> 3Date: Fri, 20 Jan 2017 13:33:05 +0200 4Subject: [PATCH] Add support for prefixing /etc from RPM_ETCCONFIGDIR 5 environment variable 6 7This is needed so that rpm can pick up target-specific configuration 8from target rootfs instead of its own native sysroot. 9 10Upstream-Status: Inappropriate [oe-core specific] 11Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com> 12--- 13 lib/rpmrc.c | 18 +++++++++++++----- 14 1 file changed, 13 insertions(+), 5 deletions(-) 15 16diff --git a/lib/rpmrc.c b/lib/rpmrc.c 17index dc8d42aeb..3f2996850 100644 18--- a/lib/rpmrc.c 19+++ b/lib/rpmrc.c 20@@ -481,11 +481,14 @@ static void setDefaults(void) 21 userrc = xstrdup(oldrc); 22 } 23 } 24+ const char *etcconfdir = getenv("RPM_ETCCONFIGDIR"); 25+ if (etcconfdir == NULL) 26+ etcconfdir = ""; 27 28 if (!defrcfiles) { 29 defrcfiles = rstrscat(NULL, confdir, "/rpmrc", ":", 30 confdir, "/" RPM_VENDOR "/rpmrc", ":", 31- SYSCONFDIR "/rpmrc", NULL); 32+ etcconfdir, SYSCONFDIR "/rpmrc", NULL); 33 } 34 35 /* macrofiles may be pre-set from --macros */ 36@@ -495,9 +498,9 @@ static void setDefaults(void) 37 confdir, "/platform/%{_target}/macros", ":", 38 confdir, "/fileattrs/*.attr", ":", 39 confdir, "/" RPM_VENDOR "/macros", ":", 40- SYSCONFDIR "/rpm/macros.*", ":", 41- SYSCONFDIR "/rpm/macros", ":", 42- SYSCONFDIR "/rpm/%{_target}/macros", NULL); 43+ etcconfdir, SYSCONFDIR "/rpm/macros.*", ":", 44+ etcconfdir, SYSCONFDIR "/rpm/macros", ":", 45+ etcconfdir, SYSCONFDIR "/rpm/%{_target}/macros", NULL); 46 } 47 48 free(usermacros); 49@@ -1142,7 +1145,11 @@ static void read_auxv(void) 50 */ 51 static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os) 52 { 53- const char * const platform_path = SYSCONFDIR "/rpm/platform"; 54+ const char *etcconfdir = getenv("RPM_ETCCONFIGDIR"); 55+ if (etcconfdir == NULL) 56+ etcconfdir = ""; 57+ 58+ const char * const platform_path = rstrscat(NULL, etcconfdir, SYSCONFDIR "/rpm/platform", NULL); 59 static struct utsname un; 60 char * chptr; 61 canonEntry canon; 62@@ -1462,6 +1469,7 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os) 63 64 if (arch) *arch = un.machine; 65 if (os) *os = un.sysname; 66+ free(platform_path); 67 } 68 69 static 70