Skip to content

Commit

Permalink
Merge branch 'release/1.15.9'
Browse files Browse the repository at this point in the history
  • Loading branch information
lueschem committed Jan 16, 2024
2 parents bdd8eb1 + 5d5c22f commit 7b333c2
Show file tree
Hide file tree
Showing 25 changed files with 131 additions and 577 deletions.
8 changes: 8 additions & 0 deletions debian/changelog
@@ -1,3 +1,11 @@
edi (1.15.9) jammy; urgency=medium

* Removed obsolete QEMU handling. Closes #87.
* Reworked command runner.
* Updated readthedocs-sphinx-search as advised by Read the Docs.

-- Matthias Luescher <lueschem@gmail.com> Tue, 16 Jan 2024 13:42:03 +0100

edi (1.15.8) jammy; urgency=medium

[ Matthias Luescher ]
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Expand Up @@ -55,8 +55,8 @@
# built documents.
#
# The short X.Y version.
version = '1.15.8'
release = '1.15.8'
version = '1.15.9'
release = '1.15.9'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
26 changes: 0 additions & 26 deletions docs/config_management/yaml.rst
Expand Up @@ -114,32 +114,6 @@ If you would like to bootstrap an image right now, you can run the following com
sudo edi image bootstrap my-project-develop.yml
:code:`qemu` Section
++++++++++++++++++++

If the target architecture does not match the host architecture edi uses QEMU to emulate the foreign architecture.
edi automatically detects the necessity of an architecture emulation and takes the necessary steps to set up QEMU.
As QEMU evolves quickly it is often desirable to point edi to a very recent version of QEMU. The QEMU section allows
you to do this. The following settings are available:

.. topic:: Settings

*package:*
The name of the qemu package that should get downloaded.
If not specified edi assumes that the package is named :code:`qemu-user-static`.
*repository:*
The repository specification where QEMU will get downloaded from.
A valid value looks like this: :code:`deb http://deb.debian.org/debian/ bookworm main`.
If unspecified, edi will try to download QEMU from the repository indicated in the bootstrap section.
*repository_key:*
The signature key for the QEMU repository.
*Attention*: If you do not specify a key the downloaded QEMU package will not be verified.
*Hint*: It is a good practice to download such a key from a
https server.
A valid repository key value is: :code:`https://ftp-master.debian.org/keys/archive-key-10.asc`.


.. _ordered_node_section:

Ordered Node Section
Expand Down
2 changes: 1 addition & 1 deletion docs/requirements.txt
@@ -1,3 +1,3 @@
sphinx==7.2.6
sphinx-rtd-theme==1.3.0
readthedocs-sphinx-search==0.3.1
readthedocs-sphinx-search==0.3.2
2 changes: 1 addition & 1 deletion edi/__init__.py
Expand Up @@ -24,7 +24,7 @@
import logging
import requests
import argcomplete
from edi.commands import clean, config, image, lxc, qemu, target, version, documentation # noqa: ignore=F401
from edi.commands import clean, config, image, lxc, target, version, documentation # noqa: ignore=F401
from edi.lib.commandfactory import get_sub_commands, get_command
from edi.lib.helpers import print_error_and_exit, FatalError
from edi.lib.edicommand import EdiCommand
Expand Down
3 changes: 1 addition & 2 deletions edi/commands/__init__.py
Expand Up @@ -24,7 +24,6 @@
lxcprepare, profile, publish, stop) # noqa: ignore=F401
from edi.commands.configcommands import configclean, configinit # noqa: ignore=F401
from edi.commands.targetcommands import targetconfigure # noqa: ignore=F401
from edi.commands.qemucommands import fetch, qemuclean # noqa: ignore=F401
from edi.commands.documentationcommands import render # noqa: ignore=F401

__all__ = ["config", "image", "lxc", "version", "clean", "target", "qemu", "documentation"]
__all__ = ["config", "image", "lxc", "version", "clean", "target", "documentation"]
35 changes: 21 additions & 14 deletions edi/commands/imagecommands/bootstrap.py
Expand Up @@ -25,11 +25,10 @@
from codecs import open
from aptsources.sourceslist import SourceEntry
from edi.commands.image import Image
from edi.commands.qemucommands.fetch import Fetch
from edi.lib.helpers import (FatalError, chown_to_user, print_success,
get_workdir, get_artifact_dir, create_artifact_dir)
from edi.lib.configurationparser import command_context
from edi.lib.shellhelpers import run, get_chroot_cmd, require, mount_aware_tempdir
from edi.lib.shellhelpers import run, get_chroot_cmd, require, mount_aware_tempdir, get_debian_architecture
from edi.lib.proxyhelpers import ProxySetup
from edi.lib.keyhelpers import fetch_repository_key, build_keyring

Expand All @@ -52,8 +51,9 @@ def run_cli(self, cli_args):
def dry_run(self, config_file):
return self._dispatch(config_file, run_method=self._dry_run)

def _dry_run(self):
return Fetch().dry_run(self.config.get_base_config_file())
@staticmethod
def _dry_run():
return {}

def run(self, config_file):
return self._dispatch(config_file, run_method=self._run)
Expand All @@ -67,7 +67,7 @@ def _run(self):

self._require_sudo()

qemu_executable = Fetch().run(self.config.get_base_config_file())
needs_qemu = self._needs_qemu()

print("Going to bootstrap initial image - be patient.")

Expand All @@ -81,7 +81,7 @@ def _run(self):
chown_to_user(tempdir)
key_data = fetch_repository_key(self.config.get_bootstrap_repository_key())
keyring_file = build_keyring(tempdir, "temp_keyring.gpg", key_data)
rootfs = self._run_debootstrap(tempdir, keyring_file, qemu_executable)
rootfs = self._run_debootstrap(tempdir, keyring_file, needs_qemu)
self._postprocess_rootfs(rootfs, key_data)
archive = self._pack_image(tempdir, rootfs)
chown_to_user(archive)
Expand All @@ -107,9 +107,6 @@ def _clean(self):
os.remove(self._result())
print_success("Removed bootstrap image {}.".format(self._result()))

if self.clean_depth > 0:
Fetch().clean_recursive(self.config.get_base_config_file(), self.clean_depth - 1)

def _dispatch(self, config_file, run_method):
self._setup_parser(config_file)
return run_method()
Expand All @@ -123,7 +120,7 @@ def _result(self):
return os.path.join(get_artifact_dir(), archive_name)

@require("debootstrap", "'sudo apt install debootstrap'")
def _run_debootstrap(self, tempdir, keyring_file, qemu_executable):
def _run_debootstrap(self, tempdir, keyring_file, needs_qemu):
additional_packages = ','.join(self.config.get_bootstrap_additional_packages())
rootfs = os.path.join(tempdir, "rootfs")
bootstrap_source = SourceEntry(self.config.get_bootstrap_repository())
Expand All @@ -132,7 +129,7 @@ def _run_debootstrap(self, tempdir, keyring_file, qemu_executable):
cmd = list()
cmd.append("debootstrap")
cmd.append("--arch={0}".format(self.config.get_bootstrap_architecture()))
if qemu_executable:
if needs_qemu:
cmd.append("--foreign")
cmd.append("--variant=minbase")
cmd.append("--include={0}".format(additional_packages))
Expand All @@ -145,9 +142,7 @@ def _run_debootstrap(self, tempdir, keyring_file, qemu_executable):
cmd.append(bootstrap_source.uri)
run(cmd, sudo=True, log_threshold=logging.INFO, env=ProxySetup().get_environment())

if qemu_executable:
qemu_target_path = os.path.join(rootfs, "usr", "bin")
shutil.copy(qemu_executable, qemu_target_path)
if needs_qemu:
second_stage_cmd = get_chroot_cmd(rootfs)
second_stage_cmd.append("/debootstrap/debootstrap")
second_stage_cmd.append("--second-stage")
Expand Down Expand Up @@ -180,3 +175,15 @@ def _postprocess_rootfs(self, rootfs, key_data):
with open(sources_list, mode='w', encoding='utf-8') as f:
f.write(('# edi bootstrap repository\n{}\n'
).format(self.config.get_bootstrap_repository()))

def _needs_qemu(self):
if not self.config.has_bootstrap_node():
return False
host_architecture = get_debian_architecture()
container_architecture = self.config.get_bootstrap_architecture()
if host_architecture == container_architecture:
return False
elif host_architecture == 'amd64' and container_architecture == 'i386':
return False
else:
return True
17 changes: 12 additions & 5 deletions edi/commands/imagecommands/create.py
Expand Up @@ -22,7 +22,7 @@
import logging
from edi.commands.image import Image
from edi.commands.lxccommands.export import Export
from edi.lib.commandrunner import CommandRunner
from edi.lib.commandrunner import CommandRunner, Artifact, ArtifactType
from edi.lib.configurationparser import command_context
from edi.lib.helpers import print_success

Expand Down Expand Up @@ -53,15 +53,19 @@ def _dry_run(self):
plugins = {}
if self._input_artifact() is not None:
plugins.update(Export().dry_run(self.config.get_base_config_file()))
command_runner = CommandRunner(self.config, self.section, self._input_artifact())
command_runner = CommandRunner(self.config, self.section, Artifact(name='edi_input_artifact',
url=self._input_artifact(),
type=ArtifactType.PATH))
plugins.update(command_runner.get_plugin_report())
return plugins

def run(self, config_file):
return self._dispatch(config_file, run_method=self._run)

def _run(self):
command_runner = CommandRunner(self.config, self.section, self._input_artifact())
command_runner = CommandRunner(self.config, self.section, Artifact(name='edi_input_artifact',
url=self._input_artifact(),
type=ArtifactType.PATH))

if command_runner.require_root():
self._require_sudo()
Expand All @@ -76,8 +80,9 @@ def _run(self):
result = command_runner.run()

if result:
formatted_results = [f"{a.name}: {a.url}" for a in result]
print_success(("Completed the image creation post processing commands.\n"
"The following artifacts are now available:\n- {}".format('\n- '.join(result))))
"The following artifacts are now available:\n- {}".format('\n- '.join(formatted_results))))
return result

def clean_recursive(self, config_file, depth):
Expand All @@ -88,7 +93,9 @@ def clean(self, config_file):
self._dispatch(config_file, run_method=self._clean)

def _clean(self):
command_runner = CommandRunner(self.config, self.section, self._input_artifact())
command_runner = CommandRunner(self.config, self.section, Artifact(name='edi_input_artifact',
url=self._input_artifact(),
type=ArtifactType.PATH))
if command_runner.require_root_for_clean():
self._require_sudo()
command_runner.clean()
Expand Down
38 changes: 0 additions & 38 deletions edi/commands/qemu.py

This file was deleted.

22 changes: 0 additions & 22 deletions edi/commands/qemucommands/__init__.py

This file was deleted.

0 comments on commit 7b333c2

Please sign in to comment.