summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXavier Chantry <shiningxc@gmail.com>2009-08-19 18:35:32 +0200
committerDan McGee <dan@archlinux.org>2009-09-06 22:53:54 +0200
commit65c1f06be5a9c4bdb197b61563da7c2e28162392 (patch)
treecc715dc8a677a2568700a16dcac047f500c1a20e /src
parent5b27e78ba015a48baf2d3c8687fdf3084781f9c9 (diff)
downloadpacman-65c1f06be5a9c4bdb197b61563da7c2e28162392.tar.gz
pacman-65c1f06be5a9c4bdb197b61563da7c2e28162392.tar.xz
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 <shiningxc@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/pacman.c17
1 files changed, 16 insertions, 1 deletions
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 */