Skip to content

Commit

Permalink
Merge branch 'main' into homebrew
Browse files Browse the repository at this point in the history
  • Loading branch information
m2Giles authored May 15, 2024
2 parents 6b3aee3 + 6b38313 commit 4e4ba70
Show file tree
Hide file tree
Showing 16 changed files with 220 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/reusable-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ jobs:
registry: cgr.dev/chainguard

- name: Maximize build space
uses: ublue-os/remove-unwanted-software@v6
uses: ublue-os/remove-unwanted-software@v7

- name: Check just syntax
uses: ublue-os/just-action@v1
Expand Down
108 changes: 108 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
{
"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": [
"build-iso",
"${input:outputChoice}"
],
"problemMatcher": []
},
{
"label": "Build ISO (testing)",
"command": "just",
"args": [
"build-iso-installer-main",
"${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": "outputChoice",
"type": "pickString",
"description": "Choose which container to build",
"default": "bluefin",
"options": [
"bluefin",
"bluefin-dx",
"bluefin latest",
"bluefin-dx latest",
"aurora",
"aurora-dx"
]
}
]
}
7 changes: 6 additions & 1 deletion Justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export project_root := `git rev-parse --show-toplevel`
export git_branch := ` git branch --show-current`
export gts := "39"
export latest := "40"

Expand Down Expand Up @@ -32,7 +33,7 @@ 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 || { exit 1; }
just --unstable --fmt -f $file
done
echo "Checking syntax: ${project_root}/Justfile"
just --unstable --fmt -f ${project_root}/Justfile || { exit 1; }
Expand All @@ -57,6 +58,10 @@ run-booted-home image="" target="" version="":
build-iso image="" target="" version="":
@{{ project_root }}/scripts/build-iso.sh {{ image }} {{ target }} {{ version }}

# Create ISO from local dev build image - use build-container-installer:main
build-iso-installer-main image="" target="" version="":
@{{ project_root }}/scripts/build-iso-intstaller-main.sh {{ image }} {{ target }} {{ version }}

# Run ISO from local dev build image
run-iso image="" target="" version="":
@{{ project_root }}/scripts/run-iso.sh {{ image }} {{ target }} {{ version }}
Expand Down
5 changes: 4 additions & 1 deletion scripts/build-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
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
Expand All @@ -27,6 +30,6 @@ $container_mgr build -f Containerfile \
--build-arg="IMAGE_NAME=${tag}" \
--build-arg="IMAGE_FLAVOR=main" \
--build-arg="IMAGE_VENDOR=localhost" \
--tag localhost/"${tag}":"${version}" \
--tag localhost/"${tag}:${version}-${git_branch}" \
--target "${target}" \
"${project_root}"
40 changes: 40 additions & 0 deletions scripts/build-iso-installer-main.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/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

# Common Build ISO
# shellcheck disable=SC1091
. "${project_root}/scripts/common-build-iso.sh"

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}"/scripts/files/build-iso-makefile-patch:/build-container-installer/container/Makefile \
--volume "${workspace}/${flatpak_dir_shortname}":"/build-container-installer/${flatpak_dir_shortname}" \
--volume "${workspace}"/scripts/files/output:/build-container-installer/build \
ghcr.io/jasonn3/build-container-installer:main \
ARCH="x86_64" \
ENABLE_CACHE_DNF="false" \
ENABLE_CACHE_SKOPEO="false" \
ENABLE_FLATPAK_DEPENDENCIES="false" \
ENROLLMENT_PASSWORD="ublue-os" \
FLATPAK_REMOTE_REFS_DIR="${flatpak_dir_shortname}" \
IMAGE_NAME="${tag}" \
IMAGE_REPO="localhost" \
IMAGE_TAG="${version}-${git_branch}" \
ISO_NAME="build/${tag}-${version}-${git_branch}.iso" \
SECURE_BOOT_KEY_URL='https://github.com/ublue-os/akmods/raw/main/certs/public_key.der' \
VARIANT="${variant}" \
VERSION="${version}"
7 changes: 5 additions & 2 deletions scripts/build-iso.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
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

# Common Build ISO
# shellcheck disable=SC1091
Expand All @@ -30,8 +33,8 @@ ${container_mgr} run --rm --privileged \
FLATPAK_REMOTE_REFS_DIR="${flatpak_dir_shortname}" \
IMAGE_NAME="${tag}" \
IMAGE_REPO="localhost" \
IMAGE_TAG="${version}" \
ISO_NAME="build/${tag}-${version}.iso" \
IMAGE_TAG="${version}-${git_branch}" \
ISO_NAME="build/${tag}-${version}-${git_branch}.iso" \
SECURE_BOOT_KEY_URL='https://github.com/ublue-os/akmods/raw/main/certs/public_key.der' \
VARIANT="${variant}" \
VERSION="${version}"
6 changes: 4 additions & 2 deletions scripts/cleanup-dir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
if [[ -z ${project_root} ]]; then
project_root=$(git rev-parse --show-toplevel)
fi
# shellcheck disable=SC1091
. "${project_root}/scripts/sudoif.sh"

set -euox pipefail

#shellcheck disable=SC2154
rm -f "${project_root}"/scripts/files/output/* #ISOs
sudoif rm -f "${project_root}"/scripts/files/output/* #ISOs
rm -f "${project_root}"/*_flatapks/flatpaks_with_deps #Flatpak Deps
rm -rf "${project_root}"/flatpak.* #Flatpak Tempdir
rm -rf "${project_root}"/scripts/files/home/ublue-os/* #Test User Home
sudoif rm -rf "${project_root}"/scripts/files/home/ublue-os/* #Test User Home
2 changes: 1 addition & 1 deletion scripts/cleanup-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ container_mgr=(
for i in "${container_mgr[@]}"; do
if [[ $(command -v "$i") ]]; then
echo "Container Manager: ${i}"
ID=$(${i} images --filter "reference=localhost/bluefin*-build" --filter "reference=localhost/aurora*-build" --format "{{.ID}}")
ID=$(${i} images --filter "reference=localhost/bluefin*-build*" --filter "reference=localhost/aurora*-build*" --format "{{.ID}}")
xargs -I {} "${i}" image rm {} <<< "$ID"
echo ""
fi
Expand Down
26 changes: 9 additions & 17 deletions scripts/common-build-iso.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
#!/usr/bin/bash
#shellcheck disable=SC2154,SC2034

# shellcheck disable=SC1091
. "${project_root}/scripts/sudoif.sh"

# Check if inside rootless container
if [[ -f /run/.containerenv ]]; then
#shellcheck disable=SC1091
Expand All @@ -17,16 +20,6 @@ if "${container_mgr}" info | grep Root | grep -q /home; then
echo "Cannot build ISO with rootless container..."
exit 1
fi
function work-in-process(){
echo "ISO Builder script is a Work In Process"
secs=5
while [ $secs -gt 0 ]
do
printf "\r\033[KWaiting %.d seconds." $((secs--))
sleep 1
done
}
work-in-process

# Get Inputs
image=$1
Expand All @@ -43,6 +36,9 @@ tag=$(just _tag "${image}" "${target}")
# Don't use -build suffix, flatpak dependency using ghcr
ghcr_tag=${tag::-6}

# Remove old ISO if present
sudoif rm -f "${project_root}/scripts/files/output/${tag}-${version}-${git_branch}.iso"
sudoif rm -f "${project_root}/scripts/files/output/${tag}-${version}-${git_branch}.iso-CHECKSUM"

# Set Base Image
base_image=$(just _base_image "${image}")
Expand All @@ -59,7 +55,7 @@ else
fi

# Make sure image actually exists, build if it doesn't
ID=$(${container_mgr} images --filter reference=localhost/"${tag}":"${version}" --format "{{.ID}}")
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${version}-${git_branch}" --format "{{.ID}}")
if [[ -z ${ID} ]]; then
just build "${image}" "${target}" "${version}"
fi
Expand All @@ -83,7 +79,7 @@ ostree refs --repo=\${FLATPAK_SYSTEM_DIR}/repo | grep '^deploy/' | grep -v 'org\
EOF

workspace=${project_root}
if [[ -f /.dockerenv ]]; then
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}
Expand All @@ -97,15 +93,11 @@ if [[ ! -f ${project_root}/${flatpak_dir_shortname}/flatpaks_with_deps ]]; then
-e FLATPAK_TRIGGERSDIR=/flatpak/triggers \
--volume "${FLATPAK_REFS_DIR}":/output \
--volume "${TEMP_FLATPAK_INSTALL_DIR}":/temp_flatpak_install_dir \
"ghcr.io/ublue-os/${ghcr_tag}:${version}" /temp_flatpak_install_dir/script.sh
"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}"

# Remove old ISO if present
rm -f "${project_root}/scripts/files/output/${tag}-${version}.iso"
rm -f "${project_root}/scripts/files/output/${tag}-${version}.iso-CHECKSUM"
7 changes: 6 additions & 1 deletion scripts/get-defaults.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,16 @@ fi
# if no target, base
if [[ -z "${target}" ]]; then
target="base"

# if $2 is numeric, assume that is version and target is base
elif [[ ${target} =~ ^[0-9]+$ ]]; then
version=${target}
target="base"
elif [[ ${target} =~ latest ]]; then
version=${target}
target="base"
elif [[ ${target} =~ gts ]]; then
version=${target}
target="base"
fi

# if no version, bluefin is GTS, Aurora is Latest
Expand Down
2 changes: 1 addition & 1 deletion scripts/list-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ container_mgr=(
for i in "${container_mgr[@]}"; do
if [[ $(command -v "$i") ]]; then
echo "Container Manager: ${i}"
${i} images --filter "reference=localhost/bluefin*-build" --filter "reference=localhost/aurora*-build"
${i} images --filter "reference=localhost/bluefin*-build*" --filter "reference=localhost/aurora*-build*"
echo ""
fi
done
9 changes: 7 additions & 2 deletions scripts/run-booted-guest.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
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=SC2154,SC1091
. "${project_root}/scripts/sudoif.sh"

# Get inputs
image=$1
Expand All @@ -28,7 +33,7 @@ if "${container_mgr}" info | grep Root | grep -q /home; then
fi

# Check to see if image exists, build it if it doesn't
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${version}" --format "{{.ID}}")
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${version}-${git_branch}" --format "{{.ID}}")
if [[ -z ${ID} ]]; then
just build "${image}" "${target}" "${version}"
fi
Expand Down Expand Up @@ -87,4 +92,4 @@ fi
if [[ -z ${project_root} ]]; then
project_root=$(git rev-parse --show-toplevel)
fi
rm -rf "${project_root}/scripts/files/home/ublue-os"
sudoif rm -rf "${project_root}/scripts/files/home/ublue-os"
5 changes: 4 additions & 1 deletion scripts/run-booted-home.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
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
image=$1
Expand All @@ -28,7 +31,7 @@ if "${container_mgr}" info | grep Root | grep -q /home; then
fi

# Check to see if image exists, build it if it doesn't
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${version}" --format "{{.ID}}")
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${version}-${git_branch}" --format "{{.ID}}")
if [[ -z ${ID} ]]; then
just build "${image}" "${target}" "${version}"
fi
Expand Down
Loading

0 comments on commit 4e4ba70

Please sign in to comment.