Skip to content

Commit

Permalink
Merge branch 'master' into kiwi-use-default-ruby
Browse files Browse the repository at this point in the history
  • Loading branch information
imobachgs authored Jan 10, 2025
2 parents ce0aeb0 + 46a4610 commit 042e904
Show file tree
Hide file tree
Showing 73 changed files with 1,338 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
root = true

# 2 space indentation
[{*.sh}]
[*.sh]
indent_style = space
indent_size = 2
6 changes: 6 additions & 0 deletions live/root/usr/lib/dracut/modules.d/99agama-cmdline/README
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dracut agama-cmdline module
-------------------------------

This module writes any agama configuration given through the kernel cmdline
to its own cmdline conf file copying it to the sysroot.

Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#! /bin/sh

[ -e /dracut-state.sh ] && . /dracut-state.sh

. /lib/dracut-lib.sh

get_agama_args() {
local _i _found

for _i in $CMDLINE; do
case $_i in
LIBSTORAGE_* | YAST_* | agama* | Y2* | ZYPP_*)
_found=1
;;
esac

if [ -n "$_found" ]; then
printf "Agama variable found ($_i)"
if ! strstr "$_i" "="; then
# Set the variable as a boolean if there is no assignation
_i="${_i}=1"
fi
echo $_i >>/etc/cmdline.d/99-agama-cmdline.conf
fi
unset _found
done

return 0
}

get_agama_args
21 changes: 21 additions & 0 deletions live/root/usr/lib/dracut/modules.d/99agama-cmdline/module-setup.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# called by dracut
check() {
return 0
}

# called by dracut
depends() {
return 0
}

installkernel() {
return 0
}

# called by dracut
install() {
inst_hook cmdline 99 "$moddir/agama-cmdline-conf.sh"
inst_hook pre-pivot 99 "$moddir/save-agama-conf.sh"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#! /bin/sh

[ -e /dracut-state.sh ] && . /dracut-state.sh

. /lib/dracut-lib.sh

if [ -e /etc/cmdline.d/99-agama-cmdline.conf ]; then
echo "Creating agama conf"
mkdir -p "$NEWROOT/etc/agama.d"
cp /etc/cmdline.d/99-agama-cmdline.conf "$NEWROOT/etc/agama.d/cmdline.conf"
fi
7 changes: 7 additions & 0 deletions live/src/agama-installer.changes
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ Fri Jan 10 09:03:06 UTC 2025 - Imobach Gonzalez Sosa <[email protected]>

- Depend on Ruby's default version (gh#agama-project/agama#1872).

-------------------------------------------------------------------
Wed Jan 8 12:10:39 UTC 2025 - Knut Anderssen <[email protected]>

- Make agama kernel cmdline options available in the sysroot at
/etc/agama.d/cmdline.conf and set it as a EnvironmentFile
in Agama related services (gh#agama-project/agama#1866).

-------------------------------------------------------------------
Tue Dec 10 12:46:06 UTC 2024 - Michal Filka <[email protected]>

Expand Down
16 changes: 8 additions & 8 deletions live/src/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,11 +82,11 @@ echo "root_disk=live:LABEL=$label" >>/etc/cmdline.d/10-liveroot.conf
# if there's a default network location, add it here
# echo "root_net=" >> /etc/cmdline.d/10-liveroot.conf
echo 'install_items+=" /etc/cmdline.d/10-liveroot.conf "' >/etc/dracut.conf.d/10-liveroot-file.conf
echo 'add_dracutmodules+=" dracut-menu "' >>/etc/dracut.conf.d/10-liveroot-file.conf
echo 'add_dracutmodules+=" dracut-menu agama-cmdline "' >>/etc/dracut.conf.d/10-liveroot-file.conf

if [ "${arch}" = "s390x" ];then
# workaround for custom bootloader setting
touch /config.bootoptions
if [ "${arch}" = "s390x" ]; then
# workaround for custom bootloader setting
touch /config.bootoptions
fi

# replace the @@LIVE_MEDIUM_LABEL@@ with the real Live partition label name from KIWI
Expand All @@ -111,7 +111,7 @@ rm /var/log/zypper.log /var/log/zypp/history
# reduce the "vim-data" content, this package is huge (37MB unpacked!), keep only
# support for JSON (for "agama config edit") and Ruby (fixing/debugging the Ruby
# service)
rpm -ql vim-data | grep -v -e '/ruby.vim$' -e '/json.vim$' -e colors | xargs rm 2> /dev/null || true
rpm -ql vim-data | grep -v -e '/ruby.vim$' -e '/json.vim$' -e colors | xargs rm 2>/dev/null || true

du -h -s /usr/{share,lib}/locale/

Expand All @@ -125,7 +125,7 @@ du -h -s /usr/{share,lib}/locale/
mkdir -p /etc/agama.d
# emulate "localectl list-locales" call, it cannot be used here because it
# insists on running systemd as PID 1 :-/
ls -1 -d /usr/lib/locale/*.utf8 | sed -e "s#/usr/lib/locale/##" -e "s#utf8#UTF-8#" > /etc/agama.d/locales
ls -1 -d /usr/lib/locale/*.utf8 | sed -e "s#/usr/lib/locale/##" -e "s#utf8#UTF-8#" >/etc/agama.d/locales

# delete translations and unusupported languages (makes ISO about 22MiB smaller)
# build list of ignore options for "ls" with supported languages like "-I cs* -I de* -I es* ..."
Expand All @@ -138,7 +138,7 @@ ls -1 "${IGNORE_OPTS[@]}" -I "en_US*" -I "C.*" /usr/lib/locale/ | xargs -I% sh -

# delete unused translations (MO files)
for t in zypper gettext-runtime p11-kit; do
rm -f /usr/share/locale/*/LC_MESSAGES/$t.mo
rm -f /usr/share/locale/*/LC_MESSAGES/$t.mo
done
du -h -s /usr/{share,lib}/locale/

Expand Down Expand Up @@ -180,7 +180,7 @@ du -h -s /lib/modules /lib/firmware

# disable the services included by dependencies
for s in purge-kernels; do
systemctl -f disable $s || true
systemctl -f disable $s || true
done

# Only used for OpenCL and X11 acceleration on vmwgfx (?), saves ~50MiB
Expand Down
7 changes: 6 additions & 1 deletion products.d/agama-products.changes
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
-------------------------------------------------------------------
Wed Jan 8 14:07:21 UTC 2025 - Imobach Gonzalez Sosa <[email protected]>

- Add support for products registration (jsc#PED-11192,
gh#agama-project/agama#1809).

-------------------------------------------------------------------
Tue Jan 7 12:57:13 UTC 2025 - Lubos Kocman <[email protected]>

- Drop yast from Leap 16.0 software selection
code-o-o#leap/features#173


-------------------------------------------------------------------
Mon Jan 6 14:41:28 UTC 2025 - Angela Briel <[email protected]>

Expand Down
17 changes: 4 additions & 13 deletions products.d/sles_160.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
id: SLES_16.0
id: SLES
name: SUSE Linux Enterprise Server 16.0 Alpha
registration: "mandatory"
version: "16-0"
# ------------------------------------------------------------------------------
# WARNING: When changing the product description delete the translations located
# at the at translations/description key below to avoid using obsolete
Expand Down Expand Up @@ -50,18 +52,7 @@ translations:
altyapı için güvenli ve uyarlanabilir işletim sistemidir. Şirket içinde,
bulutta ve uçta iş açısından kritik iş yüklerini çalıştırır.
software:
installation_repositories:
# Use plain HTTP repositories, HTTPS does not work without importing the SSL
# certificate. It is safe as the repository is GPG checked and you neeed VPN
# to reach the internal server anyway.
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-Packages-16.0-x86_64/
archs: x86_64
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-Packages-16.0-aarch64/
archs: aarch64
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-Packages-16.0-ppc64le/
archs: ppc
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-Packages-16.0-s390x/
archs: s390
installation_repositories: []

mandatory_patterns:
- base_traditional
Expand Down
18 changes: 5 additions & 13 deletions products.d/sles_sap_160.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
id: SLES_SAP_16.0
id: SLES-SAP
name: SUSE Linux Enterprise Server for SAP Applications 16.0 Beta
archs: x86_64,aarch64,ppc
registration: "mandatory"
version: "16-0"
# ------------------------------------------------------------------------------
# WARNING: When changing the product description delete the translations located
# at the at translations/description key below to avoid using obsolete
Expand All @@ -14,18 +17,7 @@ icon: SUSE.svg
translations:
description:
software:
installation_repositories:
# Use plain HTTP repositories, HTTPS does not work without importing the SSL
# certificate. It is safe as the repository is GPG checked and you neeed VPN
# to reach the internal server anyway.
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-SAP-Packages-16.0-x86_64/
archs: x86_64
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-SAP-Packages-16.0-aarch64/
archs: aarch64
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-SAP-Packages-16.0-ppc64le/
archs: ppc
- url: http://download.suse.de/ibs/SUSE:/SLFO:/Products:/SLES:/16.0:/TEST/product/repo/SLES-SAP-Packages-16.0-s390x/
archs: s390
installation_repositories: []

mandatory_patterns:
- base_traditional
Expand Down
17 changes: 10 additions & 7 deletions rust/agama-lib/src/product/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@
// find current contact information at www.suse.com.

use std::collections::HashMap;
use std::str::FromStr;

use crate::dbus::get_property;
use crate::error::ServiceError;
use crate::software::model::RegistrationRequirement;
use crate::software::proxies::SoftwareProductProxy;
Expand All @@ -39,6 +41,8 @@ pub struct Product {
pub description: String,
/// Product icon (e.g., "default.svg")
pub icon: String,
/// Registration requirement
pub registration: RegistrationRequirement,
}

/// D-Bus client for the software service
Expand Down Expand Up @@ -72,11 +76,17 @@ impl<'a> ProductClient<'a> {
Some(value) => value.try_into().unwrap(),
None => "default.svg",
};

let registration = get_property::<String>(&data, "registration")
.map(|r| RegistrationRequirement::from_str(&r).unwrap_or_default())
.unwrap_or_default();

Product {
id,
name,
description: description.to_string(),
icon: icon.to_string(),
registration,
}
})
.collect();
Expand Down Expand Up @@ -114,13 +124,6 @@ impl<'a> ProductClient<'a> {
Ok(self.registration_proxy.email().await?)
}

pub async fn registration_requirement(&self) -> Result<RegistrationRequirement, ServiceError> {
let requirement = self.registration_proxy.requirement().await?;
// unknown number can happen only if we do programmer mistake
let result: RegistrationRequirement = requirement.try_into().unwrap();
Ok(result)
}

/// register product
pub async fn register(&self, code: &str, email: &str) -> Result<(u32, String), ServiceError> {
let mut options: HashMap<&str, &zbus::zvariant::Value> = HashMap::new();
Expand Down
21 changes: 19 additions & 2 deletions rust/agama-lib/src/product/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// To contact SUSE LLC about this file by physical or electronic mail, you may
// find current contact information at www.suse.com.

use crate::software::model::RegistrationError;
use crate::software::model::RegistrationInfo;
use crate::software::model::RegistrationParams;
use crate::software::model::SoftwareConfig;
Expand Down Expand Up @@ -64,13 +65,29 @@ impl ProductHTTPClient {
}

/// register product
pub async fn register(&self, key: &str, email: &str) -> Result<(u32, String), ServiceError> {
pub async fn register(&self, key: &str, email: &str) -> Result<(), ServiceError> {
// note RegistrationParams != RegistrationInfo, fun!
let params = RegistrationParams {
key: key.to_owned(),
email: email.to_owned(),
};
let result = self
.client
.post_void("/software/registration", &params)
.await;

self.client.post("/software/registration", &params).await
let Err(error) = result else {
return Ok(());
};

let message = match error {
ServiceError::BackendError(_, details) => {
let details: RegistrationError = serde_json::from_str(&details).unwrap();
format!("{} (error code: {})", details.message, details.id)
}
_ => format!("Could not register the product: #{error:?}"),
};

Err(ServiceError::FailedRegistration(message))
}
}
13 changes: 2 additions & 11 deletions rust/agama-lib/src/product/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,17 +68,8 @@ impl ProductStore {
}
}
if let Some(reg_code) = &settings.registration_code {
let (result, message);
if let Some(email) = &settings.registration_email {
(result, message) = self.product_client.register(reg_code, email).await?;
} else {
(result, message) = self.product_client.register(reg_code, "").await?;
}
// FIXME: name the magic numbers. 3 is Registration not required
// FIXME: well don't register when not required (no regcode in profile)
if result != 0 && result != 3 {
return Err(ServiceError::FailedRegistration(message));
}
let email = settings.registration_email.as_deref().unwrap_or("");
self.product_client.register(reg_code, email).await?;
probe = true;
}

Expand Down
42 changes: 20 additions & 22 deletions rust/agama-lib/src/software/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,38 +47,36 @@ pub struct RegistrationInfo {
pub key: String,
/// Registration email. Empty value mean email not used or not registered.
pub email: String,
/// if registration is required, optional or not needed for current product.
/// Change only if selected product is changed.
pub requirement: RegistrationRequirement,
}

#[derive(Clone, Debug, Serialize, Deserialize, utoipa::ToSchema)]
#[derive(
Clone,
Default,
Debug,
Serialize,
Deserialize,
strum::Display,
strum::EnumString,
utoipa::ToSchema,
)]
#[strum(serialize_all = "camelCase")]
#[serde(rename_all = "camelCase")]
pub enum RegistrationRequirement {
/// Product does not require registration
NotRequired = 0,
#[default]
No = 0,
/// Product has optional registration
Optional = 1,
/// It is mandatory to register the product
Mandatory = 2,
}

impl TryFrom<u32> for RegistrationRequirement {
type Error = ();

fn try_from(v: u32) -> Result<Self, Self::Error> {
match v {
x if x == RegistrationRequirement::NotRequired as u32 => {
Ok(RegistrationRequirement::NotRequired)
}
x if x == RegistrationRequirement::Optional as u32 => {
Ok(RegistrationRequirement::Optional)
}
x if x == RegistrationRequirement::Mandatory as u32 => {
Ok(RegistrationRequirement::Mandatory)
}
_ => Err(()),
}
}
#[derive(Clone, Serialize, Deserialize, utoipa::ToSchema)]
pub struct RegistrationError {
/// ID of error. See dbus API for possible values
pub id: u32,
/// human readable error string intended to be displayed to user
pub message: String,
}

/// Software resolvable type (package or pattern).
Expand Down
Loading

0 comments on commit 042e904

Please sign in to comment.