blob: c5caa7dc5e5814b73a9c0d80604c06184f6be859 [file] [log] [blame]
Patrick Williams44b3caf2024-04-12 16:51:14 -05001From d7143dc4e75c8bcc5cc4c852a4b972942b7e4d07 Mon Sep 17 00:00:00 2001
Brad Bishop6e60e8b2018-02-01 10:27:11 -05002From: Alexander Kanavin <alex.kanavin@gmail.com>
3Date: Fri, 20 Jan 2017 13:33:05 +0200
Patrick Williams73bd93f2024-02-20 08:07:48 -06004Subject: [PATCH] Add support for prefixing /etc from RPM_ETCCONFIGDIR
Brad Bishop6e60e8b2018-02-01 10:27:11 -05005 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 | 19 ++++++++++++++-----
14 1 file changed, 14 insertions(+), 5 deletions(-)
15
Patrick Williams73bd93f2024-02-20 08:07:48 -060016diff --git a/lib/rpmrc.c b/lib/rpmrc.c
Patrick Williams44b3caf2024-04-12 16:51:14 -050017index 483585ae4..ea858c290 100644
Patrick Williams73bd93f2024-02-20 08:07:48 -060018--- a/lib/rpmrc.c
19+++ b/lib/rpmrc.c
Patrick Williams44b3caf2024-04-12 16:51:14 -050020@@ -456,10 +456,14 @@ const char * lookupInDefaultTable(const char * name,
Brad Bishop6e60e8b2018-02-01 10:27:11 -050021 static void setDefaults(void)
22 {
23 const char *confdir = rpmConfigDir();
24+ const char *etcconfdir = getenv("RPM_ETCCONFIGDIR");
25+ if (etcconfdir == NULL)
26+ etcconfdir = "";
27+
28 if (!defrcfiles) {
29 defrcfiles = rstrscat(NULL, confdir, "/rpmrc", ":",
Patrick Williams73bd93f2024-02-20 08:07:48 -060030 confdir, "/" RPM_VENDOR "/rpmrc", ":",
31- SYSCONFDIR "/rpmrc", NULL);
32+ etcconfdir, SYSCONFDIR "/rpmrc", NULL);
Brad Bishop6e60e8b2018-02-01 10:27:11 -050033 }
34
35 #ifndef MACROFILES
Patrick Williams44b3caf2024-04-12 16:51:14 -050036@@ -469,9 +473,9 @@ static void setDefaults(void)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050037 confdir, "/platform/%{_target}/macros", ":",
38 confdir, "/fileattrs/*.attr", ":",
Patrick Williams73bd93f2024-02-20 08:07:48 -060039 confdir, "/" RPM_VENDOR "/macros", ":",
Brad Bishop6e60e8b2018-02-01 10:27:11 -050040- SYSCONFDIR "/rpm/macros.*", ":",
41- SYSCONFDIR "/rpm/macros", ":",
Patrick Williams73bd93f2024-02-20 08:07:48 -060042- SYSCONFDIR "/rpm/%{_target}/macros", NULL);
Brad Bishop6e60e8b2018-02-01 10:27:11 -050043+ etcconfdir, SYSCONFDIR "/rpm/macros.*", ":",
44+ etcconfdir, SYSCONFDIR "/rpm/macros", ":",
Patrick Williams73bd93f2024-02-20 08:07:48 -060045+ etcconfdir, SYSCONFDIR "/rpm/%{_target}/macros", NULL);
Brad Bishop6e60e8b2018-02-01 10:27:11 -050046 }
47 #else
48 macrofiles = MACROFILES;
Patrick Williams44b3caf2024-04-12 16:51:14 -050049@@ -1115,7 +1119,11 @@ static void read_auxv(void)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050050 */
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;
Patrick Williams44b3caf2024-04-12 16:51:14 -050062@@ -1435,6 +1443,7 @@ static void defaultMachine(rpmrcCtx ctx, const char ** arch, const char ** os)
Brad Bishop6e60e8b2018-02-01 10:27:11 -050063
64 if (arch) *arch = un.machine;
65 if (os) *os = un.sysname;
66+ free(platform_path);
67 }
68
69 static