Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] test: test against reference images lib generated manifest #186

Closed
wants to merge 24 commits into from
Closed
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f6ed83f
Makefile: add "make externals" to have a quick way to build externals
mvo5 Sep 2, 2024
ae5147c
examples: update otk-gen-partition-table example to "work"
mvo5 Sep 2, 2024
39e198d
[RFC] test: test against reference images lib generated manifest
mvo5 Sep 2, 2024
ee5518b
fixup! integrate otk-{gen-partition-table,make-fstab-stage}
mvo5 Sep 2, 2024
c9ebe37
fixup! use otk.external.otk-make-partition-stages to generate partiti…
mvo5 Sep 2, 2024
486e11b
fixup! use otk-make-partition-mounts-devices
mvo5 Sep 2, 2024
8949b09
fixup! use filesystem.const.partition_map.root.uuid
mvo5 Sep 3, 2024
84a5bca
fixup! use filesystem.const.partition_map.boot.uuid
mvo5 Sep 3, 2024
067fe3d
fixup! use ${filesystem.const.filename}
mvo5 Sep 3, 2024
6ad7247
example: import centos-9-x86_64-ami
mvo5 Sep 3, 2024
843af8a
fixup! restore hardcoded part_uuid/partition table UUID
mvo5 Sep 3, 2024
7ac1bdf
example: use otk.external.otk-gen-partition-table in centos-9-x86_64-…
mvo5 Sep 3, 2024
4635037
examples: extract common centos parts
mvo5 Sep 3, 2024
d7834d2
examples/centos: remove everything that is not used currently
mvo5 Sep 3, 2024
771987f
fixup! add another todo
mvo5 Sep 3, 2024
f3dd7c0
fixup! fix incorrectly generated centos-9-x86_64-ami.yaml
mvo5 Sep 3, 2024
494d5f8
centos: extract build pipeline
mvo5 Sep 3, 2024
7e0f61b
fixup! extract kernel-cmdline fragemnt
mvo5 Sep 3, 2024
7ee91a0
centos: extract grub stages into fragments
mvo5 Sep 3, 2024
28fef79
centos: extract image pipeline
mvo5 Sep 3, 2024
239b7fa
examples: merge fedora-minimal
mvo5 Sep 3, 2024
5754525
fixup! extract more from fedora-minimal
mvo5 Sep 3, 2024
2430d24
fixup! add another fixme
mvo5 Sep 3, 2024
ec10b6d
examples: remove everything fedora that is not used
mvo5 Sep 3, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ git-diff-check:
@git diff --cached --exit-code

## Package building
SRCDIR ?= $(abspath .)
COMMIT = $(shell (cd "$(SRCDIR)" && git rev-parse HEAD))
RPM_SPECFILE=rpmbuild/SPECS/otk-$(COMMIT).spec
RPM_TARBALL=rpmbuild/SOURCES/otk-$(COMMIT).tar.gz
Expand All @@ -55,3 +56,15 @@ rpm: git-diff-check $(RPM_SPECFILE) $(RPM_TARBALL)
rpmbuild -bb \
--define "_topdir $(CURDIR)/rpmbuild" \
$(RPM_SPECFILE)

# XXX: strawman target name
.PHONY: externals
IMAGES_REF ?= github.com/osbuild/images
externals:
mkdir -p "$(SRCDIR)/externals"
for otk_cmd in gen-partition-table \
make-fstab-stage \
make-partition-mounts-devices \
make-partition-stages; do \
GOBIN="$(SRCDIR)/externals" go install "$(IMAGES_REF)"/cmd/otk-$${otk_cmd}@latest ; \
done
170 changes: 153 additions & 17 deletions example/centos/centos-9-x86_64-qcow2.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,156 @@
otk.version: "1"
otk.version: 1

otk.define.centos-9-x86_64-qcow2:
architecture: "x86_64"
version: "9"
kernel_opts_list: []
sshd_password_authentication: true
modfication:
language: "C.UTF-8"
timezone: "America/New_York"
enabled_services: []
otk.define:
filesystem:
# this will expand to "root: ...\nboot: \n"etc (i.e. a real file-systems) and "kernel_opts_list:
# [list_item1, list_item2, ..]"
# (i.e. define the partition table as a map of root/boot/boot_efi vars)
# *and* it needs to undstand modifications (e.g. adding extra parititions somehow, size contraints)
otk.external.osbuild.create_partition_table_defines:
total_size: 10G
otk.external.otk-gen-partition-table:
properties:
create:
bios_boot_partition: true
esp_partition: true
esp_partition_size: "200 MiB"
type: gpt
bios: true
default_size: "10 GiB"
partitions:
- name: boot
mountpoint: /boot
label: boot
size: "1 GiB"
type: "xfs"
# XXX: make default if empty
fs_mntops: defaults
# XXX can we derive this?
part_type: BC13C2FF-59E6-4262-A352-B275FD6F7172
- name: root
mountpoint: /
label: root
type: "xfs"
# XXX: can/should we be able to leave this empy?
size: "5 GiB"
# XXX: make default if empty
fs_mntops: defaults
# XXX: can we derive this?
part_type: 0FC63DAF-8483-4772-8E79-3D69D8477DE4
# XXX: find a better way
fs_options:
otk.external.otk-make-partition-mounts-devices:
${filesystem}

otk.include.centos-9-x86_64: "common/centos-9.yaml"
otk.target.osbuild:
pipelines:
- name: build
runner: org.osbuild.centos9
stages:
- type: org.osbuild.rpm
- type: org.osbuild.selinux
options:
file_contexts: etc/selinux/targeted/contexts/files/file_contexts
labels:
/usr/bin/cp: system_u:object_r:install_exec_t:s0
- name: os
build: name:build
stages:
- type: org.osbuild.kernel-cmdline
options:
root_fs_uuid: ${filesystem.const.partition_map.root.uuid}
kernel_opts: console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0
- type: org.osbuild.rpm
- type: org.osbuild.fix-bls
options:
prefix: ""
- type: org.osbuild.locale
options:
language: C.UTF-8
- type: org.osbuild.timezone
options:
zone: America/New_York
- type: org.osbuild.sysconfig
options:
kernel:
update_default: true
default_kernel: kernel
network:
networking: true
no_zero_conf: true
- otk.external.otk-make-fstab-stage:
${filesystem}
- type: org.osbuild.grub2
options:
root_fs_uuid: ${filesystem.const.partition_map.root.uuid}
boot_fs_uuid: ${filesystem.const.partition_map.boot.uuid}
kernel_opts: console=tty0 console=ttyS0,115200n8 no_timer_check net.ifnames=0
legacy: i386-pc
uefi:
vendor: centos
unified: true
# XXX: get from rpm stage
saved_entry: ffffffffffffffffffffffffffffffff-5.14.0-496.el9.x86_64
write_cmdline: false
config:
default: saved
- type: org.osbuild.systemd
options:
default_target: multi-user.target
- type: org.osbuild.selinux
options:
file_contexts: etc/selinux/targeted/contexts/files/file_contexts
- name: image
build: name:build
stages:
otk.op.join:
values:
- otk.external.otk-make-partition-stages:
${filesystem}
- - type: org.osbuild.copy
inputs:
root-tree:
type: org.osbuild.tree
origin: org.osbuild.pipeline
references:
- name:os
options:
paths:
- from: input://root-tree/
to: mount://-/
# XXX: fugly, can we do better?
# we cannot just do
# otk.external.otk-make-partition-mounts-devices:
# here because "otk.external." does not allow siblings
mounts:
${fs_options.mounts}
devices:
${fs_options.devices}
- type: org.osbuild.grub2.inst
options:
filename: ${filesystem.const.filename}
platform: i386-pc
# XXX: export from ${filesystem} somehow?
location: 2048
core:
type: mkimage
partlabel: gpt
filesystem: xfs
prefix:
type: partition
partlabel: gpt
number: 2
path: /grub2
- name: qcow2
build: name:build
stages:
- type: org.osbuild.qemu
inputs:
image:
type: org.osbuild.files
origin: org.osbuild.pipeline
references:
name:image:
file: ${filesystem.const.filename}
options:
# XXX: provide a way to derive the name from the filesystem one?
filename: disk.qcow2
format:
type: qcow2
compat: "1.1"
sources:
org.osbuild.curl:
2 changes: 2 additions & 0 deletions src/otk/external.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def path_for(exe):
"/usr/libexec/otk/external",
"/usr/local/lib/otk/external",
"/usr/lib/otk/external",
# local developer case
"./externals",
]

env = os.getenv("OTK_EXTERNAL_PATH", None)
Expand Down
1 change: 0 additions & 1 deletion src/otk/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,6 @@ def process_defines(ctx: Context, state: State, tree: Any) -> None:
# for any other type, just set the value to the key
ctx.define(state.define_subkey(key), value)


def process_include(ctx: Context, state: State, path: pathlib.Path) -> dict:
"""
Load a yaml file and send it to resolve() for processing.
Expand Down
Loading
Loading