[elbe-devel] [PATCH 1/9] rfs: isolate create_apt_prefs into a function
Torben Hohn
torben.hohn at linutronix.de
Wed Jun 26 11:50:20 CEST 2019
in order to reuse create_apt_prefs() from virtapt cache, isolate
it into a separate function.
Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
---
elbepack/rfs.py | 75 +++++++++++++++++++++++++++++----------------------------
1 file changed, 38 insertions(+), 37 deletions(-)
diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index 8476d01b3..2b0847dd4 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -17,6 +17,43 @@ from elbepack.templates import (write_pack_template, get_preseed,
from elbepack.shellhelper import CommandError
+def create_apt_prefs(xml, rfs):
+
+ filename = rfs.path + "/etc/apt/preferences"
+
+ if os.path.exists(filename):
+ os.remove(filename)
+
+ rfs.mkdir_p("/etc/apt")
+
+ pinned_origins = []
+ if xml.has('project/mirror/url-list'):
+ for url in xml.node('project/mirror/url-list'):
+ if not url.has('binary'):
+ continue
+
+ repo = url.node('binary')
+ if 'pin' not in repo.et.attrib:
+ continue
+
+ origin = urlparse.urlsplit(repo.et.text.strip()).hostname
+ pin = repo.et.attrib['pin']
+ if 'package' in repo.et.attrib:
+ package = repo.et.attrib['package']
+ else:
+ package = '*'
+ pinning = {'pin': pin,
+ 'origin': origin,
+ 'package': package}
+ pinned_origins.append(pinning)
+
+ d = {"xml": xml,
+ "prj": xml.node("/project"),
+ "pkgs": xml.node("/target/pkg-list"),
+ "porgs": pinned_origins}
+
+ write_pack_template(filename, "preferences.mako", d)
+
class DebootstrapException (Exception):
def __init__(self):
Exception.__init__(self, "Debootstrap Failed")
@@ -54,7 +91,7 @@ class BuildEnv (object):
self.need_dumpdebootstrap = False
self.initialize_dirs(build_sources=build_sources)
- self.create_apt_prefs()
+ create_apt_prefs(self.xml, self.rfs)
def cdrom_umount(self):
if self.xml.prj.has("mirror/cdrom"):
@@ -274,42 +311,6 @@ class BuildEnv (object):
self.rfs.path, 'debconf-set-selections < %s' %
self.rfs.fname("var/cache/elbe/preseed.txt"))
- def create_apt_prefs(self):
-
- filename = self.rfs.path + "/etc/apt/preferences"
-
- if os.path.exists(filename):
- os.remove(filename)
-
- self.rfs.mkdir_p("/etc/apt")
-
- pinned_origins = []
- if self.xml.has('project/mirror/url-list'):
- for url in self.xml.node('project/mirror/url-list'):
- if not url.has('binary'):
- continue
-
- repo = url.node('binary')
- if 'pin' not in repo.et.attrib:
- continue
-
- origin = urlparse.urlsplit(repo.et.text.strip()).hostname
- pin = repo.et.attrib['pin']
- if 'package' in repo.et.attrib:
- package = repo.et.attrib['package']
- else:
- package = '*'
- pinning = {'pin': pin,
- 'origin': origin,
- 'package': package}
- pinned_origins.append(pinning)
-
- d = {"xml": self.xml,
- "prj": self.xml.node("/project"),
- "pkgs": self.xml.node("/target/pkg-list"),
- "porgs": pinned_origins}
-
- write_pack_template(filename, "preferences.mako", d)
def seed_etc(self):
passwd = self.xml.text("target/passwd")
--
2.11.0
More information about the elbe-devel
mailing list