Skip to content

Commit

Permalink
Merge branch 'release/1.13.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
lueschem committed Dec 3, 2022
2 parents 23f92da + 6e89103 commit 08c39c9
Show file tree
Hide file tree
Showing 14 changed files with 82 additions and 24 deletions.
10 changes: 5 additions & 5 deletions .github/scripts/build-package
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ set -o errexit
set -o pipefail
set -o nounset

# there is no VERSION_ID in sid/bullseye
VERSION_ID="11"
VERSION="11 (bullseye)"
# there is no VERSION_ID in testing/bookworm
VERSION_ID="12"
VERSION="12 (bookworm)"
source /etc/os-release

SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
Expand All @@ -18,12 +18,12 @@ cd "${SCRIPTDIR}/../.."

export DEBIAN_FRONTEND=noninteractive
apt-get update > /dev/null
apt-get --no-install-recommends -y install sudo > /dev/null
apt-get --no-install-recommends -y install sudo adduser > /dev/null

TESTUSER=ediuser
TESTUSERHOME=/home/${TESTUSER}
adduser --disabled-password --gecos "" ${TESTUSER}
addgroup ${TESTUSER} adm
usermod -a -G adm ${TESTUSER}

apt-get --no-install-recommends -y install git > /dev/null

Expand Down
4 changes: 2 additions & 2 deletions .github/scripts/upload-package-packagecloud
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ push_package()

push_package

if [ "${DISTRIBUTION}" == "debian" ]
if [ "${DISTRIBUTION}" == "debian" ] && [ "${DISTRIBUTION_RELEASE}" != "bookworm" ]
then
DISTRIBUTION="raspbian"
push_package
fi
fi
3 changes: 3 additions & 0 deletions .github/workflows/package-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ jobs:
- distribution: debian
distribution_release: bullseye
repository_type: packagecloud
- distribution: debian
distribution_release: bookworm
repository_type: packagecloud
- distribution: ubuntu
distribution_release: "18.04"
repository_type: launchpad
Expand Down
10 changes: 10 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
edi (1.13.0) jammy; urgency=medium

[ Matthias Lüscher ]
* Prevent hash collision during parallel image build. Closes #69.
* Avoid rewriting existing lxc profile.
* Added Debian bookworm build.
* Inherit bootstrap architecture from host architecture if unspecified.

-- Matthias Lüscher (Launchpad) <m.luescher@datacomm.ch> Sat, 03 Dec 2022 17:32:40 +0100

edi (1.12.0) jammy; urgency=medium

[ Matthias Lüscher ]
Expand Down
4 changes: 2 additions & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
# built documents.
#
# The short X.Y version.
version = '1.12.0'
release = '1.12.0'
version = '1.13.0'
release = '1.13.0'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
3 changes: 2 additions & 1 deletion docs/config_management/yaml.rst
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ This section tells edi how the initial system shall be bootstrapped. The followi
*architecture:*
- The architecture of the target system.
For Debian possible values are any supported architecture such as
:code:`amd64`, :code:`armel` or :code:`armhf`.
:code:`amd64`, :code:`arm64` or :code:`armhf`.
If no architecture is specified then the architecture of the system that runs :code:`edi` will be inherited.
*repository:*
- The repository specification where the initial image will get bootstrapped from.
A valid value looks like this: :code:`deb http://deb.debian.org/debian/ buster main`.
Expand Down
4 changes: 2 additions & 2 deletions edi/commands/lxccommands/stop.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ def _dispatch(self, config_file, run_method):

def _result(self):
# a generated container name
return 'edi-tmp-{}'.format(hashlib.sha256(self.config.get_configuration_name().encode()
).hexdigest()[:20])
return 'edi-{}-{}'.format(hashlib.sha256(self.config.get_configuration_name().encode()).hexdigest()[:8],
self.config.get_project_directory_hash())
4 changes: 2 additions & 2 deletions edi/lib/configurationparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from edi.lib.proxyhelpers import ProxySetup
from edi.lib.sshkeyhelpers import get_user_ssh_pub_keys
from edi.lib.versionhelpers import get_edi_version, get_stripped_version
from edi.lib.shellhelpers import get_user_home_directory, get_current_display
from edi.lib.shellhelpers import get_user_home_directory, get_current_display, get_debian_architecture
from edi.lib.lxchelpers import get_lxd_version
from packaging.version import Version
from edi.lib.urlhelpers import obfuscate_url_password
Expand Down Expand Up @@ -160,7 +160,7 @@ def get_bootstrap_repository(self):
def get_bootstrap_architecture(self):
architecture = self._get_bootstrap_item("architecture", None)
if not architecture:
raise FatalError('''Missing mandatory element 'architecture' in section 'bootstrap'.''')
architecture = get_debian_architecture()
return architecture

def get_bootstrap_tool(self):
Expand Down
15 changes: 13 additions & 2 deletions edi/lib/lxchelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,16 @@ def is_profile_existing(name):
return result.returncode == 0


@require('lxc', lxd_install_hint, LxdVersion.check)
def get_profile_description(name):
cmd = [lxc_exec(), "profile", "show", name]
result = run(cmd, check=False, stderr=subprocess.PIPE)
if result.returncode == 0:
return yaml.safe_load(result.stdout).get('description', '')
else:
return ''


@require('lxc', lxd_install_hint, LxdVersion.check)
def write_lxc_profile(profile_text):
new_profile = False
Expand All @@ -228,8 +238,9 @@ def write_lxc_profile(profile_text):
run(create_cmd)
new_profile = True

edit_cmd = [lxc_exec(), "profile", "edit", ext_profile_name]
run(edit_cmd, input=profile_content)
if get_profile_description(ext_profile_name) == "":
edit_cmd = [lxc_exec(), "profile", "edit", ext_profile_name]
run(edit_cmd, input=profile_content)

return ext_profile_name, new_profile

Expand Down
2 changes: 1 addition & 1 deletion edi/lib/versionhelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

# The do_release script will update this version!
# During launchpad debuild neither the git version nor the package version is available.
edi_fallback_version = '1.12.0'
edi_fallback_version = '1.13.0'


def get_edi_version():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
- name: Replace temporary hostname in /etc/hostname file.
lineinfile:
dest: /etc/hostname
regexp: '^edi-tmp-[a-z0-9]{20}$'
regexp: '^edi-[a-z0-9]{8}-[a-z0-9]{8}$'
line: '{{ hostname }}'
backrefs: yes

- name: Replace temporary hostname in /etc/hosts file.
lineinfile:
dest: /etc/hosts
regexp: '^(127\.0\.1\.1.*)edi-tmp-[a-z0-9]{20}(.*)$'
regexp: '^(127\.0\.1\.1.*)edi-[a-z0-9]{8}-[a-z0-9]{8}(.*)$'
line: '\1{{ hostname }}\2'
backrefs: yes
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
setup(
name='edi',

version='1.12.0',
version='1.13.0',

description='Embedded Development Infrastructure - edi',
long_description=long_description,
Expand Down
5 changes: 2 additions & 3 deletions tests/lib/test_configurationparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import pytest
from edi.lib.helpers import FatalError
from edi.lib.shellhelpers import get_debian_architecture
from aptsources.sourceslist import SourceEntry
from edi.lib.configurationparser import ConfigurationParser, command_context

Expand Down Expand Up @@ -156,6 +157,4 @@ def test_config_nodes_absence(empty_config_file):
with pytest.raises(FatalError) as error:
parser.get_bootstrap_repository()
assert "repository" in error.value.message
with pytest.raises(FatalError) as error:
parser.get_bootstrap_architecture()
assert "architecture" in error.value.message
assert parser.get_bootstrap_architecture() == get_debian_architecture()
36 changes: 35 additions & 1 deletion tests/lib/test_lxchelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
from edi.lib.lxchelpers import (get_server_image_compression_algorithm,
get_file_extension_from_image_compression_algorithm, lxc_exec,
get_lxd_version, LxdVersion, is_bridge_available, create_bridge,
is_container_running)
is_container_running, get_profile_description, is_profile_existing,
write_lxc_profile)
from edi.lib.shellhelpers import mockablerun, run
from tests.libtesting.helpers import get_command, get_sub_command
from tests.libtesting.contextmanagers.mocked_executable import mocked_executable, mocked_lxd_version_check
Expand Down Expand Up @@ -172,3 +173,36 @@ def test_is_bridge_available():
cmd = [lxc_exec(), "network", "delete", bridge_name]
run(cmd)
assert not is_bridge_available(bridge_name)


@pytest.mark.requires_lxc
def test_is_description_empty_on_inexistent_profile():
assert "" == get_profile_description("this-edi-profile-does-not-exist")


@pytest.mark.requires_lxc
def test_is_description_empty_on_created_profile():
profile_name = 'this-is-an-unused-edi-pytest-profile'
if is_profile_existing(profile_name):
run([lxc_exec(), "profile", "delete", profile_name])

run([lxc_exec(), "profile", "create", profile_name])
assert "" == get_profile_description(profile_name)

run([lxc_exec(), "profile", "delete", profile_name])


@pytest.mark.requires_lxc
def test_write_profile():
profile_text = """
name: this-is-an-unused-edi-pytest-profile
description: Some description
config: {}
devices: {}
"""

profile_name, _ = write_lxc_profile(profile_text)
assert is_profile_existing(profile_name)
assert "Some description" == get_profile_description(profile_name)
run([lxc_exec(), "profile", "delete", profile_name])
assert not is_profile_existing(profile_name)

0 comments on commit 08c39c9

Please sign in to comment.