[elbe-devel] [PATCH] elbepack: drop install_elbe_version functionality

Thomas Weißschuh thomas.weissschuh at linutronix.de
Thu Jun 20 15:34:48 CEST 2024


Modifying an initvm after its creation is ripe with issues.
For examples the repository CDROM will be out of date,
the code setting up the initvm doesn't match the code running inside it,
etc...

Don't support such a usecase.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh at linutronix.de>
---
 bash-completion                                 |  3 +-
 docs/elbe-control.rst                           |  6 ----
 elbepack/commands/control.py                    |  3 --
 elbepack/daemons/soap/datatypes.py              | 13 +-------
 elbepack/daemons/soap/esoap.py                  | 42 ++-----------------------
 elbepack/soapclient.py                          | 31 ------------------
 newsfragments/+install_elbe_version.removal.txt |  1 +
 7 files changed, 5 insertions(+), 94 deletions(-)

diff --git a/bash-completion b/bash-completion
index 9e0e7c787585..3a882f54cfde 100644
--- a/bash-completion
+++ b/bash-completion
@@ -109,8 +109,7 @@ _cmd_args_completion_elbe()
                 cmd_opt=$(_elbe_subcmd_with_opt 'rm_log list_projects list_users add_user create_project reset_project \
                                                  del_project set_xml build build_sysroot build_sdk build_cdroms get_file \
                                                  build_chroot_tarball dump_file get_files wait_busy set_cdrom set_orig \
-                                                 shutdown_initvm set_pdebuild build_pbuilder update_pbuilder \
-                                                 install_elbe_version')
+						 shutdown_initvm set_pdebuild build_pbuilder update_pbuilder')
                 ;;
             check_updates)
                 file_arg=true
diff --git a/docs/elbe-control.rst b/docs/elbe-control.rst
index a04008229ab3..d93f73b72026 100644
--- a/docs/elbe-control.rst
+++ b/docs/elbe-control.rst
@@ -33,7 +33,6 @@ SYNOPSIS
       elbe control [options] get_file <build-dir> <filename>
       elbe control [options] dump_file <build-dir> <filename>
       elbe control [options] shutdown_initvm
-      elbe control [options] install_elbe_version <version>
 
 DESCRIPTION
 ===========
@@ -189,11 +188,6 @@ a ./debian folder with a valid debianization.
 *shutdown_initvm*
    Make the initvm shutdown.
 
-*install_elbe_version* [version]
-   Make the initvm install a specific elbe version. Defaults to the
-   version of the elbe executable. This requires, that the initvm has
-   package sources configured properly.
-
 Examples
 ========
 
diff --git a/elbepack/commands/control.py b/elbepack/commands/control.py
index 0ce26fdc7107..f729388e1cbc 100644
--- a/elbepack/commands/control.py
+++ b/elbepack/commands/control.py
@@ -160,9 +160,6 @@ def run_command(argv):
                 'Please install same versions of elbe in initvm and on your '
                 'machine.',
                 file=sys.stderr)
-            print(
-                f'To install elbe v{elbe_version} into the initvm use '
-                "'elbe control --ignore-version-diff install_elbe_version'")
 
             if not opt.ignore_version:
                 sys.exit(16)
diff --git a/elbepack/daemons/soap/datatypes.py b/elbepack/daemons/soap/datatypes.py
index 4dc6eca7b97a..4ef31d89cba2 100644
--- a/elbepack/daemons/soap/datatypes.py
+++ b/elbepack/daemons/soap/datatypes.py
@@ -3,7 +3,7 @@
 # SPDX-FileCopyrightText: 2015-2017 Linutronix GmbH
 
 from spyne.model.complex import ComplexModel
-from spyne.model.primitive import DateTime, Integer, Unicode
+from spyne.model.primitive import DateTime, Unicode
 
 
 class SoapProject (ComplexModel):
@@ -21,14 +21,3 @@ class SoapFile (ComplexModel):
 
     name = Unicode()
     description = Unicode()
-
-
-class SoapCmdReply (ComplexModel):
-    __namespace__ = 'soap'
-
-    ret = Integer()
-    out = Unicode()
-
-    def __init__(self, ret, out):
-        self.ret = ret
-        self.out = out
diff --git a/elbepack/daemons/soap/esoap.py b/elbepack/daemons/soap/esoap.py
index 33efa91c3940..314a4f953541 100644
--- a/elbepack/daemons/soap/esoap.py
+++ b/elbepack/daemons/soap/esoap.py
@@ -6,7 +6,6 @@
 import binascii
 import fnmatch
 import os
-import pathlib
 import subprocess
 import tarfile
 from tempfile import NamedTemporaryFile
@@ -17,10 +16,10 @@ from spyne.model.primitive import Boolean, Integer, String
 from spyne.service import ServiceBase
 
 from elbepack.elbexml import ValidationMode
-from elbepack.version import elbe_version, is_devel
+from elbepack.version import elbe_version
 
 from .authentication import authenticated_admin, authenticated_uid
-from .datatypes import SoapCmdReply, SoapFile, SoapProject
+from .datatypes import SoapFile, SoapProject
 from .faults import soap_faults
 
 
@@ -51,43 +50,6 @@ class ESoap (ServiceBase):
     def list_users(self):
         return [u.name for u in self.app.pm.db.list_users()]
 
-    @rpc(String, String(max_occurs='unbounded'), _returns=SoapCmdReply)
-    @soap_faults
-    @authenticated_admin
-    def install_elbe_version(self, version, pkglist):
-        if is_devel:
-            return SoapCmdReply(10,
-                                'Initvm is in devel mode: installing another\n'
-                                'elbe version will not have any effect.\n')
-
-        pkgs = [F'"{p}={version}*"' for p in pkglist]
-
-        # Prevent, that elbe daemon is restarted by the
-        # prerm/postinst scripts.
-        # elbe daemon does it itself, because cherrypy
-        # notices that.
-        policy_rc_d = pathlib.Path('/usr/sbin/policy-rc.d')
-        policy_rc_d.touch(mode=0o755)
-        policy_rc_d.write_text('#!/bin/sh\nexit 101\n')
-        try:
-            env = os.environ()
-            env.update({
-                'LANG': 'C',
-                'LANGUAGE': 'C',
-                'LC_ALL': 'C',
-                'DEBIAN_FRONTEND': 'noninteractive',
-                'DEBCONF_NONINTERACTIVE_SEEN': 'true',
-            })
-
-            cmd = ('apt-get update; '
-                   f"apt-get install -y --allow-downgrades {' '.join(pkgs)}")
-
-            ps = subprocess.run(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
-        finally:
-            policy_rc_d.unlink()
-
-        return SoapCmdReply(ps.returncode, ps.stdout)
-
     @rpc(String, String, String, String, Boolean)
     @soap_faults
     @authenticated_admin
diff --git a/elbepack/soapclient.py b/elbepack/soapclient.py
index ad9b0b5e8dfb..a80e9d6974ae 100644
--- a/elbepack/soapclient.py
+++ b/elbepack/soapclient.py
@@ -21,7 +21,6 @@ from suds.client import Client
 
 from elbepack.config import cfg
 from elbepack.elbexml import ElbeXML, ValidationMode
-from elbepack.version import elbe_initvm_packagelist, elbe_version
 
 
 def set_suds_debug(debug):
@@ -716,36 +715,6 @@ class UpdatePbuilderAction(ClientAction):
 ClientAction.register(UpdatePbuilderAction)
 
 
-class InstallElbeVersion(ClientAction):
-
-    tag = 'install_elbe_version'
-
-    def execute(self, client, _opt, args):
-        if len(args) > 1:
-            print(
-                'usage: elbe control install_elbe_version [version]',
-                file=sys.stderr)
-            sys.exit(198)
-
-        if args:
-            version = args[0]
-        else:
-            version = elbe_version
-
-        result = client.service.install_elbe_version(version,
-                                                     elbe_initvm_packagelist)
-
-        print(result.out)
-
-        if result.ret == 0:
-            print('\nSuccess !!!')
-        else:
-            print(f'\nError: apt returns {result.ret}')
-
-
-ClientAction.register(InstallElbeVersion)
-
-
 class RepoAction(ClientAction):
     repoactiondict = {}
 
diff --git a/newsfragments/+install_elbe_version.removal.txt b/newsfragments/+install_elbe_version.removal.txt
new file mode 100644
index 000000000000..951a383ab867
--- /dev/null
+++ b/newsfragments/+install_elbe_version.removal.txt
@@ -0,0 +1 @@
+Drop `install_elbe_version`.

---
base-commit: 6706783bfad7009801bfd404e7884651d00caab2
change-id: 20240620-install_elbe_version-0551a12fba0b

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh at linutronix.de>



More information about the elbe-devel mailing list