Skip to content

Commit

Permalink
refactor!: Rename template to generate and move rebase/upgrade
Browse files Browse the repository at this point in the history
…under `switch` (#116)

This updates the `template` subcommand to be `generate`. The `template`
usage will continue to work as an alias to `generate`. A new `switch`
command is added that will manage both `rpm-ostree rebase` and
`rpm-ostree upgrade` and is fully replacing the respective subcommands
as a breaking change.

The new `switch` command is under the feature flag `switch` and will
currently only build for the `main` branch builds until it is moved as a
default feature (`v0.9.0`).

Closes #159
  • Loading branch information
gmpinder authored May 27, 2024
1 parent 968cf3d commit 02b2fe5
Show file tree
Hide file tree
Showing 21 changed files with 672 additions and 62 deletions.
2 changes: 1 addition & 1 deletion .helix/languages.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[language-server.rust-analyzer.config]
cargo.features = []
cargo.features = "all"

[language-server.rust-analyzer.config.check]
command = "clippy"
Expand Down
71 changes: 64 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 17 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,18 @@ version = "0.8.9"

[workspace.dependencies]
anyhow = "1"
chrono = "0.4.35"
chrono = "0.4"
clap = { version = "4", features = ["derive", "cargo", "unicode"] }
colored = "2.1.0"
colored = "2"
env_logger = "0.11"
format_serde_error = "0.3.0"
format_serde_error = "0.3"
indexmap = { version = "2", features = ["serde"] }
log = "0.4"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
serde_yaml = "0.9.30"
typed-builder = "0.18.1"
uuid = { version = "1.7.0", features = ["v4"] }
serde_yaml = "0.9"
typed-builder = "0.18"
uuid = { version = "1", features = ["v4"] }

[workspace.lints.rust]
unsafe_code = "forbid"
Expand Down Expand Up @@ -59,22 +60,24 @@ clap-verbosity-flag = "2"
clap_complete = "4"
clap_complete_nushell = "4"
fuzzy-matcher = "0.3"
lenient_semver = "0.4.2"
once_cell = "1.19.0"
lenient_semver = "0.4"
once_cell = "1"
open = "5"
os_info = "3.7" # update os module config and tests when upgrading os_info
os_info = "3"
requestty = { version = "0.5", features = ["macros", "termion"] }
semver = { version = "1.0.22", features = ["serde"] }
semver = { version = "1", features = ["serde"] }
shadow-rs = "0.26"
urlencoding = "2.1.3"
users = "0.11.0"
tempdir = "0.3"
urlencoding = "2"
users = "0.11"

# Workspace dependencies
anyhow.workspace = true
chrono.workspace = true
clap.workspace = true
colored.workspace = true
env_logger.workspace = true
indexmap.workspace = true
log.workspace = true
serde.workspace = true
serde_json.workspace = true
Expand All @@ -86,13 +89,13 @@ uuid.workspace = true
default = []
stages = ["blue-build-recipe/stages"]
copy = ["blue-build-recipe/copy"]
switch = []

[dev-dependencies]
rusty-hook = "0.11.2"
rusty-hook = "0.11"

[build-dependencies]
shadow-rs = "0.26"
dunce = "1.0.4"

[lints]
workspace = true
Expand Down
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,18 @@ sudo bluebuild upgrade recipes/recipe.yml

The `--reboot` argument can be used with this command as well.

##### Switch

> NOTE: This is an unstable feature and can only be used when installing from the `main` image or with the `switch` feature flag when compiling.
With the switch command, you can build and boot an image locally using an `oci-archive` tarball. The `switch` command can be run as a normal user and will only ask for `sudo` permissions when moving the archive into `/etc/bluebuild`.

```bash
bluebuild switch recipes/recipe.yml
```

You can initiate an immediate restart by adding the `--reboot/-r` option.

#### CI Builds

##### GitHub
Expand Down
23 changes: 16 additions & 7 deletions integration-tests/Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ all:
BUILD +build
BUILD +rebase
BUILD +upgrade
BUILD +switch

test-image:
FROM +build-template --src=template-containerfile
Expand Down Expand Up @@ -45,7 +46,7 @@ build-template:

template-containerfile:
FROM +test-base
RUN bluebuild -vv template recipes/recipe.yml | tee Containerfile
RUN bluebuild -vv generate recipes/recipe.yml | tee Containerfile

SAVE ARTIFACT /test

Expand All @@ -57,13 +58,13 @@ template-legacy-containerfile:

template-secureblue:
FROM +secureblue-base
RUN bluebuild -vv template -o Containerfile recipes/general/recipe-silverblue-nvidia.yml
RUN bluebuild -vv generate -o Containerfile recipes/general/recipe-silverblue-nvidia.yml

SAVE ARTIFACT /test

template-secureblue-ucore:
FROM +secureblue-base
RUN bluebuild -vv template -o Containerfile recipes/server/recipe-server-main.yml
RUN bluebuild -vv generate -o Containerfile recipes/server/recipe-server-main.yml

SAVE ARTIFACT /test

Expand All @@ -73,15 +74,21 @@ build:
RUN bluebuild -vv build recipes/recipe.yml

rebase:
FROM +test-base
FROM +legacy-base

RUN bluebuild -vv rebase recipes/recipe.yml
RUN bluebuild -vv rebase config/recipe.yml

upgrade:
FROM +legacy-base

RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
RUN bluebuild -vv upgrade config/recipe.yml

switch:
FROM +test-base

RUN mkdir -p /etc/bluebuild && touch $BB_TEST_LOCAL_IMAGE
RUN bluebuild -vv upgrade recipes/recipe.yml
RUN bluebuild -vv switch recipes/recipe.yml

secureblue-base:
FROM +test-base
Expand All @@ -93,7 +100,8 @@ secureblue-base:

legacy-base:
FROM ../+blue-build-cli-alpine
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test.tar.gz
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test-legacy.tar.gz
ENV CLICOLOR_FORCE=1

COPY ./mock-scripts/ /usr/bin/
Expand All @@ -107,6 +115,7 @@ legacy-base:

test-base:
FROM ../+blue-build-cli-alpine
RUN apk update --no-cache && apk add bash grep jq sudo coreutils
ENV BB_TEST_LOCAL_IMAGE=/etc/bluebuild/cli_test.tar.gz
ENV CLICOLOR_FORCE=1

Expand Down
7 changes: 6 additions & 1 deletion integration-tests/mock-scripts/buildah
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

print_version_json() {
local version="1.24.0"
Expand All @@ -8,6 +8,11 @@ print_version_json() {
main() {
if [[ "$1" == "version" && "$2" == "--json" ]]; then
print_version_json
elif [[ "$1" == "build" && "$6" == *"cli_test.tar.gz" ]]; then
tarpath=$(echo "$6" | awk -F ':' '{print $2}')
echo "Exporting image to a tarball (JK JUST A MOCK!)"
echo "${tarpath}"
touch $tarpath
else
echo 'Running buildah'
fi
Expand Down
7 changes: 6 additions & 1 deletion integration-tests/mock-scripts/podman
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash

print_version_json() {
local version="4.0.0"
Expand All @@ -8,6 +8,11 @@ print_version_json() {
main() {
if [[ "$1" == "version" && "$2" == "-f" && "$3" == "json" ]]; then
print_version_json
elif [[ "$1" == "build" && "$6" == *"cli_test.tar.gz" ]]; then
tarpath=$(echo "$6" | awk -F ':' '{print $2}')
echo "Exporting image to a tarball (JK JUST A MOCK!)"
echo "${tarpath}"
touch $tarpath
else
echo 'Running podman'
fi
Expand Down
21 changes: 18 additions & 3 deletions integration-tests/mock-scripts/rpm-ostree
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/sh
#!/bin/bash

set -euo pipefail

echo 'Running rpm-ostree'

if [ "$1" = "rebase" ]; then
if [ "$2" = "ostree-unverified-image:oci-archive:$BB_TEST_LOCAL_IMAGE" ]; then
echo "Rebased to local image $BB_TEST_LOCAL_IMAGE"
Expand All @@ -13,6 +11,23 @@ if [ "$1" = "rebase" ]; then
fi
elif [ "$1" = "upgrade" ]; then
echo "Performing upgrade for $BB_TEST_LOCAL_IMAGE"
elif [ "$1" = "status" ]; then
cat <<EOF
{
"deployments": [
{
"container-image-reference": "ostree-image-signed:docker://ghcr.io/blue-build/cli/test",
"booted": true,
"staged": false
},
{
"container-image-reference": "ostree-image-signed:docker://ghcr.io/blue-build/cli/test:last",
"booted": false,
"staged": false
}
]
}
EOF
else
echo "Arg $1 is not recognized"
exit 1
Expand Down
4 changes: 2 additions & 2 deletions recipe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ license.workspace = true

[dependencies]
blue-build-utils = { version = "=0.8.9", path = "../utils" }
chrono = "0.4"
indexmap = { version = "2", features = ["serde"] }

anyhow.workspace = true
chrono.workspace = true
colored.workspace = true
log.workspace = true
indexmap.workspace = true
serde.workspace = true
serde_yaml.workspace = true
serde_json.workspace = true
Expand Down
Loading

0 comments on commit 02b2fe5

Please sign in to comment.