diff options
author | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-10-25 00:19:45 +0200 |
---|---|---|
committer | Matthias Schiffer <mschiffer@universe-factory.net> | 2021-10-25 00:19:45 +0200 |
commit | 34ac18d20c13a78914d447fee83204811a27b1e4 (patch) | |
tree | 56763d4ea46927105fcc6a71e03d5bd75a6947a6 /crates/runner/src/paths.rs | |
parent | a1a185370da27f2cc3df84d3a8d7141f9ce7db16 (diff) | |
download | rebel-34ac18d20c13a78914d447fee83204811a27b1e4.tar rebel-34ac18d20c13a78914d447fee83204811a27b1e4.zip |
Move runner into separate crate
Diffstat (limited to 'crates/runner/src/paths.rs')
-rw-r--r-- | crates/runner/src/paths.rs | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/crates/runner/src/paths.rs b/crates/runner/src/paths.rs new file mode 100644 index 0000000..632f030 --- /dev/null +++ b/crates/runner/src/paths.rs @@ -0,0 +1,106 @@ +//! Build directory structure used through rebel +//! +//! # Current structure +//! +//! ```text +//! build/ +//! ├── rootfs.tar +//! ├── downloads/ +//! │ └── ... +//! ├── state/ +//! │ ├── output/ +//! │ │ ├── <input hash>.tar.tmp # during packing +//! │ │ ├── <archive hash>.tar # files are renamed when packing is finished +//! │ │ └── ... +//! │ ├── layer/ +//! │ │ ├── <layer hash>/ # overlayfs layer dir of finished tasks +//! │ │ └── ... +//! │ └── task/ +//! │ ├── <input hash>/ +//! │ │ ├── layer/ # overlayfs layer dir (moved to layer/ after build) +//! │ │ ├── work/ # overlayfs work dir (discarded after build) +//! │ │ ├── task.json.tmp # during write +//! │ │ └── task.json # after write +//! │ └── ... +//! └── tmp/ # tmpfs (mounted on start of rebel) +//! ├── rootfs/ # unpacked rootfs.tar +//! └── task/ +//! └── <input hash>/ +//! ├── build/ # mount point for /build directory +//! │ ├── downloads/ # downloaded sources +//! │ ├── dest/ # collected as output after build +//! │ ├── sysroot/ # sysroot mountpoint +//! │ ├── task/ # internal runner files +//! │ └── work/ # build overlay mountpoint +//! ├── rootfs/ # rootfs overlay mountpoint +//! └── depends/ # overlayed on rootfs in container +//! ``` + +use common::string_hash::*; + +pub const ROOTFS_ARCHIVE: &str = "build/rootfs.tar"; + +pub const DOWNLOADS_DIR: &str = "build/downloads"; + +pub const TMP_DIR: &str = "build/tmp"; +pub const ROOTFS_DIR: &str = "build/tmp/rootfs"; +pub const TASK_TMP_DIR: &str = "build/tmp/task"; + +pub const TASK_TMP_ROOTFS_SUBDIR: &str = "rootfs"; +pub const TASK_TMP_DEPENDS_SUBDIR: &str = "depends"; + +pub const OUTPUT_STATE_DIR: &str = "build/state/output"; +pub const TASK_STATE_DIR: &str = "build/state/task"; +pub const LAYER_STATE_DIR: &str = "build/state/layer"; + +pub const TASK_STATE_LAYER_SUBDIR: &str = "layer"; +pub const TASK_STATE_WORK_SUBDIR: &str = "work"; + +pub const TASK_BUILDDIR: &str = "build"; +pub const TASK_DESTDIR: &str = "build/dest"; +pub const TASK_DLDIR: &str = "build/downloads"; +pub const TASK_TASKDIR: &str = "build/task"; +pub const TASK_WORKDIR: &str = "build/work"; +pub const TASK_SYSROOT: &str = "opt/toolchain/sysroot"; + +pub const TASK_RUN: &str = "run"; + +pub fn join(paths: &[&str]) -> String { + paths.join("/") +} + +pub fn abs(path: &str) -> String { + join(&["", path]) +} + +pub fn task_tmp_dir(hash: &InputHash) -> String { + join(&[TASK_TMP_DIR, &hash.to_string()]) +} + +pub fn task_state_dir(hash: &InputHash) -> String { + join(&[TASK_STATE_DIR, &hash.to_string()]) +} + +pub fn task_cache_tmp_filename(hash: &InputHash) -> String { + join(&[TASK_STATE_DIR, &hash.to_string(), "task.json.tmp"]) +} + +pub fn task_cache_filename(hash: &InputHash) -> String { + join(&[TASK_STATE_DIR, &hash.to_string(), "task.json"]) +} + +pub fn task_log_filename(hash: &InputHash) -> String { + join(&[TASK_STATE_DIR, &hash.to_string(), "task.log"]) +} + +pub fn layer_dir(hash: &LayerHash) -> String { + join(&[LAYER_STATE_DIR, &hash.to_string()]) +} + +pub fn archive_tmp_filename(hash: &InputHash) -> String { + join(&[OUTPUT_STATE_DIR, &format!("{}.tar.tmp", hash)]) +} + +pub fn archive_filename(hash: &ArchiveHash) -> String { + join(&[OUTPUT_STATE_DIR, &format!("{}.tar", hash)]) +} |