lol
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

patool: 2.4.0 -> 3.1.0 (#368882)

authored by scrumplex.net and committed by

GitHub 7fa1a3c6 fd90f5c2

+329 -2
+11 -2
pkgs/development/python-modules/patool/default.nix
··· 38 38 in 39 39 buildPythonPackage rec { 40 40 pname = "patool"; 41 - version = "2.4.0"; 41 + version = "3.1.0"; 42 42 format = "setuptools"; 43 43 44 44 #pypi doesn't have test data ··· 46 46 owner = "wummel"; 47 47 repo = pname; 48 48 rev = "refs/tags/${version}"; 49 - hash = "sha256-dWyC8uTVUb06liNcJaG4oK9wqIDmwAl6i6cg4XRRRdQ="; 49 + hash = "sha256-mt/GUIRJHB2/Rritc+uNkolZzguYy2G/NKnSKNxKsLk="; 50 50 }; 51 51 52 + patches = [ 53 + # https://github.com/wummel/patool/pull/173 54 + ./fix-rar-detection.patch 55 + ]; 56 + 52 57 postPatch = '' 53 58 substituteInPlace patoolib/util.py \ 54 59 --replace "path = None" 'path = os.environ["PATH"] + ":${lib.makeBinPath compression-utilities}"' ··· 61 66 "test_unzip_file" 62 67 "test_zip" 63 68 "test_zip_file" 69 + "test_7z" 70 + "test_7z_file" 71 + "test_7za_file" 72 + "test_p7azip" 64 73 ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ "test_ar" ]; 65 74 66 75 meta = with lib; {
+318
pkgs/development/python-modules/patool/fix-rar-detection.patch
··· 1 + From d10324eac4429ff3d7d38ad24a19210699229e07 Mon Sep 17 00:00:00 2001 2 + From: Alfred Wingate <parona@protonmail.com> 3 + Date: Wed, 11 Dec 2024 06:34:36 +0200 4 + Subject: [PATCH 1/4] Use application/gzip as the preferred mimetype for gzip 5 + 6 + Signed-off-by: Alfred Wingate <parona@protonmail.com> 7 + --- 8 + patoolib/__init__.py | 1 - 9 + patoolib/mime.py | 16 +++++++++++++--- 10 + tests/test_mime.py | 4 ++-- 11 + 3 files changed, 15 insertions(+), 6 deletions(-) 12 + 13 + diff --git a/patoolib/__init__.py b/patoolib/__init__.py 14 + index d665a28a..2247b615 100644 15 + --- a/patoolib/__init__.py 16 + +++ b/patoolib/__init__.py 17 + @@ -127,7 +127,6 @@ 18 + 'application/x-cpio': 'cpio', 19 + 'application/x-debian-package': 'deb', 20 + 'application/x-dms': 'dms', 21 + - 'application/x-gzip': 'gzip', 22 + 'application/x-iso9660-image': 'iso', 23 + 'application/x-lz4': 'lz4', 24 + 'application/x-lzop': 'lzop', 25 + diff --git a/patoolib/mime.py b/patoolib/mime.py 26 + index 12405ada..c9d8894b 100644 27 + --- a/patoolib/mime.py 28 + +++ b/patoolib/mime.py 29 + @@ -135,9 +135,11 @@ def guess_mime(filename: str) -> tuple[str | None, str | None]: 30 + Mime2Encoding: dict[str, str] = dict( 31 + [(_val, _key) for _key, _val in Encoding2Mime.items()] 32 + ) 33 + -# libmagic before version 5.14 identified .gz files as application/x-gzip 34 + -Mime2Encoding['application/x-gzip'] = 'gzip' 35 + 36 + +LegacyMimeType: dict[str, str] = { 37 + + # libmagic before version 5.14 identified .gz files as application/x-gzip 38 + + 'application/x-gzip': "application/gzip", 39 + +} 40 + 41 + def guess_mime_mimedb(filename: str) -> tuple[str | None, str | None]: 42 + """Guess MIME type from given filename. 43 + @@ -192,6 +194,10 @@ def guess_mime_file(filename: str) -> tuple[str | None, str | None]: 44 + except (OSError, subprocess.CalledProcessError) as err: 45 + log_warning(f"error executing {cmd}: {err}") 46 + mime2 = None 47 + + 48 + + if mime2 in LegacyMimeType: 49 + + mime2 = LegacyMimeType[mime2] 50 + + 51 + # Some file(1) implementations return an empty or unknown mime type 52 + # when the uncompressor program is not installed, other 53 + # implementation return the original file type. 54 + @@ -227,6 +233,10 @@ def guess_mime_file_mime( 55 + except OSError as err: 56 + # ignore errors, as file(1) is only a fallback 57 + log_warning(f"error executing {cmd}: {err}") 58 + + 59 + + if mime in LegacyMimeType: 60 + + mime = LegacyMimeType[mime] 61 + + 62 + if mime not in ArchiveMimetypes: 63 + mime, encoding = None, None 64 + return mime, encoding 65 + @@ -253,7 +263,7 @@ def get_file_mime_encoding(parts: Sequence[str]) -> str | None: 66 + "cpio archive": "application/x-cpio", 67 + "ASCII cpio archive": "application/x-cpio", 68 + "Debian binary package": "application/x-debian-package", 69 + - "gzip compressed data": "application/x-gzip", 70 + + "gzip compressed data": "application/gzip", 71 + "LZMA compressed data": "application/x-lzma", 72 + "LRZIP compressed data": "application/x-lrzip", 73 + "lzop compressed data": "application/x-lzop", 74 + diff --git a/tests/test_mime.py b/tests/test_mime.py 75 + index 40e73edf..3f292dfc 100644 76 + --- a/tests/test_mime.py 77 + +++ b/tests/test_mime.py 78 + @@ -81,8 +81,8 @@ def test_mime_file(self): 79 + self.mime_test_file("t.cpio.foo", "application/x-cpio") 80 + self.mime_test_file("t.deb", "application/x-debian-package") 81 + self.mime_test_file("t.deb.foo", "application/x-debian-package") 82 + - self.mime_test_file("t.txt.gz", ("application/gzip", "application/x-gzip")) 83 + - self.mime_test_file("t.txt.gz.foo", ("application/gzip", "application/x-gzip")) 84 + + self.mime_test_file("t.txt.gz", "application/gzip") 85 + + self.mime_test_file("t.txt.gz.foo", "application/gzip") 86 + self.mime_test_file("t.jar", "application/zip") 87 + self.mime_test_file("t.jar.foo", "application/zip") 88 + self.mime_test_file("t.txt.lzma", "application/x-lzma") 89 + 90 + From e7501d1c7805696ff5b2ecc779f7a56ab2425c3f Mon Sep 17 00:00:00 2001 91 + From: Alfred Wingate <parona@protonmail.com> 92 + Date: Wed, 11 Dec 2024 06:37:54 +0200 93 + Subject: [PATCH 2/4] Change rar mime type to application/vnd.rar 94 + 95 + https://github.com/file/file/commit/d46a1f3dbbf58eb510c1779b8bdcc59d5ee24ab9 96 + https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1068700 97 + 98 + Signed-off-by: Alfred Wingate <parona@protonmail.com> 99 + --- 100 + patoolib/__init__.py | 2 +- 101 + patoolib/mime.py | 9 ++++++--- 102 + tests/test_mime.py | 16 ++++++++-------- 103 + 3 files changed, 15 insertions(+), 12 deletions(-) 104 + 105 + diff --git a/patoolib/__init__.py b/patoolib/__init__.py 106 + index 2247b615..8b13181c 100644 107 + --- a/patoolib/__init__.py 108 + +++ b/patoolib/__init__.py 109 + @@ -136,7 +136,6 @@ 110 + 'application/x-lrzip': 'lrzip', 111 + 'application/x-lzh': 'lzh', 112 + 'application/x-ms-wim': 'wim', 113 + - 'application/x-rar': 'rar', 114 + 'application/x-redhat-package-manager': 'rpm', 115 + 'application/x-rpm': 'rpm', 116 + 'application/x-rzip': 'rzip', 117 + @@ -147,6 +146,7 @@ 118 + 'application/x-xz': 'xz', 119 + 'application/x-zip-compressed': 'zip', 120 + 'application/x-zoo': 'zoo', 121 + + 'application/vnd.rar': 'rar', 122 + 'application/zip': 'zip', 123 + 'application/zpaq': 'zpaq', 124 + "application/zstd": "zstd", 125 + diff --git a/patoolib/mime.py b/patoolib/mime.py 126 + index c9d8894b..8de9b180 100644 127 + --- a/patoolib/mime.py 128 + +++ b/patoolib/mime.py 129 + @@ -54,8 +54,8 @@ def add_mimedb_data(mimedb: mimetypes.MimeTypes) -> None: 130 + add_mimetype(mimedb, 'application/x-lzma', '.lzma') 131 + add_mimetype(mimedb, 'application/x-xz', '.xz') 132 + add_mimetype(mimedb, 'application/java-archive', '.jar') 133 + - add_mimetype(mimedb, 'application/x-rar', '.rar') 134 + - add_mimetype(mimedb, 'application/x-rar', '.cbr') 135 + + add_mimetype(mimedb, 'application/vnd.rar', '.rar') 136 + + add_mimetype(mimedb, 'application/vnd.rar', '.cbr') 137 + add_mimetype(mimedb, 'application/x-7z-compressed', '.7z') 138 + add_mimetype(mimedb, 'application/x-7z-compressed', '.cb7') 139 + add_mimetype(mimedb, 'application/x-cab', '.cab') 140 + @@ -139,8 +139,11 @@ def guess_mime(filename: str) -> tuple[str | None, str | None]: 141 + LegacyMimeType: dict[str, str] = { 142 + # libmagic before version 5.14 identified .gz files as application/x-gzip 143 + 'application/x-gzip': "application/gzip", 144 + + # libmagic before version 5.46 identified .rar files as application/x-rar 145 + + 'application/x-rar': "application/vnd.rar", 146 + } 147 + 148 + + 149 + def guess_mime_mimedb(filename: str) -> tuple[str | None, str | None]: 150 + """Guess MIME type from given filename. 151 + @return: tuple (mime, encoding) 152 + @@ -268,7 +271,7 @@ def get_file_mime_encoding(parts: Sequence[str]) -> str | None: 153 + "LRZIP compressed data": "application/x-lrzip", 154 + "lzop compressed data": "application/x-lzop", 155 + "Microsoft Cabinet archive data": "application/vnd.ms-cab-compressed", 156 + - "RAR archive data": "application/x-rar", 157 + + "RAR archive data": "application/vnd.rar", 158 + "RPM ": "application/x-redhat-package-manager", 159 + "POSIX tar archive": "application/x-tar", 160 + "xz compressed data": "application/x-xz", 161 + diff --git a/tests/test_mime.py b/tests/test_mime.py 162 + index 3f292dfc..8f3ecb8c 100644 163 + --- a/tests/test_mime.py 164 + +++ b/tests/test_mime.py 165 + @@ -91,10 +91,10 @@ def test_mime_file(self): 166 + self.mime_test_file("t.txt.lz.foo", "application/x-lzip") 167 + self.mime_test_file("t.txt.lzo", "application/x-lzop") 168 + self.mime_test_file("t.txt.lzo.foo", "application/x-lzop") 169 + - self.mime_test_file("t.rar", "application/x-rar") 170 + - self.mime_test_file("t.rar.foo", "application/x-rar") 171 + - self.mime_test_file("t.cbr", "application/x-rar") 172 + - self.mime_test_file("t.cbr.foo", "application/x-rar") 173 + + self.mime_test_file("t.rar", "application/vnd.rar") 174 + + self.mime_test_file("t.rar.foo", "application/vnd.rar") 175 + + self.mime_test_file("t.cbr", "application/vnd.rar") 176 + + self.mime_test_file("t.cbr.foo", "application/vnd.rar") 177 + self.mime_test_file("t.rpm", "application/x-rpm") 178 + self.mime_test_file("t.rpm.foo", "application/x-rpm") 179 + self.mime_test_file("t.tar", "application/x-tar") 180 + @@ -197,8 +197,8 @@ def test_nested_gzip(self): 181 + """Test mime detection of archives with double compression""" 182 + # We won't extract this with rar, as it doesn't support archives wrapped in gzip 183 + # compression, but we will recognize the archive as a gzip-wrapped rar-file 184 + - self.mime_test_file("t.rar.gz", "application/x-rar", "gzip") 185 + - self.mime_test_file("t.rar.gz.foo", "application/x-rar", "gzip") 186 + + self.mime_test_file("t.rar.gz", "application/vnd.rar", "gzip") 187 + + self.mime_test_file("t.rar.gz.foo", "application/vnd.rar", "gzip") 188 + 189 + @needs_program('file') 190 + @needs_program('gzip') 191 + @@ -237,7 +237,7 @@ def test_mime_mimedb(self): 192 + self.mime_test_mimedb("t .bz2", "application/x-bzip2") 193 + self.mime_test_mimedb("t .bz3", "application/x-bzip3") 194 + self.mime_test_mimedb("t.cab", "application/x-cab") 195 + - self.mime_test_mimedb("t.cbr", ("application/rar", "application/x-rar")) 196 + + self.mime_test_mimedb("t.cbr", ("application/rar", "application/vnd.rar")) 197 + self.mime_test_mimedb("t.cpio", "application/x-cpio") 198 + self.mime_test_mimedb("t.deb", "application/x-debian-package") 199 + self.mime_test_mimedb("t.gz", "application/gzip") 200 + @@ -247,7 +247,7 @@ def test_mime_mimedb(self): 201 + self.mime_test_mimedb("t.txt.lz", "application/x-lzip") 202 + self.mime_test_mimedb("t.txt.lz4", "application/x-lz4") 203 + self.mime_test_mimedb("t.lzo", "application/x-lzop") 204 + - self.mime_test_mimedb("t.rar", ("application/rar", "application/x-rar")) 205 + + self.mime_test_mimedb("t.rar", ("application/rar", "application/vnd.rar")) 206 + self.mime_test_mimedb( 207 + "t.rpm", ("application/x-redhat-package-manager", "application/x-rpm") 208 + ) 209 + 210 + From 85fafd16ec01a7eb793e04011617bb47211d446a Mon Sep 17 00:00:00 2001 211 + From: Alfred Wingate <parona@protonmail.com> 212 + Date: Wed, 11 Dec 2024 06:40:41 +0200 213 + Subject: [PATCH 3/4] Remove references to application/rar 214 + 215 + application/vnd.rar is the IANA assigned mime type for rar. libmagic has 216 + never refered to application/rar either, so there is no use for backwards 217 + compatibility. 218 + 219 + https://www.iana.org/assignments/media-types/application/vnd.rar 220 + 221 + Signed-off-by: Alfred Wingate <parona@protonmail.com> 222 + --- 223 + patoolib/__init__.py | 1 - 224 + tests/test_mime.py | 4 ++-- 225 + 2 files changed, 2 insertions(+), 3 deletions(-) 226 + 227 + diff --git a/patoolib/__init__.py b/patoolib/__init__.py 228 + index 8b13181c..51f8b4eb 100644 229 + --- a/patoolib/__init__.py 230 + +++ b/patoolib/__init__.py 231 + @@ -110,7 +110,6 @@ 232 + 'application/jar': 'zip', # reported on older systems such as ubuntu 14.04 233 + 'application/java-archive': 'zip', 234 + 'application/vnd.android.package-archive': 'zip', 235 + - 'application/rar': 'rar', 236 + 'application/vnd.ms-cab-compressed': 'cab', 237 + 'application/x-7z-compressed': '7z', 238 + 'application/x-ace': 'ace', 239 + diff --git a/tests/test_mime.py b/tests/test_mime.py 240 + index 8f3ecb8c..287d8208 100644 241 + --- a/tests/test_mime.py 242 + +++ b/tests/test_mime.py 243 + @@ -237,7 +237,7 @@ def test_mime_mimedb(self): 244 + self.mime_test_mimedb("t .bz2", "application/x-bzip2") 245 + self.mime_test_mimedb("t .bz3", "application/x-bzip3") 246 + self.mime_test_mimedb("t.cab", "application/x-cab") 247 + - self.mime_test_mimedb("t.cbr", ("application/rar", "application/vnd.rar")) 248 + + self.mime_test_mimedb("t.cbr", "application/vnd.rar") 249 + self.mime_test_mimedb("t.cpio", "application/x-cpio") 250 + self.mime_test_mimedb("t.deb", "application/x-debian-package") 251 + self.mime_test_mimedb("t.gz", "application/gzip") 252 + @@ -247,7 +247,7 @@ def test_mime_mimedb(self): 253 + self.mime_test_mimedb("t.txt.lz", "application/x-lzip") 254 + self.mime_test_mimedb("t.txt.lz4", "application/x-lz4") 255 + self.mime_test_mimedb("t.lzo", "application/x-lzop") 256 + - self.mime_test_mimedb("t.rar", ("application/rar", "application/vnd.rar")) 257 + + self.mime_test_mimedb("t.rar", "application/vnd.rar") 258 + self.mime_test_mimedb( 259 + "t.rpm", ("application/x-redhat-package-manager", "application/x-rpm") 260 + ) 261 + 262 + From bab80a04a72941b3c53e5fce1f96f5a2fc531280 Mon Sep 17 00:00:00 2001 263 + From: Alfred Wingate <parona@protonmail.com> 264 + Date: Wed, 11 Dec 2024 07:04:19 +0200 265 + Subject: [PATCH 4/4] Remove references to application/x-redhat-package-manager 266 + 267 + libmagic has never referred to x-redhat-package-manager and has had 268 + x-rpm since 3.30. Red Hat themselves use x-rpm in their mailcap. 269 + 270 + https://pagure.io/mailcap/blob/master/f/mime.types 271 + 272 + Signed-off-by: Alfred Wingate <parona@protonmail.com> 273 + --- 274 + patoolib/__init__.py | 1 - 275 + patoolib/mime.py | 2 +- 276 + tests/test_mime.py | 4 +--- 277 + 3 files changed, 2 insertions(+), 5 deletions(-) 278 + 279 + diff --git a/patoolib/__init__.py b/patoolib/__init__.py 280 + index 51f8b4eb..9d8bc849 100644 281 + --- a/patoolib/__init__.py 282 + +++ b/patoolib/__init__.py 283 + @@ -135,7 +135,6 @@ 284 + 'application/x-lrzip': 'lrzip', 285 + 'application/x-lzh': 'lzh', 286 + 'application/x-ms-wim': 'wim', 287 + - 'application/x-redhat-package-manager': 'rpm', 288 + 'application/x-rpm': 'rpm', 289 + 'application/x-rzip': 'rzip', 290 + 'application/x-shar': 'shar', 291 + diff --git a/patoolib/mime.py b/patoolib/mime.py 292 + index 8de9b180..ffad9cd0 100644 293 + --- a/patoolib/mime.py 294 + +++ b/patoolib/mime.py 295 + @@ -272,7 +272,7 @@ def get_file_mime_encoding(parts: Sequence[str]) -> str | None: 296 + "lzop compressed data": "application/x-lzop", 297 + "Microsoft Cabinet archive data": "application/vnd.ms-cab-compressed", 298 + "RAR archive data": "application/vnd.rar", 299 + - "RPM ": "application/x-redhat-package-manager", 300 + + "RPM ": "application/x-rpm", 301 + "POSIX tar archive": "application/x-tar", 302 + "xz compressed data": "application/x-xz", 303 + "Zip archive data": "application/zip", 304 + diff --git a/tests/test_mime.py b/tests/test_mime.py 305 + index 287d8208..a337f87a 100644 306 + --- a/tests/test_mime.py 307 + +++ b/tests/test_mime.py 308 + @@ -248,9 +248,7 @@ def test_mime_mimedb(self): 309 + self.mime_test_mimedb("t.txt.lz4", "application/x-lz4") 310 + self.mime_test_mimedb("t.lzo", "application/x-lzop") 311 + self.mime_test_mimedb("t.rar", "application/vnd.rar") 312 + - self.mime_test_mimedb( 313 + - "t.rpm", ("application/x-redhat-package-manager", "application/x-rpm") 314 + - ) 315 + + self.mime_test_mimedb("t.rpm", "application/x-rpm") 316 + self.mime_test_mimedb("t.tar", "application/x-tar") 317 + self.mime_test_mimedb("t.cbt", "application/x-tar") 318 + self.mime_test_mimedb("t.tar.bz2", "application/x-tar", "bzip2")