[File] [PATCH] of Magdir/archive for Debian binary package; GNU variant *.ipk
Jörg Jenderek
joerg.jen.der.ek at gmx.net
Fri Feb 14 23:00:03 UTC 2020
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Hello,
some days ago i updated package on my enigma tv receiver. The
update packages used by opkp manager have the file name extension ipk.
According to Wikipedia the Debian package format is used for such
updates. When running file command version 5.38 on such examples
and other Debian packages i get an output like:
libc6-dev_2.28-2_mips.deb:
Debian binary package (format 2.0), with control.tar.xz,
data compression xz
openjdk-6-source_6b11-9.1_all.deb:
Debian binary package (format 2.0), with control.tar.gz,
data compression bz2
opkg_0.2.4-r0-vuplus0-vti005_armv7ahf-vfp-neon.ipk:
Debian binary package (format 2.0), with control.tar.gz,
data compression gz/
opkg-arch-config_1.0-r1-vti04_vuultimo4k.ipk:
Debian binary package (format 2.0), with control.tar.gz,
data compression gz/
xfslibs-test-lzma.deb:
Debian binary package (format 2.0), with control.tar.gz,
Instead "gz" after data compression for some examples "gz/" is shown.
This is not a big error, but this cosmetic error may irritate users.
Furthermore with --extension option only deb/udeb is displayed.
So i change/add lines in Magdir/archive. So old line for showing file
name extensions get additional "ipk" word and now becomes
!:ext deb/udeb/ipk
In current version look for third archive name by line like
>>0 search/0x93e4f data.tar. \b, data compression
For Debian package third archive member has file name data.tar.gz,
data.tar.xz, data.tar.bz2 or data.tar.lzma. So last part of file name
indicated used data compression. This was shown by line
>>>&0 string x %.4s
For BSD variant of ar archives stored filenames are right-padded
with ASCII spaces (0x20). So some additional spaces at the end
after gz do not hurt by above magic line.
Unfortunately also System V (or GNU) variant of ar archive is
sometimes used like in inspected ipk archives. There slash
character ('/' 0x2F) is used to mark the end of the filename. So by
above line phrase "gz/ " is displayed.
Of course a regular expression could be used to catch last name
extension.
But i decided to use another method. So i display the 2 beginning
characters of name extension by line
>>>&0 string x %.2s
Then check if next character is not a terminating space or slash.
If this is true, then display this character. This now looks:
>>>&2 ubyte !0x20
>>>>&-1 ubyte !0x2f
>>>>>&-1 ubyte x \b%c
Then do the same procedure for possible fourth character by lines
>>>>>>&0 ubyte !0x20
>>>>>>>&-1 ubyte !0x2f
>>>>>>>>&-1 ubyte x \b%c
After applying the above mentioned modifications by patch
file-5.38-archive-ipk.diff then i get an output like:
libc6-dev_2.28-2_mips.deb:
Debian binary package (format 2.0), with control.tar.xz,
data compression xz
openjdk-6-source_6b11-9.1_all.deb:
Debian binary package (format 2.0), with control.tar.gz,
data compression bz2
opkg_0.2.4-r0-vuplus0-vti005_armv7ahf-vfp-neon.ipk:
Debian binary package (format 2.0), with control.tar.gz,
data compression gz
opkg-arch-config_1.0-r1-vti04_vuultimo4k.ipk:
Debian binary package (format 2.0), with control.tar.gz,
data compression gz
xfslibs-test-lzma.deb:
Debian binary package (format 2.0), with control.tar.gz,
data compression lzma
I hope my diff file can be applied in future version of
file utility.
With best wishes
Jörg Jenderek
- --
Jörg Jenderek
-----BEGIN PGP SIGNATURE-----
Comment: Using GnuPG with Thunderbird - https://www.enigmail.net/
iF0EARECAB0WIQS5/qNWKD4ASGOJGL+v8rHJQhrU1gUCXkcmYQAKCRCv8rHJQhrU
1qsbAJsFIBG44s5YpBMG1ejV/wkL0hYJqwCgr5eCifxKqjWUSH90vvYN/0UEUkg=
=S2Kf
-----END PGP SIGNATURE-----
-------------- next part --------------
--- file-5.38/magic/Magdir/archive.old 2019-11-15 21:03:14 +0000
+++ file-5.38/magic/Magdir/archive 2020-02-14 22:40:38 +0000
@@ -237,5 +237,6 @@
>14 string -binary Debian binary package
!:mime application/vnd.debian.binary-package
-!:ext deb/udeb
+# For ipk packager see also https://en.wikipedia.org/wiki/Opkg
+!:ext deb/udeb/ipk
# This should not happen
>14 default x Unknown Debian package
@@ -251,5 +252,14 @@
# the above line only works if FILE_BYTES_MAX in ../../src/file.h is raised
# for example like libreoffice-dev-doc_1%3a5.2.7-1+rpi1+deb9u3_all.deb
->>>&0 string x %.4s
+>>>&0 string x %.2s
+# skip space (0x20 BSD) and slash (0x2f System V) character marking end of name
+>>>&2 ubyte !0x20
+>>>>&-1 ubyte !0x2f
+# display 3rd character of file name extension like 2 of bz2 or m of lzma
+>>>>>&-1 ubyte x \b%c
+>>>>>>&0 ubyte !0x20
+>>>>>>>&-1 ubyte !0x2f
+# display 4th character of file name extension like a of lzma
+>>>>>>>>&-1 ubyte x \b%c
# splitted debian package case
>68 string =2.1\n
-------------- next part --------------
A non-text attachment was scrubbed...
Name: file-5.38-archive-ipk.diff.sig
Type: application/octet-stream
Size: 95 bytes
Desc: not available
URL: <https://mailman.astron.com/pipermail/file/attachments/20200215/f762dec8/attachment.obj>
More information about the File
mailing list