The following commit has been merged in the master branch:
commit 865a375dca37b1d2f1db9eedd4f124519e1624bc
Author: Raphaël Hertzog <[email protected]>
Date:   Fri Jan 28 10:42:47 2011 +0100

    libdpkg: Update pkgbin.arch to be a pointer to struct dpkg_arch
    
    Sponsored-by: Linaro Limited
    
    [[email protected]:
     - Distinguish between missing and empty Architecture field. ]
    
    Signed-off-by: Guillem Jover <[email protected]>

diff --git a/dpkg-deb/build.c b/dpkg-deb/build.c
index 75132ee..3c34399 100644
--- a/dpkg-deb/build.c
+++ b/dpkg-deb/build.c
@@ -374,9 +374,9 @@ pkg_get_pathname(const char *dir, struct pkginfo *pkg)
   const char *versionstring, *arch_sep;
 
   versionstring = versiondescribe(&pkg->available.version, vdew_never);
-  arch_sep = pkg->available.arch[0] == '\0' ? "" : "_";
+  arch_sep = pkg->available.arch->type == arch_none ? "" : "_";
   m_asprintf(&path, "%s/%s_%s%s%s%s", dir, pkg->name, versionstring,
-             arch_sep, pkg->available.arch, DEBEXT);
+             arch_sep, pkg->available.arch->name, DEBEXT);
 
   return path;
 }
diff --git a/lib/dpkg/dpkg-db.h b/lib/dpkg/dpkg-db.h
index 72fb6de..e196f71 100644
--- a/lib/dpkg/dpkg-db.h
+++ b/lib/dpkg/dpkg-db.h
@@ -31,6 +31,7 @@
 #include <dpkg/macros.h>
 #include <dpkg/varbuf.h>
 #include <dpkg/version.h>
+#include <dpkg/arch.h>
 
 DPKG_BEGIN_DECLS
 
@@ -115,10 +116,10 @@ struct pkgbin {
     multiarch_allowed,
     multiarch_foreign,
   } multiarch;
+  const struct dpkg_arch *arch;
   const char *description;
   const char *maintainer;
   const char *source;
-  const char *arch;
   const char *installedsize;
   const char *origin;
   const char *bugs;
diff --git a/lib/dpkg/dump.c b/lib/dpkg/dump.c
index 95cbffa..f1cc504 100644
--- a/lib/dpkg/dump.c
+++ b/lib/dpkg/dump.c
@@ -5,6 +5,8 @@
  * Copyright © 1995 Ian Jackson <[email protected]>
  * Copyright © 2001 Wichert Akkerman
  * Copyright © 2006,2008-2011 Guillem Jover <[email protected]>
+ * Copyright © 2011 Linaro Limited
+ * Copyright © 2011 Raphaël Hertzog <[email protected]>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -187,6 +189,25 @@ w_multiarch(struct varbuf *vb,
 }
 
 void
+w_architecture(struct varbuf *vb,
+               const struct pkginfo *pigp, const struct pkgbin *pifp,
+               enum fwriteflags flags, const struct fieldinfo *fip)
+{
+  if (!pifp->arch)
+    return;
+  if (pifp->arch->type == arch_none)
+    return;
+
+  if (flags & fw_printheader) {
+    varbuf_add_str(vb, fip->name);
+    varbuf_add_str(vb, ": ");
+  }
+  varbuf_add_str(vb, pifp->arch->name);
+  if (flags & fw_printheader)
+    varbuf_add_char(vb, '\n');
+}
+
+void
 w_priority(struct varbuf *vb,
            const struct pkginfo *pigp, const struct pkgbin *pifp,
            enum fwriteflags flags, const struct fieldinfo *fip)
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index b86587f..ffb24b7 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -5,6 +5,8 @@
  * Copyright © 1995 Ian Jackson <[email protected]>
  * Copyright © 2001 Wichert Akkerman
  * Copyright © 2006-2011 Guillem Jover <[email protected]>
+ * Copyright © 2011 Linaro Limited
+ * Copyright © 2011 Raphaël Hertzog <[email protected]>
  *
  * This is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -173,6 +175,20 @@ f_multiarch(struct pkginfo *pigp, struct pkgbin *pifp,
 }
 
 void
+f_architecture(struct pkginfo *pigp, struct pkgbin *pifp,
+               struct parsedb_state *ps,
+               const char *value, const struct fieldinfo *fip)
+{
+  if (!*value)
+    return;
+
+  pifp->arch = dpkg_arch_find(value);
+  if (pifp->arch->type == arch_illegal)
+    parse_warn(ps, _("'%s' is not a valid architecture name: %s"),
+               value, dpkg_arch_name_is_illegal(value));
+}
+
+void
 f_section(struct pkginfo *pigp, struct pkgbin *pifp,
           struct parsedb_state *ps,
           const char *value, const struct fieldinfo *fip)
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index 1be7351..5897628 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -59,7 +59,7 @@ const struct fieldinfo fieldinfos[]= {
   { "Origin",           f_charfield,       w_charfield,      PKGIFPOFF(origin) 
       },
   { "Maintainer",       f_charfield,       w_charfield,      
PKGIFPOFF(maintainer)    },
   { "Bugs",             f_charfield,       w_charfield,      PKGIFPOFF(bugs)   
       },
-  { "Architecture",     f_charfield,       w_charfield,      PKGIFPOFF(arch)   
       },
+  { "Architecture",     f_architecture,    w_architecture                      
       },
   { "Source",           f_charfield,       w_charfield,      PKGIFPOFF(source) 
       },
   { "Version",          f_version,         w_version,        
PKGIFPOFF(version)       },
   { "Revision",         f_revision,        w_null                              
       },
@@ -192,10 +192,13 @@ pkg_parse_verify(struct parsedb_state *ps,
     /* We always want usable architecture information (as long as the package
      * is in such a state that it make sense), so that it can be used safely
      * on string comparisons and the like. */
-    parse_ensure_have_field(ps, &pkgbin->arch, "architecture");
-  } else if (pkgbin->arch == NULL) {
-    pkgbin->arch = "";
+    if (pkgbin->arch == NULL)
+      parse_warn(ps, _("missing %s"), "architecture");
+    else if (pkgbin->arch->type == arch_none)
+      parse_warn(ps, _("empty value for %s"), "architecture");
   }
+  if (pkgbin->arch == NULL)
+    pkgbin->arch = dpkg_arch_find(NULL);
 
   /* Check the Config-Version information:
    * If there is a Config-Version it is definitely to be used, but
diff --git a/lib/dpkg/parsedump.h b/lib/dpkg/parsedump.h
index 101daca..0701b7b 100644
--- a/lib/dpkg/parsedump.h
+++ b/lib/dpkg/parsedump.h
@@ -72,6 +72,7 @@ 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_architecture;
 freadfunction f_trigpend, f_trigaw;
 
 enum fwriteflags {
@@ -85,6 +86,7 @@ typedef void fwritefunction(struct varbuf*,
 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_architecture;
 fwritefunction w_filecharf;
 fwritefunction w_trigpend, w_trigaw;
 
diff --git a/src/help.c b/src/help.c
index e9ffd2e..9208410 100644
--- a/src/help.c
+++ b/src/help.c
@@ -270,7 +270,7 @@ do_script(struct pkginfo *pkg, struct pkgbin *pif,
   pid = subproc_fork();
   if (pid == 0) {
     if (setenv("DPKG_MAINTSCRIPT_PACKAGE", pkg->name, 1) ||
-        setenv("DPKG_MAINTSCRIPT_ARCH", pif->arch, 1) ||
+        setenv("DPKG_MAINTSCRIPT_ARCH", pif->arch->name, 1) ||
         setenv("DPKG_MAINTSCRIPT_NAME", cmd->argv[0], 1) ||
         setenv("DPKG_RUNNING_VERSION", PACKAGE_VERSION, 1))
       ohshite(_("unable to setenv for maintainer script"));
diff --git a/src/processarc.c b/src/processarc.c
index 7c0201a..1651608 100644
--- a/src/processarc.c
+++ b/src/processarc.c
@@ -496,11 +496,11 @@ void process_archive(const char *filename) {
     return;
   }
 
-  if (strcmp(pkg->available.arch, "all") &&
-      strcmp(pkg->available.arch, native_arch))
+  if (pkg->available.arch->type != arch_all &&
+      pkg->available.arch->type != arch_native)
     forcibleerr(fc_architecture,
                 _("package architecture (%s) does not match system (%s)"),
-                pkg->available.arch, native_arch);
+                pkg->available.arch->name, native_arch);
 
   for (deconpil= deconfigure;
        deconpil;

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to