From efbae17abe758123c683511216f87d5e2c36218a Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Mon, 13 May 2019 10:48:09 +0200 Subject: core/pacman: add patches for automatically changing "i686" to "pentium4" if "Architecture = auto" --- core/pacman/PKGBUILD | 13 ++++++++++ core/pacman/pentium4-auto-config.patch | 37 +++++++++++++++++++++++++++ core/pacman/pentium4-tests.patch | 46 ++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 core/pacman/pentium4-auto-config.patch create mode 100644 core/pacman/pentium4-tests.patch diff --git a/core/pacman/PKGBUILD b/core/pacman/PKGBUILD index f75db89a..ae268502 100644 --- a/core/pacman/PKGBUILD +++ b/core/pacman/PKGBUILD @@ -22,3 +22,16 @@ if [ ! "${CARCH}" = "i686" ]; then ' )" fi + +# patches for the "i686" -> "pentium4" mangling if "Architecture = auto" +# see auto-pentium4 branch in git.archlinux32.org:archlinux32/pacman.git +source+=('pentium4-auto-config.patch' + 'pentium4-tests.patch') +sha256sums+=('266276a16aac85a9ee4745968a7bcac833505afa2896b60301997bbe2863fabd' + '8e3d1b2dff0cfd7db462bae0d1def5bb83d169128117e2b6ea72d489ab7b0077') + +prepare() { + cd "$pkgname-$pkgver" + patch -p1 -i ../pentium4-auto-config.patch + patch -p1 -i ../pentium4-tests.patch +} diff --git a/core/pacman/pentium4-auto-config.patch b/core/pacman/pentium4-auto-config.patch new file mode 100644 index 00000000..5401a64b --- /dev/null +++ b/core/pacman/pentium4-auto-config.patch @@ -0,0 +1,37 @@ +diff --git a/src/pacman/conf.c b/src/pacman/conf.c +index 3b79fbc7..2325f688 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..abb6f933 100644 +--- a/src/pacman/pacman.c ++++ b/src/pacman/pacman.c +@@ -274,8 +274,15 @@ static void setuseragent(void) + int len; + + uname(&un); ++ char machine[8]; ++ strncpy(machine, un.machine, 8); ++ if(strcmp(machine, "i686") == 0) { ++ __builtin_cpu_init(); ++ if (__builtin_cpu_supports("sse2")) ++ strncpy(machine, "pentium4", 8); ++ } + 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/core/pacman/pentium4-tests.patch b/core/pacman/pentium4-tests.patch new file mode 100644 index 00000000..bf0ee2da --- /dev/null +++ b/core/pacman/pentium4-tests.patch @@ -0,0 +1,46 @@ +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"] -- cgit v1.2.3