mirror of
https://github.com/ublue-os/bazzite.git
synced 2025-01-26 00:35:19 +00:00
feat(dev): add easy local iso and vscode integration (#1127)
* feat(dev): add easy local iso and vscode integration * fix: remove unused variables.
This commit is contained in:
parent
aa72329e3d
commit
532190ecce
109
.vscode/tasks.json
vendored
Normal file
109
.vscode/tasks.json
vendored
Normal file
@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
@ -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}"
|
||||
@ -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 \
|
||||
@ -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}"
|
||||
@ -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 && \
|
||||
|
68
Justfile
Normal file
68
Justfile
Normal file
@ -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
just_scripts/build-image.sh
Executable file
45
just_scripts/build-image.sh
Executable file
@ -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}"
|
143
just_scripts/build-iso-installer-main.sh
Normal file
143
just_scripts/build-iso-installer-main.sh
Normal file
@ -0,0 +1,143 @@
|
||||
#!/usr/bin/bash
|
||||
#shellcheck disable=SC2154
|
||||
|
||||
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
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "${project_root}/just_scripts/sudoif.sh"
|
||||
|
||||
# Check if inside rootless container
|
||||
if [[ -f /run/.containerenv ]]; then
|
||||
#shellcheck disable=SC1091
|
||||
source /run/.containerenv
|
||||
#shellcheck disable=SC2154
|
||||
if [[ "${rootless}" -eq "1" ]]; then
|
||||
echo "Cannot build ISO inside rootless podman container... Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
container_mgr=$(just _container_mgr)
|
||||
# If using rootless container manager, exit. Might not be best check
|
||||
if "${container_mgr}" info | grep Root | grep -q /home; then
|
||||
echo "Cannot build ISO with rootless container..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get Inputs
|
||||
target=$1
|
||||
image=$2
|
||||
orig_image=$2
|
||||
|
||||
# Set image/target/version based on inputs
|
||||
# shellcheck disable=SC2154,SC1091
|
||||
. "${project_root}/just_scripts/get-defaults.sh"
|
||||
|
||||
# Set Container tag name
|
||||
tag=$(just _tag "${image}")
|
||||
|
||||
# Remove old ISO if present
|
||||
sudoif rm -f "${project_root}/just_scripts/output/${tag}-${git_branch}.iso"
|
||||
sudoif rm -f "${project_root}/just_scripts/output/${tag}-${git_branch}.iso-CHECKSUM"
|
||||
|
||||
# Set Base Image
|
||||
if [[ ${image} =~ "gnome" ]]; then
|
||||
base_image="silverblue"
|
||||
else
|
||||
base_image="kinoite"
|
||||
fi
|
||||
|
||||
# Set variant and flatpak dir
|
||||
if [[ "${base_image}" =~ "silverblue" ]]; then
|
||||
flatpak_dir_shortname="installer/gnome_flatpaks"
|
||||
elif [[ "${base_image}" =~ "kinoite" ]]; then
|
||||
flatpak_dir_shortname="installer/kde_flatpaks"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
variant="Kinoite"
|
||||
if [[ ${target} =~ "deck" ]]; then
|
||||
extra_boot_params="inst.resolution=1280x800"
|
||||
fi
|
||||
|
||||
# Make sure image actually exists, build if it doesn't
|
||||
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${latest}-${git_branch}" --format "{{.ID}}")
|
||||
if [[ -z ${ID} ]]; then
|
||||
just build "${target}" "${orig_image}"
|
||||
fi
|
||||
|
||||
# Make temp space
|
||||
TEMP_FLATPAK_INSTALL_DIR=$(mktemp -d -p "${project_root}" flatpak.XXX)
|
||||
# Get list of refs from directory
|
||||
FLATPAK_REFS_DIR=${project_root}/${flatpak_dir_shortname}
|
||||
FLATPAK_REFS_DIR_LIST=$(tr '\n' ' ' < "${FLATPAK_REFS_DIR}/flatpaks")
|
||||
|
||||
# Generate install script
|
||||
cat << EOF > "${TEMP_FLATPAK_INSTALL_DIR}/script.sh"
|
||||
cat /temp_flatpak_install_dir/script.sh
|
||||
mkdir -p /flatpak/flatpak /flatpak/triggers
|
||||
mkdir /var/tmp || true
|
||||
chmod -R 1777 /var/tmp
|
||||
flatpak config --system --set languages "*"
|
||||
flatpak remote-add --system flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
flatpak install --system -y ${FLATPAK_REFS_DIR_LIST}
|
||||
ostree refs --repo=\${FLATPAK_SYSTEM_DIR}/repo | grep '^deploy/' | grep -v 'org\.freedesktop\.Platform\.openh264' | sed 's/^deploy\///g' > /output/flatpaks_with_deps
|
||||
EOF
|
||||
|
||||
workspace=${project_root}
|
||||
if [[ -f /.dockerenv || -f /run/.containerenv ]]; then
|
||||
FLATPAK_REFS_DIR=${LOCAL_WORKSPACE_FOLDER}/${flatpak_dir_shortname}
|
||||
TEMP_FLATPAK_INSTALL_DIR="${LOCAL_WORKSPACE_FOLDER}/$(echo "${TEMP_FLATPAK_INSTALL_DIR}" | rev | cut -d / -f 1 | rev)"
|
||||
workspace=${LOCAL_WORKSPACE_FOLDER}
|
||||
fi
|
||||
|
||||
# Generate Flatpak Dependency List
|
||||
if [[ ! -f ${project_root}/${flatpak_dir_shortname}/flatpaks_with_deps ]]; then
|
||||
"${container_mgr}" run --rm --privileged \
|
||||
--entrypoint bash \
|
||||
-e FLATPAK_SYSTEM_DIR=/flatpak/flatpak \
|
||||
-e FLATPAK_TRIGGERSDIR=/flatpak/triggers \
|
||||
--volume "${FLATPAK_REFS_DIR}":/output \
|
||||
--volume "${TEMP_FLATPAK_INSTALL_DIR}":/temp_flatpak_install_dir \
|
||||
"ghcr.io/ublue-os/${base_image}-main:${version}" /temp_flatpak_install_dir/script.sh
|
||||
fi
|
||||
|
||||
# Remove Temp Directory
|
||||
if [[ -f /.dockerenv ]]; then
|
||||
TEMP_FLATPAK_INSTALL_DIR=${project_root}/$(echo "${TEMP_FLATPAK_INSTALL_DIR}" | rev | cut -d / -f 1 | rev)
|
||||
fi
|
||||
rm -rf "${TEMP_FLATPAK_INSTALL_DIR}"
|
||||
|
||||
if [[ ${container_mgr} =~ "podman" ]]; then
|
||||
api_socket=/run/podman/podman.sock
|
||||
elif [[ ${container_mgr} =~ "docker" ]]; then
|
||||
api_socket=/var/run/docker.sock
|
||||
fi
|
||||
|
||||
# Make ISO
|
||||
${container_mgr} run --rm --privileged \
|
||||
--volume "${api_socket}":/var/run/docker.sock \
|
||||
--volume "${workspace}"/just_scripts/build-iso-makefile-patch:/build-container-installer/container/Makefile \
|
||||
--volume "${workspace}/${flatpak_dir_shortname}":"/build-container-installer/${flatpak_dir_shortname}" \
|
||||
--volume "${workspace}"/just_scripts/output:/build-container-installer/build \
|
||||
--volume "${workspace}"/installer/lorax_templates:/additional_lorax_templates \
|
||||
ghcr.io/jasonn3/build-container-installer:main \
|
||||
ADDITIONAL_TEMPLATES="/additional_lorax_templates/remove_root_password_prompt.tmpl" \
|
||||
ARCH="x86_64" \
|
||||
ENABLE_CACHE_DNF="false" \
|
||||
ENABLE_CACHE_SKOPEO="false" \
|
||||
ENABLE_FLATPAK_DEPENDENCIES="false" \
|
||||
ENROLLMENT_PASSWORD="ublue-os" \
|
||||
EXTRA_BOOT_PARAMS="${extra_boot_params}" \
|
||||
FLATPAK_REMOTE_REFS_DIR="${flatpak_dir_shortname}" \
|
||||
IMAGE_NAME="${tag}" \
|
||||
IMAGE_REPO="localhost" \
|
||||
IMAGE_TAG="${latest}-${git_branch}" \
|
||||
ISO_NAME="build/${tag}-${git_branch}.iso" \
|
||||
SECURE_BOOT_KEY_URL='https://github.com/ublue-os/akmods/raw/main/certs/public_key.der' \
|
||||
VARIANT="${variant}" \
|
||||
VERSION="${latest}"
|
11
just_scripts/build-iso-makefile-patch
Normal file
11
just_scripts/build-iso-makefile-patch
Normal file
@ -0,0 +1,11 @@
|
||||
$(IMAGE_NAME)-$(IMAGE_TAG):
|
||||
skopeo copy docker-daemon:$(IMAGE_REPO)/$(IMAGE_NAME):$(IMAGE_TAG) oci:$(IMAGE_NAME)-$(IMAGE_TAG)
|
||||
|
||||
install-deps:
|
||||
$(install_pkg) skopeo
|
||||
|
||||
FILES=$(filter-out Makefile,$(wildcard *))
|
||||
clean:
|
||||
ifneq ($(FILES),)
|
||||
rm -Rf $(FILES)
|
||||
endif
|
143
just_scripts/build-iso.sh
Normal file
143
just_scripts/build-iso.sh
Normal file
@ -0,0 +1,143 @@
|
||||
#!/usr/bin/bash
|
||||
#shellcheck disable=SC2154
|
||||
|
||||
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
|
||||
|
||||
# shellcheck disable=SC1091
|
||||
. "${project_root}/just_scripts/sudoif.sh"
|
||||
|
||||
# Check if inside rootless container
|
||||
if [[ -f /run/.containerenv ]]; then
|
||||
#shellcheck disable=SC1091
|
||||
source /run/.containerenv
|
||||
#shellcheck disable=SC2154
|
||||
if [[ "${rootless}" -eq "1" ]]; then
|
||||
echo "Cannot build ISO inside rootless podman container... Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
container_mgr=$(just _container_mgr)
|
||||
# If using rootless container manager, exit. Might not be best check
|
||||
if "${container_mgr}" info | grep Root | grep -q /home; then
|
||||
echo "Cannot build ISO with rootless container..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get Inputs
|
||||
target=$1
|
||||
image=$2
|
||||
orig_image=$2
|
||||
|
||||
# Set image/target/version based on inputs
|
||||
# shellcheck disable=SC2154,SC1091
|
||||
. "${project_root}/just_scripts/get-defaults.sh"
|
||||
|
||||
# Set Container tag name
|
||||
tag=$(just _tag "${image}")
|
||||
|
||||
# Remove old ISO if present
|
||||
sudoif rm -f "${project_root}/just_scripts/output/${tag}-${git_branch}.iso"
|
||||
sudoif rm -f "${project_root}/just_scripts/output/${tag}-${git_branch}.iso-CHECKSUM"
|
||||
|
||||
# Set Base Image
|
||||
if [[ ${image} =~ "gnome" ]]; then
|
||||
base_image="silverblue"
|
||||
else
|
||||
base_image="kinoite"
|
||||
fi
|
||||
|
||||
# Set variant and flatpak dir
|
||||
if [[ "${base_image}" =~ "silverblue" ]]; then
|
||||
flatpak_dir_shortname="installer/gnome_flatpaks"
|
||||
elif [[ "${base_image}" =~ "kinoite" ]]; then
|
||||
flatpak_dir_shortname="installer/kde_flatpaks"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
variant="Kinoite"
|
||||
if [[ ${target} =~ "deck" ]]; then
|
||||
extra_boot_params="inst.resolution=1280x800"
|
||||
fi
|
||||
|
||||
# Make sure image actually exists, build if it doesn't
|
||||
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${latest}-${git_branch}" --format "{{.ID}}")
|
||||
if [[ -z ${ID} ]]; then
|
||||
just build "${target}" "${orig_image}"
|
||||
fi
|
||||
|
||||
# Make temp space
|
||||
TEMP_FLATPAK_INSTALL_DIR=$(mktemp -d -p "${project_root}" flatpak.XXX)
|
||||
# Get list of refs from directory
|
||||
FLATPAK_REFS_DIR=${project_root}/${flatpak_dir_shortname}
|
||||
FLATPAK_REFS_DIR_LIST=$(tr '\n' ' ' < "${FLATPAK_REFS_DIR}/flatpaks")
|
||||
|
||||
# Generate install script
|
||||
cat << EOF > "${TEMP_FLATPAK_INSTALL_DIR}/script.sh"
|
||||
cat /temp_flatpak_install_dir/script.sh
|
||||
mkdir -p /flatpak/flatpak /flatpak/triggers
|
||||
mkdir /var/tmp || true
|
||||
chmod -R 1777 /var/tmp
|
||||
flatpak config --system --set languages "*"
|
||||
flatpak remote-add --system flathub https://flathub.org/repo/flathub.flatpakrepo
|
||||
flatpak install --system -y ${FLATPAK_REFS_DIR_LIST}
|
||||
ostree refs --repo=\${FLATPAK_SYSTEM_DIR}/repo | grep '^deploy/' | grep -v 'org\.freedesktop\.Platform\.openh264' | sed 's/^deploy\///g' > /output/flatpaks_with_deps
|
||||
EOF
|
||||
|
||||
workspace=${project_root}
|
||||
if [[ -f /.dockerenv || -f /run/.containerenv ]]; then
|
||||
FLATPAK_REFS_DIR=${LOCAL_WORKSPACE_FOLDER}/${flatpak_dir_shortname}
|
||||
TEMP_FLATPAK_INSTALL_DIR="${LOCAL_WORKSPACE_FOLDER}/$(echo "${TEMP_FLATPAK_INSTALL_DIR}" | rev | cut -d / -f 1 | rev)"
|
||||
workspace=${LOCAL_WORKSPACE_FOLDER}
|
||||
fi
|
||||
|
||||
# Generate Flatpak Dependency List
|
||||
if [[ ! -f ${project_root}/${flatpak_dir_shortname}/flatpaks_with_deps ]]; then
|
||||
"${container_mgr}" run --rm --privileged \
|
||||
--entrypoint bash \
|
||||
-e FLATPAK_SYSTEM_DIR=/flatpak/flatpak \
|
||||
-e FLATPAK_TRIGGERSDIR=/flatpak/triggers \
|
||||
--volume "${FLATPAK_REFS_DIR}":/output \
|
||||
--volume "${TEMP_FLATPAK_INSTALL_DIR}":/temp_flatpak_install_dir \
|
||||
"ghcr.io/ublue-os/${base_image}-main:${version}" /temp_flatpak_install_dir/script.sh
|
||||
fi
|
||||
|
||||
# Remove Temp Directory
|
||||
if [[ -f /.dockerenv ]]; then
|
||||
TEMP_FLATPAK_INSTALL_DIR=${project_root}/$(echo "${TEMP_FLATPAK_INSTALL_DIR}" | rev | cut -d / -f 1 | rev)
|
||||
fi
|
||||
rm -rf "${TEMP_FLATPAK_INSTALL_DIR}"
|
||||
|
||||
if [[ ${container_mgr} =~ "podman" ]]; then
|
||||
api_socket=/run/podman/podman.sock
|
||||
elif [[ ${container_mgr} =~ "docker" ]]; then
|
||||
api_socket=/var/run/docker.sock
|
||||
fi
|
||||
|
||||
# Make ISO
|
||||
${container_mgr} run --rm --privileged \
|
||||
--volume "${api_socket}":/var/run/docker.sock \
|
||||
--volume "${workspace}"/just_scripts/build-iso-makefile-patch:/build-container-installer/container/Makefile \
|
||||
--volume "${workspace}/${flatpak_dir_shortname}":"/build-container-installer/${flatpak_dir_shortname}" \
|
||||
--volume "${workspace}"/just_scripts/output:/build-container-installer/build \
|
||||
--volume "${workspace}"/installer/lorax_templates:/additional_lorax_templates \
|
||||
ghcr.io/jasonn3/build-container-installer:latest \
|
||||
ADDITIONAL_TEMPLATES="/additional_lorax_templates/remove_root_password_prompt.tmpl" \
|
||||
ARCH="x86_64" \
|
||||
ENABLE_CACHE_DNF="false" \
|
||||
ENABLE_CACHE_SKOPEO="false" \
|
||||
ENABLE_FLATPAK_DEPENDENCIES="false" \
|
||||
ENROLLMENT_PASSWORD="ublue-os" \
|
||||
EXTRA_BOOT_PARAMS="${extra_boot_params}" \
|
||||
FLATPAK_REMOTE_REFS_DIR="${flatpak_dir_shortname}" \
|
||||
IMAGE_NAME="${tag}" \
|
||||
IMAGE_REPO="localhost" \
|
||||
IMAGE_TAG="${latest}-${git_branch}" \
|
||||
ISO_NAME="build/${tag}-${git_branch}.iso" \
|
||||
SECURE_BOOT_KEY_URL='https://github.com/ublue-os/akmods/raw/main/certs/public_key.der' \
|
||||
VARIANT="${variant}" \
|
||||
VERSION="${latest}"
|
11
just_scripts/cleanup-dir.sh
Executable file
11
just_scripts/cleanup-dir.sh
Executable file
@ -0,0 +1,11 @@
|
||||
#!/usr/bin/bash
|
||||
if [[ -z ${project_root} ]]; then
|
||||
project_root=$(git rev-parse --show-toplevel)
|
||||
fi
|
||||
# shellcheck disable=SC1091
|
||||
. "${project_root}/just_scripts/sudoif.sh"
|
||||
|
||||
set -euox pipefail
|
||||
|
||||
#shellcheck disable=SC2154
|
||||
sudoif rm -f "${project_root}"/just_scripts/output/* #ISOs
|
15
just_scripts/cleanup-images.sh
Executable file
15
just_scripts/cleanup-images.sh
Executable file
@ -0,0 +1,15 @@
|
||||
#!/usr/bin/bash
|
||||
set -euox pipefail
|
||||
container_mgr=(
|
||||
docker
|
||||
podman
|
||||
podman-remote
|
||||
)
|
||||
for i in "${container_mgr[@]}"; do
|
||||
if [[ $(command -v "$i") ]]; then
|
||||
echo "Container Manager: ${i}"
|
||||
ID=$(${i} images --filter "reference=localhost/bazzite*-build")
|
||||
xargs -I {} "${i}" image rm {} <<< "$ID"
|
||||
echo ""
|
||||
fi
|
||||
done
|
21
just_scripts/container_mgr.sh
Executable file
21
just_scripts/container_mgr.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/bash
|
||||
valid_manager=(
|
||||
docker
|
||||
podman
|
||||
podman-remote
|
||||
)
|
||||
if [[ -n ${CONTAINER_MGR} ]]; then
|
||||
if [[ "${valid_manager[*]}" =~ ${CONTAINER_MGR} ]]; then
|
||||
echo "${CONTAINER_MGR}"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
elif [[ $(command -v docker) ]]; then
|
||||
echo docker
|
||||
elif [[ $(command -v podman) ]]; then
|
||||
echo podman
|
||||
elif [[ $(command -v podman-remote) ]];then
|
||||
echo podman-remote
|
||||
else
|
||||
exit 1
|
||||
fi
|
46
just_scripts/get-defaults.sh
Executable file
46
just_scripts/get-defaults.sh
Executable file
@ -0,0 +1,46 @@
|
||||
#!/usr/bin/bash
|
||||
if [[ -z "${image}" ]]; then
|
||||
image=${default_image}
|
||||
fi
|
||||
|
||||
if [[ -z "${target}" ]]; then
|
||||
target=${default_target}
|
||||
elif [[ ${target} == "deck" ]]; then
|
||||
target="bazzite-deck"
|
||||
elif [[ ${target} == "nvidia" ]]; then
|
||||
target="bazzite-nvidia"
|
||||
fi
|
||||
|
||||
valid_images=(
|
||||
silverblue
|
||||
kinoite
|
||||
gnome
|
||||
kde
|
||||
)
|
||||
image=${image,,}
|
||||
if [[ ! ${valid_images[*]} =~ ${image} ]]; then
|
||||
echo "Invalid image..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
target=${target,,}
|
||||
valid_targets=(
|
||||
bazzite
|
||||
bazzite-deck
|
||||
bazzite-nvidia
|
||||
)
|
||||
if [[ ! ${valid_targets[*]} =~ ${target} ]]; then
|
||||
echo "Invalid target..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
desktop=""
|
||||
if [[ ${image} == "gnome" || ${image} == "silverblue" ]]; then
|
||||
desktop="-gnome"
|
||||
fi
|
||||
image="${target}${desktop}"
|
||||
if [[ ${image} =~ "nvidia" ]]; then
|
||||
image="bazzite${desktop}-nvidia"
|
||||
fi
|
||||
|
||||
|
13
just_scripts/list-images.sh
Executable file
13
just_scripts/list-images.sh
Executable file
@ -0,0 +1,13 @@
|
||||
#!/usr/bin/bash
|
||||
set -euo pipefail
|
||||
container_mgr=(
|
||||
docker
|
||||
podman
|
||||
podman-remote
|
||||
)
|
||||
for i in "${container_mgr[@]}"; do
|
||||
if [[ $(command -v "$i") ]]; then
|
||||
echo "Container Manager: ${i}"
|
||||
${i} images --filter "reference=localhost/bazzite*-build"
|
||||
fi
|
||||
done
|
30
just_scripts/run-image.sh
Normal file
30
just_scripts/run-image.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/bash
|
||||
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
|
||||
set -eo pipefail
|
||||
|
||||
# Get Inputs
|
||||
target=$1
|
||||
image=$2
|
||||
orig_image=$2
|
||||
|
||||
# Get image/target/version based on inputs
|
||||
# shellcheck disable=SC2154,SC1091
|
||||
. "${project_root}/just_scripts/get-defaults.sh"
|
||||
|
||||
# Get variables
|
||||
container_mgr=$(just _container_mgr)
|
||||
tag=$(just _tag "${image}")
|
||||
|
||||
# Check if requested image exist, if it doesn't build it
|
||||
ID=$(${container_mgr} images --filter reference=localhost/"${tag}":"${latest}-${git_branch}" --format "{{.ID}}")
|
||||
if [[ -z ${ID} ]]; then
|
||||
just build "${target}" "${orig_image}"
|
||||
fi
|
||||
|
||||
# Run image
|
||||
"${container_mgr}" run -it --rm localhost/"${tag}:${latest}-${git_branch}" /usr/bin/bash
|
41
just_scripts/run-iso.sh
Normal file
41
just_scripts/run-iso.sh
Normal file
@ -0,0 +1,41 @@
|
||||
#!/usr/bin/bash
|
||||
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
|
||||
set -eo pipefail
|
||||
|
||||
# Get Inputs
|
||||
target=$1
|
||||
image=$2
|
||||
orig_image=$2
|
||||
|
||||
# Get image/target/version based on inputs
|
||||
# shellcheck disable=SC2154,SC1091
|
||||
. "${project_root}/just_scripts/get-defaults.sh"
|
||||
|
||||
# Get variables
|
||||
container_mgr=$(just _container_mgr)
|
||||
tag=$(just _tag "${image}")
|
||||
|
||||
#check if ISO exists. Create if it doesn't
|
||||
if [[ ! -f "${project_root}/just_scripts/output/${tag}-${git_branch}.iso" ]]; then
|
||||
just build-iso "$target" "$orig_image"
|
||||
fi
|
||||
|
||||
workspace=${project_root}
|
||||
if [[ -f /.dockerenv ]]; then
|
||||
workspace=${LOCAL_WORKSPACE_FOLDER}
|
||||
fi
|
||||
|
||||
${container_mgr} run --rm --cap-add NET_ADMIN \
|
||||
--publish 127.0.0.1:8006:8006 \
|
||||
--env "CPU_CORES=2" \
|
||||
--env "RAM_SIZE=4G" \
|
||||
--env "DISK_SIZE=64G" \
|
||||
--env "BOOT_MODE=uefi" \
|
||||
--device=/dev/kvm \
|
||||
--volume "${workspace}/just_scripts/output/${tag}-${git_branch}.iso":/boot.iso \
|
||||
docker.io/qemux/qemu-docker
|
14
just_scripts/sudoif.sh
Executable file
14
just_scripts/sudoif.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/usr/bin/bash
|
||||
function sudoif(){
|
||||
if [[ "${TERM_PROGRAM}" == "vscode" && \
|
||||
! -f /run/.containerenv && \
|
||||
! -f /.dockerenv ]]; then
|
||||
[[ $(command -v systemd-run) ]] && \
|
||||
/usr/bin/systemd-run --uid=0 --gid=0 -d -E TERM="$TERM" -t -q -P -G "$@" \
|
||||
|| exit 1
|
||||
else
|
||||
[[ $(command -v sudo) ]] && \
|
||||
/usr/bin/sudo "$@" \
|
||||
|| exit 1
|
||||
fi
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user