Skip to content

Commit

Permalink
feat: Generate image info
Browse files Browse the repository at this point in the history
Provides a useful reference for the state of the current installed image
that can be utilized via ublue update for auto-signing or in scripts to
determine what changes to make and exclude

Also ships jq for parsing generated image information

For example...

`jq '."image-flavor"' /usr/share/ublue-os/image-info.json`

... would print the flavor of the image (I.E. nvidia)
  • Loading branch information
EyeCantCU committed Sep 22, 2023
1 parent bb4cf9f commit 75e26c9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}"


FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS main

ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}"
ARG IMAGE_VENDOR="ublue-os"
ARG IMAGE_FLAVOR="${IMAGE_FLAVOR:-main}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}"

COPY github-release-install.sh /tmp/github-release-install.sh
COPY image-info.sh /tmp/image-info.sh
COPY main-install.sh /tmp/main-install.sh
COPY main-post-install.sh /tmp/main-post-install.sh
COPY main-packages.json /tmp/main-packages.json
Expand All @@ -18,6 +22,7 @@ COPY --from=ghcr.io/ublue-os/akmods:${FEDORA_MAJOR_VERSION} /rpms /tmp/akmods-rp

COPY system_files /

RUN /tmp/image-info.sh
RUN /tmp/main-install.sh
RUN /tmp/main-post-install.sh

Expand All @@ -30,7 +35,10 @@ RUN mkdir -p /var/tmp && chmod -R 1777 /var/tmp


FROM main AS nvidia

ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}"
ARG IMAGE_VENDOR="ublue-os"
ARG IMAGE_FLAVOR="${IMAGE_FLAVOR:-nvidia}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-38}"
ARG NVIDIA_MAJOR_VERSION="${NVIDIA_MAJOR_VERSION:-535}"

Expand All @@ -39,6 +47,7 @@ COPY nvidia-post-install.sh /tmp/nvidia-post-install.sh

COPY --from=ghcr.io/ublue-os/akmods-nvidia:${FEDORA_MAJOR_VERSION}-${NVIDIA_MAJOR_VERSION} /rpms /tmp/akmods-rpms

RUN /tmp/image-info.sh
RUN /tmp/nvidia-install.sh
RUN /tmp/nvidia-post-install.sh
RUN rm -rf /tmp/* /var/*
Expand Down
26 changes: 26 additions & 0 deletions image-info.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash

set -oue pipefail

IMAGE_INFO="/usr/share/ublue-os/image-info.json"
IMAGE_REF="docker://ghcr.io/$IMAGE_VENDOR/$IMAGE_NAME"

case $FEDORA_MAJOR_VERSION in
38)
IMAGE_TAG="latest"
;;
*)
IMAGE_TAG="$FEDORA_MAJOR_VERSION"
;;
esac

cat > $IMAGE_INFO <<EOF
{
"image-name": "$IMAGE_NAME",
"image-flavor": "$IMAGE_FLAVOR",
"image-vendor": "$IMAGE_VENDOR",
"image-ref": "$IMAGE_REF",
"image-tag":"$IMAGE_TAG",
"fedora-version": "$FEDORA_MAJOR_VERSION"
}
EOF
1 change: 1 addition & 0 deletions main-packages.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"htop",
"intel-media-driver",
"just",
"jq",
"kernel-devel-matched",
"kernel-tools",
"libheif-tools",
Expand Down

0 comments on commit 75e26c9

Please sign in to comment.