Menu

#1472 Debian ar archives are not extracted correctly

None
open-wont-fix
nobody
None
1
2019-05-16
2015-01-21
No

See http://ftp.osuosl.org/pub/ubuntu/pool/main/a/adduser/adduser_3.112ubuntu1_all.deb
Using 7zip 9.36beta
There should be 3 files in them:

9242 Jan 27 2010 control.tar.gz
110198 Jan 27 2010 data.tar.gz
4 Jan 27 2010 debian-binary

Zip only show one file data.tar

Discussion

  • Philippe Ombredanne

    Note that FWIW the size of the extracted file seem to be exactly 256000 which is a conspicuous number alright

     

    Last edit: Philippe Ombredanne 2015-01-22
  • Igor Pavlov

    Igor Pavlov - 2015-01-22

    It's feature to reduce one step in most cases.
    You can open top level via context menu:

    Open Archive > *
    
     
  • Igor Pavlov

    Igor Pavlov - 2015-01-22

    or from command line

    7z l a.deb -t*
    
     
  • Philippe Ombredanne

    BTW the 256000 size is correct for data.tar: data.tar processing may be ok
    but these two files where entirely missed from the extraction:
    control.tar.gz
    debian-binary

     
  • Philippe Ombredanne

    And for reference https://sourceforge.net/p/p7zip/bugs/141/ is the corresponding bug on Linux

     
  • Philippe Ombredanne

    Igor: my bad: with t* we are getting the control file.
    we are still missing the debian-binary file:

    On Linux:
    ~/tmp/deb$ 7z l adduser_3.112ubuntu1_all.deb -t*

    7-Zip [64] 9.20  Copyright (c) 1999-2010 Igor Pavlov  2010-11-18
    p7zip Version 9.20 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,4 CPUs)
    
    Listing archive: adduser_3.112ubuntu1_all.deb
    
    --
    Path = adduser_3.112ubuntu1_all.deb
    Type = Deb
    Physical Size = 119632
    
       Date      Time    Attr         Size   Compressed  Name
    ------------------- ----- ------------ ------------  ------------------------
    2010-01-27 02:26:35 .....         9242         9242  control.tar.gz
    2010-01-27 02:26:35 .....       110198       110198  data.tar.gz
    ------------------- ----- ------------ ------------  ------------------------
                                    119440       119440  2 files, 0 folders
    

    On windows:
    "c:\Program Files\7-Zip\7z.exe" l -t* adduser_3.112ubuntu1_all.deb

    7-Zip [64] 9.36 beta  Copyright (c) 1999-2014 Igor Pavlov  2014-12-26
    
    Listing archive: adduser_3.112ubuntu1_all.deb
    
    --
    Path = adduser_3.112ubuntu1_all.deb
    Type = Ar
    Physical Size = 119632
    SubType = deb
    
       Date      Time    Attr         Size   Compressed  Name
    ------------------- ----- ------------ ------------  ------------------------
    2010-01-27 11:26:35 .....         9242         9242  control.tar.gz
    2010-01-27 11:26:35 .....       110198       110198  data.tar.gz
    ------------------- ----- ------------ ------------  ------------------------
    2010-01-27 11:26:35             119440       119440  2 files
    
    Kernel  Time =     0.015 =    9%
    User    Time =     0.000 =    0%
    Process Time =     0.015 =    9%    Virtual  Memory =      2 MB
    Global  Time =     0.157 =  100%    Physical Memory =      4 MB
    
     
  • Igor Pavlov

    Igor Pavlov - 2015-01-22

    debian-binary doesn't contain any important information.
    So 7-Zip ignores it.

     
  • Philippe Ombredanne

    Igor: I think this rather dangerous for 7z to decide if the data contained in a file is important or not and this is a bug in my book.
    The debian-binary contains the version of the debian format and is part of the ar achrive alright.

    with ar I get

    ~/tmp/deb/ext$ ar -x  -o  ../adduser_3.112ubuntu1_all.deb
    ~/tmp/deb/ext$ ls -al
    total 132
    drwrwxr-x 2 pombredanne pombredanne   4096 Jan 22 02:30 .
    drwxrwxr-x 3 pombredanne pombredanne   4096 Jan 22 02:27 ..
    -rw-r--r-- 1 pombredanne pombredanne   9242 Jan 27  2010 control.tar.gz
    -rw-r--r-- 1 pombredanne pombredanne 110198 Jan 27  2010 data.tar.gz
    -rw-r--r-- 1 pombredanne pombredanne      4 Jan 27  2010 debian-binary
    ~/tmp/deb/ext$ cat debian-binary
    

    2.0

     

    Last edit: Philippe Ombredanne 2015-01-22
  • Igor Pavlov

    Igor Pavlov - 2015-01-22

    There are many data in different formats that is not shown in listing.
    I just considered that small file (4 bytes) as header of deb format. Note that almost all deb files (maybe all?) contain "2.0" in debian-binary. So 7-Zip doesn't show that file.

    How can you use these 4 bytes from debian-binary file?

     

    Last edit: Igor Pavlov 2015-01-22
  • Philippe Ombredanne

    This file is essential as it identifies an ar archive as being a deb file.
    Per wikipedia http://en.wikipedia.org/wiki/Deb_%28file_format%29#Implementation ::

    Since Debian 0.93, a deb file is implemented as an ar archive. Canonical contents of
    this archive are three files:
    -debian-binary: deb format version number. This is "2.0" for current versions of Debian.
    -control.tar, control.tar.gz or control.tar.xz: all package meta-information. 
     It tells dpkg what to configure when the package is being installed.
    -data.tar, data.tar.gz, data.tar.bz2, data.tar.lzma or data.tar.xz: the actual installable files.
    
    The debian-binary file must be the first entry in the archive, 
    otherwise it will not be recognized as a Debian package.
    

    Per debian http://manpages.debian.org/cgi-bin/man.cgi?query=deb&manpath=unstable::

    The first member is named debian-binary and contains a series of lines,
    separated by newlines. Currently only one line is present,  the  format
    version number, 2.0 at the time this manual page was written.  Programs
    which read new-format archives should be prepared for the minor  number
    to be increased and new lines to be present, and should ignore these if
    this is the case.
    
     
  • Igor Pavlov

    Igor Pavlov - 2015-01-23

    7-Zip extracts files from debain package. Headers and service file are not important for most cases.
    Can you write why do you need that file at 7-Zip extracting?

     
  • Philippe Ombredanne

    Igor you wrote:
    Headers and service file are not important for most cases.

    Well, I want to extract debian files reliably. Meaning that I expect all the files that are in an original archive to be extracted, and that there is nothing that should be ignored by 7zip based on some criteria, regardless how small or mundane.

    It should not be up to 7zip to decide for me if a file is not important.

    Otherwise I cannot really trust 7zip for extracting debian ar files and may be other files.

    Again the debian-binary file is what makes an ar file a deb file and is important even if small as it separates a plain ar from a deb.

    If I extract some arbitrary ar file, that will tell me that this was a debian archive, even if it may not have a .deb extension.

     

    Last edit: Philippe Ombredanne 2015-01-23
  • Igor Pavlov

    Igor Pavlov - 2015-01-23

    Note, that there are two different things:
    1) extracting AR archive
    2) extracting DEB archive

    When we extract DEB archive. then some archive files in AR archive are just headers for DEB archive data. And we don't need these headers at most cases. We need only important data.

    Actually that problem doesn't look to important for me now.
    So I don't want to change that code.

     
  • Philippe Ombredanne

    I cannot understand why you find this bug not important.
    But this is your code so I do not have to understand, only accept ... that said would you accept a patch at least?

    The fix needed seems to be only to delete some code to avoid any special handling of deb files, something like that (un-tested though, do you have a test suite? I could not find it in the source drops)

    Cordially
    Philippe

    diff --git a/CPP/7zip/Archive/ArHandler.cpp b/CPP/7zip/Archive/ArHandler.cpp
    index b7dcda8..ac8e49b 100644
    --- a/CPP/7zip/Archive/ArHandler.cpp
    +++ b/CPP/7zip/Archive/ArHandler.cpp
    @@ -614,16 +614,6 @@
    if (!_items.IsEmpty() && _items[0].Name == "debian-binary")
    {
    _type = kType_Deb;
    - _items.DeleteFrontal(1);
    - for (unsigned i = 0; i < _items.Size(); i++)
    - if (_items[i].Name.IsPrefixedBy("data.tar."))
    - if (_mainSubfile < 0)
    - _mainSubfile = i;
    - else
    - {
    - _mainSubfile = -1;
    - break;
    - }
    }
    else
    {

     
  • Igor Pavlov

    Igor Pavlov - 2015-01-23
    • status: open --> open-wont-fix
    • Group: -->
     
  • Igor Pavlov

    Igor Pavlov - 2015-01-23

    again:
    It's not bug.
    It's feature, that hides the file that is treated as header.
    if you can write any argument, why that service file is useful, I can think about changing the code.

    I suppose that users just need to extract files from DEB data.tar in 99% cases. in 1 % case maybe they want to look control.tar. And maybe in 0.01% cases they want to look that debian-binary.

     

    Last edit: Igor Pavlov 2015-01-23
    • mirh

      mirh - 2019-05-16

      I suppose that users just need to extract files from DEB data.tar in 99% cases. in 1 % case maybe they want to look control.tar.

      My educate guess would be that if you are extracting files inside a package individually (rather than, you know, normally letting everything be handled by the OS's manager), then chances are that 99% is an overestimation of "normal users".
      I, for one, was quite interested into checking dependencies used in different repositories for example (and was pretty much confused, before I noticed file-roller was showing quite more)

      We could discuss all day whether a file-header is effectively worth then, but I don't see how in the heaven a totally normal file is to be dumped

       
  • Igor Pavlov

    Igor Pavlov - 2015-01-23

    In general it must work so:

    When 7-Zip sees service file debian-binary, then it doesn't think that archive is AR type. It thinks that archive is AR:DEB.
    And that type is fixed for future operations. For example, if update operation is supported for such archive, you are not allowed to change / delete that service file and so on. You can think about that file as part of DEB format header.

    Maybe sometimes we want to open DEB archives in raw AR format, that will show that file. But that feature is not implemented now. 7-Zip opens archives in most deep subtype, if subtype is detected.

     

    Last edit: Igor Pavlov 2015-01-23

Log in to post a comment.