[elbe-devel] [PATCH v3] Remove duplicated slashes from primary mirror

Daniel Braunwarth daniel.braunwarth at kuka.com
Thu Sep 9 13:45:29 CEST 2021


This patch removes any duplicated slashes in the primary mirror URL.

This patch fixes #272.

Changes since v1:
* Replace duplicated slashes at all possible places.
* Use str.format() instead of f-strings.

Changes since v2:
* Rebase

Signed-off-by: Daniel Braunwarth <daniel.braunwarth at kuka.com>
---
 elbepack/debinstaller.py |  5 +++--
 elbepack/elbexml.py      | 10 ++++++----
 2 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/elbepack/debinstaller.py b/elbepack/debinstaller.py
index b739c83e6..9871aa069 100644
--- a/elbepack/debinstaller.py
+++ b/elbepack/debinstaller.py
@@ -193,8 +193,9 @@ def get_primary_mirror(prj):
         m = prj.node("mirror")
 
         mirror = m.text("primary_proto") + "://"
-        mirror += m.text("primary_host") + "/"
-        mirror += m.text("primary_path")
+        mirror += "{}/{}".format(m.text("primary_host"),
+                                 m.text("primary_path")
+                                ).replace("//", "/")
     else:
         raise NoKinitrdException("Broken xml file: "
                                  "no cdrom and no primary host")
diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 3234af06b..eabd1f2fd 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -120,8 +120,9 @@ class ElbeXML:
             m = self.node("initvm/mirror")
 
             mirror = m.text("primary_proto") + "://"
-            mirror += m.text("primary_host") + "/"
-            mirror += m.text("primary_path")
+            mirror += "{}/{}".format(m.text("primary_host"),
+                                     m.text("primary_path")
+                                    ).replace("//", "/")
 
         elif self.xml.has("initvm/mirror/cdrom") and cdrompath:
             mirror = "file://%s" % cdrompath
@@ -136,8 +137,9 @@ class ElbeXML:
                 mirror = m.text("host")
             else:
                 mirror = m.text("primary_proto") + "://"
-                mirror += m.text("primary_host") + "/"
-                mirror += m.text("primary_path")
+                mirror += "{}/{}".format(m.text("primary_host"),
+                                         m.text("primary_path")
+                                        ).replace("//", "/")
 
         elif self.prj.has("mirror/cdrom") and cdrompath:
             mirror = "file://%s" % cdrompath
-- 
2.33.0



More information about the elbe-devel mailing list