diff options
author | Xavier Chantry <shiningxc@gmail.com> | 2009-08-19 18:35:32 +0200 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2009-09-06 15:53:54 -0500 |
commit | 65c1f06be5a9c4bdb197b61563da7c2e28162392 (patch) | |
tree | cc715dc8a677a2568700a16dcac047f500c1a20e | |
parent | 5b27e78ba015a48baf2d3c8687fdf3084781f9c9 (diff) |
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>
-rw-r--r-- | doc/pacman.conf.5.txt | 6 | ||||
-rw-r--r-- | etc/pacman.conf.in | 3 | ||||
-rw-r--r-- | scripts/rankmirrors.py.in | 2 | ||||
-rw-r--r-- | src/pacman/pacman.c | 17 |
4 files changed, 24 insertions, 4 deletions
diff --git a/doc/pacman.conf.5.txt b/doc/pacman.conf.5.txt index 59bed156..640e62bb 100644 --- a/doc/pacman.conf.5.txt +++ b/doc/pacman.conf.5.txt @@ -181,10 +181,12 @@ Include = /etc/pacman.d/mirrorlist During parsing, pacman will define the `$repo` variable to the name of the current section. This is often utilized in files specified using the 'Include' -directive so all repositories can use the same mirrorfile. +directive so all repositories can use the same mirrorfile. pacman also defines +the `$arch` variable to the value of `Architecture`, so the same mirrorfile can +even be used for different architectures. -------- -Server = ftp://ftp.archlinux.org/$repo/os/arch +Server = ftp://ftp.archlinux.org/$repo/os/$arch -------- The order of repositories in the configuration files matters; repositories diff --git a/etc/pacman.conf.in b/etc/pacman.conf.in index 929d38ba..fc841b70 100644 --- a/etc/pacman.conf.in +++ b/etc/pacman.conf.in @@ -42,6 +42,7 @@ Architecture = auto # - repositories listed first will take precedence when packages # have identical names, regardless of version number # - URLs will have $repo replaced by the name of the current repo +# - URLs will have $arch replaced by the name of the architecture # # Repository entries are of the format: # [repo-name] @@ -57,7 +58,7 @@ Architecture = auto # servers immediately after the header and they will be used before the # default mirrors. #[core] -#Server = ftp://ftp.example.com/foobar/$repo/os/i686/ +#Server = ftp://ftp.example.com/foobar/$repo/os/$arch/ # The file referenced here should contain a list of 'Server = ' lines. #Include = @sysconfdir@/pacman.d/mirrorlist diff --git a/scripts/rankmirrors.py.in b/scripts/rankmirrors.py.in index 4b253b67..6bfa6612 100644 --- a/scripts/rankmirrors.py.in +++ b/scripts/rankmirrors.py.in @@ -156,6 +156,8 @@ if __name__ == "__main__": # if the $repo var is used in the url, replace it by core tempUrl = Template(serverUrl).safe_substitute(repo='core') + # if the $arch var is used in the url, replace it by i686 + tempUrl = Template(tempUrl).safe_substitute(arch='i686') # add @DBEXT@ to server name. the repo name is parsed # from the mirror url; it is the third (or fourth) dir 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 */ |