Skip to content

Implemented conversion of files section from AutoYaST xml format to Agama JSON#2125

Merged
jreidinger merged 5 commits intofiles_autofrom
files_ay_convertor
Mar 11, 2025
Merged

Implemented conversion of files section from AutoYaST xml format to Agama JSON#2125
jreidinger merged 5 commits intofiles_autofrom
files_ay_convertor

Conversation

@mchf
Copy link
Contributor

@mchf mchf commented Mar 7, 2025

Problem

We want to (partially) support files section when converting old AY profile into Agama's new json based

Solution

implemented files reader for Agama's AutoYaST converter.
For now only static file sources are supported no dynamic files allowed (files embedded into the profile)

Testing

  • Tested manually

@mchf mchf force-pushed the files_ay_convertor branch from 873adfb to de1b4ef Compare March 7, 2025 10:22

files_json = files.reduce([]) do |res, file|
# Currently we support only url to file source
file["source"] = file.delete("file_location")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you get rust part wrong. There are two enum options:

  • url ( here file location )
  • content ( the file_content )

so in the end only file_script should not be supported.

Copy link
Contributor Author

@mchf mchf Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok ... that's why this is a draft for discussion

# Currently we support only url to file source
file["source"] = file.delete("file_location")
file["destination"] = file.delete("file_path")
file["permissions"] = file.delete("file_permissions")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is exact autoyast format? rust part do not support "0o" so it should look like "777" or "0640" is possible, but not "0o644"

Copy link
Contributor Author

@mchf mchf Mar 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well in documentation / example was 444 ... in AY's rng is "STRING" . No other definition found so far.

@mchf
Copy link
Contributor Author

mchf commented Mar 7, 2025

new screenshot for untagged enums:
files json

return {} if file.nil? || file.empty?

if file.key?("file_location")
{ "source": { "url": file["file_location"] } }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still not correct. "source should not be there. We use same format as scripts: https://agama-project.github.io/docs/user/unattended/scripts#scripts-definition

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i worked according to https://serde.rs/enum-representations.html ... and then for whatever reason added struct member name "source" :-/


file["destination"] = f["file_path"] if f["file_path"]
file["permissions"] = f["file_permissions"] if f["file_permissions"]
file["owner"] = f["file_owner"] if f["file_owner"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned we will need to translate dot into colon as agama will use "root:root" and autoyast according to docu I found uses "root.root" see https://documentation.suse.com/sles/15-SP5/html/SLES-all/cha-configuration-installation-options.html#id-1.7.5.2.38.11

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as discussed with imo files won't have owner field and instead there will be user and group field.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see 939ed07

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so instead of { "owner": "user:group" } add two json members { "user": "user", "group": "group" }? Ok, will update accordingly

@mchf mchf requested a review from jreidinger March 7, 2025 19:42
@mchf mchf force-pushed the files_ay_convertor branch from 7a3ebb2 to 6fa4b93 Compare March 7, 2025 19:43
@jreidinger jreidinger changed the base branch from after-release-beta2 to files_auto March 11, 2025 13:34
@jreidinger jreidinger marked this pull request as ready for review March 11, 2025 13:43
@jreidinger
Copy link
Contributor

I will merge it now and fine tune and test it in my branch together.

@jreidinger jreidinger merged commit 9744345 into files_auto Mar 11, 2025
4 of 6 checks passed
@jreidinger jreidinger deleted the files_ay_convertor branch March 11, 2025 13:45
@imobachgs imobachgs mentioned this pull request Mar 27, 2025
imobachgs added a commit that referenced this pull request Mar 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants