Skip to content

Commit

Permalink
alpm: Support alpm 13 and 14
Browse files Browse the repository at this point in the history
This should also help in running alpm job in debian CI (which
currently has alpm 13).
  • Loading branch information
sidt4 committed Aug 24, 2024
1 parent 527a1f4 commit f90ba2a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 12 deletions.
24 changes: 15 additions & 9 deletions backends/alpm/meson.build
Original file line number Diff line number Diff line change
@@ -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',
Expand Down Expand Up @@ -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,
)
Expand Down
2 changes: 2 additions & 0 deletions backends/alpm/pk-alpm-config.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 9 additions & 3 deletions backends/alpm/pk-alpm-transaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f90ba2a

Please sign in to comment.