summaryrefslogtreecommitdiff
path: root/0004-Process-source-URLs-with-fragment-in-pre-push-hook.patch
blob: e25203842cbe02daea2990157b15b550ec5d3551 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
From 6d813d40aff91345b171323512b3ae641a168d45 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lubom=C3=ADr=20Sedl=C3=A1=C5=99?= <lsedlar@redhat.com>
Date: Mon, 27 Feb 2023 08:36:20 +0100
Subject: [PATCH] Process source URLs with fragment in pre-push hook
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Some download services do not have the actual filename in the URL.
Packagers work around that by adding a fragment to the URL. This is then
ignored by any server, but tricks RPM into getting the correct filename.

Example:

    Source0: https://crates.io/api/v1/crates/actix/0.13.0/download#/actix-0.13.0.crate

The filename is obviously `actix-0.13.0.crate`, but rpkg without this
patch will come up with `download`.

Signed-off-by: Lubomír Sedlář <lsedlar@redhat.com>
---
 pyrpkg/__init__.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pyrpkg/__init__.py b/pyrpkg/__init__.py
index 6a0e9eb..c650851 100644
--- a/pyrpkg/__init__.py
+++ b/pyrpkg/__init__.py
@@ -4464,7 +4464,9 @@ class Commands(object):
                 # find out the format of the source file path. From URL use just the file name.
                 # We want to keep hierarchy of the files if possible
                 res = urllib.parse.urlparse(file_location)
-                if res.scheme and res.netloc:
+                if res.scheme and res.fragment:
+                    source_files.append(os.path.basename(res.fragment))
+                elif res.scheme and res.netloc:
                     source_files.append(os.path.basename(res.path))
                 else:
                     source_files.append(file_location)
-- 
2.39.2