The following commit has been merged in the master branch:
commit 5631564609ec8855cdcab384139ca2e81c2519ce
Author: Steve Langasek <[email protected]>
Date: Fri Feb 4 22:52:25 2011 +0100
libdpkg: Add new archsatisfied() function
The function archsatisfied(pkgbin, deppossi) returns true if pkgbin is a
valid solution to deppossi when considering the architecture requirement
set by the dependency and the announced multiarch type for pkgbin. It
returns false otherwise.
Signed-off-by: Guillem Jover <[email protected]>
diff --git a/lib/dpkg/depcon.c b/lib/dpkg/depcon.c
index b5089cd..6f96890 100644
--- a/lib/dpkg/depcon.c
+++ b/lib/dpkg/depcon.c
@@ -3,6 +3,7 @@
* depcon.c - dependency and conflict checking
*
* Copyright © 1995 Ian Jackson <[email protected]>
+ * Copyright © 2009 Canonical Ltd.
*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,6 +24,7 @@
#include <dpkg/dpkg.h>
#include <dpkg/dpkg-db.h>
+#include <dpkg/arch.h>
bool
versionsatisfied(struct pkgbin *it, struct deppossi *against)
@@ -30,3 +32,44 @@ versionsatisfied(struct pkgbin *it, struct deppossi *against)
return versionsatisfied3(&it->version, &against->version,
against->verrel);
}
+
+/**
+ * Check if the architecture qualifier in the dependency is satisfied.
+ *
+ * The rules are supposed to be:
+ * - unqualified Depends/Pre-Depends/Recommends/Suggests are only
+ * satisfied by a package of a different architecture if the target
+ * package is Multi-Arch: foreign.
+ * - Depends/Pre-Depends/Recommends/Suggests on pkg:any are satisfied by
+ * a package of a different architecture if the target package is
+ * Multi-Arch: allowed.
+ * - all other Depends/Pre-Depends/Recommends/Suggests are only
+ * satisfied by packages of the same architecture.
+ * - Architecture: all packages are treated the same as packages of the
+ * native architecture.
+ * - Conflicts/Replaces/Breaks are assumed to apply to packages of any arch.
+ */
+bool
+archsatisfied(struct pkgbin *it, struct deppossi *against)
+{
+ const struct dpkg_arch *dep_arch, *pkg_arch;
+
+ if (it->multiarch == multiarch_foreign)
+ return true;
+
+ dep_arch = against->arch;
+ if (dep_arch->type == arch_wildcard &&
+ (it->multiarch == multiarch_allowed ||
+ against->up->type == dep_conflicts ||
+ against->up->type == dep_replaces ||
+ against->up->type == dep_breaks))
+ return true;
+
+ pkg_arch = it->arch;
+ if (dep_arch->type == arch_none || dep_arch->type == arch_all)
+ dep_arch = dpkg_arch_get_native();
+ if (pkg_arch->type == arch_none || pkg_arch->type == arch_all)
+ pkg_arch = dpkg_arch_get_native();
+
+ return (dep_arch == pkg_arch);
+}
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index fdc4760..af6d3b1 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -355,6 +355,7 @@ bool epochsdiffer(const struct versionrevision *a,
/*** from depcon.c ***/
bool versionsatisfied(struct pkgbin *it, struct deppossi *against);
+bool archsatisfied(struct pkgbin *it, struct deppossi *against);
/*** from nfmalloc.c ***/
void *nfmalloc(size_t);
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]