-
Notifications
You must be signed in to change notification settings - Fork 4
Adding support for a new Stackbuild specific schema #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
davidcassany
wants to merge
1
commit into
OSInside:main
Choose a base branch
from
davidcassany:add_new_stackbuild_schema
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#========================================== | ||
# Fake rnc file used only to convert | ||
# stackbuild schema.rnc file to schema.rng | ||
# without requiring the actual KIWI schema | ||
# file | ||
# | ||
start = | ||
## The start pattern of an image | ||
k.image |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns="http://relaxng.org/ns/structure/1.0"> | ||
<!-- | ||
========================================== | ||
Fake rnc file used only to convert | ||
stackbuild schema.rnc file to schema.rng | ||
without requiring the actual KIWI schema | ||
file | ||
|
||
--> | ||
<start> | ||
<ref name="k.image"> | ||
<a:documentation>The start pattern of an image</a:documentation> | ||
</ref> | ||
</start> | ||
</grammar> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#================ | ||
# FILE : schema.rnc | ||
#**************** | ||
# PROJECT : KIWI - Stack Build Plugin | ||
# COPYRIGHT : (c) 2021 SUSE LINUX Products GmbH | ||
# : | ||
# AUTHOR : David Cassany <[email protected]> | ||
# : | ||
# BELONGS TO : Operating System images | ||
# : | ||
# DESCRIPTION : This is the RELAX NG Schema for KIWI Rebuild Images | ||
# : plugin configuration files. The schema is maintained | ||
# : in the relax compact syntax. Any changes should | ||
# : made in !! *** schema.rnc *** !! | ||
# : | ||
# : | ||
# STATUS : Development | ||
#**************** | ||
|
||
namespace rng = "http://relaxng.org/ns/structure/1.0" | ||
|
||
# The real include value is computed and replaced in memory at runtime | ||
# to match the actual KIWI schema of the KIWI module being loaded | ||
include "kiwi-fake-schema.rnc" { | ||
k.image.schemaversion.attribute = | ||
## The allowed Schema version (fixed value) | ||
attribute schemaversion { "0.1" } | ||
|
||
k.image.attlist = k.image.name.attribute | ||
& k.image.stackbuild.attribute | ||
& k.image.displayname.attribute? | ||
& k.image.id? | ||
& k.image.schemaversion.attribute | ||
& ( k.image.noNamespaceSchemaLocation.attribute? | ||
| k.image.schemaLocation.attribute? )? | ||
|
||
k.image = | ||
## The root element of the configuration file | ||
element image { | ||
k.image.attlist & | ||
k.description? & | ||
k.preferences* & | ||
k.profiles? & | ||
k.users* & | ||
k.drivers* & | ||
k.strip* & | ||
k.repository* & | ||
k.packages* | ||
} | ||
} | ||
|
||
div{ | ||
k.image.stackbuild.attribute = | ||
## Identifies description as a stackbuild XML | ||
attribute stackbuild { "true" } | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
================ | ||
FILE : schema.rnc | ||
**************** | ||
PROJECT : KIWI - Stack Build Plugin | ||
COPYRIGHT : (c) 2021 SUSE LINUX Products GmbH | ||
: | ||
AUTHOR : David Cassany <[email protected]> | ||
: | ||
BELONGS TO : Operating System images | ||
: | ||
DESCRIPTION : This is the RELAX NG Schema for KIWI Rebuild Images | ||
: plugin configuration files. The schema is maintained | ||
: in the relax compact syntax. Any changes should | ||
: made in !! *** schema.rnc *** !! | ||
: | ||
: | ||
STATUS : Development | ||
**************** | ||
--> | ||
<grammar xmlns:a="http://relaxng.org/ns/compatibility/annotations/1.0" xmlns:rng="http://relaxng.org/ns/structure/1.0" xmlns="http://relaxng.org/ns/structure/1.0"> | ||
<!-- | ||
The real include value is computed and replaced in memory at runtime | ||
to match the actual KIWI schema of the KIWI module being loaded | ||
--> | ||
<include href="kiwi-fake-schema.rng"> | ||
<define name="k.image.schemaversion.attribute"> | ||
<attribute name="schemaversion"> | ||
<a:documentation>The allowed Schema version (fixed value)</a:documentation> | ||
<value>0.1</value> | ||
</attribute> | ||
</define> | ||
<define name="k.image.attlist"> | ||
<interleave> | ||
<ref name="k.image.name.attribute"/> | ||
<ref name="k.image.stackbuild.attribute"/> | ||
<optional> | ||
<ref name="k.image.displayname.attribute"/> | ||
</optional> | ||
<optional> | ||
<ref name="k.image.id"/> | ||
</optional> | ||
<ref name="k.image.schemaversion.attribute"/> | ||
<optional> | ||
<choice> | ||
<optional> | ||
<ref name="k.image.noNamespaceSchemaLocation.attribute"/> | ||
</optional> | ||
<optional> | ||
<ref name="k.image.schemaLocation.attribute"/> | ||
</optional> | ||
</choice> | ||
</optional> | ||
</interleave> | ||
</define> | ||
<define name="k.image"> | ||
<element name="image"> | ||
<a:documentation>The root element of the configuration file</a:documentation> | ||
<interleave> | ||
<ref name="k.image.attlist"/> | ||
<optional> | ||
<ref name="k.description"/> | ||
</optional> | ||
<zeroOrMore> | ||
<ref name="k.preferences"/> | ||
</zeroOrMore> | ||
<optional> | ||
<ref name="k.profiles"/> | ||
</optional> | ||
<zeroOrMore> | ||
<ref name="k.users"/> | ||
</zeroOrMore> | ||
<zeroOrMore> | ||
<ref name="k.drivers"/> | ||
</zeroOrMore> | ||
<zeroOrMore> | ||
<ref name="k.strip"/> | ||
</zeroOrMore> | ||
<zeroOrMore> | ||
<ref name="k.repository"/> | ||
</zeroOrMore> | ||
<zeroOrMore> | ||
<ref name="k.packages"/> | ||
</zeroOrMore> | ||
</interleave> | ||
</element> | ||
</define> | ||
</include> | ||
<div> | ||
<define name="k.image.stackbuild.attribute"> | ||
<attribute name="stackbuild"> | ||
<a:documentation>Identifies description as a stackbuild XML</a:documentation> | ||
<value>true</value> | ||
</attribute> | ||
</define> | ||
</div> | ||
</grammar> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidcassany This is really great work 👍 👍
The only part I struggle with is that fake schema. as stackbuild has a kiwi requirement you should have kiwi in the devenv as well as in the system as a dependency later on. In kiwi I developed a method named
project_file
which allows to reference any file that belongs to the project. The schema file belongs to the project and can be looked up as followsOn my system with a pip installed kiwi this gives
Shouldn't this work for your case too ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw it and this was the key to actually solve the schema validation, I am using it to dynamically replace the fake included file with the actual KIWI schema that is used at runtime. This was the key to solve the schema validation issues I had in the past.
The only reason to exist of this
kiwi-fake-schema
is to actually runmake kiwi_stackbuild_plugin/schema.rng
which in turn callstrang -I rnc -O rng <inputfile> <outputfile>
. The problem is that it runs a nested syntax conversion, so it also parses and converts any included file in the input.rnc file.So calling
also reads
kiwi_stackbuild_plugin/kiwi-fake-schema.rnc
and creates akiwi_stackbuild_plugin/kiwi-fake-schema.rng
. Using a real kiwi path here in this context is tricky, as this is just trying to convert from RNC format to RNG nothing else, I don't feel like running a dynamic path discovery here which requires active python development environment is what we want here, this is more a build/packaging thing than a runtime concern. Moreover there is the risk of overwriting and messing with conversion of the included RNC file (the actual kiwi schema from the system). I bet there might be better ways of building and managing it. Probably another option would be to simply forget about RNC and use directly the RNG XML file as the schema, since it is a simple schema I think it should be doable too.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's an option to write RNG directly. The RNC is the so called compact form of a RelaxNG schema. Most people use the compact form because it's easier to read and to maintain. But in this special case it might be ok to work with the RNG format and avoid the conversion