[elbe-devel] [PATCH] Enable usage of APT sources without components

Braunwarth, Daniel Daniel.Braunwarth at kuka.com
Wed Jun 9 13:26:13 CEST 2021


According to the APT sources manual [1] it is valid to define a sources
entry without any given component:

deb [ option1=value1 option2=value2 ] uri suite [component1] [...]

This is, for instance, how repositories hosted by mini-dinstall [2]
must to be configured.

For example a valid sources entry for a mini-dinstall repository would
be:

deb http://dummy.foo/bar buster/

Without this patch, such a sources entry causes a IndexError.

[1] https://manpages.debian.org/buster/apt/sources.list
[2] https://manpages.debian.org/buster/mini-dinstall/mini-dinstall

Signed-off-by: Daniel Braunwarth <daniel.braunwarth at kuka.com>
---
 elbepack/elbexml.py | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/elbepack/elbexml.py b/elbepack/elbexml.py
index 610880ea2..3234af06b 100644
--- a/elbepack/elbexml.py
+++ b/elbepack/elbexml.py
@@ -280,7 +280,6 @@ class ElbeXML:
                 lsplit = line.split(" ")
                 url = lsplit[1]
                 suite = lsplit[2]
-                section = lsplit[3]
                 r = {}
 
                 #
@@ -294,10 +293,23 @@ class ElbeXML:
                 else:
                     r["url"] = "%s/dists/%s/" % (url, suite)
 
-                if line.startswith("deb "):
-                    r["binstr"] = (section + "/binary-%s/Packages" % arch)
-                else:
-                    r["srcstr"] = (section + "/source/Sources")
+                #
+                # Try to get sections.
+                # If no sections has been passed, this is also valid syntax but
+                # needs some special handling.
+                #
+                try:
+                    section = lsplit[3]
+                    if line.startswith("deb "):
+                        r["binstr"] = (section + "/binary-%s/Packages" % arch)
+                    else:
+                        r["srcstr"] = (section + "/source/Sources")
+                except IndexError:
+                    if line.startswith("deb "):
+                        r["binstr"] = "Packages"
+                    else:
+                        r["srcstr"] = "Sources"
+
                 repos.append(r)
 
         if not self.prj:
-- 
2.32.0


More information about the elbe-devel mailing list