Adapted supplementary structures (taken from Alexander Burmatov commits at git://git.altlinux.org/people/thatman/packages/proxmox.new.git)

This commit is contained in:
Сергей Конев 2024-10-28 13:42:54 +03:00
parent 235ed36f10
commit f559a28390
4 changed files with 122 additions and 10 deletions

View File

@ -28,6 +28,8 @@ pub enum APTRepositoryPackageType {
Deb,
/// Debian source package
DebSrc,
/// RPM package
Rpm,
}
serde_plain::derive_display_from_serialize!(APTRepositoryPackageType);
@ -114,9 +116,10 @@ pub struct APTRepositoryOption {
},
},
)]
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
/// Describes an APT repository.
#[cfg(not(feature = "alt-linux"))]
pub struct APTRepository {
/// List of package types.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
@ -150,6 +153,98 @@ pub struct APTRepository {
pub enabled: bool,
}
#[api(
properties: {
Types: {
description: "List of package types.",
type: Array,
items: {
type: APTRepositoryPackageType,
},
},
URIs: {
description: "List of repository URIs.",
type: Array,
items: {
description: "Repository URI.",
type: String,
},
},
Suites: {
description: "List of distributions.",
type: Array,
items: {
description: "Package distribution.",
type: String,
},
},
Components: {
description: "List of repository components.",
type: Array,
items: {
description: "Repository component.",
type: String,
},
},
Options: {
type: Array,
optional: true,
items: {
description: "Vendor ID.",
type: String,
},
},
Comment: {
description: "Associated comment.",
type: String,
optional: true,
},
FileType: {
type: APTRepositoryFileType,
},
Enabled: {
description: "Whether the repository is enabled or not.",
type: Boolean,
},
},
)]
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "PascalCase")]
/// Describes an APT repository.
#[cfg(feature = "alt-linux")]
pub struct APTRepository {
/// List of package types.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub types: Vec<APTRepositoryPackageType>,
/// List of repository URIs.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
#[serde(rename = "URIs")]
pub uris: Vec<String>,
/// List of package distributions.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub suites: Vec<String>,
/// List of repository components.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub components: Vec<String>,
/// Additional options.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub options: Vec<String>,
/// Associated comment.
#[serde(default, skip_serializing_if = "String::is_empty")]
pub comment: String,
/// Format of the defining file.
pub file_type: APTRepositoryFileType,
/// Whether the repository is enabled or not.
pub enabled: bool,
}
#[api(
properties: {
"file-type": {
@ -291,6 +386,18 @@ pub enum APTRepositoryHandle {
CephReefNoSubscription,
/// Ceph Reef test repository.
CephReefTest,
/// Check install
#[serde(rename = "checkinstall")]
CheckInstall,
/// Debug info
#[serde(rename = "debuginfo")]
DebugInfo,
/// Classic
#[serde(rename = "classic")]
Classic,
/// GOST crypto
#[serde(rename = "gostcrypto")]
GostCrypto,
}
serde_plain::derive_display_from_serialize!(APTRepositoryHandle);

View File

@ -2,10 +2,10 @@ use std::path::{Path, PathBuf};
use anyhow::{format_err, Error};
#[cfg(not(feature = "alt-linux"))]
use crate::repositories::release::DebianCodename;
#[cfg(feature = "alt-linux")]
use crate::repositories::release::ALTBranchID;
#[cfg(not(feature = "alt-linux"))]
use crate::repositories::release::DebianCodename;
use proxmox_apt_api_types::{
APTRepository, APTRepositoryFile, APTRepositoryFileError, APTRepositoryFileType,
APTRepositoryInfo, APTRepositoryPackageType,
@ -59,7 +59,11 @@ pub trait APTRepositoryFileImpl {
/// Checks if old or unstable suites are configured and that the Debian security repository
/// has the correct suite. Also checks that the `stable` keyword is not used.
fn check_suites(&self, current_codename: DebianCodename) -> Vec<APTRepositoryInfo>;
fn check_suites(
&self,
#[cfg(not(feature = "alt-linux"))] current_codename: DebianCodename,
#[cfg(feature = "alt-linux")] current_codename: ALTBranchID,
) -> Vec<APTRepositoryInfo>;
/// Checks for official URIs.
fn check_uris(&self, apt_lists_dir: &Path) -> Vec<APTRepositoryInfo>;
@ -275,10 +279,8 @@ impl APTRepositoryFileImpl for APTRepositoryFile {
/// has the correct suite. Also checks that the `stable` keyword is not used.
fn check_suites(
&self,
#[cfg(not(feature = "alt-linux"))]
current_codename: DebianCodename,
#[cfg(feature = "alt-linux")]
current_codename: ALTBranchID
#[cfg(not(feature = "alt-linux"))] current_codename: DebianCodename,
#[cfg(feature = "alt-linux")] current_codename: ALTBranchID,
) -> Vec<APTRepositoryInfo> {
let mut infos = vec![];

View File

@ -10,7 +10,7 @@ use proxmox_apt_api_types::{
APTStandardRepository,
};
#[cfg(not(feature = "alt-linux"))]
pub use repository::APTRepositoryOption;
pub use proxmox_apt_api_types::APTRepositoryOption;
use proxmox_config_digest::ConfigDigest;
pub use repository::APTRepositoryImpl;

View File

@ -5,9 +5,12 @@ use anyhow::{bail, format_err, Error};
use crate::repositories::standard::APTRepositoryHandleImpl;
use proxmox_apt_api_types::{
APTRepository, APTRepositoryFileType, APTRepositoryHandle, APTRepositoryOption,
APTRepository, APTRepositoryFileType, APTRepositoryHandle,
};
#[cfg(not(feature = "alt-linux"))]
use crate::repositories::APTRepositoryOption;
pub trait APTRepositoryImpl {
/// Crates an empty repository.
fn new(file_type: APTRepositoryFileType) -> Self;