spectool: Download text as text

This commit is contained in:
Miro Hrončok 2021-01-25 12:40:27 +01:00
parent fe6aa3d1c8
commit 26bfd64822
2 changed files with 41 additions and 1 deletions

33
77.patch Normal file
View File

@ -0,0 +1,33 @@
From 6a582f49fa958e4ba3e374d0e77d814524111dfb Mon Sep 17 00:00:00 2001
From: Miro Hrončok <miro@hroncok.cz>
Date: Jan 23 2021 13:15:35 +0000
Subject: Use Accept-Encoding: identity together with decode_content=False
This should fix both the issues:
- gzips decompressed: https://pagure.io/rpmdevtools/issue/72
- texts compressed: https://pagure.io/rpmdevtools/issue/76
$ file tor-0.4.5.4-rc.tar.gz tor-0.4.5.4-rc.tar.gz.asc xrootd-5.0.3.tar.gz
tor-0.4.5.4-rc.tar.gz: gzip compressed data, max compression, from Unix, original size modulo 2^32 35962880
tor-0.4.5.4-rc.tar.gz.asc: PGP signature Signature (old)
xrootd-5.0.3.tar.gz: gzip compressed data, max compression, from Unix, original size modulo 2^32 981462405
---
diff --git a/rpmdev-spectool b/rpmdev-spectool
index 56a2d43..a324fab 100755
--- a/rpmdev-spectool
+++ b/rpmdev-spectool
@@ -239,6 +239,9 @@ def download(url, target, headers=None, tracker: Optional[ProgressTracker] = Non
headers = {}
headers.setdefault("User-Agent", "rpmdev-spectool")
+ # identity should prevent servers from sending gzip-compressed text
+ # which would later not be decompressed because we set decode_content=False
+ headers.setdefault("Accept-Encoding", "identity")
ret = requests.get(url, headers=headers, stream=True)
ret.raise_for_status()

View File

@ -1,6 +1,6 @@
Name: rpmdevtools
Version: 9.3
Release: 2%{?dist}
Release: 3%{?dist}
Summary: RPM Development Tools
# rpmdev-setuptree is GPLv2, everything else GPLv2+
@ -8,6 +8,10 @@ License: GPLv2+ and GPLv2
URL: https://pagure.io/rpmdevtools
Source0: https://releases.pagure.org/rpmdevtools/%{name}-%{version}.tar.xz
# Use Accept-Encoding: identity together with decode_content=False
# This is to avoid text files downloaded gzipped
Patch1: https://pagure.io/rpmdevtools/pull-request/77.patch
# Fedora-specific downstream patches
## Force legacy datestamp by default until rhbz#1715412 is resolved
Patch1001: 0001-Force-legacy-datestamp-while-RHBZ-1715412-is-still-a.patch
@ -116,6 +120,9 @@ echo ".so man1/rpmdev-spectool.1" > %{buildroot}%{_mandir}/man1/spectool.1
%changelog
* Mon Jan 25 2021 Miro Hrončok <mhroncok@redhat.com> - 9.3-3
- spectool: Download text as text
* Fri Jan 22 2021 Michal Domonkos <mdomonko@redhat.com> - 9.3-2
- Replace requests-download dependency with requests