summaryrefslogtreecommitdiffstats
path: root/crates/runner/src/paths.rs
blob: ac0d7586e7a4602bd264c28d3d5eec7ab277cdc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//! Build directory structure used through rebel
//!
//! # Current structure
//!
//! ```text
//! build/
//! ├── build.lock
//! ├── 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
//! │       │   ├── task.log          # stdout/stderr output of the task
//! │       │   └── task.lock         # task lockfile
//! │       └── ...
//! └── tmp/                          # temporary files (cleaned on start)
//!     ├── rootfs/                   # unpacked rootfs.tar
//!     └── task/
//!         └── <input hash>/
//!             ├── 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)])
}