aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/rpm/rpm/rpm-canonarch.patch
blob: 41ab498a0ffec891b2e3f934540db7b8946e531d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
lib/rpmrc.c: Update --target processing to support full GNU canonical arch

Prior to this patch, when using --target, RPM supported the format:
  <arch>
  <arch>-<os>
  <arch>-<os>-gnu
  <arch>-<arbitrary items>-<os>
  <arch>-<arbitrary items>-<os>-gnu

This patch changes the list of supported items to:
  <arch>
  <arch>-<os>
  <arch>-<os>-gnu
  <arch>-<vendor>-<os>
  <arch>-<vendor>-<os>-<extension>

Upstream-Status: Pending

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>

Index: rpm-5.4.14/lib/rpmrc.c
===================================================================
--- rpm-5.4.14.orig/lib/rpmrc.c
+++ rpm-5.4.14/lib/rpmrc.c
@@ -925,8 +925,8 @@ static void getMachineInfo(int type, /*@
 
 static void rpmRebuildTargetVars(const char ** target, const char ** canontarget)
 {
-
-    char *ca = NULL, *co = NULL, *ct = NULL;
+    /* ca = arch, cv = vendor, co = os, ce = extension, ct = canon target */
+    char *ca = NULL, *cv = NULL, *co = NULL, *ce = NULL, *ct = NULL;
     int x;
 
     /* Rebuild the compat table to recalculate the current target arch.  */
@@ -936,23 +936,60 @@ static void rpmRebuildTargetVars(const c
     rpmSetTables(RPM_MACHTABLE_BUILDARCH, RPM_MACHTABLE_BUILDOS);
 
     if (target && *target) {
+	/* GNU canonical format is:
+	 *  <arch>-<vendor>-<os>[-extension]
+	 *
+	 * We support the both the GNU canonical format
+	 * as well as the traditional RPM formats: 
+	 *  <arch>
+	 *  <arch>-<os>[-gnu]
+	 */
 	char *c;
 	/* Set arch and os from specified build target */
 	ca = xstrdup(*target);
-	if ((c = strchr(ca, '-')) != NULL) {
+	if ((c = strchr(ca, '-')) == NULL) {
+	    /* Format is <arch> */
+	    ;
+	} else {
 	    *c++ = '\0';
-	    
-	    if ((co = strrchr(c, '-')) == NULL) {
-		co = c;
+	    cv = c;
+
+	    if ((c = strchr(c, '-')) == NULL) {
+		/* Format is <arch>-<os> */
+		co = cv;
+		cv = NULL;
 	    } else {
-		if (!xstrcasecmp(co, "-gnu"))
-		    *co = '\0';
-		if ((co = strrchr(c, '-')) == NULL)
-		    co = c;
-		else
-		    co++;
+		*c++ = '\0';
+		co = c;
+
+		if ((c = strchr(c, '-')) == NULL) {
+		    /* Might be:
+		     *  <arch>-<vendor>-<os>
+		     *  <arch>-<os>-gnu
+		     */
+		    if (!xstrcasecmp(co, "gnu")) {
+			/* Format was <arch>-<os>-gnu */
+			ce = co;
+			co = cv;
+			cv = NULL;
+		    }
+		} else {
+		    /* Format was <arch>-<vendor>-<os>-<extension> */
+		    *c++ = '\0';
+		    ce = c;
+		}
 	    }
+	    if (cv != NULL) cv = xstrdup(cv);
 	    if (co != NULL) co = xstrdup(co);
+	    if (ce != NULL) {
+		/* We need to prefix it with a "-" */
+		char * lce = NULL;
+
+		lce = xmalloc(strlen(ce) + sizeof("-"));
+		sprintf(lce, "-%s", ce);
+
+		ce = lce;
+	    }
 	}
     } else {
 	const char *a = NULL;
@@ -995,8 +1032,16 @@ static void rpmRebuildTargetVars(const c
     addMacro(NULL, "_target", NULL, ct, RMIL_RPMRC);
     delMacro(NULL, "_target_cpu");
     addMacro(NULL, "_target_cpu", NULL, ca, RMIL_RPMRC);
+    if (cv) {
+	delMacro(NULL, "_target_vendor");
+	addMacro(NULL, "_target_vendor", NULL, cv, RMIL_RPMRC);
+    }
     delMacro(NULL, "_target_os");
     addMacro(NULL, "_target_os", NULL, co, RMIL_RPMRC);
+    if (ce) {
+	delMacro(NULL, "_gnu");
+	addMacro(NULL, "_gnu", NULL, ce, RMIL_RPMRC);
+    }
 
     if (canontarget)
 	*canontarget = ct;
@@ -1004,8 +1049,12 @@ static void rpmRebuildTargetVars(const c
 	ct = _free(ct);
     ca = _free(ca);
     /*@-usereleased@*/
+    cv = _free(cv);
+    /*@-usereleased@*/
     co = _free(co);
     /*@=usereleased@*/
+    ce = _free(ce);
+    /*@-usereleased@*/
 }
 
 void rpmFreeRpmrc(void)