-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #270 from jmt-lab/ootb/external-kits/download
twoliter: fetch command for downloading and extracting external kits
- Loading branch information
Showing
12 changed files
with
511 additions
and
98 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,13 @@ | ||
[package] | ||
name = "buildsys-config" | ||
version = "0.1.0" | ||
authors = ["Jarrett Tierney <[email protected]>"] | ||
license = "MIT OR Apache-2.0" | ||
edition = "2021" | ||
publish = false | ||
# Don't rebuild crate just because of changes to README. | ||
exclude = ["README.md"] | ||
|
||
[dependencies] | ||
anyhow = "1" | ||
serde = { version = "1", features = ["derive"]} |
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,33 @@ | ||
use anyhow::anyhow; | ||
use serde::Deserialize; | ||
use std::fmt::{Display, Formatter}; | ||
|
||
pub const EXTERNAL_KIT_DIRECTORY: &str = "build/external-kits"; | ||
pub const EXTERNAL_KIT_METADATA: &str = "build/external-kits/external-kit-metadata.json"; | ||
|
||
#[derive(Deserialize, Debug, Clone, PartialEq)] | ||
pub enum DockerArchitecture { | ||
Amd64, | ||
Arm64, | ||
} | ||
|
||
impl TryFrom<&str> for DockerArchitecture { | ||
type Error = anyhow::Error; | ||
|
||
fn try_from(value: &str) -> std::result::Result<Self, Self::Error> { | ||
match value { | ||
"x86_64" | "amd64" => Ok(DockerArchitecture::Amd64), | ||
"aarch64" | "arm64" => Ok(DockerArchitecture::Arm64), | ||
_ => Err(anyhow!("invalid architecture '{}'", value)), | ||
} | ||
} | ||
} | ||
|
||
impl Display for DockerArchitecture { | ||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result { | ||
f.write_str(match self { | ||
Self::Amd64 => "amd64", | ||
Self::Arm64 => "arm64", | ||
}) | ||
} | ||
} |
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
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
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,24 @@ | ||
use crate::lock::Lock; | ||
use crate::project; | ||
use anyhow::Result; | ||
use clap::Parser; | ||
use std::path::PathBuf; | ||
|
||
#[derive(Debug, Parser)] | ||
pub(crate) struct Fetch { | ||
/// Path to Twoliter.toml. Will search for Twoliter.toml when absent | ||
#[clap(long = "project-path")] | ||
project_path: Option<PathBuf>, | ||
|
||
#[clap(long = "arch", default_value = "x86_64")] | ||
arch: String, | ||
} | ||
|
||
impl Fetch { | ||
pub(super) async fn run(&self) -> Result<()> { | ||
let project = project::load_or_find_project(self.project_path.clone()).await?; | ||
let lock_file = Lock::load(&project).await?; | ||
lock_file.fetch(&project, self.arch.as_str()).await?; | ||
Ok(()) | ||
} | ||
} |
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
Oops, something went wrong.