summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/rpm-canonarch.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-devtools/rpm/rpm/rpm-canonarch.patch')
-rw-r--r--meta/recipes-devtools/rpm/rpm/rpm-canonarch.patch136
1 files changed, 136 insertions, 0 deletions
diff --git a/meta/recipes-devtools/rpm/rpm/rpm-canonarch.patch b/meta/recipes-devtools/rpm/rpm/rpm-canonarch.patch
new file mode 100644
index 0000000000..41ab498a0f
--- /dev/null
+++ b/meta/recipes-devtools/rpm/rpm/rpm-canonarch.patch
@@ -0,0 +1,136 @@
1lib/rpmrc.c: Update --target processing to support full GNU canonical arch
2
3Prior to this patch, when using --target, RPM supported the format:
4 <arch>
5 <arch>-<os>
6 <arch>-<os>-gnu
7 <arch>-<arbitrary items>-<os>
8 <arch>-<arbitrary items>-<os>-gnu
9
10This patch changes the list of supported items to:
11 <arch>
12 <arch>-<os>
13 <arch>-<os>-gnu
14 <arch>-<vendor>-<os>
15 <arch>-<vendor>-<os>-<extension>
16
17Upstream-Status: Pending
18
19Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
20
21Index: rpm-5.4.14/lib/rpmrc.c
22===================================================================
23--- rpm-5.4.14.orig/lib/rpmrc.c
24+++ rpm-5.4.14/lib/rpmrc.c
25@@ -925,8 +925,8 @@ static void getMachineInfo(int type, /*@
26
27 static void rpmRebuildTargetVars(const char ** target, const char ** canontarget)
28 {
29-
30- char *ca = NULL, *co = NULL, *ct = NULL;
31+ /* ca = arch, cv = vendor, co = os, ce = extension, ct = canon target */
32+ char *ca = NULL, *cv = NULL, *co = NULL, *ce = NULL, *ct = NULL;
33 int x;
34
35 /* Rebuild the compat table to recalculate the current target arch. */
36@@ -936,23 +936,60 @@ static void rpmRebuildTargetVars(const c
37 rpmSetTables(RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS);
38
39 if (target && *target) {
40+ /* GNU canonical format is:
41+ * <arch>-<vendor>-<os>[-extension]
42+ *
43+ * We support the both the GNU canonical format
44+ * as well as the traditional RPM formats:
45+ * <arch>
46+ * <arch>-<os>[-gnu]
47+ */
48 char *c;
49 /* Set arch and os from specified build target */
50 ca = xstrdup(*target);
51- if ((c = strchr(ca, '-')) != NULL) {
52+ if ((c = strchr(ca, '-')) == NULL) {
53+ /* Format is <arch> */
54+ ;
55+ } else {
56 *c++ = '\0';
57-
58- if ((co = strrchr(c, '-')) == NULL) {
59- co = c;
60+ cv = c;
61+
62+ if ((c = strchr(c, '-')) == NULL) {
63+ /* Format is <arch>-<os> */
64+ co = cv;
65+ cv = NULL;
66 } else {
67- if (!xstrcasecmp(co, "-gnu"))
68- *co = '\0';
69- if ((co = strrchr(c, '-')) == NULL)
70- co = c;
71- else
72- co++;
73+ *c++ = '\0';
74+ co = c;
75+
76+ if ((c = strchr(c, '-')) == NULL) {
77+ /* Might be:
78+ * <arch>-<vendor>-<os>
79+ * <arch>-<os>-gnu
80+ */
81+ if (!xstrcasecmp(co, "gnu")) {
82+ /* Format was <arch>-<os>-gnu */
83+ ce = co;
84+ co = cv;
85+ cv = NULL;
86+ }
87+ } else {
88+ /* Format was <arch>-<vendor>-<os>-<extension> */
89+ *c++ = '\0';
90+ ce = c;
91+ }
92 }
93+ if (cv != NULL) cv = xstrdup(cv);
94 if (co != NULL) co = xstrdup(co);
95+ if (ce != NULL) {
96+ /* We need to prefix it with a "-" */
97+ char * lce = NULL;
98+
99+ lce = xmalloc(strlen(ce) + sizeof("-"));
100+ sprintf(lce, "-%s", ce);
101+
102+ ce = lce;
103+ }
104 }
105 } else {
106 const char *a = NULL;
107@@ -995,8 +1032,16 @@ static void rpmRebuildTargetVars(const c
108 addMacro(NULL, "_target", NULL, ct, RMIL_RPMRC);
109 delMacro(NULL, "_target_cpu");
110 addMacro(NULL, "_target_cpu", NULL, ca, RMIL_RPMRC);
111+ if (cv) {
112+ delMacro(NULL, "_target_vendor");
113+ addMacro(NULL, "_target_vendor", NULL, cv, RMIL_RPMRC);
114+ }
115 delMacro(NULL, "_target_os");
116 addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC);
117+ if (ce) {
118+ delMacro(NULL, "_gnu");
119+ addMacro(NULL, "_gnu", NULL, ce, RMIL_RPMRC);
120+ }
121
122 if (canontarget)
123 *canontarget = ct;
124@@ -1004,8 +1049,12 @@ static void rpmRebuildTargetVars(const c
125 ct = _free(ct);
126 ca = _free(ca);
127 /*@-usereleased@*/
128+ cv = _free(cv);
129+ /*@-usereleased@*/
130 co = _free(co);
131 /*@=usereleased@*/
132+ ce = _free(ce);
133+ /*@-usereleased@*/
134 }
135
136 void rpmFreeRpmrc(void)