mirror of
https://codeberg.org/Toasterson/ips.git
synced 2026-04-10 21:30:41 +00:00
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:
parent
0e873ee114
commit
d763bf1c34
4 changed files with 26 additions and 31 deletions
6
.github/workflows/release.yml
vendored
6
.github/workflows/release.yml
vendored
|
|
@ -15,8 +15,12 @@ jobs:
|
||||||
uses: vmactions/omnios-vm@v1
|
uses: vmactions/omnios-vm@v1
|
||||||
with:
|
with:
|
||||||
prepare: |
|
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: |
|
run: |
|
||||||
|
# Set environment variables for native libraries
|
||||||
|
export CFLAGS="-m64"
|
||||||
|
export LDFLAGS="-m64"
|
||||||
cargo build --release
|
cargo build --release
|
||||||
mkdir -p artifacts
|
mkdir -p artifacts
|
||||||
cp target/release/pkg6 artifacts/
|
cp target/release/pkg6 artifacts/
|
||||||
|
|
|
||||||
6
.github/workflows/rust.yml
vendored
6
.github/workflows/rust.yml
vendored
|
|
@ -96,8 +96,12 @@ jobs:
|
||||||
uses: vmactions/omnios-vm@v1
|
uses: vmactions/omnios-vm@v1
|
||||||
with:
|
with:
|
||||||
prepare: |
|
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: |
|
run: |
|
||||||
|
# Set environment variables for native libraries
|
||||||
|
export CFLAGS="-m64"
|
||||||
|
export LDFLAGS="-m64"
|
||||||
cargo run -p xtask -- build
|
cargo run -p xtask -- build
|
||||||
cargo run -p xtask -- build -r
|
cargo run -p xtask -- build -r
|
||||||
- name: Upload build artifacts
|
- name: Upload build artifacts
|
||||||
|
|
|
||||||
9
Vagrantfile
vendored
9
Vagrantfile
vendored
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- mode: ruby -*-
|
# -*- mode: ruby -*-
|
||||||
# vi: set ft=ruby :
|
# vi: set ft=ruby :
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.box = "openindiana/hipster"
|
config.vm.box = "omnios/stable"
|
||||||
|
|
||||||
config.vm.synced_folder ".", "/vagrant", type: "rsync",
|
config.vm.synced_folder ".", "/vagrant", type: "rsync",
|
||||||
rsync__exclude: [".git/", "target/"]
|
rsync__exclude: [".git/", "target/"]
|
||||||
|
|
@ -16,9 +16,12 @@ Vagrant.configure("2") do |config|
|
||||||
|
|
||||||
config.vm.provision "shell", inline: <<-SHELL
|
config.vm.provision "shell", inline: <<-SHELL
|
||||||
set -ex
|
set -ex
|
||||||
pkg install -v developer/lang/rustc build-essential jq
|
pkg set-publisher -g https://pkg.omnios.org/r151056/extra/ extra.omnios
|
||||||
mkdir /ws
|
pkg install -v developer/lang/rustc build-essential jq library/zlib library/lz4
|
||||||
|
mkdir -p /ws
|
||||||
chown vagrant:vagrant /ws
|
chown vagrant:vagrant /ws
|
||||||
|
if ! zfs list rpool/zones > /dev/null 2>&1; then
|
||||||
zfs create -o mountpoint=/zones rpool/zones
|
zfs create -o mountpoint=/zones rpool/zones
|
||||||
|
fi
|
||||||
SHELL
|
SHELL
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -81,14 +81,12 @@ impl std::fmt::Display for OutputFormat {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, Diagnostic)]
|
#[derive(Error, Debug, Diagnostic)]
|
||||||
#[error("pkgtree error: {message}")]
|
#[error("pkgtree error: {0}")]
|
||||||
#[diagnostic(
|
#[diagnostic(
|
||||||
code(ips::pkgtree_error),
|
code(ips::pkgtree_error),
|
||||||
help("See logs with RUST_LOG=pkgtree=debug for more details.")
|
help("See logs with RUST_LOG=pkgtree=debug for more details.")
|
||||||
)]
|
)]
|
||||||
struct PkgTreeError {
|
struct PkgTreeError(String);
|
||||||
message: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
struct Edge {
|
struct Edge {
|
||||||
|
|
@ -133,9 +131,7 @@ fn main() -> Result<()> {
|
||||||
tracing_subscriber::fmt().with_env_filter(env_filter).init();
|
tracing_subscriber::fmt().with_env_filter(env_filter).init();
|
||||||
|
|
||||||
// Load image
|
// Load image
|
||||||
let image = Image::load(&cli.image_path).map_err(|e| PkgTreeError {
|
let image = Image::load(&cli.image_path).map_err(|e| PkgTreeError(format!("Failed to load image at {:?}: {}", cli.image_path, e)))?;
|
||||||
message: format!("Failed to load image at {:?}: {}", cli.image_path, e),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
// Targeted analysis of solver error file has top priority if provided
|
// Targeted analysis of solver error file has top priority if provided
|
||||||
if let Some(err_path) = &cli.solver_error_file {
|
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 {
|
let mut pkgs = if let Some(ref needle) = cli.package {
|
||||||
image
|
image
|
||||||
.query_catalog(Some(needle.as_str()))
|
.query_catalog(Some(needle.as_str()))
|
||||||
.map_err(|e| PkgTreeError {
|
.map_err(|e| PkgTreeError(format!("Failed to query catalog: {}", e)))?
|
||||||
message: format!("Failed to query catalog: {}", e),
|
|
||||||
})?
|
|
||||||
} else {
|
} else {
|
||||||
image.query_catalog(None).map_err(|e| PkgTreeError {
|
image.query_catalog(None).map_err(|e| PkgTreeError(format!("Failed to query catalog: {}", e)))?
|
||||||
message: format!("Failed to query catalog: {}", e),
|
|
||||||
})?
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Filter by publisher if specified
|
// Filter by publisher if specified
|
||||||
|
|
@ -773,9 +765,7 @@ fn query_catalog_cached_mut(
|
||||||
return Ok(v.clone());
|
return Ok(v.clone());
|
||||||
}
|
}
|
||||||
let mut out = Vec::new();
|
let mut out = Vec::new();
|
||||||
for p in image.query_catalog(Some(stem)).map_err(|e| PkgTreeError {
|
for p in image.query_catalog(Some(stem)).map_err(|e| PkgTreeError(format!("Failed to query catalog for {}: {}", stem, e)))? {
|
||||||
message: format!("Failed to query catalog for {}: {}", stem, e),
|
|
||||||
})? {
|
|
||||||
out.push((p.publisher, p.fmri));
|
out.push((p.publisher, p.fmri));
|
||||||
}
|
}
|
||||||
ctx.catalog_cache.insert(stem.to_string(), out.clone());
|
ctx.catalog_cache.insert(stem.to_string(), out.clone());
|
||||||
|
|
@ -793,9 +783,7 @@ fn get_manifest_cached(
|
||||||
}
|
}
|
||||||
let manifest_opt = image
|
let manifest_opt = image
|
||||||
.get_manifest_from_catalog(fmri)
|
.get_manifest_from_catalog(fmri)
|
||||||
.map_err(|e| PkgTreeError {
|
.map_err(|e| PkgTreeError(format!("Failed to load manifest for {}: {}", fmri.to_string(), e)))?;
|
||||||
message: format!("Failed to load manifest for {}: {}", fmri.to_string(), e),
|
|
||||||
})?;
|
|
||||||
let manifest = manifest_opt.unwrap_or_else(|| libips::actions::Manifest::new());
|
let manifest = manifest_opt.unwrap_or_else(|| libips::actions::Manifest::new());
|
||||||
ctx.manifest_cache.insert(key, manifest.clone());
|
ctx.manifest_cache.insert(key, manifest.clone());
|
||||||
Ok(manifest)
|
Ok(manifest)
|
||||||
|
|
@ -1030,9 +1018,7 @@ fn run_dangling_scan(
|
||||||
format: OutputFormat,
|
format: OutputFormat,
|
||||||
) -> Result<()> {
|
) -> Result<()> {
|
||||||
// Query full catalog once
|
// Query full catalog once
|
||||||
let mut pkgs = image.query_catalog(None).map_err(|e| PkgTreeError {
|
let mut pkgs = image.query_catalog(None).map_err(|e| PkgTreeError(format!("Failed to query catalog: {}", e)))?;
|
||||||
message: format!("Failed to query catalog: {}", e),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
// Build set of available non-obsolete stems AND an index of available (release, branch) pairs per stem,
|
// Build set of available non-obsolete stems AND an index of available (release, branch) pairs per stem,
|
||||||
// honoring publisher filter
|
// honoring publisher filter
|
||||||
|
|
@ -1202,9 +1188,7 @@ fn run_dangling_scan(
|
||||||
|
|
||||||
// ---------- Targeted analysis: parse pkg6 solver error text ----------
|
// ---------- Targeted analysis: parse pkg6 solver error text ----------
|
||||||
fn analyze_solver_error(image: &Image, publisher: Option<&str>, err_path: &PathBuf) -> Result<()> {
|
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 {
|
let text = std::fs::read_to_string(err_path).map_err(|e| PkgTreeError(format!("Failed to read solver error file {:?}: {}", err_path, e)))?;
|
||||||
message: format!("Failed to read solver error file {:?}: {}", err_path, e),
|
|
||||||
})?;
|
|
||||||
|
|
||||||
// Build a stack based on indentation before the tree bullet "└─".
|
// Build a stack based on indentation before the tree bullet "└─".
|
||||||
let mut stack: Vec<String> = Vec::new();
|
let mut stack: Vec<String> = Vec::new();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue