-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add cache module & refactor away client
- Loading branch information
Showing
11 changed files
with
273 additions
and
94 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,71 @@ | ||
// SPDX-FileCopyrightText: Copyright © 2020-2023 Serpent OS Developers | ||
// | ||
// SPDX-License-Identifier: MPL-2.0 | ||
|
||
use std::path::PathBuf; | ||
|
||
use stone_recipe::Recipe; | ||
|
||
struct Id(String); | ||
|
||
impl Id { | ||
fn new(recipe: &Recipe) -> Self { | ||
Self(format!( | ||
"{}-{}-{}", | ||
recipe.source.name, recipe.source.version, recipe.source.release | ||
)) | ||
} | ||
} | ||
|
||
pub struct Cache { | ||
id: Id, | ||
host_root: PathBuf, | ||
guest_root: PathBuf, | ||
} | ||
|
||
impl Cache { | ||
pub fn new( | ||
recipe: &Recipe, | ||
host_root: impl Into<PathBuf>, | ||
guest_root: impl Into<PathBuf>, | ||
) -> Self { | ||
Self { | ||
id: Id::new(recipe), | ||
host_root: host_root.into(), | ||
guest_root: guest_root.into(), | ||
} | ||
} | ||
|
||
pub fn rootfs(&self) -> Mapping { | ||
Mapping { | ||
host: self.host_root.join("root").join(&self.id.0), | ||
guest: "/".into(), | ||
} | ||
} | ||
|
||
pub fn artefacts(&self) -> Mapping { | ||
Mapping { | ||
host: self.host_root.join("artefacts").join(&self.id.0), | ||
guest: self.guest_root.join("artefacts"), | ||
} | ||
} | ||
|
||
pub fn build(&self) -> Mapping { | ||
Mapping { | ||
host: self.host_root.join("build").join(&self.id.0), | ||
guest: self.guest_root.join("build"), | ||
} | ||
} | ||
|
||
pub fn ccache(&self) -> Mapping { | ||
Mapping { | ||
host: self.host_root.join("ccache"), | ||
guest: self.guest_root.join("ccache"), | ||
} | ||
} | ||
} | ||
|
||
pub struct Mapping { | ||
pub host: PathBuf, | ||
pub guest: PathBuf, | ||
} |
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
Oops, something went wrong.