From 3179db108a83104d9de6d1d607f55f8118e92160 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 21 Apr 2021 22:47:13 +1000 Subject: 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 Patch-updated-by: Allan McRae Signed-off-by: Allan McRae --- lib/libalpm/handle.c | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) (limited to 'lib/libalpm/handle.c') diff --git a/lib/libalpm/handle.c b/lib/libalpm/handle.c index 7b8cb1da..46224a25 100644 --- a/lib/libalpm/handle.c +++ b/lib/libalpm/handle.c @@ -77,7 +77,7 @@ void _alpm_handle_free(alpm_handle_t *handle) FREELIST(handle->hookdirs); FREE(handle->logfile); FREE(handle->lockfile); - FREE(handle->arch); + FREELIST(handle->architectures); FREE(handle->gpgdir); FREELIST(handle->noupgrade); FREELIST(handle->noextract); @@ -276,10 +276,10 @@ alpm_list_t SYMEXPORT *alpm_option_get_assumeinstalled(alpm_handle_t *handle) return handle->assumeinstalled; } -const char SYMEXPORT *alpm_option_get_arch(alpm_handle_t *handle) +alpm_list_t SYMEXPORT *alpm_option_get_architectures(alpm_handle_t *handle) { CHECK_HANDLE(handle, return NULL); - return handle->arch; + return handle->architectures; } int SYMEXPORT alpm_option_get_checkspace(alpm_handle_t *handle) @@ -720,11 +720,29 @@ int SYMEXPORT alpm_option_remove_assumeinstalled(alpm_handle_t *handle, const al return 0; } -int SYMEXPORT alpm_option_set_arch(alpm_handle_t *handle, const char *arch) +int SYMEXPORT alpm_option_add_architecture(alpm_handle_t *handle, const char *arch) { + handle->architectures = alpm_list_add(handle->architectures, strdup(arch)); + return 0; +} + +int SYMEXPORT alpm_option_set_architectures(alpm_handle_t *handle, alpm_list_t *arches) +{ + CHECK_HANDLE(handle, return -1); + if(handle->architectures) FREELIST(handle->architectures); + handle->architectures = alpm_list_strdup(arches); + return 0; +} + +int SYMEXPORT alpm_option_remove_architecture(alpm_handle_t *handle, const char *arch) +{ + char *vdata = NULL; CHECK_HANDLE(handle, return -1); - if(handle->arch) FREE(handle->arch); - STRDUP(handle->arch, arch, RET_ERR(handle, ALPM_ERR_MEMORY, -1)); + handle->architectures = alpm_list_remove_str(handle->architectures, arch, &vdata); + if(vdata != NULL) { + FREE(vdata); + return 1; + } return 0; } -- cgit v1.2.3-54-g00ecf