From 073ad4ca4a1d7e41583b4b0dcceb2a84a13f5a73 Mon Sep 17 00:00:00 2001 From: Gerald Pinder Date: Sat, 14 Oct 2023 14:54:44 -0400 Subject: [PATCH] Put init and build behind feature flags --- src/bin/ublue.rs | 8 +++--- src/init.rs | 3 +++ src/lib.rs | 5 ++++ templates/init/recipe.yml | 53 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 3 deletions(-) create mode 100644 src/init.rs create mode 100644 templates/init/recipe.yml diff --git a/src/bin/ublue.rs b/src/bin/ublue.rs index be2963d..b78fad2 100644 --- a/src/bin/ublue.rs +++ b/src/bin/ublue.rs @@ -2,7 +2,7 @@ use std::path::PathBuf; use anyhow::Result; use clap::Parser; -use ublue_rs::{initialize_directory, setup_tera, CommandArgs, UblueArgs}; +use ublue_rs::{self, CommandArgs, UblueArgs}; fn main() -> Result<()> { let args = UblueArgs::parse(); @@ -13,7 +13,7 @@ fn main() -> Result<()> { containerfile, output, } => { - let (tera, context) = setup_tera(recipe, containerfile)?; + let (tera, context) = ublue_rs::setup_tera(recipe, containerfile)?; let output_str = tera.render("Containerfile", &context)?; if let Some(output) = output { std::fs::write(output, output_str)?; @@ -21,14 +21,16 @@ fn main() -> Result<()> { println!("{output_str}"); } } + #[cfg(init)] CommandArgs::Init { dir } => { let base_dir = match dir { Some(dir) => dir, None => PathBuf::from("./"), }; - initialize_directory(base_dir); + ublue_rs::initialize_directory(base_dir); } + #[cfg(build)] CommandArgs::Build { containerfile: _ } => { println!("Not yet implemented!"); todo!(); diff --git a/src/init.rs b/src/init.rs new file mode 100644 index 0000000..cb9d6c8 --- /dev/null +++ b/src/init.rs @@ -0,0 +1,3 @@ +const GITLAB_CI_FILE: &'static str = include_str!("../templates/init/gitlab-ci.yml"); +const RECIPE_FILE: &'static str = include_str!("../templates/init/recipe.yml"); +const LICENSE_FILE: &'static str = include_str!("../LICENSE"); diff --git a/src/lib.rs b/src/lib.rs index e693a18..9bc47ba 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -12,6 +12,8 @@ use tera::{from_value, Context, Tera}; pub const DEFAULT_CONTAINERFILE: &'static str = include_str!("../templates/starting_point.template"); +#[cfg(init)] +pub mod init; pub mod recipe; #[derive(Parser, Debug)] @@ -39,6 +41,7 @@ pub enum CommandArgs { }, /// Initialize a new Ublue Starting Point repo + #[cfg(init)] Init { /// The directory to extract the files into. Defaults to the current directory #[arg()] @@ -46,6 +49,7 @@ pub enum CommandArgs { }, /// Build an image from a Containerfile + #[cfg(build)] Build { #[arg()] containerfile: String, @@ -115,6 +119,7 @@ pub fn setup_tera(recipe: String, containerfile: Option) -> Result<(Ter Ok((tera, context)) } +#[cfg(init)] pub fn initialize_directory(base_dir: PathBuf) { let recipe_path = base_dir.join("recipe.yml"); diff --git a/templates/init/recipe.yml b/templates/init/recipe.yml new file mode 100644 index 0000000..7daeb74 --- /dev/null +++ b/templates/init/recipe.yml @@ -0,0 +1,53 @@ +# image will be published to ghcr.io// +name: startingpoint +# description will be included in the image's metadata +description: A starting point for further customization of uBlue images. Make your own! https://ublue.it/making-your-own/ + +# the base image to build on top of (FROM) and the version tag to use +base-image: ghcr.io/ublue-os/silverblue-main +image-version: 38 # latest is also supported if you want new updates ASAP + +# module configuration, executed in order +# you can include multiple instances of the same module +modules: + - type: files + files: + - usr: /usr # copy static configurations + # + # copies config/files/usr into your image's /usr + # + # configuration you wish to end up in /etc/ on the booted system + # should be added into /usr/etc/ as that is the proper "distro" + # config directory on ostree. Read more in the files module's README + + - type: rpm-ostree + repos: + # - https://copr.fedorainfracloud.org/coprs/atim/starship/repo/fedora-%OS_VERSION%/atim-starship-fedora-%OS_VERSION%.repo + install: + # - micro + # - starship + remove: + - firefox # default firefox removed in favor of flatpak + - firefox-langpacks # langpacks needs to also be removed to prevent dependency problems + + - type: bling # configure what to pull in from ublue-os/bling + install: + - justfiles # add "!include /usr/share/ublue-os/just/bling.just" + # in your custom.just (added by default) or local justfile + - nix-installer # shell shortcuts for determinate system's nix installers + - ublue-os-wallpapers + # - ublue-update # https://github.com/ublue-os/ublue-update + # - dconf-update-service # a service unit that updates the dconf db on boot + # - devpod # https://devpod.sh/ as an rpm + + + - type: yafti # if included, yafti and it's dependencies (pip & libadwaita) + # will be installed and set up + custom-flatpaks: # this section is optional + # - Celluloid: io.github.celluloid_player.Celluloid + # - Krita: org.kde.krita + + - type: script + scripts: + # this sets up the proper policy & signing files for signed images to work + - signing.sh