[elbe-devel] [PATCH v2 4/4] RFC: elbepack: only provide resolv.conf during download step

Thomas Weißschuh thomas.weissschuh at linutronix.de
Fri Apr 26 17:20:47 CEST 2024


Certain packages or finetunings expect to manage /etc/resolv.conf.
For example the resolvconf package contains a post-install script that
checks if no /etc/resolv.conf exists and if it does, it gets created as a
symlink to ../run/resolvconf/resolv.conf.

However the way elbe downloads and installs packages requires it to have
a working /etc/resolv.conf in the target.
This /etc/resolv.conf is copied from the initvm through the excursion
mechanism.

To enable both download with /etc/resolv.conf and installation without
/etc/resolv.conf, split the installation step into two phases, download
and installation.

Drawbacks:
* If a package installation script expects network connection this now
  fails. Arguably this would be bad practice in any case.

Closes: https://github.com/Linutronix/elbe/issues/274
Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 elbepack/efilesystem.py | 7 +++++++
 elbepack/elbeproject.py | 5 +++++
 elbepack/rpcaptcache.py | 4 ++++
 3 files changed, 16 insertions(+)

diff --git a/elbepack/efilesystem.py b/elbepack/efilesystem.py
index 39868e2b4835..b31ba072c4a3 100644
--- a/elbepack/efilesystem.py
+++ b/elbepack/efilesystem.py
@@ -332,6 +332,13 @@ class ChRootFilesystem(ElbeFilesystem):
         for excursion in self._excursions:
             excursion.end(self)
 
+    def end_excursion(self, origin):
+        for excursion in self._excursions:
+            if origin == excursion.origin:
+                self._excursions.remove(excursion)
+                excursion.end(self)
+                return
+
     def mount(self):
         if self.path == '/':
             return
diff --git a/elbepack/elbeproject.py b/elbepack/elbeproject.py
index a446907d3f61..76a2f98cb2d7 100644
--- a/elbepack/elbeproject.py
+++ b/elbepack/elbeproject.py
@@ -1065,6 +1065,11 @@ class ElbeProject:
             # the functions cleans up to much
             # self.get_rpcaptcache().cleanup(debootstrap_pkgs + pkgs)
 
+            self.get_rpcaptcache(env=target).fetch_archives()
+
+            # The package installation below may want to manage resolv.conf.
+            target.rfs.end_excursion('/etc/resolv.conf')
+
             try:
                 self.get_rpcaptcache(env=target).commit()
             except SystemError as e:
diff --git a/elbepack/rpcaptcache.py b/elbepack/rpcaptcache.py
index b9985414091f..a71a2e10b902 100644
--- a/elbepack/rpcaptcache.py
+++ b/elbepack/rpcaptcache.py
@@ -237,6 +237,10 @@ class RPCAPTCache(InChRootObject):
         self.cache.update(fetch_progress=ElbeAcquireProgress())
         self.cache.open(progress=ElbeOpProgress())
 
+    def fetch_archives(self):
+        print('Fetching packages...')
+        self.cache.fetch_archives(ElbeAcquireProgress())
+
     def commit(self):
         os.environ['DEBIAN_FRONTEND'] = 'noninteractive'
         os.environ['DEBONF_NONINTERACTIVE_SEEN'] = 'true'

-- 
2.44.0



More information about the elbe-devel mailing list