From f90ba2a8b6f787e26cbc2cff1ac0bb088c91eee0 Mon Sep 17 00:00:00 2001 From: sid Date: Sat, 24 Aug 2024 18:30:50 +0100 Subject: [PATCH] alpm: Support alpm 13 and 14 This should also help in running alpm job in debian CI (which currently has alpm 13). --- backends/alpm/meson.build | 24 +++++++++++++++--------- backends/alpm/pk-alpm-config.c | 2 ++ backends/alpm/pk-alpm-transaction.c | 12 +++++++++--- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/backends/alpm/meson.build b/backends/alpm/meson.build index 50301466a..1d82eec91 100644 --- a/backends/alpm/meson.build +++ b/backends/alpm/meson.build @@ -1,4 +1,17 @@ -alpm_dep = dependency('libalpm', version: '>=14.0.0') +alpm_dep = dependency('libalpm', version: '>=13.0.0') + +c_args = [ + '-DPK_LOG_PREFIX="PACKAGEKIT"', + '-DG_LOG_DOMAIN="PackageKit-alpm"', + '-DPK_BACKEND_CONFIG_FILE="@0@"'.format(join_paths(get_option('sysconfdir'), 'PackageKit', 'alpm.d', 'pacman.conf')), + '-DPK_BACKEND_GROUP_FILE="@0@"'.format(join_paths(get_option('sysconfdir'), 'PackageKit', 'alpm.d', 'groups.list')), + '-DPK_BACKEND_REPO_FILE="@0@"'.format(join_paths(get_option('sysconfdir'), 'PackageKit', 'alpm.d', 'repos.list')), + '-DPK_BACKEND_DEFAULT_PATH="/bin:/usr/bin:/sbin:/usr/sbin"', +] + +if alpm_dep.version().version_compare('>=14.0.0') + c_args += '-DHAVE_LIBALPM_14=1' +endif shared_module( 'pk_backend_alpm', @@ -31,14 +44,7 @@ shared_module( alpm_dep, gmodule_dep, ], - c_args: [ - '-DPK_LOG_PREFIX="PACKAGEKIT"', - '-DG_LOG_DOMAIN="PackageKit-alpm"', - '-DPK_BACKEND_CONFIG_FILE="@0@"'.format(join_paths(get_option('sysconfdir'), 'PackageKit', 'alpm.d', 'pacman.conf')), - '-DPK_BACKEND_GROUP_FILE="@0@"'.format(join_paths(get_option('sysconfdir'), 'PackageKit', 'alpm.d', 'groups.list')), - '-DPK_BACKEND_REPO_FILE="@0@"'.format(join_paths(get_option('sysconfdir'), 'PackageKit', 'alpm.d', 'repos.list')), - '-DPK_BACKEND_DEFAULT_PATH="/bin:/usr/bin:/sbin:/usr/sbin"', - ], + c_args: c_args, install: true, install_dir: pk_plugin_dir, ) diff --git a/backends/alpm/pk-alpm-config.c b/backends/alpm/pk-alpm-config.c index 3954a45fb..e18ad8174 100644 --- a/backends/alpm/pk-alpm-config.c +++ b/backends/alpm/pk-alpm-config.c @@ -615,10 +615,12 @@ pk_alpm_config_parse (PkAlpmConfig *config, const gchar *filename, continue; } +#ifdef HAVE_LIBALPM_14 if (g_strcmp0 (key, "CacheServer") == 0 && str != NULL) { /* Ignore "CacheServer" key instead of crashing */ continue; } +#endif /* report errors from above */ g_set_error (&e, PK_ALPM_ERROR, PK_ALPM_ERR_CONFIG_INVALID, diff --git a/backends/alpm/pk-alpm-transaction.c b/backends/alpm/pk-alpm-transaction.c index bc1273375..96d305a63 100644 --- a/backends/alpm/pk-alpm-transaction.c +++ b/backends/alpm/pk-alpm-transaction.c @@ -864,9 +864,15 @@ pk_alpm_conflict_build_list (const alpm_list_t *i) for (; i != NULL; i = i->next) { alpm_conflict_t *conflict = (alpm_conflict_t *) i->data; alpm_depend_t *depend = conflict->reason; - - const char *package_name1 = alpm_pkg_get_name (conflict->package1); - const char *package_name2 = alpm_pkg_get_name (conflict->package2); + const char *package_name1, *package_name2; + +#ifdef HAVE_LIBALPM_14 + package_name1 = alpm_pkg_get_name (conflict->package1); + package_name2 = alpm_pkg_get_name (conflict->package2); +#else + package_name1 = conflict->package1; + package_name2 = conflict->package2; +#endif if (g_strcmp0 (package_name1, depend->name) == 0 || g_strcmp0 (package_name2, depend->name) == 0) {