bob/lib.rs
1/*
2 * Copyright (c) 2025 Jonathan Perkin <jonathan@perkin.org.uk>
3 *
4 * Permission to use, copy, modify, and distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
7 *
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
14 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15 */
16
17//! Bob is a pkgsrc package builder that automates building packages in isolated
18//! sandbox environments with parallel build support, dependency resolution, and
19//! comprehensive reporting.
20//!
21//! # Overview
22//!
23//! Bob provides:
24//!
25//! - Automatic sandbox setup with platform-specific implementations for Linux,
26//! macOS, NetBSD, and illumos
27//! - Dependency scanning and DAG-based resolution for correct build ordering
28//! - Parallel scans and builds in separate sandboxes
29//! - Terminal UI showing real-time build progress
30//! - HTML reports of build results
31//! - Lua-based configuration for flexibility
32//!
33//! # Quick Start
34//!
35//! ```console
36//! $ bob init /path/to/config # Create configuration directory
37//! $ cd /path/to/config
38//! $ vi config.lua # Customise to taste
39//! $ bob build # Build packages
40//! ```
41//!
42//! # Modules
43//!
44//! - [`action`] - Sandbox action types for configuring filesystem mounts, copies,
45//! symlinks, and custom commands
46//! - [`build`] - Parallel package builds and result types
47//! - [`config`] - Configuration file parsing (Lua format)
48//! - [`report`] - HTML build report generation
49//! - [`sandbox`] - Sandbox creation, execution, and management
50//! - [`scan`] - Package dependency scanning and resolution
51//!
52//! # Configuration
53//!
54//! Bob uses Lua configuration files. See the [`config`] module for details on
55//! configuration options. The default file generated by `bob init` is
56//! designed to work out of the box with minimal changes on supported operating
57//! systems, but you are likely to want to customise it further.
58
59pub mod action;
60pub mod build;
61pub mod config;
62pub mod report;
63pub mod sandbox;
64pub mod scan;
65pub mod stats;
66
67// Internal modules - exposed for binary use but not primary API
68mod init;
69pub mod logging;
70mod status;
71mod tui;
72
73use std::sync::Arc;
74use std::sync::atomic::AtomicBool;
75
76/// Shared context for a build or scan run.
77pub struct RunContext {
78 /// Optional stats collector for performance metrics.
79 pub stats: Option<Arc<stats::Stats>>,
80 /// Flag to signal graceful shutdown.
81 pub shutdown: Arc<AtomicBool>,
82}
83
84impl RunContext {
85 pub fn new(shutdown: Arc<AtomicBool>) -> Self {
86 Self { stats: None, shutdown }
87 }
88
89 pub fn with_stats(mut self, stats: Arc<stats::Stats>) -> Self {
90 self.stats = Some(stats);
91 self
92 }
93}
94
95// Re-export main types for convenience
96pub use action::{Action, ActionType, FSType};
97pub use build::{Build, BuildOutcome, BuildResult, BuildSummary};
98pub use config::{Config, Options, Pkgsrc, Sandboxes};
99pub use report::write_html_report;
100pub use sandbox::Sandbox;
101pub use scan::{
102 ResolvedIndex, Scan, ScanFailure, ScanResult, SkipReason, SkippedPackage,
103};
104pub use stats::Stats;
105
106// Re-export init for CLI use
107pub use init::Init;