Browse Source

dpkg: Fix md5sum parse error messages to include package name affected

Guillem Jover 9 years ago
parent
commit
6560c152de
2 changed files with 16 additions and 13 deletions
  1. 2 0
      debian/changelog
  2. 14 13
      src/filesdb-hash.c

+ 2 - 0
debian/changelog

@@ -9,6 +9,8 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
   * Obsolete dpkg-deb bzip2 and lzma compression methods by emitting errors.
   * Remove obsolete dpkg-deb --old and --new options.
   * Remove obsolete dpkg --print-installation-architecture option.
+  * Fix dpkg error messages when parsing md5sum files to include the package
+    name affected.
   * Perl modules:
     - Obsolete Source-Version substvar in Dpkg::Substvars by emitting errors.
   * Packaging:

+ 14 - 13
src/filesdb-hash.c

@@ -2,7 +2,7 @@
  * dpkg - main program for package management
  * filesdb-hash.c - management of database of files installed on system
  *
- * Copyright © 2012 Guillem Jover <guillem@debian.org>
+ * Copyright © 2012-2014 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
@@ -85,6 +85,7 @@ parse_filehash_buffer(char *buf, char *buf_end,
                       struct pkginfo *pkg, struct pkgbin *pkgbin)
 {
 	char *thisline, *nextline;
+	const char *pkgname = pkg_name(pkg, pnaw_nonambig);
 
 	for (thisline = buf; thisline < buf_end; thisline = nextline) {
 		struct filenamenode *namenode;
@@ -93,19 +94,19 @@ parse_filehash_buffer(char *buf, char *buf_end,
 		endline = memchr(thisline, '\n', buf_end - thisline);
 		if (endline == NULL)
 			ohshit(_("control file '%s' for package '%s' is "
-			         "missing final newline"),
-			       HASHFILE, pkg_name(pkg, pnaw_nonambig));
+			         "missing final newline"), HASHFILE, pkgname);
 
 		/* The md5sum hash has a constant length. */
 		hash_end = thisline + MD5HASHLEN;
 
 		filename = hash_end + 2;
 		if (filename + 1 > endline)
-			ohshit(_("control file '%s' missing value"), HASHFILE);
+			ohshit(_("control file '%s' for package '%s' is "
+			         "missing value"), HASHFILE, pkgname);
 
 		if (hash_end[0] != ' ' || hash_end[1] != ' ')
-			ohshit(_("control file '%s' missing value separator"),
-			       HASHFILE);
+			ohshit(_("control file '%s' for package '%s' is "
+			         "missing value separator"), HASHFILE, pkgname);
 		hash_end[0] = '\0';
 
 		/* Where to start next time around. */
@@ -117,8 +118,8 @@ parse_filehash_buffer(char *buf, char *buf_end,
 		*endline = '\0';
 
 		if (endline == thisline)
-			ohshit(_("control file '%s' for package '%s' contains empty filename"),
-			       HASHFILE, pkg_name(pkg, pnaw_nonambig));
+			ohshit(_("control file '%s' for package '%s' "
+			         "contains empty filename"), HASHFILE, pkgname);
 
 		debug(dbg_eachfiledetail, "load hash '%s' for filename '%s'",
 		      thisline, filename);
@@ -143,16 +144,16 @@ parse_filehash(struct pkginfo *pkg, struct pkgbin *pkgbin)
 		if (errno == ENOENT)
 			return;
 
-		ohshite(_("cannot open '%s' control file for package '%s'"),
+		ohshite(_("cannot open control file '%s' for package '%s'"),
 		        HASHFILE, pkg_name(pkg, pnaw_nonambig));
 	}
 
 	if (fstat(fd, &st) < 0)
-		ohshite(_("cannot stat '%s' control file for package '%s'"),
+		ohshite(_("cannot stat control file '%s' for package '%s'"),
 		        HASHFILE, pkg_name(pkg, pnaw_nonambig));
 
 	if (!S_ISREG(st.st_mode))
-		ohshit(_("'%s' file for package '%s' is not a regular file"),
+		ohshit(_("control file '%s' for package '%s' is not a regular file"),
 		       HASHFILE, pkg_name(pkg, pnaw_nonambig));
 
 	if (st.st_size > 0) {
@@ -162,13 +163,13 @@ parse_filehash(struct pkginfo *pkg, struct pkgbin *pkgbin)
 		buf_end = buf + st.st_size;
 
 		if (fd_read(fd, buf, st.st_size) < 0)
-			ohshite(_("cannot read '%s' control file for package '%s'"),
+			ohshite(_("cannot read control file '%s' for package '%s'"),
 			        HASHFILE, pkg_name(pkg, pnaw_nonambig));
 
 		parse_filehash_buffer(buf, buf_end, pkg, pkgbin);
 	}
 
 	if (close(fd))
-		ohshite(_("cannot close '%s' control file for package '%s'"),
+		ohshite(_("cannot close control file '%s' for package '%s'"),
 		        HASHFILE, pkg_name(pkg, pnaw_nonambig));
 }