From acaa5c69e33271f2cdd2bd64396d97a97a202931 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20K=C3=B6hl?= Date: Wed, 6 Dec 2023 21:04:42 +0100 Subject: [PATCH] chore: add update task to update `run-bakery` --- crates/rugpi-bakery/assets/run-bakery | 24 ++++++++++++++++++++++++ crates/rugpi-bakery/src/main.rs | 5 +++++ xtask/src/main.rs | 2 +- 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100755 crates/rugpi-bakery/assets/run-bakery diff --git a/crates/rugpi-bakery/assets/run-bakery b/crates/rugpi-bakery/assets/run-bakery new file mode 100755 index 0000000..759d857 --- /dev/null +++ b/crates/rugpi-bakery/assets/run-bakery @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -euo pipefail + +DOCKER=${DOCKER:-"docker"} +DOCKER_FLAGS=${DOCKER_FLAGS:-""} + +RUGPI_DEV=${RUGPI_DEV:-"false"} + +if [ "${RUGPI_DEV}" = "false" ]; then + DOCKER_FLAGS="${DOCKER_FLAGS} --pull always" + RUGPI_VERSION=${RUGPI_VERSION:-"v0"} +else + RUGPI_VERSION=${RUGPI_VERSION:-"dev"} +fi + +RUGPI_BAKERY_IMAGE=${RUGPI_BAKERY_IMAGE:-"ghcr.io/silitics/rugpi-bakery:${RUGPI_VERSION}"} + +exec $DOCKER run --rm --privileged \ + $DOCKER_FLAGS \ + -v "$(pwd)":/project \ + -v /dev:/dev \ + "${RUGPI_BAKERY_IMAGE}" \ + "$@" diff --git a/crates/rugpi-bakery/src/main.rs b/crates/rugpi-bakery/src/main.rs index c199558..56ee4b4 100644 --- a/crates/rugpi-bakery/src/main.rs +++ b/crates/rugpi-bakery/src/main.rs @@ -36,6 +36,7 @@ pub enum Task { Bake(BakeTask), /// Spawn a shell in the Rugpi Bakery Docker container. Shell, + Update, } fn main() -> Anyhow<()> { @@ -54,6 +55,10 @@ fn main() -> Anyhow<()> { let zsh_prog = CString::new("/bin/zsh")?; nix::unistd::execv::<&CStr>(&zsh_prog, &[])?; } + Task::Update => { + println!("Update Rugpi Bakery..."); + std::fs::write("run-bakery", include_str!("../assets/run-bakery"))?; + } } Ok(()) } diff --git a/xtask/src/main.rs b/xtask/src/main.rs index c1bcdfb..116d009 100644 --- a/xtask/src/main.rs +++ b/xtask/src/main.rs @@ -31,7 +31,7 @@ fn main() -> anyhow::Result<()> { "docker", "build", "-t", - "ghcr.io/silitics/rugpi-bakery:latest", + "ghcr.io/silitics/rugpi-bakery:dev", "-f", "docker/Dockerfile.rugpi-bakery", "."