//! Build directory structure used through rebel
//!
//! # Current structure
//!
//! ```text
//! build/
//! ├── build.lock
//! ├── rootfs.tar
//! ├── downloads/
//! │ └── ...
//! ├── state/
//! │ ├── output/
//! │ │ ├── .tar.tmp # during packing
//! │ │ ├── .tar # files are renamed when packing is finished
//! │ │ └── ...
//! │ ├── layer/
//! │ │ ├── / # overlayfs layer dir of finished tasks
//! │ │ └── ...
//! │ └── task/
//! │ ├── /
//! │ │ ├── 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
//! │ │ ├── task.log # stdout/stderr output of the task
//! │ │ └── task.lock # task lockfile
//! │ └── ...
//! └── tmp/ # temporary files (cleaned on start)
//! ├── rootfs/ # unpacked rootfs.tar
//! └── task/
//! └── /
//! ├── build/ # mount point for /build directory
//! │ ├── downloads/ # downloaded sources
//! │ ├── 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 LOCKFILE: &str = "build/build.lock";
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_TASKDIR: &str = "build/task";
pub const TASK_RUN: &str = "run";
pub fn join(paths: &[&str]) -> String {
paths.join("/")
}
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 task_lock_filename(hash: &InputHash) -> String {
join(&[TASK_STATE_DIR, &hash.to_string(), "task.lock"])
}
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)])
}