2025-07-26 23:02:56 +02:00
|
|
|
use libips::actions::ActionError;
|
Introduce obsoleted package management system in IPS
- Add `obsoleted.rs` module to handle storing, metadata management, and operations for obsoleted packages.
- Implement commands for marking, listing, searching, restoring, exporting, and importing obsoleted packages (`pkg6repo`).
- Enhance `RepositoryError` with `From` implementations for various error types to manage database and serialization-related errors.
- Introduce reusable data structures for obsoleted package metadata and export representation.
- Update `Cargo.toml` and `Cargo.lock` to include new dependencies (`redb`, `bincode`, etc.).
- Document obsoleted package workflow and integration details in `doc/obsoleted_packages.md` for contributors.
- Refactor repository internals to integrate obsoleted package support without disrupting existing workflow.
- Add robust error handling, logging, and pagination for enhanced usability and scalability.
2025-07-29 16:16:12 +02:00
|
|
|
use libips::fmri::FmriError;
|
2025-07-26 17:07:59 +02:00
|
|
|
use libips::repository;
|
|
|
|
|
use miette::Diagnostic;
|
|
|
|
|
use thiserror::Error;
|
|
|
|
|
|
|
|
|
|
/// Result type for pkg6repo operations
|
|
|
|
|
pub type Result<T> = std::result::Result<T, Pkg6RepoError>;
|
|
|
|
|
|
|
|
|
|
/// Errors that can occur in pkg6repo operations
|
|
|
|
|
#[derive(Debug, Error, Diagnostic)]
|
|
|
|
|
pub enum Pkg6RepoError {
|
|
|
|
|
#[error("unsupported output format: {0}")]
|
|
|
|
|
#[diagnostic(
|
|
|
|
|
code(pkg6repo::unsupported_output_format),
|
|
|
|
|
help("Supported output formats: table, json, tsv")
|
|
|
|
|
)]
|
|
|
|
|
UnsupportedOutputFormat(String),
|
|
|
|
|
|
|
|
|
|
#[error("invalid property=value format: {0}")]
|
|
|
|
|
#[diagnostic(
|
|
|
|
|
code(pkg6repo::invalid_property_value_format),
|
|
|
|
|
help("Property-value pairs must be in the format: property=value")
|
|
|
|
|
)]
|
|
|
|
|
InvalidPropertyValueFormat(String),
|
|
|
|
|
|
|
|
|
|
#[error(transparent)]
|
|
|
|
|
#[diagnostic(transparent)]
|
|
|
|
|
RepositoryError(#[from] repository::RepositoryError),
|
|
|
|
|
|
|
|
|
|
#[error("I/O error: {0}")]
|
|
|
|
|
#[diagnostic(
|
|
|
|
|
code(pkg6repo::io_error),
|
|
|
|
|
help("Check system resources and permissions")
|
|
|
|
|
)]
|
|
|
|
|
IoError(#[from] std::io::Error),
|
|
|
|
|
|
|
|
|
|
#[error("JSON error: {0}")]
|
|
|
|
|
#[diagnostic(
|
|
|
|
|
code(pkg6repo::json_error),
|
|
|
|
|
help("Check the JSON format and try again")
|
|
|
|
|
)]
|
|
|
|
|
JsonError(#[from] serde_json::Error),
|
|
|
|
|
|
2025-07-26 23:02:56 +02:00
|
|
|
#[error("action error: {0}")]
|
|
|
|
|
#[diagnostic(
|
|
|
|
|
code(pkg6repo::action_error),
|
|
|
|
|
help("Check the action format and try again")
|
|
|
|
|
)]
|
|
|
|
|
ActionError(#[from] ActionError),
|
|
|
|
|
|
2025-07-27 11:02:37 +02:00
|
|
|
#[error("logging environment setup error: {0}")]
|
|
|
|
|
#[diagnostic(
|
|
|
|
|
code(pkg6repo::logging_env_error),
|
|
|
|
|
help("Check your logging environment configuration and try again")
|
|
|
|
|
)]
|
|
|
|
|
LoggingEnvError(String),
|
|
|
|
|
|
2025-07-26 17:07:59 +02:00
|
|
|
#[error("other error: {0}")]
|
2025-07-27 15:22:49 +02:00
|
|
|
#[diagnostic(code(pkg6repo::other_error), help("See error message for details"))]
|
2025-07-26 17:07:59 +02:00
|
|
|
Other(String),
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Convert a string to a Pkg6RepoError::Other
|
|
|
|
|
impl From<String> for Pkg6RepoError {
|
|
|
|
|
fn from(s: String) -> Self {
|
|
|
|
|
Pkg6RepoError::Other(s)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Convert a &str to a Pkg6RepoError::Other
|
|
|
|
|
impl From<&str> for Pkg6RepoError {
|
|
|
|
|
fn from(s: &str) -> Self {
|
|
|
|
|
Pkg6RepoError::Other(s.to_string())
|
|
|
|
|
}
|
2025-07-27 15:22:49 +02:00
|
|
|
}
|
Introduce obsoleted package management system in IPS
- Add `obsoleted.rs` module to handle storing, metadata management, and operations for obsoleted packages.
- Implement commands for marking, listing, searching, restoring, exporting, and importing obsoleted packages (`pkg6repo`).
- Enhance `RepositoryError` with `From` implementations for various error types to manage database and serialization-related errors.
- Introduce reusable data structures for obsoleted package metadata and export representation.
- Update `Cargo.toml` and `Cargo.lock` to include new dependencies (`redb`, `bincode`, etc.).
- Document obsoleted package workflow and integration details in `doc/obsoleted_packages.md` for contributors.
- Refactor repository internals to integrate obsoleted package support without disrupting existing workflow.
- Add robust error handling, logging, and pagination for enhanced usability and scalability.
2025-07-29 16:16:12 +02:00
|
|
|
|
|
|
|
|
/// Convert a FmriError to a Pkg6RepoError
|
|
|
|
|
impl From<FmriError> for Pkg6RepoError {
|
|
|
|
|
fn from(err: FmriError) -> Self {
|
|
|
|
|
Pkg6RepoError::Other(format!("FMRI error: {}", err))
|
|
|
|
|
}
|
|
|
|
|
}
|