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

Single magical bootargs #1824

Merged
merged 1 commit into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 2 additions & 12 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -275,18 +275,8 @@ framework:

# Copy bootargs.cfg into the final framework as its needed to boot if its not there
IF [ ! -f /framework/etc/cos/bootargs.cfg ]
IF [[ "$FLAVOR" =~ ^alpine* ]]
COPY ./images/alpine/bootargs.cfg /framework/etc/cos/bootargs.cfg
ELSE IF [[ "$FLAVOR" = "ubuntu-20-lts-arm-nvidia-jetson-agx-orin" ]]
COPY ./images/nvidia/bootargs.cfg /framework/etc/cos/bootargs.cfg
ELSE IF [[ "$FLAVOR" =~ "ubuntu" ]] && [[ ! "$FLAVOR" =~ -rpi$ ]]
COPY ./images/debian/bootargs.cfg /framework/etc/cos/bootargs.cfg
ELSE IF [[ "$FLAVOR" =~ ^opensuse-leap$ ]] || [[ "$FLAVOR" =~ ^opensuse-tumbleweed$ ]] # Be specific so it doesnt match the arm-rpi flavors
COPY ./images/opensuse/bootargs.cfg /framework/etc/cos/bootargs.cfg
ELSE IF [[ "$FLAVOR" =~ ^rockylinux* ]] || [[ "$FLAVOR" =~ ^fedora* ]] || [[ "$FLAVOR" =~ ^almalinux* ]]
COPY ./images/redhat/bootargs.cfg /framework/etc/cos/bootargs.cfg
ELSE IF [[ "$FLAVOR" =~ -rpi$ ]]
COPY ./images/rpi/bootargs.cfg /framework/etc/cos/bootargs.cfg
COPY ./images/bootargs.cfg /framework/etc/cos/bootargs.cfg
IF [[ "$FLAVOR" =~ -rpi$ ]]
COPY ./images/rpi/config.txt /framework/boot/config.txt
ELSE IF [[ "$FLAVOR" =~ ^fips-systemd* ]]
# Use a generic one like redhat which has selinux disabled so it can be used on all flavors??
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.almalinux
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ RUN dnf install -y \
which \
https://zfsonlinux.org/epel/zfs-release-2-2.el9.noarch.rpm && dnf clean all

COPY redhat/bootargs.cfg /etc/cos/bootargs.cfg

RUN mkdir -p /run/lock
RUN touch /usr/libexec/.keep
RUN systemctl enable [email protected]
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.alpine
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,8 @@ RUN apk --no-cache add \
bridge \
grub-bios \
rbd-nbd
COPY alpine/bootargs.cfg /etc/cos/bootargs.cfg

FROM common as rpicommon
COPY rpi/bootargs.cfg /etc/cos/bootargs.cfg
COPY rpi/config.txt /boot/config.txt

FROM rpicommon AS rpi3
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.debian
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ RUN apt-get update \
qemu-guest-agent \
zfsutils-linux \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY debian/bootargs.cfg /etc/cos/bootargs.cfg

FROM common AS rpicommon
RUN sed -i 's/^Components: main.*$/& non-free-firmware/' /etc/apt/sources.list.d/debian.sources
Expand All @@ -126,7 +125,6 @@ RUN apt-get update \
linux-image-arm64 \
raspi-firmware \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY rpi/bootargs.cfg /etc/cos/bootargs.cfg
COPY rpi/config.txt /boot/config.txt

FROM rpicommon AS rpi3
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.fedora
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ RUN dnf install -y \
which \
zfs && dnf clean all

COPY redhat/bootargs.cfg /etc/cos/bootargs.cfg

RUN mkdir -p /run/lock && \
touch /usr/libexec/.keep && \
systemctl enable [email protected] && \
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.opensuse-leap
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ RUN zypper in --force-resolution -y \
lldpd \
qemu-guest-agent \
&& zypper cc
COPY opensuse/bootargs.cfg /etc/cos/bootargs.cfg

FROM common AS rpicommon
RUN zypper in --force-resolution -y \
Expand All @@ -107,7 +106,6 @@ RUN zypper in --force-resolution -y \
wireless-tools \
wpa_supplicant \
&& zypper cc
COPY rpi/bootargs.cfg /etc/cos/bootargs.cfg
COPY rpi/config.txt /boot/config.txt

FROM rpicommon as rpi3
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.opensuse-tumbleweed
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,6 @@ FROM ${TARGETARCH} AS generic
RUN zypper in --force-resolution -y \
qemu-guest-agent \
&& zypper cc
COPY opensuse/bootargs.cfg /etc/cos/bootargs.cfg

FROM ${TARGETARCH} AS rpicommon
RUN zypper in --force-resolution -y \
Expand All @@ -128,7 +127,6 @@ RUN zypper in --force-resolution -y \
wireless-tools \
wpa_supplicant \
&& zypper cc
COPY rpi/bootargs.cfg /etc/cos/bootargs.cfg
COPY rpi/config.txt /boot/config.txt

FROM rpicommon AS rpi3
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.rockylinux
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ RUN dnf install -y \
https://zfsonlinux.org/epel/zfs-release-2-2.el9.noarch.rpm \
&& dnf clean all

COPY redhat/bootargs.cfg /etc/cos/bootargs.cfg

RUN mkdir -p /run/lock
RUN touch /usr/libexec/.keep
RUN systemctl enable [email protected]
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,11 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
linux-base \
qemu-guest-agent \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY debian/bootargs.cfg /etc/cos/bootargs.cfg

FROM ${TARGETARCH}-${FLAVOR} AS rpicommon
RUN apt-get update && apt-get install -y --no-install-recommends \
linux-raspi \
&& apt-get clean && rm -rf /var/lib/apt/lists/*
COPY rpi/bootargs.cfg /etc/cos/bootargs.cfg
COPY rpi/config.txt /boot/config.txt

FROM rpicommon AS ubuntu-20-lts-rpi
Expand Down
2 changes: 0 additions & 2 deletions images/Dockerfile.ubuntu-20-lts-arm-nvidia-jetson-agx-orin
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ RUN apt-get install -y libopencv-dev && \
# Drop the repository file installed by apt (we have installed the repository manually above)
RUN rm -rf /etc/apt/sources.list.d/nvidia-l4t-apt-source.list

COPY nvidia/bootargs.cfg /etc/cos/bootargs.cfg

# Symlinks to make installer work
RUN ln -s /usr/sbin/grub-install /usr/sbin/grub2-install && \
ln -s /usr/bin/grub-editenv /usr/bin/grub2-editenv
13 changes: 0 additions & 13 deletions images/alpine/bootargs.cfg

This file was deleted.

64 changes: 64 additions & 0 deletions images/bootargs.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
function setSelinux {
source (loop0)/etc/os-release
set baseSelinuxCmd=""
if regexp "rockylinux|fedora|almalinux|redhat" $KAIROS_FLAVOR; then
set baseSelinuxCmd="selinux=0"
else
# if not in recovery
if [ -z "$recoverylabel" ];then
set baseSelinuxCmd="security=selinux selinux=1"
fi
fi
}

function setExtraConsole {
source (loop0)/etc/os-release
set baseExtraConsole="console=ttyS0"
# rpi
if regexp "arm-rpi" $KAIROS_FLAVOR; then
set baseExtraConsole="console=ttyS0,115200"
fi
# nvidia orin
if regexp "arm-nvidia-jetson-agx-orin" $KAIROS_FLAVOR; then
set baseExtraConsole="console=ttyTCU0,115200"
fi
}

function setExtraArgs {
source (loop0)/etc/os-release
set baseExtraArgs=""
# rpi
if regexp "arm-rpi" $KAIROS_FLAVOR; then
set baseExtraArgs="modprobe.blacklist=vc4 8250.nr_uarts=1"
fi
}

function setKernelCmd {
# At this point we have the system mounted under (loop0)
#
# baseCmd -> Shared between all entries
# baseRootCmd -> specific bits that immucore uses to mount the boot devices and identify the image to mount
# baseSelinuxCmd -> selinux enabled/disabled
# baseExtraConsole -> extra console to set
# baseExtraArgs -> extra needed args
set baseCmd="console=tty1 net.ifnames=1 rd.cos.oemlabel=COS_OEM rd.cos.oemtimeout=10 panic=5 rd.emergency=reboot rd.shell=0 systemd.crash_reboot=yes"
if [ -n "$recoverylabel" ]; then
set baseRootCmd="root=live:LABEL=$recoverylabel rd.live.dir=/ rd.live.squashimg=$img"
else
set baseRootCmd="root=LABEL=$label cos-img/filename=$img"
fi
setSelinux
setExtraConsole
setExtraArgs
# finally set the full cmdline
set kernelcmd="$baseCmd $baseRootCmd $baseSelinuxCmd $baseExtraConsole $baseExtraArgs"
}


# grub.cfg now ships this but during upgrades we do not update the COS_GRUB partition, so no new grub.cfg is copied over there
# We need to keep it for upgrades to work.
# TODO: Deprecate in v2.8-v3.0
set kernel=/boot/vmlinuz
set initramfs=/boot/initrd
# set the kernelcmd dynamically
setKernelCmd
11 changes: 0 additions & 11 deletions images/debian/bootargs.cfg

This file was deleted.

11 changes: 0 additions & 11 deletions images/nvidia/bootargs.cfg

This file was deleted.

13 changes: 0 additions & 13 deletions images/opensuse/bootargs.cfg

This file was deleted.

13 changes: 0 additions & 13 deletions images/redhat/bootargs.cfg

This file was deleted.

23 changes: 0 additions & 23 deletions images/rpi/bootargs.cfg

This file was deleted.