2 * libdpkg - Debian packaging suite library routines
3 * depcon.c - dependency and conflict checking
5 * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
6 * Copyright © 2009 Canonical Ltd.
8 * This is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 #include <dpkg/dpkg.h>
26 #include <dpkg/dpkg-db.h>
27 #include <dpkg/arch.h>
30 versionsatisfied(struct pkgbin *it, struct deppossi *against)
32 return dpkg_version_relate(&it->version,
38 * Check if the architecture qualifier in the dependency is satisfied.
40 * The rules are supposed to be:
41 * - unqualified Depends/Pre-Depends/Recommends/Suggests are only
42 * satisfied by a package of a different architecture if the target
43 * package is Multi-Arch: foreign.
44 * - Depends/Pre-Depends/Recommends/Suggests on pkg:any are satisfied by
45 * a package of a different architecture if the target package is
46 * Multi-Arch: allowed.
47 * - all other Depends/Pre-Depends/Recommends/Suggests are only
48 * satisfied by packages of the same architecture.
49 * - Architecture: all packages are treated the same as packages of the
50 * native architecture.
51 * - Conflicts/Replaces/Breaks are assumed to apply to packages of any arch.
54 deparchsatisfied(struct pkgbin *it, const struct dpkg_arch *it_arch,
55 struct deppossi *against)
57 const struct dpkg_arch *dep_arch, *pkg_arch;
59 if (against->arch_is_implicit &&
60 it->multiarch == multiarch_foreign)
63 dep_arch = against->arch;
64 if (dep_arch->type == arch_wildcard &&
65 (it->multiarch == multiarch_allowed ||
66 against->up->type == dep_conflicts ||
67 against->up->type == dep_replaces ||
68 against->up->type == dep_breaks))
72 if (dep_arch->type == arch_none || dep_arch->type == arch_all)
73 dep_arch = dpkg_arch_get(arch_native);
74 if (pkg_arch->type == arch_none || pkg_arch->type == arch_all)
75 pkg_arch = dpkg_arch_get(arch_native);
77 return (dep_arch == pkg_arch);
81 archsatisfied(struct pkgbin *it, struct deppossi *against)
83 return deparchsatisfied(it, it->arch, against);