generated from ublue-os/base
-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(dev): add justfile for local testing and integration with vscode (…
- Loading branch information
Showing
16 changed files
with
561 additions
and
2 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 +1,3 @@ | ||
.idea | ||
*.iso | ||
*.iso-CHECKSUM* |
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,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": "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": "silverblue", | ||
"options": [ | ||
"silverblue latest", | ||
"kinoite latest", | ||
"sericea latest", | ||
"onyx latest", | ||
"base latest", | ||
"lazurite latest", | ||
"vauxite latest", | ||
"silverblue gts", | ||
"kinoite gts", | ||
"sericea gts", | ||
"onyx gts", | ||
"base gts", | ||
"lazurite gts", | ||
"vauxite gts" | ||
] | ||
} | ||
] | ||
} |
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
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,49 @@ | ||
export project_root := `git rev-parse --show-toplevel` | ||
export git_branch := ` git branch --show-current` | ||
export gts := "39" | ||
export latest := "40" | ||
export default_image := "silverblue" | ||
|
||
alias run := run-container | ||
alias build-iso := build-iso-release | ||
|
||
_default: | ||
@just --list | ||
|
||
_container_mgr: | ||
@{{ project_root }}/just_scripts/container_mgr.sh | ||
|
||
_tag image: | ||
@echo {{image}}-build | ||
|
||
# Build image | ||
build image="" version="": | ||
@{{ project_root }}/just_scripts/build-image.sh {{image}} {{version}} | ||
|
||
# Build ISO | ||
build-iso-release image="" version="": | ||
@{{ project_root }}/just_scripts/build-iso.sh {{image}} {{version}} | ||
|
||
# Build ISO using ISO Builder Git Head | ||
build-iso-git image="" version="": | ||
@{{ project_root }}/just_scripts/build-iso-installer-main.sh {{image}} {{version}} | ||
|
||
# Run ISO | ||
run-iso image="" version="": | ||
@{{ project_root }}/just_scripts/run-iso.sh {{image}} {{version}} | ||
|
||
# Run Container | ||
run-container image="" version="": | ||
@{{ project_root }}/just_scripts/run-image.sh {{image}} {{version}} | ||
|
||
# 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 |
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,29 @@ | ||
#!/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 | ||
image=$1 | ||
version=$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}") | ||
|
||
# Build Image | ||
$container_mgr build -f Containerfile \ | ||
--build-arg="IMAGE_NAME=${tag}" \ | ||
--build-arg="SOURCE_ORG=fedora-ostree-desktops" \ | ||
--build-arg="SOURCE_IMAGE=${image}" \ | ||
--build-arg="FEDORA_MAJOR_VERSION=${version}" \ | ||
--tag localhost/"${tag}:${version}-${git_branch}" \ | ||
"${project_root}" |
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,86 @@ | ||
#!/usr/bin/bash | ||
#shellcheck disable=SC2154,SC2034 | ||
|
||
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 | ||
image=$1 | ||
version=$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}-${version}-${git_branch}.iso" | ||
sudoif rm -f "${project_root}/just_scripts/output/${tag}-${version}-${git_branch}.iso-CHECKSUM" | ||
|
||
# Set variant | ||
if [[ "${image}" =~ "silverblue" ]]; then | ||
variant=Silverblue | ||
else | ||
variant=Kinoite | ||
fi | ||
|
||
if [[ ${container_mgr} =~ "podman" ]]; then | ||
api_socket=/run/podman/podman.sock | ||
elif [[ ${container_mgr} =~ "docker" ]]; then | ||
api_socket=/var/run/docker.sock | ||
fi | ||
|
||
# Make sure image actually exists, build if it doesn't | ||
ID=$(${container_mgr} images --filter reference=localhost/"${tag}:${version}-${git_branch}" --format "{{.ID}}") | ||
if [[ -z ${ID} ]]; then | ||
just build "${image}" "${version}" | ||
fi | ||
|
||
workspace=${project_root} | ||
if [[ -f /.dockerenv || -f /run/.containerenv ]]; then | ||
workspace=${LOCAL_WORKSPACE_FOLDER} | ||
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}"/just_scripts/output:/build-container-installer/build \ | ||
ghcr.io/jasonn3/build-container-installer:main \ | ||
ARCH="x86_64" \ | ||
ENABLE_CACHE_DNF="false" \ | ||
ENABLE_CACHE_SKOPEO="false" \ | ||
ENROLLMENT_PASSWORD="ublue-os" \ | ||
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}" |
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,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 |
Oops, something went wrong.