From 00ba3fb6d47dea0673c68b92cf56acbe7f211a40 Mon Sep 17 00:00:00 2001
From: Jeff Harvey-Smith <jharveysmith@yugabyte.com>
Date: Thu, 30 Jan 2025 13:14:27 -0800
Subject: [PATCH] [DB-7671] Packaging: Fix packaging URLs from the
 package_manifest

Summary:
Fix packaging URLs from the package_manifest
Jira: DB-7671

Test Plan: jenkins: build type: release

Reviewers: devops, steve.varnau

Reviewed By: steve.varnau

Subscribers: devops

Differential Revision: https://phorge.dev.yugabyte.com/D41602
---
 python/yugabyte/command_util.py |  2 +-
 python/yugabyte/release_util.py | 16 ++++++++++------
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/python/yugabyte/command_util.py b/python/yugabyte/command_util.py
index 141c9e3055fc..ee2a603c1a80 100644
--- a/python/yugabyte/command_util.py
+++ b/python/yugabyte/command_util.py
@@ -143,7 +143,7 @@ def copy_deep(src: str, dst: str, create_dst_dir: bool = False) -> None:
         logging.debug("Pulling {} to {} from the web".format(src, dst))
         opener = urllib.request.URLopener()
         opener.addheader('User-Agent', 'yugabyte')  # type: ignore[arg-type]
-        opener.retrieve(src, os.path.join(dst, os.path.basename(src)))
+        opener.retrieve(src, dst)
     elif os.path.isdir(src) and not src_is_link:
         logging.debug("Copying directory {} to {}".format(src, dst))
         mkdir_p(dst)
diff --git a/python/yugabyte/release_util.py b/python/yugabyte/release_util.py
index 2ac32aaa8554..1fd87ac5c1cf 100644
--- a/python/yugabyte/release_util.py
+++ b/python/yugabyte/release_util.py
@@ -199,13 +199,18 @@ def _rewrite_manifest(self) -> None:
                 for i in range(len(values)):
                     values[i] = self.expand_value(values[i])
 
-    def repo_expand_path(self, path: str) -> str:
+    def repo_expand_path(self, path: str) -> List[str]:
         """
         If path is relative treat it as a path within repo and make it absolute.
         """
-        if not path.startswith('/'):
-            path = os.path.join(YB_SRC_ROOT, path)
-        return path
+        return_path = []
+        if path.startswith('http'):
+            return_path = [path]
+        else:
+            if not path.startswith('/'):
+                path = os.path.join(YB_SRC_ROOT, path)
+            return_path = glob.glob(path)
+        return return_path
 
     def create_distribution(self, distribution_dir: str) -> None:
         """This method would read the release_manifest and traverse through the
@@ -227,8 +232,7 @@ def create_distribution(self, distribution_dir: str) -> None:
             for elem in self.release_manifest[dir_from_manifest]:
                 if not elem:
                     continue
-                elem = self.repo_expand_path(elem)
-                files = glob.glob(elem)
+                files = self.repo_expand_path(elem)
                 for file_path in files:
                     copy_deep(file_path,
                               os.path.join(current_dest_dir, os.path.basename(file_path)))