summaryrefslogtreecommitdiff
path: root/core/pacman/replace-i686-by-pentium4-when-architecture-is-auto.patch
blob: 32030586625481697cee60a26dacea913e41da3a (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
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index 2d8518c4..2e7fac88 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -308,6 +308,11 @@ int config_set_arch(const char *arch)
 		struct utsname un;
 		uname(&un);
 		config->arch = strdup(un.machine);
+		if(strcmp(config->arch, "i686") == 0) {
+			__builtin_cpu_init();
+			if (__builtin_cpu_supports("sse2"))
+				config->arch = strdup("pentium4");
+		}
 	} else {
 		config->arch = strdup(arch);
 	}
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index 3bb622e6..34aace6c 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -274,8 +274,18 @@ static void setuseragent(void)
 	int len;
 
 	uname(&un);
+	char machine[9];
+	strncpy(machine, un.machine, sizeof machine);
+	machine[sizeof machine-1] = '\0';
+	if(strcmp(machine, "i686") == 0) {
+		__builtin_cpu_init();
+		if (__builtin_cpu_supports("sse2")) {
+			strncpy(machine, "pentium4", sizeof machine);
+			machine[sizeof machine-1] = '\0';
+		}
+	}
 	len = snprintf(agent, 100, "pacman/%s (%s %s) libalpm/%s",
-			PACKAGE_VERSION, un.sysname, un.machine, alpm_version());
+			PACKAGE_VERSION, un.sysname, machine, alpm_version());
 	if(len >= 100) {
 		pm_printf(ALPM_LOG_WARNING, _("HTTP_USER_AGENT truncated\n"));
 	}
diff --git a/test/pacman/tests/upgrade082.py b/test/pacman/tests/upgrade082.py
index 0bdbdf71..8c30ec32 100644
--- a/test/pacman/tests/upgrade082.py
+++ b/test/pacman/tests/upgrade082.py
@@ -3,6 +3,18 @@
 import os
 machine = os.uname()[4]
 
+if machine == 'i686':
+	import re
+	fo = open('/proc/cpuinfo')
+	for line in fo:
+		name_value = [s.strip() for s in line.split(':', 1)]
+		if len(name_value) != 2:
+			continue
+		name, value = name_value
+		if name == "flags":
+			if re.match(r'.*?\bsse2\b', value) is not None:
+				machine = 'pentium4'
+
 p = pmpkg("dummy")
 p.files = ["bin/dummy",
            "usr/man/man1/dummy.1"]
diff --git a/test/pacman/tests/upgrade083.py b/test/pacman/tests/upgrade083.py
index 097ae02c..7195e35b 100644
--- a/test/pacman/tests/upgrade083.py
+++ b/test/pacman/tests/upgrade083.py
@@ -3,6 +3,18 @@
 import os
 machine = os.uname()[4]
 
+if machine == 'i686':
+	import re
+	fo = open('/proc/cpuinfo')
+	for line in fo:
+		name_value = [s.strip() for s in line.split(':', 1)]
+		if len(name_value) != 2:
+			continue
+		name, value = name_value
+		if name == "flags":
+			if re.match(r'.*?\bsse2\b', value) is not None:
+				machine = 'pentium4'
+
 p = pmpkg("dummy")
 p.files = ["bin/dummy",
            "usr/man/man1/dummy.1"]