[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

android arm: Tar checksum failed, archive corrupted



Hi,

When using apt 2.3.8 (errors has occured on older versions as well) on
a 32bit arm android device, I am getting a checksum error when trying
to install a local deb. The issue only occurs if the package has a list
of conffiles, and if the control archive has been compressed with gzip,
i.e. to .tar.gz (took me a while figuring that out..). The error looks
like:

    $ apt install ./tmp/foo.deb
    Reading package lists... Error!
    E: Tar checksum failed, archive corrupted
    E: Could not read meta data from
/data/data/com.termux/files/home/tmp/foo.deb
    E: The package lists or status file could not be parsed or opened.

Installing from the remote (apt install foo) works fine, but
downloading the deb first (apt download foo && apt install ./foo.deb)
gives the error.

By adding some debug messages to extracttar.cc:

   --- ./apt-pkg/contrib/extracttar.cc.orig	2021-09-05
   10:25:03.346706695 +0200
   +++ ./apt-pkg/contrib/extracttar.cc	2021-09-05 10:30:45.406741064
   +0200
   @@ -152,11 +152,13 @@
          memset(Tar->Checksum,' ',sizeof(Tar->Checksum));
          for (int I = 0; I != sizeof(Block); I++)
    	 NewSum += Block[I];
   -      
   +      printf("Tar->Checksum: %s, NewSum: %lu CheckSum: %lu\n", Tar-
   >Checksum, NewSum, CheckSum);
          /* Check for a block of nulls - in this case we kill gzip, GNU
   tar
           	 does this.. */
   -      if (NewSum == ' '*sizeof(Tar->Checksum))
   +      if (NewSum == ' '*sizeof(Tar->Checksum)) {
   +	 printf("Returning Done()\n");
    	 return Done();
   +      }
          
          if (NewSum != CheckSum)
    	 return _error->Error(_("Tar checksum failed, archive
   corrupted"));

I get this with a non-working deb:

   $ apt install ./tmp/foo.deb
   Tar->Checksum:         5, NewSum: 4177 CheckSum: 4177
   Tar->Checksum:         0, NewSum: 4949 CheckSum: 4949
   Tar->Checksum:         0, NewSum: 5131 CheckSum: 5131
   Tar->Checksum:         , NewSum: 4182 CheckSum: 0
   Reading package lists... Error!
   E: Tar checksum failed, archive corrupted
   E: Could not read meta data from
   /data/data/com.termux/files/home/tmp/foo.deb
   E: The package lists or status file could not be parsed or opened.

While for a working deb (everything the same, but with control.tar.xz
instead of control.tar.gz):

   $ apt install ./tmp/foo.deb
   Tar->Checksum:         5, NewSum: 4184 CheckSum: 4184
   Tar->Checksum:         0, NewSum: 4956 CheckSum: 4956
   Tar->Checksum:         0, NewSum: 5138 CheckSum: 5138
   Tar->Checksum:         , NewSum: 256 CheckSum: 0
   Returning Done()
   Reading package lists... Done
   Building dependency tree... Done
   Reading state information... Done
   Note, selecting 'foo' instead of './tmp/foo.deb'
   Tar->Checksum:         5, NewSum: 4184 CheckSum: 4184
   Tar->Checksum:         0, NewSum: 4956 CheckSum: 4956
   Tar->Checksum:         0, NewSum: 5138 CheckSum: 5138
   Tar->Checksum:         , NewSum: 256 CheckSum: 0
   Returning Done()
   The following NEW packages will be installed:
     foo
   0 upgraded, 1 newly installed, 0 to remove and 4 not upgraded.
   Need to get 0 B/804 B of archives.
   After this operation, 1024 B of additional disk space will be used.
   Get:1 /data/data/com.termux/files/home/tmp/foo.deb foo arm 1.0 [804 B]
   Selecting previously unselected package foo.
   (Reading database ... 74483 files and directories currently installed.)
   Preparing to unpack .../data/data/com.termux/files/home/tmp/foo.deb ...
   Unpacking foo (1.0) ...
   Setting up foo (1.0) ...

As mentioned, this is on android 32bit arm where apt runs in the
terminal emulator termux [1]. A bunch of patches are applied to apt
[2], but nothing that (clearly) should affect the extraction. I tried
reproducing the issue on an arm raspberry pi, but there the issue does
not occur.

I have attached the script I used for generating a minimal deb for
debugging this. Skip the conffile, or change to 

   tar -cJf ../control.tar.xz -H gnu .

and the deb installs without issues. dpkg -i ./tmp/foo.deb also works
without issues, for all debs.

Does anyone have any suggestions for other things to try for debugging
this further?

Best regards
Henrik Grimler

[1] https://termux.com/
[2] https://github.com/termux/termux-packages/tree/master/packages/apt

Attachment: minimal_deb.sh
Description: application/shellscript


Reply to: