Explorar el Código

libdpkg: Add Multi-Arch field support

This field will allow to satisfy dependencies between packages of
different architectures (beyond Architecture: all), and co-install
a package with the same name but different architecture.

The permitted values are:

* “no”

  This value is equivalent to the current default, the omission of the
  field.

* “same“

  This package is co-installable with itself, but it must not be used to
  satisfy the dependency of any package of a different architecture from
  itself.

* “foreign”

  The package is not co-installable with itself, but should be allowed
  to satisfy the dependencies of a package of a different architecture
  from itself.

* “allowed”

  This permits the reverse-dependencies of the package to annotate their
  Depends: field to indicate that a foreign architecture version of the
  package satisfies the dependencies, but does not change the resolution
  of any existing dependencies.
Guillem Jover hace 17 años
padre
commit
e215e2795f
Se han modificado 8 ficheros con 62 adiciones y 1 borrados
  1. 8 0
      lib/dpkg/dpkg-db.h
  2. 21 0
      lib/dpkg/dump.c
  3. 16 0
      lib/dpkg/fields.c
  4. 2 0
      lib/dpkg/parse.c
  5. 3 0
      lib/dpkg/parsedump.h
  6. 9 0
      lib/dpkg/parsehelp.c
  7. 2 1
      lib/dpkg/pkg.c
  8. 1 0
      src/processarc.c

+ 8 - 0
lib/dpkg/dpkg-db.h

@@ -4,6 +4,7 @@
  *
  * Copyright © 1994,1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2000,2001 Wichert Akkerman
+ * Copyright © 2006-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -108,6 +109,12 @@ struct pkgbin {
   struct deppossi *depended;
   /* The ‘essential’ flag, true = yes, false = no (absent). */
   bool essential;
+  enum pkgmultiarch {
+    multiarch_no,
+    multiarch_same,
+    multiarch_allowed,
+    multiarch_foreign,
+  } multiarch;
   const char *description;
   const char *maintainer;
   const char *source;
@@ -282,6 +289,7 @@ void copy_dependency_links(struct pkginfo *pkg,
 #include <dpkg/namevalue.h>
 
 extern const struct namevalue booleaninfos[];
+extern const struct namevalue multiarchinfos[];
 extern const struct namevalue priorityinfos[];
 extern const struct namevalue statusinfos[];
 extern const struct namevalue eflaginfos[];

+ 21 - 0
lib/dpkg/dump.c

@@ -4,6 +4,7 @@
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2001 Wichert Akkerman
+ * Copyright © 2006,2008-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -165,6 +166,26 @@ w_booleandefno(struct varbuf *vb,
   varbuf_add_str(vb, ": yes\n");
 }
 
+void
+w_multiarch(struct varbuf *vb,
+            const struct pkginfo *pigp, const struct pkgbin *pifp,
+            enum fwriteflags flags, const struct fieldinfo *fip)
+{
+  int value = PKGPFIELD(pifp, fip->integer, int);
+
+  if (!(flags & fw_printheader)) {
+    varbuf_add_str(vb, multiarchinfos[value].name);
+    return;
+  }
+  if (!value)
+    return;
+
+  varbuf_add_str(vb, fip->name);
+  varbuf_add_str(vb, ": ");
+  varbuf_add_str(vb, multiarchinfos[value].name);
+  varbuf_add_char(vb, '\n');
+}
+
 void
 w_priority(struct varbuf *vb,
            const struct pkginfo *pigp, const struct pkgbin *pifp,

+ 16 - 0
lib/dpkg/fields.c

@@ -4,6 +4,7 @@
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2001 Wichert Akkerman
+ * Copyright © 2006-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -156,6 +157,21 @@ f_boolean(struct pkginfo *pigp, struct pkgbin *pifp,
   PKGPFIELD(pifp, fip->integer, bool) = boolean;
 }
 
+void
+f_multiarch(struct pkginfo *pigp, struct pkgbin *pifp,
+            struct parsedb_state *ps,
+            const char *value, const struct fieldinfo *fip)
+{
+  int multiarch;
+
+  if (!*value)
+    return;
+
+  multiarch = parse_nv_last(ps, _("foreign/allowed/same/no in quadstate field"),
+                            multiarchinfos, value);
+  PKGPFIELD(pifp, fip->integer, int) = multiarch;
+}
+
 void
 f_section(struct pkginfo *pigp, struct pkgbin *pifp,
           struct parsedb_state *ps,

+ 2 - 0
lib/dpkg/parse.c

@@ -3,6 +3,7 @@
  * parse.c - database file parsing, main package/field loop
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2006,2008-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -51,6 +52,7 @@ const struct fieldinfo fieldinfos[]= {
   { "Package",          f_name,            w_name                                     },
   { "Essential",        f_boolean,         w_booleandefno,   PKGIFPOFF(essential)     },
   { "Status",           f_status,          w_status                                   },
+  { "Multi-Arch",       f_multiarch,       w_multiarch,      PKGIFPOFF(multiarch)     },
   { "Priority",         f_priority,        w_priority                                 },
   { "Section",          f_section,         w_section                                  },
   { "Installed-Size",   f_charfield,       w_charfield,      PKGIFPOFF(installedsize) },

+ 3 - 0
lib/dpkg/parsedump.h

@@ -4,6 +4,7 @@
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
  * Copyright © 2001 Wichert Akkerman
+ * Copyright © 2008-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -70,6 +71,7 @@ typedef void freadfunction(struct pkginfo *pigp, struct pkgbin *pifp,
 freadfunction f_name, f_charfield, f_priority, f_section, f_status, f_filecharf;
 freadfunction f_boolean, f_dependency, f_conffiles, f_version, f_revision;
 freadfunction f_configversion;
+freadfunction f_multiarch;
 freadfunction f_trigpend, f_trigaw;
 
 enum fwriteflags {
@@ -82,6 +84,7 @@ typedef void fwritefunction(struct varbuf*,
 			    enum fwriteflags flags, const struct fieldinfo*);
 fwritefunction w_name, w_charfield, w_priority, w_section, w_status, w_configversion;
 fwritefunction w_version, w_null, w_booleandefno, w_dependency, w_conffiles;
+fwritefunction w_multiarch;
 fwritefunction w_filecharf;
 fwritefunction w_trigpend, w_trigaw;
 

+ 9 - 0
lib/dpkg/parsehelp.c

@@ -3,6 +3,7 @@
  * parsehelp.c - helpful routines for parsing and writing
  *
  * Copyright © 1995 Ian Jackson <ian@chiark.greenend.org.uk>
+ * Copyright © 2006-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -76,6 +77,14 @@ const struct namevalue booleaninfos[] = {
   { .name = NULL }
 };
 
+const struct namevalue multiarchinfos[] = {
+  NAMEVALUE_DEF("no",      multiarch_no),
+  NAMEVALUE_DEF("same",    multiarch_same),
+  NAMEVALUE_DEF("allowed", multiarch_allowed),
+  NAMEVALUE_DEF("foreign", multiarch_foreign),
+  { .name = NULL }
+};
+
 const struct namevalue priorityinfos[] = {
   NAMEVALUE_DEF("required",                      pri_required),
   NAMEVALUE_DEF("important",                     pri_important),

+ 2 - 1
lib/dpkg/pkg.c

@@ -3,7 +3,7 @@
  * pkg.c - primitives for pkg handling
  *
  * Copyright © 1995, 1996 Ian Jackson <ian@chiark.greenend.org.uk>
- * Copyright © 2009 Guillem Jover <guillem@debian.org>
+ * Copyright © 2009-2011 Guillem Jover <guillem@debian.org>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -31,6 +31,7 @@ void
 pkgbin_blank(struct pkgbin *pkgbin)
 {
 	pkgbin->essential = false;
+	pkgbin->multiarch = multiarch_no;
 	pkgbin->depends = NULL;
 	pkgbin->depended = NULL;
 	pkgbin->description = NULL;

+ 1 - 0
src/processarc.c

@@ -1140,6 +1140,7 @@ void process_archive(const char *filename) {
    * can find out what other packages refer to this one. So,
    * we don't copy it. We go straight on to copy the text fields. */
   pkg->installed.essential= pkg->available.essential;
+  pkg->installed.multiarch = pkg->available.multiarch;
   pkg->installed.description= pkg->available.description;
   pkg->installed.maintainer= pkg->available.maintainer;
   pkg->installed.source= pkg->available.source;