feat: Implement build state tracking and interactive package specification creation
- Added StateTracker to manage build steps and allow resuming interrupted builds. - Updated post_extract function to utilize StateTracker for patch and command execution. - Introduced makefile.rs to handle building and installing packages via Makefile. - Created interactive.rs for an interactive package specification creator with SHA256 computation for source URLs. - Enhanced checksum verification to support multiple algorithms (SHA256, SHA512, MD5). - Added example configuration files in contrib for system-wide and user-level Depot configurations. - Updated tests to cover new functionality and ensure correctness of state tracking and interactive creation.
This commit is contained in:
@@ -40,3 +40,71 @@ pub fn build(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::package::{Build, BuildFlags, BuildType, Dependencies, PackageInfo};
|
||||
use tempfile::tempdir;
|
||||
use std::fs;
|
||||
use std::os::unix::fs as unix_fs;
|
||||
|
||||
fn mk_spec(name: &str, version: &str) -> PackageSpec {
|
||||
PackageSpec {
|
||||
package: PackageInfo {
|
||||
name: name.into(),
|
||||
version: version.into(),
|
||||
revision: 1,
|
||||
description: "d".into(),
|
||||
homepage: "h".into(),
|
||||
license: "MIT".into(),
|
||||
},
|
||||
packages: Vec::new(),
|
||||
alternatives: Default::default(),
|
||||
manual_sources: Vec::new(),
|
||||
source: vec![crate::package::Source {
|
||||
url: "h".into(),
|
||||
sha256: "s".into(),
|
||||
extract_dir: "e".into(),
|
||||
patches: Vec::new(),
|
||||
post_extract: Vec::new(),
|
||||
}],
|
||||
build: Build {
|
||||
build_type: BuildType::Bin,
|
||||
flags: BuildFlags::default(),
|
||||
},
|
||||
dependencies: Dependencies::default(),
|
||||
spec_dir: std::path::PathBuf::from("."),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_bin_build_copies_files_and_symlinks() -> Result<()> {
|
||||
let tmp_src = tempdir()?;
|
||||
let tmp_dest = tempdir()?;
|
||||
let src = tmp_src.path();
|
||||
let dest = tmp_dest.path();
|
||||
|
||||
// Create a directory and files
|
||||
fs::create_dir_all(src.join("usr/bin"))?;
|
||||
fs::write(src.join("usr/bin/hello"), b"hi")?;
|
||||
|
||||
// Create a symlink
|
||||
let target = src.join("usr/lib/libdummy.so");
|
||||
fs::create_dir_all(target.parent().unwrap())?;
|
||||
fs::write(&target, b"lib")?;
|
||||
unix_fs::symlink(&target, src.join("usr/lib/libdummy.so.link"))?;
|
||||
|
||||
let spec = mk_spec("bin-test", "1.0");
|
||||
build(&spec, src, dest, None)?;
|
||||
|
||||
// Check copied file
|
||||
assert!(dest.join("usr/bin/hello").exists());
|
||||
|
||||
// Check symlink target exists at dest
|
||||
let link_path = dest.join("usr/lib/libdummy.so.link");
|
||||
assert!(link_path.exists());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user