Simplify PkgTreeError struct and consolidate error handling logic across main.rs. Update OmniOS workflows and Vagrantfile to include additional libraries and improve configuration consistency.

This commit is contained in:
Till Wegmueller 2026-01-18 17:05:59 +01:00
parent 0e873ee114
commit d763bf1c34
No known key found for this signature in database
4 changed files with 26 additions and 31 deletions

View file

@ -15,8 +15,12 @@ jobs:
uses: vmactions/omnios-vm@v1
with:
prepare: |
pkg install -v ooce/developer/rust ooce/omnios-build-tools ooce/util/jq
pkg set-publisher -g https://pkg.omnios.org/r151056/extra/ extra.omnios
pkg install -v ooce/developer/rust ooce/omnios-build-tools ooce/util/jq library/zlib library/lz4
run: |
# Set environment variables for native libraries
export CFLAGS="-m64"
export LDFLAGS="-m64"
cargo build --release
mkdir -p artifacts
cp target/release/pkg6 artifacts/

View file

@ -96,8 +96,12 @@ jobs:
uses: vmactions/omnios-vm@v1
with:
prepare: |
pkg install -v ooce/developer/rust ooce/omnios-build-tools ooce/util/jq
pkg set-publisher -g https://pkg.omnios.org/r151056/extra/ extra.omnios
pkg install -v ooce/developer/rust ooce/omnios-build-tools ooce/util/jq library/zlib library/lz4
run: |
# Set environment variables for native libraries
export CFLAGS="-m64"
export LDFLAGS="-m64"
cargo run -p xtask -- build
cargo run -p xtask -- build -r
- name: Upload build artifacts

11
Vagrantfile vendored
View file

@ -1,7 +1,7 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "openindiana/hipster"
config.vm.box = "omnios/stable"
config.vm.synced_folder ".", "/vagrant", type: "rsync",
rsync__exclude: [".git/", "target/"]
@ -16,9 +16,12 @@ Vagrant.configure("2") do |config|
config.vm.provision "shell", inline: <<-SHELL
set -ex
pkg install -v developer/lang/rustc build-essential jq
mkdir /ws
pkg set-publisher -g https://pkg.omnios.org/r151056/extra/ extra.omnios
pkg install -v developer/lang/rustc build-essential jq library/zlib library/lz4
mkdir -p /ws
chown vagrant:vagrant /ws
zfs create -o mountpoint=/zones rpool/zones
if ! zfs list rpool/zones > /dev/null 2>&1; then
zfs create -o mountpoint=/zones rpool/zones
fi
SHELL
end

View file

@ -81,14 +81,12 @@ impl std::fmt::Display for OutputFormat {
}
#[derive(Error, Debug, Diagnostic)]
#[error("pkgtree error: {message}")]
#[error("pkgtree error: {0}")]
#[diagnostic(
code(ips::pkgtree_error),
help("See logs with RUST_LOG=pkgtree=debug for more details.")
)]
struct PkgTreeError {
message: String,
}
struct PkgTreeError(String);
#[derive(Debug, Clone)]
struct Edge {
@ -133,9 +131,7 @@ fn main() -> Result<()> {
tracing_subscriber::fmt().with_env_filter(env_filter).init();
// Load image
let image = Image::load(&cli.image_path).map_err(|e| PkgTreeError {
message: format!("Failed to load image at {:?}: {}", cli.image_path, e),
})?;
let image = Image::load(&cli.image_path).map_err(|e| PkgTreeError(format!("Failed to load image at {:?}: {}", cli.image_path, e)))?;
// Targeted analysis of solver error file has top priority if provided
if let Some(err_path) = &cli.solver_error_file {
@ -166,13 +162,9 @@ fn main() -> Result<()> {
let mut pkgs = if let Some(ref needle) = cli.package {
image
.query_catalog(Some(needle.as_str()))
.map_err(|e| PkgTreeError {
message: format!("Failed to query catalog: {}", e),
})?
.map_err(|e| PkgTreeError(format!("Failed to query catalog: {}", e)))?
} else {
image.query_catalog(None).map_err(|e| PkgTreeError {
message: format!("Failed to query catalog: {}", e),
})?
image.query_catalog(None).map_err(|e| PkgTreeError(format!("Failed to query catalog: {}", e)))?
};
// Filter by publisher if specified
@ -773,9 +765,7 @@ fn query_catalog_cached_mut(
return Ok(v.clone());
}
let mut out = Vec::new();
for p in image.query_catalog(Some(stem)).map_err(|e| PkgTreeError {
message: format!("Failed to query catalog for {}: {}", stem, e),
})? {
for p in image.query_catalog(Some(stem)).map_err(|e| PkgTreeError(format!("Failed to query catalog for {}: {}", stem, e)))? {
out.push((p.publisher, p.fmri));
}
ctx.catalog_cache.insert(stem.to_string(), out.clone());
@ -793,9 +783,7 @@ fn get_manifest_cached(
}
let manifest_opt = image
.get_manifest_from_catalog(fmri)
.map_err(|e| PkgTreeError {
message: format!("Failed to load manifest for {}: {}", fmri.to_string(), e),
})?;
.map_err(|e| PkgTreeError(format!("Failed to load manifest for {}: {}", fmri.to_string(), e)))?;
let manifest = manifest_opt.unwrap_or_else(|| libips::actions::Manifest::new());
ctx.manifest_cache.insert(key, manifest.clone());
Ok(manifest)
@ -1030,9 +1018,7 @@ fn run_dangling_scan(
format: OutputFormat,
) -> Result<()> {
// Query full catalog once
let mut pkgs = image.query_catalog(None).map_err(|e| PkgTreeError {
message: format!("Failed to query catalog: {}", e),
})?;
let mut pkgs = image.query_catalog(None).map_err(|e| PkgTreeError(format!("Failed to query catalog: {}", e)))?;
// Build set of available non-obsolete stems AND an index of available (release, branch) pairs per stem,
// honoring publisher filter
@ -1202,9 +1188,7 @@ fn run_dangling_scan(
// ---------- Targeted analysis: parse pkg6 solver error text ----------
fn analyze_solver_error(image: &Image, publisher: Option<&str>, err_path: &PathBuf) -> Result<()> {
let text = std::fs::read_to_string(err_path).map_err(|e| PkgTreeError {
message: format!("Failed to read solver error file {:?}: {}", err_path, e),
})?;
let text = std::fs::read_to_string(err_path).map_err(|e| PkgTreeError(format!("Failed to read solver error file {:?}: {}", err_path, e)))?;
// Build a stack based on indentation before the tree bullet "└─".
let mut stack: Vec<String> = Vec::new();