The following commit has been merged in the master branch:
commit 1309c6a7d3c5aa4a0094c0e12ba3aa60ae2c0a6d
Author: Guillem Jover <guil...@debian.org>
Date:   Mon Jan 30 21:31:53 2012 +0100

    dpkg: Compute and track hashes for newly unpacked file
    
    This will be used for checksum generation at unpack time, and for shared
    file verification.

diff --git a/src/archives.c b/src/archives.c
index e65c672..3a2f8ec 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -254,6 +254,7 @@ tarobject_extract(struct tarcontext *tc, struct tar_entry 
*te,
 
   struct filenamenode *linknode;
   char fnamebuf[256];
+  char *newhash;
 
   switch (te->type) {
   case tar_filetype_file:
@@ -267,9 +268,12 @@ tarobject_extract(struct tarcontext *tc, struct tar_entry 
*te,
     debug(dbg_eachfiledetail, "tarobject file open size=%jd",
           (intmax_t)te->size);
 
-    fd_fd_copy(tc->backendpipe, fd, te->size,
-               _("backend dpkg-deb during `%.255s'"),
-               path_quote_filename(fnamebuf, te->name, 256));
+    newhash = nfmalloc(MD5HASHLEN + 1);
+    fd_fd_copy_and_md5(tc->backendpipe, fd, newhash, te->size,
+                       _("backend dpkg-deb during `%.255s'"),
+                       path_quote_filename(fnamebuf, te->name, 256));
+    namenode->newhash = newhash;
+    debug(dbg_eachfiledetail, "tarobject file hash=%s", namenode->newhash);
 
     tarobject_skip_padding(tc, te);
 
@@ -320,7 +324,8 @@ tarobject_extract(struct tarcontext *tc, struct tar_entry 
*te,
     varbuf_end_str(&hardlinkfn);
     if (link(hardlinkfn.buf, path))
       ohshite(_("error creating hard link `%.255s'"), te->name);
-    debug(dbg_eachfiledetail, "tarobject hardlink");
+    namenode->newhash = linknode->newhash;
+    debug(dbg_eachfiledetail, "tarobject hardlink hash=%s", namenode->newhash);
     break;
   case tar_filetype_symlink:
     /* We've already checked for an existing directory. */
diff --git a/src/filesdb.c b/src/filesdb.c
index 4a888a5..1fa291c 100644
--- a/src/filesdb.c
+++ b/src/filesdb.c
@@ -628,6 +628,7 @@ void filesdbinit(void) {
     for (fnn= bins[i]; fnn; fnn= fnn->next) {
       fnn->flags= 0;
       fnn->oldhash = NULL;
+      fnn->newhash = EMPTYHASHFLAG;
       fnn->filestat = NULL;
     }
 }
@@ -671,6 +672,7 @@ struct filenamenode *findnamenode(const char *name, enum 
fnnflags flags) {
   newnode->next = NULL;
   newnode->divert = NULL;
   newnode->statoverride = NULL;
+  newnode->newhash = EMPTYHASHFLAG;
   newnode->filestat = NULL;
   newnode->trig_interested = NULL;
   *pointerp= newnode;
diff --git a/src/filesdb.h b/src/filesdb.h
index de62aa1..a54616e 100644
--- a/src/filesdb.h
+++ b/src/filesdb.h
@@ -97,6 +97,9 @@ struct filenamenode {
   /* Valid iff this namenode is in the newconffiles list. */
   const char *oldhash;
 
+  /* Valid iff the file was unpacked and hashed on this run. */
+  const char *newhash;
+
   struct stat *filestat;
   struct trigfileint *trig_interested;
 };

-- 
dpkg's main repository


-- 
To UNSUBSCRIBE, email to debian-dpkg-cvs-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to