From 5fa8bb1f5628614da6d71ebe205e3c5f51808787 Mon Sep 17 00:00:00 2001 From: Nahum Shalman Date: Thu, 13 Aug 2009 13:19:15 -0400 Subject: [PATCH] example support for $arch in pacman configuration This is completely untested code written by someone who is not a C programmer. It is intended to hint at the correct solution to be written by a better programmer. --- src/pacman/pacman.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 77c558d..8cf96b0 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -704,6 +704,9 @@ static int _parseconfig(const char *file, const char *givensection, char *ptr, *section = NULL; pmdb_t *db = NULL; int ret = 0; + struct utsname un; + + uname(&un); pm_printf(PM_LOG_DEBUG, "config: attempting to read file %s\n", file); fp = fopen(file, "r"); @@ -880,6 +883,9 @@ static int _parseconfig(const char *file, const char *givensection, /* let's attempt a replacement for the current repo */ char *server = strreplace(ptr, "$repo", section); + /* let's attempt a replacement for the current architecture */ + char *server = strreplace(ptr, "$arch", un.machine); + if(alpm_db_setserver(db, server) != 0) { /* pm_errno is set by alpm_db_setserver */ pm_printf(PM_LOG_ERROR, _("could not add server URL to database '%s': %s (%s)\n"), -- 1.6.4