Subject: Re: bug#52477: 27.1; .crx and .crx3 are zip files

From: "Trent W. Buck" <[email-masked]>
Date: Wed, 22 Dec 2021 14:50:43 +1100

Eli Zaretskii wrote:
> > From: Michael Albinus <[email-masked]>
> > Cc: [email-masked],  [email-masked],  [email-masked]
> > Date: Thu, 16 Dec 2021 12:59:01 +0100
> > 
> > > If the file doesn't follow the PKZip spec in the initial signature,
> > > who knows what else in that spec doesn't it follow?  The ZIP spec has
> > > a lot of special rules and formatting requirements, so if a file
> > > doesn't follow them, how can we support it without knowing its exact
> > > format specification?
> > 
> > ".crx" files are Chrome Extensions, as shown by Stefan. They are
> > specified, see for example <https://developer.chrome.com/docs/extensions/reference/>.
> > 
> > Personally, I have no strong opinion whether we shall support them.
> 
> Me neither, but if someone wants to extend arc-mode.el to support
> those extension, that would be welcome, I think.  My point is that we
> cannot just add this file type before we implement those extensions.

FTR, as the end user, I don't really care HOW it's implemented.

I also don't really care about editing, i.e. read-only support is fine.
I have a similar "eyeball the result" workflow for .deb using

    /usr/share/emacs/site-lisp/elpa-src/debian-el-37/deb-view.el

Another case of "it's a zip, but" is the .pyz, which
has an (optional) shebang before the PK:

    bash5$ mkdir MyCoolApp
    bash5$ touch MyCoolApp/__init__.py
    bash5$ echo 'print("Hello, World!")' >MyCoolApp/__main__.py
    bash5$ python3 -m zipapp --compress --python=/usr/bin/python3 MyCoolApp
    bash5$ ./MyCoolApp.pyz
    Hello, World!
    bash5$ head -n1 MyCoolApp.pyz
    #!/usr/bin/python3
    bash5$ file MyCoolApp.pyz
    MyCoolApp.pyz: Zip archive data, made by v2.0 UNIX, extract using at least v2.0, last modified Tue Jun 10 02:57:41 2014, uncompressed size 23, method=deflate

    bash5$ emacs MyCoolApp.pyz
    <Emacs does not understand it>

Someone mentioned libarchive, originally from BSD, which provides a
standard interface to EVERY(ish) archive and compression format.

Is it reasonable for emacs to just chuck out arc-mode (and tar-mode
and jka-compr) and instead just use libarchive?
It's already used by vlc and a lot of GNOME stuff.

libarchive already understands both .pyz and .crx3 files, at least for reading:

    bash5$ bsdtar -vtf MyCoolApp.pyz
    -rw-r--r--  0 0      0          23 Dec 22 14:33 __main__.py
    -rw-r--r--  0 0      0           0 Dec 22 14:33 __init__.py

    bash5$ bsdtar -vtf jamhcnnkihinmdlkakkaopbjbbcngflc_99.0.4764.2_all_nfh7crk5nxg3omjxfwx5cuhrz4.crx3
    -rw-rw-r--  0 0      0        3484 Dec 13 12:34 hyph-und-ethi.hyb
    -rw-rw-r--  0 0      0        2712 Dec 13 12:34 hyph-tk.hyb
    -rw-rw-r--  0 0      0         703 Dec 13 12:34 hyph-te.hyb
    -rw-rw-r--  0 0      0         554 Dec 13 12:34 hyph-ta.hyb
    -rw-rw-r--  0 0      0        6631 Dec 13 12:34 hyph-sl.hyb
    -rw-rw-r--  0 0      0        1414 Dec 13 12:34 hyph-pt.hyb
    -rw-rw-r--  0 0      0         607 Dec 13 12:34 hyph-pa.hyb
    -rw-rw-r--  0 0      0         647 Dec 13 12:34 hyph-or.hyb
    -rw-rw-r--  0 0      0      145263 Dec 13 12:34 hyph-nn.hyb
    -rw-rw-r--  0 0      0      145263 Dec 13 12:34 hyph-nb.hyb
    -rw-rw-r--  0 0      0         687 Dec 13 12:34 hyph-mr.hyb
    -rw-rw-r--  0 0      0        5142 Dec 13 12:34 hyph-mn-cyrl.hyb
    -rw-rw-r--  0 0      0         776 Dec 13 12:34 hyph-ml.hyb
    -rw-rw-r--  0 0      0        1839 Dec 13 12:34 hyph-la.hyb
    -rw-rw-r--  0 0      0         711 Dec 13 12:34 hyph-kn.hyb
    -rw-rw-r--  0 0      0         605 Dec 13 12:34 hyph-hy.hyb
    -rw-rw-r--  0 0      0      317251 Dec 13 12:34 hyph-hu.hyb
    -rw-rw-r--  0 0      0        3031 Dec 13 12:34 hyph-hr.hyb
    -rw-rw-r--  0 0      0         687 Dec 13 12:34 hyph-hi.hyb
    -rw-rw-r--  0 0      0         655 Dec 13 12:34 hyph-gu.hyb
    -rw-rw-r--  0 0      0       35824 Dec 13 12:34 hyph-ga.hyb
    -rw-rw-r--  0 0      0        8165 Dec 13 12:34 hyph-fr.hyb
    -rw-rw-r--  0 0      0         665 Dec 13 12:34 hyph-eu.hyb
    -rw-rw-r--  0 0      0       21421 Dec 13 12:34 hyph-et.hyb
    -rw-rw-r--  0 0      0       14995 Dec 13 12:34 hyph-es.hyb
    -rw-rw-r--  0 0      0       59802 Dec 13 12:34 hyph-en-us.hyb
    -rw-rw-r--  0 0      0       46607 Dec 13 12:34 hyph-en-gb.hyb
    -rw-rw-r--  0 0      0      120218 Dec 13 12:34 hyph-de-ch-1901.hyb
    -rw-rw-r--  0 0      0      120412 Dec 13 12:34 hyph-de-1996.hyb
    -rw-rw-r--  0 0      0      121393 Dec 13 12:34 hyph-de-1901.hyb
    -rw-rw-r--  0 0      0        6967 Dec 13 12:34 hyph-da.hyb
    -rw-rw-r--  0 0      0       35913 Dec 13 12:34 hyph-cy.hyb
    -rw-rw-r--  0 0      0       52842 Dec 13 12:34 hyph-cu.hyb
    -rw-rw-r--  0 0      0         703 Dec 13 12:34 hyph-bn.hyb
    -rw-rw-r--  0 0      0        3467 Dec 13 12:34 hyph-bg.hyb
    -rw-rw-r--  0 0      0        6098 Dec 13 12:34 hyph-be.hyb
    -rw-rw-r--  0 0      0         703 Dec 13 12:34 hyph-as.hyb
    -rw-r--r--  0 0      0         178 Dec 13 12:34 manifest.json
    drwxrwxr-x  0 0      0           0 Dec 13 12:34 _metadata/
    -rw-rw-r--  0 0      0        5698 Dec 13 12:34 _metadata/verified_contents.json