michal-grzedzicki / rpms / rpm

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