From bac0fa3eb2932994cb691770c1473394780a0134 Mon Sep 17 00:00:00 2001
From: Michael Johnson <johnsomor@gmail.com>
Date: Thu, 8 Aug 2019 14:14:11 -0700
Subject: [PATCH] Fix the pypi element for multiple mirror URLs

The 'pypi' mirror element is generating invalid pip.conf files
when more than one "DIB_PYPI_MIRROR_URL" is specified.
This patch fixes the pip.conf file rendering to use a proper form
when there are multiple "extra_index_url" provided.

Closes-Bug: #1839558
Change-Id: Ibda0e7390955683560e09b486f636775643ff57c
---
 .../elements/pypi/pre-install.d/04-configure-pypi-mirror    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/diskimage_builder/elements/pypi/pre-install.d/04-configure-pypi-mirror b/diskimage_builder/elements/pypi/pre-install.d/04-configure-pypi-mirror
index 9ad74c454..335f3d58a 100755
--- a/diskimage_builder/elements/pypi/pre-install.d/04-configure-pypi-mirror
+++ b/diskimage_builder/elements/pypi/pre-install.d/04-configure-pypi-mirror
@@ -57,8 +57,10 @@ def main():
         output.write('trusted-host =  %s\n' % (urlparse(indices[0]).hostname,))
         if retries is not None:
             output.write('retries = %s\n' % retries)
-        for index in indices[1:]:
-            output.write('extra-index-url = %s\n' % (index,))
+        if len(indices) > 1:
+            output.write('extra-index-url =\n')
+            for index in indices[1:]:
+                output.write('    %s\n' % (index,))
     with open(home + '/.pydistutils.cfg', 'wt') as output:
         output.write('[easy_install]\n')
         output.write('index_url = %s\n' % (easy_index,))