This is an automated email from the git hooks/post-receive script.

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=4dfa2cb392e442938a7a4fcb90a46826f90abb2e

commit 4dfa2cb392e442938a7a4fcb90a46826f90abb2e
Author: Guillem Jover <[email protected]>
AuthorDate: Fri Feb 22 09:47:43 2019 +0100

    libdpkg: Clarify field names in error and warning messages
    
    Move all field names to be format arguments so that these do not get
    accidentally translated. Use fip->name instead of hardcoding the field
    name. Always refer to the field names as "'%s' field". Use the proper
    field names instead of descriptions. And capitalize their names.
---
 debian/changelog     |  1 +
 lib/dpkg/fields.c    | 43 ++++++++++++++++++++++---------------------
 lib/dpkg/parse.c     | 28 +++++++++++++++-------------
 lib/dpkg/parsehelp.c |  8 ++++----
 4 files changed, 42 insertions(+), 38 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index ad55eea6f..a0f88a3df 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,7 @@ dpkg (1.19.5) UNRELEASED; urgency=medium
     -maxdepth 1. Thanks to Ralf Treinen <[email protected]>. Closes: #922799
   * dpkg-genbuildinfo: Add support for a new Build-Tainted-By field in
     .buildinfo files. Suggested by Alexander E. Patrakov <[email protected]>.
+  * libdpkg: Clarify field names in error and warning messages.
   * Perl modules:
     - Dpkg::Vendor::Debian: Add support for merged-usr-via-symlinks tainted
       tag. Suggested by Alexander E. Patrakov <[email protected]>.
diff --git a/lib/dpkg/fields.c b/lib/dpkg/fields.c
index 1389e6ebc..63f9441bd 100644
--- a/lib/dpkg/fields.c
+++ b/lib/dpkg/fields.c
@@ -103,7 +103,7 @@ f_name(struct pkginfo *pkg, struct pkgbin *pkgbin,
 
   e = pkg_name_is_illegal(value);
   if (e != NULL)
-    parse_error(ps, _("invalid package name (%.250s)"), e);
+    parse_error(ps, _("invalid package name in '%s' field: %s"), fip->name, e);
   /* We use the new name, as pkg_hash_find_set() may have done a tolower for 
us. */
   pkg->set->name = pkg_hash_find_set(value)->name;
 }
@@ -118,10 +118,10 @@ f_archives(struct pkginfo *pkg, struct pkgbin *pkgbin,
   int allowextend;
 
   if (!*value)
-    parse_error(ps, _("empty archive details field '%s'"), fip->name);
+    parse_error(ps, _("empty archive details '%s' field"), fip->name);
   if (!(ps->flags & pdb_recordavailable))
     parse_error(ps,
-                _("archive details field '%s' not allowed in status file"),
+                _("archive details '%s' field not allowed in status file"),
                fip->name);
   allowextend = !pkg->archives;
   fdpp = &pkg->archives;
@@ -136,7 +136,7 @@ f_archives(struct pkginfo *pkg, struct pkgbin *pkgbin,
     if (!fdp) {
       if (!allowextend)
         parse_error(ps,
-                    _("too many values in archive details field '%s' "
+                    _("too many values in archive details '%s' field "
                       "(compared to others)"), fip->name);
       fdp = nfmalloc(sizeof(*fdp));
       fdp->next= NULL;
@@ -151,7 +151,7 @@ f_archives(struct pkginfo *pkg, struct pkgbin *pkgbin,
   }
   if (*fdpp)
     parse_error(ps,
-                _("too few values in archive details field '%s' "
+                _("too few values in archive details '%s' field "
                   "(compared to others)"), fip->name);
 }
 
@@ -201,8 +201,8 @@ f_architecture(struct pkginfo *pkg, struct pkgbin *pkgbin,
 {
   pkgbin->arch = dpkg_arch_find(value);
   if (pkgbin->arch->type == DPKG_ARCH_ILLEGAL)
-    parse_warn(ps, _("'%s' is not a valid architecture name: %s"),
-               value, dpkg_arch_name_is_illegal(value));
+    parse_warn(ps, _("'%s' is not a valid architecture name in '%s' field: 
%s"),
+               value, fip->name, dpkg_arch_name_is_illegal(value));
 }
 
 void
@@ -243,7 +243,7 @@ f_status(struct pkginfo *pkg, struct pkgbin *pkgbin,
   if (ps->flags & pdb_rejectstatus)
     parse_error(ps,
                 _("value for '%s' field not allowed in this context"),
-                "Status");
+                fip->name);
   if (ps->flags & pdb_recordavailable)
     return;
 
@@ -261,8 +261,8 @@ f_version(struct pkginfo *pkg, struct pkgbin *pkgbin,
           const char *value, const struct fieldinfo *fip)
 {
   parse_db_version(ps, &pkgbin->version, value,
-                   _("error in '%s' field string '%.250s'"),
-                   "Version", value);
+                   _("'%s' field value '%.250s'"),
+                   fip->name, value);
 }
 
 void
@@ -294,13 +294,13 @@ f_configversion(struct pkginfo *pkg, struct pkgbin 
*pkgbin,
   if (ps->flags & pdb_rejectstatus)
     parse_error(ps,
                 _("value for '%s' field not allowed in this context"),
-                "Config-Version");
+                fip->name);
   if (ps->flags & pdb_recordavailable)
     return;
 
   parse_db_version(ps, &pkg->configversion, value,
-                   _("error in '%s' field string '%.250s'"),
-                   "Config-Version", value);
+                   _("'%s' field value '%.250s'"),
+                   fip->name, value);
 
 }
 
@@ -348,8 +348,8 @@ f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
     if (c == '\n') continue;
     if (c != ' ')
       parse_error(ps,
-                  _("value for '%s' has line starting with non-space '%c'"),
-                  "Conffiles", c);
+                  _("value for '%s' field has line starting with non-space 
'%c'"),
+                  fip->name, c);
     for (endent = value; (c = *endent) != '\0' && c != '\n'; endent++) ;
     conffvalue_lastword(value, endent, endent,
                        &hashstart, &hashlen, &endfn,
@@ -365,7 +365,8 @@ f_conffiles(struct pkginfo *pkg, struct pkgbin *pkgbin,
     namelen= (int)(endfn-value);
     if (namelen <= 0)
       parse_error(ps,
-                  _("root or null directory is listed as a conffile"));
+                  _("root or empty directory listed as a conffile in '%s' 
field"),
+                  fip->name);
     newptr = nfmalloc(namelen+2);
     newptr[0]= '/';
     memcpy(newptr+1,value,namelen);
@@ -540,7 +541,7 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
         if ((dop->verrel != DPKG_RELATION_EQ) && (fip->integer == 
dep_provides))
           parse_warn(ps,
                      _("only exact versions may be used for '%s' field"),
-                     "Provides");
+                     fip->name);
 
         if (!c_isspace(*p) && !c_isalnum(*p)) {
           parse_warn(ps,
@@ -596,8 +597,8 @@ f_dependency(struct pkginfo *pkg, struct pkgbin *pkgbin,
           fip->integer == dep_breaks ||
           fip->integer == dep_provides ||
           fip->integer == dep_replaces)
-        parse_error(ps,
-                    _("alternatives ('|') not allowed in %s field"), 
fip->name);
+        parse_error(ps, _("alternatives ('|') not allowed in '%s' field"),
+                    fip->name);
       p++;
       while (c_isspace(*p))
         p++;
@@ -656,7 +657,7 @@ f_trigpend(struct pkginfo *pend, struct pkgbin *pkgbin,
   if (ps->flags & pdb_rejectstatus)
     parse_error(ps,
                 _("value for '%s' field not allowed in this context"),
-                "Triggers-Pending");
+                fip->name);
 
   while ((word = scan_word(&value))) {
     emsg = trig_name_is_illegal(word);
@@ -681,7 +682,7 @@ f_trigaw(struct pkginfo *aw, struct pkgbin *pkgbin,
   if (ps->flags & pdb_rejectstatus)
     parse_error(ps,
                 _("value for '%s' field not allowed in this context"),
-                "Triggers-Awaited");
+                fip->name);
 
   while ((word = scan_word(&value))) {
     struct dpkg_error err;
diff --git a/lib/dpkg/parse.c b/lib/dpkg/parse.c
index b5e38dd14..a2663cf5f 100644
--- a/lib/dpkg/parse.c
+++ b/lib/dpkg/parse.c
@@ -177,7 +177,7 @@ pkg_parse_verify(struct parsedb_state *ps,
   struct dependency *dep;
   struct deppossi *dop;
 
-  parse_must_have_field(ps, pkg->set->name, "package name");
+  parse_must_have_field(ps, pkg->set->name, "Package");
 
   /* XXX: We need to check for status != PKG_STAT_HALFINSTALLED as while
    * unpacking an unselected package, it will not have yet all data in
@@ -186,9 +186,9 @@ pkg_parse_verify(struct parsedb_state *ps,
   if ((ps->flags & pdb_recordavailable) ||
       (pkg->status != PKG_STAT_NOTINSTALLED &&
        pkg->status != PKG_STAT_HALFINSTALLED)) {
-    parse_ensure_have_field(ps, &pkgbin->description, "description");
-    parse_ensure_have_field(ps, &pkgbin->maintainer, "maintainer");
-    parse_must_have_field(ps, pkgbin->version.version, "version");
+    parse_ensure_have_field(ps, &pkgbin->description, "Description");
+    parse_ensure_have_field(ps, &pkgbin->maintainer, "Maintainer");
+    parse_must_have_field(ps, pkgbin->version.version, "Version");
   }
 
   /* XXX: Versions before dpkg 1.10.19 did not preserve the Architecture
@@ -200,9 +200,9 @@ pkg_parse_verify(struct parsedb_state *ps,
      * is in such a state that it make sense), so that it can be used safely
      * on string comparisons and the like. */
     if (pkgbin->arch->type == DPKG_ARCH_NONE)
-      parse_warn(ps, _("missing %s"), "architecture");
+      parse_warn(ps, _("missing '%s' field"), "Architecture");
     else if (pkgbin->arch->type == DPKG_ARCH_EMPTY)
-      parse_warn(ps, _("empty value for %s"), "architecture");
+      parse_warn(ps, _("empty value for '%s' field"), "Architecture");
   }
   /* Mark missing architectures as empty, to distinguish these from
    * unused slots in the db. */
@@ -211,12 +211,12 @@ pkg_parse_verify(struct parsedb_state *ps,
 
   if (pkgbin->arch->type == DPKG_ARCH_EMPTY &&
       pkgbin->multiarch == PKG_MULTIARCH_SAME)
-    parse_error(ps, _("package has field '%s' but is missing architecture"),
+    parse_error(ps, _("package has '%s' field but is missing architecture"),
                 "Multi-Arch: same");
   if (pkgbin->arch->type == DPKG_ARCH_ALL &&
       pkgbin->multiarch == PKG_MULTIARCH_SAME)
-    parse_error(ps, _("package has field '%s' but is architecture all"),
-                "Multi-Arch: same");
+    parse_error(ps, _("package has '%s' field but is architecture '%s'"),
+                "Multi-Arch: same", "all");
 
   /* Generate the cached fully qualified package name representation. */
   pkgbin->pkgname_archqual = pkgbin_name_archqual(pkg, pkgbin);
@@ -241,7 +241,8 @@ pkg_parse_verify(struct parsedb_state *ps,
           pkg->status == PKG_STAT_NOTINSTALLED ||
           pkg->status == PKG_STAT_TRIGGERSPENDING)
         parse_error(ps,
-                    _("Config-Version for package with inappropriate Status"));
+                    _("'%s' field present for package with inappropriate '%s' 
field"),
+                    "Config-Version", "Status");
     } else {
       if (pkg->status == PKG_STAT_INSTALLED ||
           pkg->status == PKG_STAT_TRIGGERSPENDING)
@@ -420,11 +421,12 @@ parse_find_pkg_slot(struct parsedb_state *ps,
     /* Verify we don't allow something that will mess up the db. */
     if (pkgset_installed_instances(db_set) > 1 &&
         !selection && new_pkgbin->multiarch != PKG_MULTIARCH_SAME)
-      ohshit(_("%s %s (Multi-Arch: %s) is not co-installable with "
-               "%s which has multiple installed instances"),
+      ohshit(_("package %s (%s) with field '%s: %s' is not co-installable "
+               "with %s which has multiple installed instances"),
              pkgbin_name(new_pkg, new_pkgbin, pnaw_always),
              versiondescribe(&new_pkgbin->version, vdew_nonambig),
-             multiarchinfos[new_pkgbin->multiarch].name, db_set->name);
+             "Multi-Arch", multiarchinfos[new_pkgbin->multiarch].name,
+             db_set->name);
 
     /* If we are parsing the status file, use a slot per arch. */
     if (ps->type == pdb_file_status)
diff --git a/lib/dpkg/parsehelp.c b/lib/dpkg/parsehelp.c
index 453077fd9..caba83afb 100644
--- a/lib/dpkg/parsehelp.c
+++ b/lib/dpkg/parsehelp.c
@@ -296,9 +296,9 @@ parse_must_have_field(struct parsedb_state *ps,
                       const char *value, const char *what)
 {
   if (!value)
-    parse_error(ps, _("missing %s"), what);
+    parse_error(ps, _("missing '%s' field"), what);
   else if (!*value)
-    parse_error(ps, _("empty value for %s"), what);
+    parse_error(ps, _("empty value for '%s' field"), what);
 }
 
 void
@@ -308,9 +308,9 @@ parse_ensure_have_field(struct parsedb_state *ps,
   static const char empty[] = "";
 
   if (!*value) {
-    parse_warn(ps, _("missing %s"), what);
+    parse_warn(ps, _("missing '%s' field"), what);
     *value = empty;
   } else if (!**value) {
-    parse_warn(ps, _("empty value for %s"), what);
+    parse_warn(ps, _("empty value for '%s' field"), what);
   }
 }

-- 
Dpkg.Org's dpkg

Reply via email to