Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions rust/agama-lib/src/bootloader/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ pub struct BootloaderSettings {
#[serde(skip_serializing_if = "Option::is_none")]
pub timeout: Option<u32>,
}

impl BootloaderSettings {
pub fn to_option(self) -> Option<Self> {
if self.stop_on_boot_menu.is_none() && self.timeout.is_none() {
None
} else {
Some(self)
}
}
}
4 changes: 2 additions & 2 deletions rust/agama-lib/src/bootloader/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ impl BootloaderStore {
})
}

pub async fn load(&self) -> Result<BootloaderSettings, ServiceError> {
self.bootloader_client.get_config().await
pub async fn load(&self) -> Result<Option<BootloaderSettings>, ServiceError> {
Ok(self.bootloader_client.get_config().await?.to_option())
}

pub async fn store(&self, settings: &BootloaderSettings) -> Result<(), ServiceError> {
Expand Down
9 changes: 7 additions & 2 deletions rust/agama-lib/src/files/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@ impl FilesStore {
}

/// loads the list of user files from http API
pub async fn load(&self) -> Result<Vec<UserFile>, ServiceError> {
self.files_client.get_files().await
pub async fn load(&self) -> Result<Option<Vec<UserFile>>, ServiceError> {
let res = self.files_client.get_files().await?;
if res.is_empty() {
Ok(None)
} else {
Ok(Some(res))
}
}

/// stores the list of user files via http API
Expand Down
4 changes: 4 additions & 0 deletions rust/agama-lib/src/install_settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,17 @@ use std::path::Path;
#[serde(rename_all = "camelCase")]
pub struct InstallSettings {
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub bootloader: Option<BootloaderSettings>,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub files: Option<Vec<UserFile>>,
#[serde(default)]
pub hostname: Option<HostnameSettings>,
#[serde(default, flatten)]
pub user: Option<UserSettings>,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub software: Option<SoftwareSettings>,
#[serde(default)]
pub product: Option<ProductSettings>,
Expand All @@ -65,6 +68,7 @@ pub struct InstallSettings {
#[serde(default)]
pub localization: Option<LocalizationSettings>,
#[serde(default)]
#[serde(skip_serializing_if = "Option::is_none")]
pub scripts: Option<ScriptsConfig>,
}

Expand Down
14 changes: 14 additions & 0 deletions rust/agama-lib/src/scripts/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,17 @@ pub struct ScriptsConfig {
#[serde(skip_serializing_if = "Option::is_none")]
pub init: Option<Vec<InitScript>>,
}

impl ScriptsConfig {
pub fn to_option(self) -> Option<Self> {
if self.pre.is_none()
&& self.post_partitioning.is_none()
&& self.post.is_none()
&& self.init.is_none()
{
None
} else {
Some(self)
}
}
}
10 changes: 10 additions & 0 deletions rust/agama-lib/src/software/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,13 @@ pub struct SoftwareSettings {
#[serde(skip_serializing_if = "Option::is_none")]
pub packages: Option<Vec<String>>,
}

impl SoftwareSettings {
pub fn to_option(self) -> Option<Self> {
if self.patterns.is_none() && self.packages.is_none() {
None
} else {
Some(self)
}
}
}
8 changes: 4 additions & 4 deletions rust/agama-lib/src/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,15 @@ impl Store {
/// Loads the installation settings from the HTTP interface.
pub async fn load(&self) -> Result<InstallSettings, ServiceError> {
let mut settings = InstallSettings {
bootloader: Some(self.bootloader.load().await?),
files: Some(self.files.load().await?),
bootloader: self.bootloader.load().await?,
files: self.files.load().await?,
hostname: Some(self.hostname.load().await?),
network: Some(self.network.load().await?),
software: Some(self.software.load().await?),
software: self.software.load().await?.to_option(),
user: Some(self.users.load().await?),
product: Some(self.product.load().await?),
localization: Some(self.localization.load().await?),
scripts: Some(self.scripts.load().await?),
scripts: self.scripts.load().await?.to_option(),
..Default::default()
};

Expand Down
6 changes: 6 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Apr 7 14:02:57 UTC 2025 - Josef Reidinger <jreidinger@suse.com>

- Skip exporting scripts, files, bootloader and softare section
in profile if they are empty (gh#agama-project/agama#2250)

-------------------------------------------------------------------
Tue Apr 1 12:44:57 UTC 2025 - Ladislav Slezák <lslezak@suse.com>

Expand Down
Loading