feat(dev): improve just commands (#1297)
Co-authored-by: Jorge O. Castro <jorge.castro@gmail.com>
This commit is contained in:
parent
07cbac3ca6
commit
6b38313476
15 changed files with 222 additions and 36 deletions
108
.vscode/tasks.json
vendored
Normal file
108
.vscode/tasks.json
vendored
Normal file
|
|
@ -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"
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
13
Justfile
13
Justfile
|
|
@ -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"
|
||||
|
||||
|
|
@ -21,9 +22,9 @@ 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 || { exit 1; }
|
||||
just --unstable --fmt --check -f $file
|
||||
done
|
||||
just --unstable --fmt --check -f ${project_root}/Justfile || { exit 1; }
|
||||
just --unstable --fmt --check -f ${project_root}/Justfile
|
||||
|
||||
# Fix Just Syntax
|
||||
[private]
|
||||
|
|
@ -31,9 +32,9 @@ 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
|
||||
just --unstable --fmt -f ${project_root}/Justfile || { exit 1; }
|
||||
just --unstable --fmt -f ${project_root}/Justfile
|
||||
|
||||
# Build Image
|
||||
build image="" target="" version="":
|
||||
|
|
@ -55,6 +56,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 }}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
scripts/build-iso-installer-main.sh
Normal file
40
scripts/build-iso-installer-main.sh
Normal file
|
|
@ -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}"
|
||||
|
|
@ -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
|
||||
|
|
@ -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}"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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}")
|
||||
|
|
@ -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
|
||||
|
|
@ -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}
|
||||
|
|
@ -97,7 +93,7 @@ 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
|
||||
|
|
@ -105,7 +101,3 @@ 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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
set -eo pipefail
|
||||
|
||||
# Get Inputs
|
||||
|
|
@ -18,10 +21,10 @@ container_mgr=$(just _container_mgr)
|
|||
tag=$(just _tag "${image}" "${target}")
|
||||
|
||||
# Check if requested image exist, if it doesn't build it
|
||||
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
|
||||
|
||||
# Run image
|
||||
"${container_mgr}" run -it --rm localhost/"${tag}":"${version}" /usr/bin/bash
|
||||
"${container_mgr}" run -it --rm localhost/"${tag}:${version}-${git_branch}" /usr/bin/bash
|
||||
|
|
|
|||
|
|
@ -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
|
||||
set -eo pipefail
|
||||
|
||||
# Get Inputs
|
||||
|
|
@ -18,7 +21,7 @@ container_mgr=$(just _container_mgr)
|
|||
tag=$(just _tag "${image}" "${target}")
|
||||
|
||||
#check if ISO exists. Create if it doesn't
|
||||
if [[ ! -f "${project_root}/scripts/files/output/${tag}-${version}.iso" ]]; then
|
||||
if [[ ! -f "${project_root}/scripts/files/output/${tag}-${version}-${git_branch}.iso" ]]; then
|
||||
just build-iso "$image" "$target" "$version"
|
||||
fi
|
||||
|
||||
|
|
@ -34,5 +37,5 @@ ${container_mgr} run --rm --cap-add NET_ADMIN \
|
|||
--env "DISK_SIZE=64G" \
|
||||
--env "BOOT_MODE=uefi" \
|
||||
--device=/dev/kvm \
|
||||
--volume "${workspace}/scripts/files/output/${tag}-${version}.iso":/boot.iso \
|
||||
--volume "${workspace}/scripts/files/output/${tag}-${version}-${git_branch}.iso":/boot.iso \
|
||||
docker.io/qemux/qemu-docker
|
||||
|
|
|
|||
14
scripts/sudoif.sh
Normal file
14
scripts/sudoif.sh
Normal 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…
Reference in a new issue