teknoraver / rpms / rpm

Forked from rpms/rpm 3 months ago
Clone

Blame SOURCES/rpm-4.6.0-niagara.patch

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