image: re-enable autologin for debug and console images (#3355)

* image: remove autologin via mkosi

In mkosi v24 --autologin no longer works for ttyS consoles. Since the CSPs use those exclusively for their serial consoles, we need to replace this with another solution (see next commit)

* image: add getty systemd unit for debug images

This replaces the mkosi --autologin solution with a getty systemd unit for ttyS0.
Note that both console and debug images hace their consoles enabled.
This commit is contained in:
3u13r 2024-09-17 14:07:28 +02:00 committed by GitHub
parent a295ecaffb
commit 1f887c7868
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 16 additions and 32 deletions

View File

@ -70,8 +70,6 @@ def _mkosi_image_impl(ctx):
args.add("--kernel-command-line", ctx.attr.kernel_command_line)
for key, value in ctx.attr.kernel_command_line_dict.items():
args.add("--kernel-command-line", "{}={}".format(key, value))
if ctx.attr.autologin:
args.add("--autologin", "yes")
info = ctx.toolchains["@constellation//bazel/mkosi:toolchain_type"].mkosi
if not info.valid:
@ -110,7 +108,6 @@ mkosi_image = rule(
implementation = _mkosi_image_impl,
attrs = {
"architecture": attr.string(),
"autologin": attr.bool(),
"base_trees": attr.label_list(allow_files = True),
"distribution": attr.string(),
"env": attr.string_dict(),

View File

@ -2,6 +2,7 @@ enable systemd-timesyncd.service
enable systemd-networkd.service
enable systemd-networkd-wait-online.service
enable configure-constel-csp.service
enable serial-getty@tty0.service
enable dbus.service
enable dbus-broker.service
enable dbus-daemon.service

View File

@ -0,0 +1,12 @@
[Unit]
Description=autologin
ConditionPathExists=/proc/cmdline
ConditionKernelCommandLine=|constellation.console
ConditionKernelCommandLine=|constellation.debug
[Service]
ExecStart=
ExecStart=-/sbin/agetty -o '-p -f -- \\u' --keep-baud --autologin root 115200,57600,38400,9600 - $TERM
[Install]
WantedBy=multi-user.target

View File

@ -1,6 +1,6 @@
load("//bazel/mkosi:mkosi_image.bzl", "mkosi_image")
load("//bazel/osimage:upload_os_images.bzl", "upload_os_images")
load(":variants.bzl", "CSPS", "STREAMS", "VARIANTS", "autologin", "base_image", "constellation_packages", "images_for_csp", "images_for_csp_and_stream", "images_for_stream", "kernel_command_line", "kernel_command_line_dict")
load(":variants.bzl", "CSPS", "STREAMS", "VARIANTS", "base_image", "constellation_packages", "images_for_csp", "images_for_csp_and_stream", "images_for_stream", "kernel_command_line", "kernel_command_line_dict")
[
mkosi_image(
@ -10,11 +10,6 @@ load(":variants.bzl", "CSPS", "STREAMS", "VARIANTS", "autologin", "base_image",
] + glob([
"mkosi.repart/**",
]),
autologin = autologin(
variant["csp"],
variant["attestation_variant"],
stream,
),
base_trees = [
base_image(
variant["csp"],

View File

@ -86,7 +86,7 @@ csp_settings = {
},
},
"qemu": {
"autologin": True,
"kernel_command_line": "constellation.console", # All qemu images have console enabled independent of stream
"kernel_command_line_dict": {
"console": "ttyS0",
"constel.csp": "qemu",
@ -136,10 +136,9 @@ attestation_variant_settings = {
stream_settings = {
"console": {
"autologin": True,
"kernel_command_line": "constellation.console",
},
"debug": {
"autologin": True,
"kernel_command_line": "constellation.debug",
},
"nightly": {},
@ -181,26 +180,6 @@ def constellation_packages(stream):
"//bootstrapper/cmd/bootstrapper:bootstrapper-package",
] + base_packages
def autologin(csp, attestation_variant, stream):
"""Generates a boolean indicating whether autologin should be enabled for the given csp, attestation_variant and stream.
Args:
csp: The cloud service provider to use.
attestation_variant: The attestation variant to use.
stream: The stream to use.
Returns:
A boolean indicating whether autologin should be enabled.
"""
out = None
for settings in from_settings(csp, attestation_variant, stream):
if not "autologin" in settings:
continue
if out != None and out != settings["autologin"]:
fail("Inconsistent autologin settings")
out = settings["autologin"]
return out
def kernel_command_line(csp, attestation_variant, stream):
cmdline = base_cmdline
for settings in from_settings(csp, attestation_variant, stream, default = {}):