-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: combine asus and surface builds with nvidia
This is a WIP commit which shows has the first steps of asus/surface main images mostly working in a Containerfile and skipping main/main. The nvidia parts will be built in a second target. Github workflows have not yet been touched.
- Loading branch information
Showing
8 changed files
with
231 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,51 @@ | ||
ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}" | ||
ARG BASE_IMAGE="ghcr.io/ublue-os/${IMAGE_NAME}-main" | ||
ARG SOURCE_IMAGE="${SOURCE_IMAGE:-silverblue-main}" | ||
ARG SOURCE_ORG="${SOURCE_ORG:-ublue-os}" | ||
ARG BASE_IMAGE="ghcr.io/${SOURCE_ORG}/${SOURCE_IMAGE}" | ||
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}" | ||
|
||
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS nvidia | ||
FROM ${BASE_IMAGE}:${FEDORA_MAJOR_VERSION} AS main | ||
|
||
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}" | ||
ARG HWE_FLAVOR="{HWE_FLAVOR:-main}" | ||
ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}" | ||
ARG IMAGE_VENDOR="ublue-os" | ||
ARG IMAGE_FLAVOR="${IMAGE_FLAVOR:-nvidia}" | ||
ARG IMAGE_VENDOR="${IMAGE_VENDOR:-ublue-os}" | ||
ARG RPMFUSION_MIRROR="" | ||
|
||
COPY *.sh /tmp/ | ||
COPY ${HWE_FLAVOR}/ /tmp/ | ||
|
||
RUN mkdir -p /var/lib/alternatives && \ | ||
IMAGE_FLAVOR=main /tmp/image-info.sh && \ | ||
/tmp/install.sh && \ | ||
mv /var/lib/alternatives /staged-alternatives && \ | ||
rm -rf /tmp/* /var/* && \ | ||
ostree container commit && \ | ||
mkdir -p /var/lib && mv /staged-alternatives /var/lib/alternatives && \ | ||
mkdir -p /tmp /var/tmp && \ | ||
chmod -R 1777 /tmp /var/tmp | ||
|
||
FROM main AS nvidia | ||
|
||
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-39}" | ||
ARG HWE_FLAVOR="{HWE_FLAVOR:-main}" | ||
ARG IMAGE_NAME="${IMAGE_NAME:-silverblue}" | ||
ARG IMAGE_VENDOR="${IMAGE_VENDOR:-ublue-os}" | ||
ARG NVIDIA_MAJOR_VERSION="${NVIDIA_MAJOR_VERSION:-550}" | ||
ARG RPMFUSION_MIRROR="" | ||
|
||
COPY image-info.sh /tmp/image-info.sh | ||
COPY install.sh /tmp/install.sh | ||
COPY post-install.sh /tmp/post-install.sh | ||
COPY --from=ghcr.io/ublue-os/akmods-nvidia:${HWE_FLAVOR}-${FEDORA_MAJOR_VERSION}-${NVIDIA_MAJOR_VERSION} /rpms /tmp/akmods-rpms | ||
|
||
COPY --from=ghcr.io/ublue-os/akmods-nvidia:main-${FEDORA_MAJOR_VERSION}-${NVIDIA_MAJOR_VERSION} /rpms /tmp/akmods-rpms | ||
COPY image-info.sh /tmp/ | ||
COPY nvidia/*.sh /tmp/ | ||
|
||
RUN /tmp/image-info.sh && \ | ||
RUN mkdir -p /var/lib/alternatives && \ | ||
IMAGE_FLAVOR=nvidia /tmp/image-info.sh && \ | ||
/tmp/install.sh && \ | ||
/tmp/post-install.sh && \ | ||
rm -rf /tmp/* /var/* | ||
|
||
RUN ostree container commit && \ | ||
mkdir -p /var/tmp && chmod -R 1777 /tmp /var/tmp | ||
mv /var/lib/alternatives /staged-alternatives && \ | ||
rm -rf /tmp/* /var/* && \ | ||
ostree container commit && \ | ||
mkdir -p /var/lib && mv /staged-alternatives /var/lib/alternatives && \ | ||
mkdir -p /tmp /var/tmp && \ | ||
chmod -R 1777 /tmp /var/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"all": { | ||
"include": { | ||
"all": [ | ||
"asusctl", | ||
"asusctl-rog-gui", | ||
"fprintd" | ||
] | ||
}, | ||
"exclude": { | ||
"all": [] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/bin/sh | ||
|
||
set -ouex pipefail | ||
|
||
if [[ "${FEDORA_MAJOR_VERSION}" -le 38 ]]; then | ||
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-{cisco-openh264,modular,updates-modular}.repo | ||
else | ||
sed -i 's@enabled=1@enabled=0@g' /etc/yum.repos.d/fedora-cisco-openh264.repo | ||
fi | ||
|
||
if [ -n "${RPMFUSION_MIRROR}" ]; then | ||
# force use of single rpmfusion mirror | ||
echo "Using single rpmfusion mirror: ${RPMFUSION_MIRROR}" | ||
sed -i.bak "s%^metalink=%#metalink=%" /etc/yum.repos.d/rpmfusion-*.repo | ||
sed -i "s%^#baseurl=http://download1.rpmfusion.org%baseurl=${RPMFUSION_MIRROR}%" /etc/yum.repos.d/rpmfusion-*.repo | ||
# after F40 launches, bump to 41 | ||
if [[ "${FEDORA_MAJOR_VERSION}" -ge 40 ]]; then | ||
sed -i "s%free/fedora/releases%free/fedora/development%" /etc/yum.repos.d/rpmfusion-*.repo | ||
fi | ||
fi | ||
|
||
rpm-ostree install \ | ||
/tmp/akmods-rpms/ublue-os/ublue-os-nvidia-addons-*.rpm | ||
|
||
source /tmp/akmods-rpms/kmods/nvidia-vars.${NVIDIA_MAJOR_VERSION} | ||
|
||
if [[ "${IMAGE_NAME}" == "kinoite" ]]; then | ||
VARIANT_PKGS="supergfxctl-plasmoid supergfxctl" | ||
elif [[ "${IMAGE_NAME}" == "silverblue" ]]; then | ||
VARIANT_PKGS="gnome-shell-extension-supergfxctl-gex supergfxctl" | ||
else | ||
VARIANT_PKGS="" | ||
fi | ||
|
||
rpm-ostree install \ | ||
xorg-x11-drv-${NVIDIA_PACKAGE_NAME}-{,cuda-,devel-,kmodsrc-,power-}${NVIDIA_FULL_VERSION} \ | ||
xorg-x11-drv-${NVIDIA_PACKAGE_NAME}-libs.i686 \ | ||
nvidia-container-toolkit nvidia-vaapi-driver ${VARIANT_PKGS} \ | ||
/tmp/akmods-rpms/kmods/kmod-${NVIDIA_PACKAGE_NAME}-${KERNEL_VERSION}-${NVIDIA_AKMOD_VERSION}.fc${RELEASE}.rpm | ||
|
||
if [ -n "${RPMFUSION_MIRROR}" ]; then | ||
# reset forced use of single rpmfusion mirror | ||
echo "Revert from single rpmfusion mirror: ${RPMFUSION_MIRROR}" | ||
rename -v .repo.bak .repo /etc/yum.repos.d/rpmfusion-*repo.bak | ||
fi |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
|
||
set -ouex pipefail | ||
|
||
RELEASE="$(rpm -E %fedora)" | ||
|
||
# build list of all packages requested for inclusion | ||
INCLUDED_PACKAGES=($(jq -r "[(.all.include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ | ||
(select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".include | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ | ||
| sort | unique[]" /tmp/packages.json)) | ||
|
||
# build list of all packages requested for exclusion | ||
EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ | ||
(select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ | ||
| sort | unique[]" /tmp/packages.json)) | ||
|
||
|
||
# ensure exclusion list only contains packages already present on image | ||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then | ||
EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]})) | ||
fi | ||
|
||
# simple case to install where no packages need excluding | ||
if [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -eq 0 ]]; then | ||
rpm-ostree install \ | ||
${INCLUDED_PACKAGES[@]} | ||
|
||
# install/excluded packages both at same time | ||
elif [[ "${#INCLUDED_PACKAGES[@]}" -gt 0 && "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then | ||
rpm-ostree override remove \ | ||
${EXCLUDED_PACKAGES[@]} \ | ||
$(printf -- "--install=%s " ${INCLUDED_PACKAGES[@]}) | ||
|
||
else | ||
echo "No packages to install." | ||
|
||
fi | ||
|
||
# check if any excluded packages are still present | ||
# (this can happen if an included package pulls in a dependency) | ||
EXCLUDED_PACKAGES=($(jq -r "[(.all.exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[]), \ | ||
(select(.\"$FEDORA_MAJOR_VERSION\" != null).\"$FEDORA_MAJOR_VERSION\".exclude | (.all, select(.\"$IMAGE_NAME\" != null).\"$IMAGE_NAME\")[])] \ | ||
| sort | unique[]" /tmp/packages.json)) | ||
|
||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then | ||
EXCLUDED_PACKAGES=($(rpm -qa --queryformat='%{NAME} ' ${EXCLUDED_PACKAGES[@]})) | ||
fi | ||
|
||
# remove any excluded packages which are still present on image | ||
if [[ "${#EXCLUDED_PACKAGES[@]}" -gt 0 ]]; then | ||
rpm-ostree override remove \ | ||
${EXCLUDED_PACKAGES[@]} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"all": { | ||
"include": { | ||
"all": [ | ||
"fprintd" | ||
] | ||
}, | ||
"exclude": { | ||
"all": [] | ||
} | ||
} | ||
} |