Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2021-04-21 22:47:13 +1000
committerAllan McRae <allan@archlinux.org>2021-04-22 00:15:21 +1000
commit3179db108a83104d9de6d1d607f55f8118e92160 (patch)
tree2141a5a0a565bbfc8261bbc434bcfa53830115a1 /src
parentabdb4d7fa699ae3b8ff09ba79656f6853b9a1357 (diff)
Add support for multiple 'Architecture' values
This allows architecture to be multivalued. On x86-64 machines, this could be something like: Architecture = x86-64-v3 x86-64 We use the first specified Architecture value in mirrorlist $arch variable replacement, as this is backwards-compatible and sane. Original-patch-by: Dan McGee <dan@archlinux.org> Patch-updated-by: Allan McRae <allan@archlinux.org> Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'src')
-rw-r--r--src/pacman/conf.c33
-rw-r--r--src/pacman/conf.h4
-rw-r--r--src/pacman/pacman-conf.c4
-rw-r--r--src/pacman/pacman.c2
4 files changed, 26 insertions, 17 deletions
diff --git a/src/pacman/conf.c b/src/pacman/conf.c
index cde96716..9578daa3 100644
--- a/src/pacman/conf.c
+++ b/src/pacman/conf.c
@@ -159,7 +159,7 @@ int config_free(config_t *oldconfig)
FREELIST(oldconfig->cachedirs);
free(oldconfig->xfercommand);
free(oldconfig->print_format);
- free(oldconfig->arch);
+ FREELIST(oldconfig->architectures);
wordsplit_free(oldconfig->xfercommand_argv);
free(oldconfig);
@@ -394,16 +394,19 @@ cleanup:
}
-int config_set_arch(const char *arch)
+int config_add_architecture(char *arch)
{
if(strcmp(arch, "auto") == 0) {
struct utsname un;
+ char *newarch;
uname(&un);
- config->arch = strdup(un.machine);
- } else {
- config->arch = strdup(arch);
+ newarch = strdup(un.machine);
+ free(arch);
+ arch = newarch;
}
- pm_printf(ALPM_LOG_DEBUG, "config: arch: %s\n", config->arch);
+
+ pm_printf(ALPM_LOG_DEBUG, "config: arch: %s\n", arch);
+ config->architectures = alpm_list_add(config->architectures, arch);
return 0;
}
@@ -638,9 +641,12 @@ static int _parse_options(const char *key, char *value,
} else if(strcmp(key, "HookDir") == 0) {
setrepeatingoption(value, "HookDir", &(config->hookdirs));
} else if(strcmp(key, "Architecture") == 0) {
- if(!config->arch) {
- config_set_arch(value);
+ alpm_list_t *i, *arches = NULL;
+ setrepeatingoption(value, "Architecture", &arches);
+ for(i = arches; i; i = alpm_list_next(i)) {
+ config_add_architecture(i->data);
}
+ alpm_list_free(arches);
} else if(strcmp(key, "DBPath") == 0) {
/* don't overwrite a path specified on the command line */
if(!config->dbpath) {
@@ -751,17 +757,20 @@ static int _parse_options(const char *key, char *value,
static char *replace_server_vars(config_t *c, config_repo_t *r, const char *s)
{
- if(c->arch == NULL && strstr(s, "$arch")) {
+ if(c->architectures == NULL && strstr(s, "$arch")) {
pm_printf(ALPM_LOG_ERROR,
_("mirror '%s' contains the '%s' variable, but no '%s' is defined.\n"),
s, "$arch", "Architecture");
return NULL;
}
- if(c->arch) {
+ /* use first specified architecture */
+ if(c->architectures) {
char *temp, *replaced;
+ alpm_list_t *i = config->architectures;
+ const char *arch = i->data;
- replaced = strreplace(s, "$arch", c->arch);
+ replaced = strreplace(s, "$arch", arch);
temp = replaced;
replaced = strreplace(temp, "$repo", r->name);
@@ -893,7 +902,7 @@ static int setup_libalpm(void)
pm_printf(ALPM_LOG_WARNING, _("no '%s' configured\n"), "XferCommand");
}
- alpm_option_set_arch(handle, config->arch);
+ alpm_option_set_architectures(handle, config->architectures);
alpm_option_set_checkspace(handle, config->checkspace);
alpm_option_set_usesyslog(handle, config->usesyslog);
diff --git a/src/pacman/conf.h b/src/pacman/conf.h
index 1b9fb337..316c8d0f 100644
--- a/src/pacman/conf.h
+++ b/src/pacman/conf.h
@@ -57,7 +57,6 @@ typedef struct __config_t {
unsigned short usesyslog;
unsigned short color;
unsigned short disable_dl_timeout;
- char *arch;
char *print_format;
/* unfortunately, we have to keep track of paths both here and in the library
* because they can come from both the command line or config file, and we
@@ -70,6 +69,7 @@ typedef struct __config_t {
char *sysroot;
alpm_list_t *hookdirs;
alpm_list_t *cachedirs;
+ alpm_list_t *architectures;
unsigned short op_q_isfile;
unsigned short op_q_info;
@@ -244,7 +244,7 @@ int config_free(config_t *oldconfig);
void config_repo_free(config_repo_t *repo);
-int config_set_arch(const char *arch);
+int config_add_architecture(char *arch);
int parseconfig(const char *file);
int parseconfigfile(const char *file);
int setdefaults(config_t *c);
diff --git a/src/pacman/pacman-conf.c b/src/pacman/pacman-conf.c
index f8fac75d..6ca21119 100644
--- a/src/pacman/pacman-conf.c
+++ b/src/pacman/pacman-conf.c
@@ -258,7 +258,7 @@ static void dump_config(void)
show_list_str("NoUpgrade", config->noupgrade);
show_list_str("NoExtract", config->noextract);
- show_str("Architecture", config->arch);
+ show_list_str("Architecture", config->architectures);
show_str("XferCommand", config->xfercommand);
show_bool("UseSyslog", config->usesyslog);
@@ -364,7 +364,7 @@ static int list_directives(void)
} else if(strcasecmp(i->data, "Architecture") == 0) {
- show_str("Architecture", config->arch);
+ show_list_str("Architecture", config->architectures);
} else if(strcasecmp(i->data, "XferCommand") == 0) {
show_str("XferCommand", config->xfercommand);
diff --git a/src/pacman/pacman.c b/src/pacman/pacman.c
index b2aabc08..7e810127 100644
--- a/src/pacman/pacman.c
+++ b/src/pacman/pacman.c
@@ -377,7 +377,7 @@ static int parsearg_global(int opt)
{
switch(opt) {
case OP_ARCH:
- config_set_arch(optarg);
+ config_add_architecture(strdup(optarg));
break;
case OP_ASK:
config->noask = 1;