michal-grzedzicki / rpms / rpm

Forked from rpms/rpm 4 months ago
Clone
5523e9
diff -up rpm-4.9.1.3/lib/rpmrc.c.niagara rpm-4.9.1.3/lib/rpmrc.c
5523e9
--- rpm-4.9.1.3/lib/rpmrc.c.niagara	2012-04-19 17:06:23.130595223 +0200
5523e9
+++ rpm-4.9.1.3/lib/rpmrc.c	2012-04-19 17:06:23.134739249 +0200
5523e9
@@ -718,6 +718,31 @@ exit:
5523e9
     return rc;
5523e9
 }
5523e9
 
5523e9
+#if defined(__linux__) && defined(__sparc__)
5523e9
+static int is_sun4v()
5523e9
+{
5523e9
+	char buffer[4096], *p;
5523e9
+	int fd = open("/proc/cpuinfo", O_RDONLY);
5523e9
+	if (read(fd, &buffer, sizeof(buffer) - 1) == -1) {
5523e9
+		rpmlog(RPMLOG_WARNING, _("read(/proc/cpuinfo) failed\n"));
5523e9
+		close(fd);
5523e9
+		return 0;
5523e9
+	}
5523e9
+	close(fd);
5523e9
+
5523e9
+	p = strstr(buffer, "type");
5523e9
+	p = strtok(p, "\n");
5523e9
+	p = strstr(p, "sun");
5523e9
+	if (p == NULL) {
5523e9
+		rpmlog(RPMLOG_WARNING, _("/proc/cpuinfo has no 'type' line\n"));
5523e9
+		return 0;
5523e9
+	} else if (strcmp(p, "sun4v") == 0) {
5523e9
+		return 1;
5523e9
+	}
5523e9
+	return 0;
5523e9
+}
5523e9
+#endif
5523e9
+
5523e9
 
5523e9
 #	if defined(__linux__) && defined(__i386__)
5523e9
 #include <setjmp.h>
5523e9
@@ -1178,6 +1203,13 @@ static void defaultMachine(const char **
5523e9
 		personality(oldpers);
5523e9
 	    }
5523e9
 	}
5523e9
+	if (is_sun4v()){
5523e9
+	    if (strcmp(un.machine, "sparcv9") == 0 || strcmp(un.machine, "sparc") == 0 ) {
5523e9
+	        strcpy(un.machine, "sparcv9v");
5523e9
+	    } else if (strcmp(un.machine, "sparc64") == 0 ) {
5523e9
+	        strcpy(un.machine, "sparc64v");
5523e9
+	    }
5523e9
+	}
5523e9
 #	endif	/* sparc*-linux */
5523e9
 
5523e9
 #	if defined(__linux__) && defined(__powerpc__)
5523e9
diff -up rpm-4.9.1.3/rpmrc.in.niagara rpm-4.9.1.3/rpmrc.in
5523e9
--- rpm-4.9.1.3/rpmrc.in.niagara	2012-04-19 17:06:23.131476769 +0200
5523e9
+++ rpm-4.9.1.3/rpmrc.in	2012-04-19 17:06:23.135738996 +0200
5523e9
@@ -316,7 +316,7 @@ arch_compat: sun4c: sparc
5523e9
 arch_compat: sun4d: sparc
5523e9
 arch_compat: sun4m: sparc
5523e9
 arch_compat: sun4u: sparc64
5523e9
-arch_compat: sparc64v: sparc64
5523e9
+arch_compat: sparc64v: sparc64 sparcv9v
5523e9
 arch_compat: sparc64: sparcv9
5523e9
 arch_compat: sparcv9v: sparcv9
5523e9
 arch_compat: sparcv9: sparcv8