From 65c1f06be5a9c4bdb197b61563da7c2e28162392 Mon Sep 17 00:00:00 2001 From: Xavier Chantry Date: Wed, 19 Aug 2009 18:35:32 +0200 Subject: Allow $arch to be used in Server similarly to the $repo variable, Server can now contain $arch, which will be automatically replaced by the appropriate architecture. This allows us to have one universal mirrorlist file, for both i686 and x86_64, woohoo! Signed-off-by: Xavier Chantry Signed-off-by: Dan McGee --- src/pacman/pacman.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c index 5fab247d..6e5147c5 100644 --- a/src/pacman/pacman.c +++ b/src/pacman/pacman.c @@ -897,7 +897,22 @@ static int _parseconfig(const char *file, const char *givensection, } } else if(strcmp(key, "Server") == 0) { /* let's attempt a replacement for the current repo */ - char *server = strreplace(ptr, "$repo", section); + char *temp = strreplace(ptr, "$repo", section); + /* let's attempt a replacement for the arch */ + const char *arch = alpm_option_get_arch(); + char *server; + if(arch) { + server = strreplace(temp, "$arch", arch); + free(temp); + } else { + if(strstr(temp, "$arch")) { + pm_printf(PM_LOG_ERROR, _("The mirror '%s' contains the $arch" + " variable, but no Architecture is defined.\n"), ptr); + ret = 1; + goto cleanup; + } + server = temp; + } if(alpm_db_setserver(db, server) != 0) { /* pm_errno is set by alpm_db_setserver */ -- cgit v1.2.3-24-g4f1b