1
0
mirror of https://github.com/moparisthebest/pacman synced 2024-11-14 21:35:02 -05:00

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>
This commit is contained in:
Xavier Chantry 2009-08-19 18:35:32 +02:00 committed by Dan McGee
parent 5b27e78ba0
commit 65c1f06be5
4 changed files with 24 additions and 4 deletions

View File

@ -181,10 +181,12 @@ Include = /etc/pacman.d/mirrorlist
During parsing, pacman will define the `$repo` variable to the name of the 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' 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 The order of repositories in the configuration files matters; repositories

View File

@ -42,6 +42,7 @@ Architecture = auto
# - repositories listed first will take precedence when packages # - repositories listed first will take precedence when packages
# have identical names, regardless of version number # have identical names, regardless of version number
# - URLs will have $repo replaced by the name of the current repo # - 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: # Repository entries are of the format:
# [repo-name] # [repo-name]
@ -57,7 +58,7 @@ Architecture = auto
# servers immediately after the header and they will be used before the # servers immediately after the header and they will be used before the
# default mirrors. # default mirrors.
#[core] #[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. # The file referenced here should contain a list of 'Server = ' lines.
#Include = @sysconfdir@/pacman.d/mirrorlist #Include = @sysconfdir@/pacman.d/mirrorlist

View File

@ -156,6 +156,8 @@ if __name__ == "__main__":
# if the $repo var is used in the url, replace it by core # if the $repo var is used in the url, replace it by core
tempUrl = Template(serverUrl).safe_substitute(repo='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 # add @DBEXT@ to server name. the repo name is parsed
# from the mirror url; it is the third (or fourth) dir # from the mirror url; it is the third (or fourth) dir

View File

@ -897,7 +897,22 @@ static int _parseconfig(const char *file, const char *givensection,
} }
} else if(strcmp(key, "Server") == 0) { } else if(strcmp(key, "Server") == 0) {
/* let's attempt a replacement for the current repo */ /* 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) { if(alpm_db_setserver(db, server) != 0) {
/* pm_errno is set by alpm_db_setserver */ /* pm_errno is set by alpm_db_setserver */