Skip to content

Commit

Permalink
EBcL main repo
Browse files Browse the repository at this point in the history
- Merge main repo and apt config
- Add EBcL main repo
- Remove elbe support
  • Loading branch information
Thomas Irgang (thir820) committed Nov 19, 2024
1 parent 9c513a7 commit 4eaa40f
Show file tree
Hide file tree
Showing 24 changed files with 280 additions and 375 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// README at: https://github.com/devcontainers/templates/tree/main/src/ubuntu
{
"name": "EB corbos Linux build tools",
"image": "linux.elektrobit.com/ebcl/sdk:v1.3.10",
"image": "ghcr.io/elektrobit/ebcl_dev_container:v1.4.0",
// This script will get the container and tag it with the local container tag.
"initializeCommand": "${PWD}/init_workspace",
"postCreateCommand": "${PWD}/setup_workspace",
Expand Down
2 changes: 1 addition & 1 deletion docs/root_generator.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _finalize_ to cleanup temporary artifacts.
The build process implemented in *create_root* executes the following high level steps:

- In case of a sysroot build: Add additional packages to the list of selected packages.
- Create the root tarball using either _elbe_, _kiwi_ or _debootstrap_.
- Create the root tarball using either _kiwi_ or _debootstrap_.
- In case of not skipping the configuration: Copy the overlays and run the config scripts.
- Move the resulting tarball to the output folder.

Expand Down
2 changes: 1 addition & 1 deletion ebcl/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "1.3.1"
__version__ = "1.3.2"
21 changes: 20 additions & 1 deletion ebcl/common/apt.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def from_config(cls, repo_config: dict[str, Any], arch: CpuArch):
)

@classmethod
def ebcl_apt(cls, arch: CpuArch, release: str = '1.2'):
def ebcl_apt(cls, arch: CpuArch, release: str = '1.4'):
""" Get the EBcL apt repo. """
url = os.environ.get(
'EBCL_REPO_URL', 'http://linux.elektrobit.com/eb-corbos-linux')
Expand All @@ -61,6 +61,25 @@ def ebcl_apt(cls, arch: CpuArch, release: str = '1.2'):
key_gpg=gpg
)

@classmethod
def ebcl_primary_repo(cls, arch: CpuArch, release: str = '1.4'):
""" Get the EBcL apt repo. """
url = os.environ.get(
'EBCL_REPO_URL', 'http://linux.elektrobit.com/eb-corbos-linux')
release = os.environ.get('EBCL_VERSION', release)
key = os.environ.get(
'EBCL_REPO_KEY', 'file:///build/keys/elektrobit.pub')
gpg = os.environ.get(
'EBCL_REPO_GPG', '/etc/apt/trusted.gpg.d/elektrobit.gpg')
return cls(
url=f'{url}/{release}',
distro='jammy',
components=['main'],
arch=arch,
key_url=key,
key_gpg=gpg
)

def __init__(
self,
url: str = "http://archive.ubuntu.com/ubuntu",
Expand Down
24 changes: 11 additions & 13 deletions ebcl/common/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ class Config:
'kernel', 'tar', 'busybox', 'modules', 'root_device', 'devices', 'kernel_version',
'modules_folder', 'result_pattern', 'image', 'berrymill_conf', 'use_berrymill',
'use_bootstrap_package', 'bootstrap_package', 'bootstrap', 'kiwi_root_overlays',
'use_kiwi_defaults', 'kiwi_scripts', 'kvm', 'image_version', 'type', 'primary_repo',
'root_password', 'hostname', 'domain', 'console', 'packer', 'sysroot_packages',
'sysroot_defaults', 'primary_distro', 'base'
'use_kiwi_defaults', 'kiwi_scripts', 'kvm', 'image_version', 'type',
'root_password', 'hostname', 'domain', 'console', 'sysroot_packages',
'sysroot_defaults', 'primary_distro', 'base', 'debootstrap_flags'
]

def __init__(self, config_file: str, output_path: str):
Expand Down Expand Up @@ -124,9 +124,9 @@ def __init__(self, config_file: str, output_path: str):
# Root filesystem build type.
self.type: BuildType = BuildType.DEBOOTSTRAP
# Primary repo for debootstrap
self.primary_repo: Optional[str] = None
# Primary repo for debootstrap
self.primary_distro: Optional[str] = None
# Additional debootstrap parameters
self.debootstrap_flags: Optional[str] = None
# Password for the root user
self.root_password: Optional[str] = 'linux'
# Hostname for the root filesystem
Expand All @@ -135,8 +135,6 @@ def __init__(self, config_file: str, output_path: str):
self.domain: str = 'elektrobit.com'
# Console
self.console: Optional[str] = None
# Packer for the result of the elbe build.
self.packer: str = 'none'
# Additional sysroot packages.
self.sysroot_packages: list[VersionDepends] = []
# Add default extensions for sysroot builds
Expand Down Expand Up @@ -212,6 +210,9 @@ def _parse_yaml(self, file: str):
ebcl_apt = Apt.ebcl_apt(self.arch)
self.proxy.add_apt(ebcl_apt)
self.apt_repos.append(ebcl_apt)
ebcl_main = Apt.ebcl_primary_repo(self.arch)
self.proxy.add_apt(ebcl_main)
self.apt_repos.append(ebcl_main)

host_files = parse_files(
config.get('host_files', None),
Expand Down Expand Up @@ -397,12 +398,12 @@ def _parse_yaml(self, file: str):
if 'type' in config:
self.type = BuildType.from_str(config.get('type', None))

if 'primary_repo' in config:
self.primary_repo = config.get('primary_repo', None)

if 'primary_distro' in config:
self.primary_distro = config.get('primary_distro', None)

if 'debootstrap_flags' in config:
self.debootstrap_flags = config.get('debootstrap_flags', None)

if 'root_password' in config:
self.root_password = config.get('root_password', 'linux')

Expand All @@ -415,9 +416,6 @@ def _parse_yaml(self, file: str):
if 'console' in config:
self.console = config.get('console', None)

if 'packer' in config:
self.packer = config.get('packer', 'none')

if 'sysroot_packages' in config:
if inherit_packages:
sysroot_packages = parse_package_config(
Expand Down
9 changes: 2 additions & 7 deletions ebcl/common/types/build_type.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,18 @@

class BuildType(Enum):
""" Build type for the root filesystem build. """
ELBE = 1
KIWI = 2
DEBOOTSTRAP = 3

@classmethod
def from_str(cls, build_type: Optional[str]):
""" Get ImageType from str. """
if not build_type:
return cls.ELBE
return cls.DEBOOTSTRAP

if isinstance(build_type, cls):
return build_type

if build_type == 'elbe':
return cls.ELBE
elif build_type == 'kiwi':
return cls.KIWI
elif build_type == 'debootstrap':
Expand All @@ -28,9 +25,7 @@ def from_str(cls, build_type: Optional[str]):
return None

def __str__(self) -> str:
if self.value == 1:
return "elbe"
elif self.value == 2:
if self.value == 2:
return "kiwi-ng"
elif self.value == 3:
return "debootstrap"
Expand Down
18 changes: 3 additions & 15 deletions ebcl/common/types/cpu_arch.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,20 +46,8 @@ def __str__(self) -> str:
else:
return "UNKNOWN"

def get_elbe_arch(self) -> str:
""" Get the arch string for the elbe image description. """
if self.value == 1:
return "amd64"
elif self.value == 2:
return "aarch64"
elif self.value == 3:
return "armhf"

raise UnsupportedCpuArchitecture(
f'Unsupported CPU architecture {str(self)} for elbe build!')

def get_kiwi_arch(self) -> str:
""" Get the arch string for the elbe image description. """
""" Get the arch string for the kiwi image description. """
if self.value == 1:
return "x86_64"
elif self.value == 2:
Expand All @@ -69,7 +57,7 @@ def get_kiwi_arch(self) -> str:
f'Unsupported CPU architecture {str(self)} for kiwi-ng build!')

def get_berrymill_arch(self) -> str:
""" Get the arch string for the elbe image description. """
""" Get the arch string for the berrymill image description. """
if self.value == 1:
return "amd64"
elif self.value == 2:
Expand All @@ -79,7 +67,7 @@ def get_berrymill_arch(self) -> str:
f'Unsupported CPU architecture {str(self)} for berrymill build!')

def get_box_arch(self) -> str:
""" Get the arch string for the elbe image description. """
""" Get the arch string for the kiwi box build. """
if self.value == 1:
return "--x86_64"
elif self.value == 2:
Expand Down
31 changes: 27 additions & 4 deletions ebcl/tools/root/debootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from typing import Optional

from ebcl.common import get_cache_folder
from ebcl.common.apt import Apt
from ebcl.common.config import Config


Expand Down Expand Up @@ -37,7 +38,7 @@ def _get_apt_hash(self, debootstrap_hash: str) -> str:
def _get_debootstrap_hash(self) -> str:
""" Generate hash for the debootstrap configuration. """
params = f'{self.config.arch} {self.debootstrap_variant} ' \
f'{self.config.primary_distro} {self.config.primary_repo}'
f'{self.config.primary_distro} {self._find_deboostrap_repo()}'

return hashlib.md5(params.encode('utf-8')).digest().hex()

Expand Down Expand Up @@ -141,14 +142,36 @@ def _unmount_special_folders(self):
check=False
)

def _find_deboostrap_repo(self) -> Optional[Apt]:
""" Find apt repository for debootstrap. """
for apt in self.config.apt_repos:
if apt.distro == self.config.primary_distro:
if 'main' in apt.components:
return apt
return None

def _run_debootstrap(self) -> bool:
""" Run debootstrap and store result in cache. """
fake = self.config.fake

repo = self._find_deboostrap_repo()
if repo is None:
logging.critical('No apt repo for deboostrap found!')
return False

keyring = ''
(_pub, gpg) = repo.get_key_files()
if gpg is not None:
keyring = f' --keyring={gpg} '

user_flags = ''
if self.config.debootstrap_flags:
user_flags = self.config.debootstrap_flags

fake.run_sudo(
f'debootstrap --arch={self.config.arch} --variant={self.debootstrap_variant} '
f'{self.config.primary_distro} {self.config.target_dir} '
f'{self.config.primary_repo}',
f'debootstrap --arch={self.config.arch} {keyring} {user_flags} --variant={self.debootstrap_variant} '
f'{repo.distro} {self.config.target_dir} '
f'{repo.url}',
cwd=self.config.target_dir,
check=True
)
Expand Down
Loading

0 comments on commit 4eaa40f

Please sign in to comment.