Package: reprepro
Version: 5.1.1-1~bpo8+1

As a result of some server issues I recently re-imported all of the raspbian 
repos into a new reprepro instance. A few weeks later a user complained that 
contents files were missing from our repo. After doing some investigation it 
seems that reprepro can't read one of our packages. I was able to succesfully 
extract the package using using dpkg-deb.

So I decided to manually pick apart the package. It appears that the data member is 
called "data.tar.gz" but is in-fact uncompressed.

While this does seem a bit strange IMO if dpkg can handle a package reprepro 
should too.

I attempted to implement handling for this case but I could not get it to work, 
I attatch a debdiff of my attempt anyway.

The package is available for download from 
http://archive.raspbian.org/raspbian/pool/main/l/linux-3.10/linux-source-3.10_3.10.11-1+rpi7_all.deb

repo@bytemark2017:~/private/private$ reprepro -VV export jessie
Exporting jessie...
<--snip-->
 generating main/Contents-armhf...
Reading filelist for 
pool/main/l/linux-3.10/linux-source-3.10_3.10.11-1+rpi7_all.deb
Error decompressing gz data: incorrect header check -3
open data.tar within 
'./pool/main/l/linux-3.10/linux-source-3.10_3.10.11-1+rpi7_all.deb' failed: 
Uncompression error
repo@bytemark2017:~/private/private$ dpkg-deb -x 
pool/main/l/linux-3.10/linux-source-3.10_3.10.11-1+rpi7_all.deb /tmp/testextract
repo@bytemark2017:~/private/private$ ar t 
pool/main/l/linux-3.10/linux-source-3.10_3.10.11-1+rpi7_all.deb
debian-binary
control.tar.gz
data.tar.gz
repo@bytemark2017:~/private/private$ ls
usr
repo@bytemark2017:/tmp/testextract$ ar x 
~/private/private/pool/main/l/linux-3.10/linux-source-3.10_3.10.11-1+rpi7_all.deb
repo@bytemark2017:/tmp/testextract$ ls
control.tar.gz  data.tar.gz  debian-binary  usr
repo@bytemark2017:/tmp/testextract$ file data.tar.gz
data.tar.gz: POSIX tar archive (GNU)
repo@bytemark2017:/tmp/testextract$


diff -Nru reprepro-5.1.1/debian/changelog reprepro-5.1.1/debian/changelog
--- reprepro-5.1.1/debian/changelog     2017-01-08 12:21:09.000000000 +0000
+++ reprepro-5.1.1/debian/changelog     2017-05-21 03:27:45.000000000 +0000
@@ -1,3 +1,10 @@
+reprepro (5.1.1-1~bpo8+1+test) UNRELEASED; urgency=medium
+
+  * If data tar extraction fails try again as uncompressed.
+    Some packages have an uncompressed data.tar.gz 
+
+ -- root <r...@bytemark2017.raspbian.org>  Sun, 21 May 2017 03:07:25 +0000
+
 reprepro (5.1.1-1~bpo8+1) jessie-backports; urgency=medium
 
   * Rebuild for jessie-backports.
diff -Nru reprepro-5.1.1/debian/patches/series 
reprepro-5.1.1/debian/patches/series
--- reprepro-5.1.1/debian/patches/series        1970-01-01 00:00:00.000000000 
+0000
+++ reprepro-5.1.1/debian/patches/series        2017-05-21 03:09:07.000000000 
+0000
@@ -0,0 +1 @@
+uncompression.diff
diff -Nru reprepro-5.1.1/debian/patches/uncompression.diff 
reprepro-5.1.1/debian/patches/uncompression.diff
--- reprepro-5.1.1/debian/patches/uncompression.diff    1970-01-01 
00:00:00.000000000 +0000
+++ reprepro-5.1.1/debian/patches/uncompression.diff    2017-05-21 
03:30:27.000000000 +0000
@@ -0,0 +1,44 @@
+ If data tar extraction fails try again as uncompressed.
+    Some packages have an uncompressed data.tar.gz.
+
+Index: reprepro-5.1.1/debfilecontents.c
+===================================================================
+--- reprepro-5.1.1.orig/debfilecontents.c
++++ reprepro-5.1.1/debfilecontents.c
+@@ -55,7 +55,6 @@ static retvalue read_data_tar(/*@out@*/c
+                       ar_archivemember_read,
+                       ar_archivemember_close);
+       if (a != ARCHIVE_OK) {
+-              filelistcompressor_cancel(&c);
+               e = archive_errno(tar);
+               if (e == -EINVAL) /* special code to say there is none */
+                       fprintf(stderr,
+@@ -65,7 +64,27 @@ static retvalue read_data_tar(/*@out@*/c
+                       fprintf(stderr,
+ "open data.tar within '%s' failed: %d:%d:%s\n", debfile, a, e,
+                               archive_error_string(tar));
+-              return RET_ERROR;
++              fprintf(stderr,"retrying uncompressed");
++              ar_archivemember_setcompression(ar, c_none);
++              a = archive_read_open(tar, ar,
++                              ar_archivemember_open,
++                              ar_archivemember_read,
++                              ar_archivemember_close);
++              if (a != ARCHIVE_OK) {
++                      e = archive_errno(tar);
++                      if (e == -EINVAL) /* special code to say there is none 
*/
++                              fprintf(stderr,
++"open data.tar within '%s' failed: %s\n",
++                                      debfile, archive_error_string(tar));
++                      else
++                              fprintf(stderr,
++"open data.tar within '%s' failed: %d:%d:%s\n", debfile, a, e,
++                                      archive_error_string(tar));
++      
++                      filelistcompressor_cancel(&c);
++              
++                      return RET_ERROR;
++              }
+       }
+       while ((a=archive_read_next_header(tar, &entry)) == ARCHIVE_OK) {
+               const char *name = archive_entry_pathname(entry);

Reply via email to