Skip to content

Commit

Permalink
feat(dev): add easy local iso and vscode integration (ublue-os#1127)
Browse files Browse the repository at this point in the history
* feat(dev): add easy local iso and vscode integration

* fix: remove unused variables.
  • Loading branch information
m2Giles authored May 15, 2024
1 parent aa72329 commit 532190e
Show file tree
Hide file tree
Showing 15 changed files with 717 additions and 3 deletions.
109 changes: 109 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Connect to VM",
"dependsOn": [
"Run-ISO",
"Open Browser"
],
"problemMatcher": []
},
{
"label": "Open Browser",
"command": "${input:openSimpleBrowser}",
"problemMatcher": []
},
{
"label": "Build Container",
"command": "just",
"args": [
"build",
"${input:outputChoice}"
],
"problemMatcher": [],
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "Build ISO",
"command": "just",
"args": [
"${input:installerChoice}",
"${input:outputChoice}"
],
"problemMatcher": []
},
{
"label": "Run-ISO",
"command": "just",
"args": [
"run-iso",
"${input:outputChoice}"
],
"problemMatcher": [],
"isBackground": true
},
{
"label": "List Images",
"command": "just",
"args": [
"list-images"
],
"problemMatcher": []
},
{
"label": "Check justfiles",
"command": "just",
"args": [
"just-check"
],
"problemMatcher": []
},
{
"label": "Run Container",
"command": "just",
"args": [
"run-container",
"${input:outputChoice}"
],
"problemMatcher": []
}
],
"inputs": [
{
"id": "openSimpleBrowser",
"type": "command",
"command": "simpleBrowser.show",
"args": [
"http://localhost:8006"
]
},
{
"id": "installerChoice",
"type": "pickString",
"description": "Choose which Installer Builder to use",
"default": "build-iso",
"options": [
"build-iso",
"build-iso-git"
]
},
{
"id": "outputChoice",
"type": "pickString",
"description": "Choose which container to build",
"default": "bazzite",
"options": [
"bazzite",
"bazzite-deck",
"bazzite-nvidia",
"bazzite gnome",
"bazzite-deck gnome",
"bazzite-nvidia gnome"
]
}
]
}
10 changes: 7 additions & 3 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ ARG SOURCE_IMAGE="${SOURCE_IMAGE:-$BASE_IMAGE_NAME-$BASE_IMAGE_FLAVOR}"
ARG BASE_IMAGE="ghcr.io/ublue-os/${SOURCE_IMAGE}"
ARG FEDORA_MAJOR_VERSION="${FEDORA_MAJOR_VERSION:-40}"

FROM ghcr.io/ublue-os/akmods:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} as akmods
FROM ghcr.io/ublue-os/akmods-extra:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} as akmods-extra

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

ARG IMAGE_NAME="${IMAGE_NAME:-bazzite}"
Expand Down Expand Up @@ -112,8 +115,8 @@ RUN mkdir -p /tmp/mediatek-firmware && \
ostree container commit

# Add ublue packages, add needed negativo17 repo and then immediately disable due to incompatibility with RPMFusion
COPY --from=ghcr.io/ublue-os/akmods:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} /rpms /tmp/akmods-rpms
COPY --from=ghcr.io/ublue-os/akmods-extra:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} /rpms /tmp/akmods-rpms
COPY --from=akmods /rpms /tmp/akmods-rpms
COPY --from=akmods-extra /rpms /tmp/akmods-rpms
RUN sed -i 's@enabled=0@enabled=1@g' /etc/yum.repos.d/_copr_ublue-os-akmods.repo && \
curl -Lo /etc/yum.repos.d/negativo17-fedora-multimedia.repo https://negativo17.org/repos/fedora-multimedia.repo && \
rpm-ostree install \
Expand Down Expand Up @@ -771,6 +774,7 @@ RUN /usr/libexec/containerbuild/image-info && \
systemctl disable batterylimit.service && \
ostree container commit

FROM ghcr.io/ublue-os/akmods-nvidia:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} as nvidia-akmods
FROM bazzite as bazzite-nvidia

ARG IMAGE_NAME="${IMAGE_NAME:-bazzite-nvidia}"
Expand Down Expand Up @@ -798,7 +802,7 @@ RUN rpm-ostree override remove \
ostree container commit

# Install NVIDIA driver
COPY --from=ghcr.io/ublue-os/akmods-nvidia:${KERNEL_FLAVOR}-${FEDORA_MAJOR_VERSION} /rpms /tmp/akmods-rpms
COPY --from=nvidia-akmods /rpms /tmp/akmods-rpms
RUN sed -i 's@enabled=0@enabled=1@g' /etc/yum.repos.d/rpmfusion-nonfree.repo && \
sed -i 's@enabled=0@enabled=1@g' /etc/yum.repos.d/rpmfusion-nonfree-updates.repo && \
sed -i 's@enabled=0@enabled=1@g' /etc/yum.repos.d/rpmfusion-nonfree-updates-testing.repo && \
Expand Down
68 changes: 68 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
export project_root := `git rev-parse --show-toplevel`
export git_branch := ` git branch --show-current`
export latest := "40"
export default_image := "kinoite"
export default_target := "bazzite"

alias build-iso := build-iso-release
alias run := run-container

_default:
@just --list

_container_mgr:
@{{ project_root }}/just_scripts/container_mgr.sh

_tag image:
@echo {{image}}-build

# Check Just Syntax
just-check:
#!/usr/bin/bash
find "${project_root}" -type f -name "*.just" | while read -r file; do
echo "Checking syntax: $file"
just --unstable --fmt --check -f $file
done
just --unstable --fmt --check -f ${project_root}/Justfile

# Fix Just Syntax
[private]
just-fix:
#!/usr/bin/bash
find "${project_root}" -type f -name "*.just" | while read -r file; do
echo "Checking syntax: $file"
just --unstable --fmt -f $file
done
just --unstable --fmt -f ${project_root}/Justfile

# Build image
build target="" image="":
@{{ project_root }}/just_scripts/build-image.sh {{target}} {{image}}

# Build ISO
build-iso-release target="" image="":
@{{ project_root }}/just_scripts/build-iso.sh {{target}} {{image}}

# Build ISO using ISO Builder Git Head
build-iso-git target="" image="":
@{{ project_root }}/just_scripts/build-iso-installer-main.sh {{target}} {{image}}

# Run ISO
run-iso target="" image="":
@{{ project_root }}/just_scripts/run-iso.sh {{target}} {{image}}

# Run Container
run-container target="" image="":
@{{ project_root }}/just_scripts/run-image.sh {{target}} {{image}}

# List Images
list-images:
@{{ project_root }}/just_scripts/list-images.sh

# Clean Images
clean-images:
@{{ project_root }}/just_scripts/cleanup-images.sh

# Clean ISOs
clean-isos:
@{{ project_root }}/just_scripts/cleanup-dir.sh
45 changes: 45 additions & 0 deletions just_scripts/build-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/bash
set -eo pipefail
if [[ -z ${project_root} ]]; then
project_root=$(git rev-parse --show-toplevel)
fi
if [[ -z ${git_branch} ]]; then
git_branch=$(git branch --show-current)
fi

# Get Inputs
target=$1
image=$2

# Set image/target/version based on inputs
# shellcheck disable=SC2154,SC1091
. "${project_root}/just_scripts/get-defaults.sh"

# Get info
container_mgr=$(just _container_mgr)
tag=$(just _tag "${image}")

if [[ ${image} =~ "gnome" ]]; then
base_image="silverblue"
else
base_image="kinoite"
fi

if [[ ${target} =~ "nvidia" ]]; then
flavor="nvidia"
else
flavor="main"
fi

# Build Image
$container_mgr build -f Containerfile \
--build-arg="IMAGE_NAME=${tag}" \
--build-arg="BASE_IMAGE_NAME=${base_image}" \
--build-arg="BASE_IMAGE_FLAVOR=${flavor}" \
--build-arg="IMAGE_FLAVOR=${flavor}" \
--build-arg="KERNEL_FLAVOR=fsync" \
--build-arg="SOURCE_IMAGE=${base_image}-${flavor}" \
--build-arg="FEDORA_MAJOR_VERSION=${latest}" \
--target="${target}" \
--tag localhost/"${tag}:${latest}-${git_branch}" \
"${project_root}"
Loading

0 comments on commit 532190e

Please sign in to comment.