osbuild2/bootiso: arch-based xz compression option

Added a helper function to the bootiso stage for setting the BCJ option
for xz compression.
The FSCompression struct is changed to use a pointer for the Options
substruct so it can be omitted when nil (omitempty).
This commit is contained in:
Achilleas Koutsou 2021-03-29 19:00:46 +02:00 committed by Ondřej Budai
parent 3cf8a545a6
commit f7882993f9
3 changed files with 23 additions and 8 deletions

View file

@ -732,7 +732,7 @@ func (t *imageTypeS2) bootISOMonoStageOptions(kernelVer string) *osbuild.BootISO
Size: 4096,
Compression: osbuild.FSCompression{
Method: "xz",
Options: osbuild.FSCompressionOptions{
Options: &osbuild.FSCompressionOptions{
// TODO: based on image arch
BCJ: "x86",
},

View file

@ -752,6 +752,10 @@ func (t *imageType) kickstartStageOptions(ostreeURL, ostreeRef string) *osbuild.
}
func (t *imageType) bootISOMonoStageOptions(kernelVer string) *osbuild.BootISOMonoStageOptions {
comprOptions := new(osbuild.FSCompressionOptions)
if bcj := osbuild.BCJOption(t.arch.Name()); bcj != "" {
comprOptions.BCJ = bcj
}
return &osbuild.BootISOMonoStageOptions{
Product: osbuild.Product{
Name: "Red Hat Enterprise Linux",
@ -774,11 +778,8 @@ func (t *imageType) bootISOMonoStageOptions(kernelVer string) *osbuild.BootISOMo
RootFS: osbuild.RootFS{
Size: 4096,
Compression: osbuild.FSCompression{
Method: "xz",
Options: osbuild.FSCompressionOptions{
// TODO: based on image arch
BCJ: "x86",
},
Method: "xz",
Options: comprOptions,
},
},
}

View file

@ -37,14 +37,28 @@ type RootFS struct {
}
type FSCompression struct {
Method string `json:"method"`
Options FSCompressionOptions `json:"options,omitempty"`
Method string `json:"method"`
Options *FSCompressionOptions `json:"options,omitempty"`
}
type FSCompressionOptions struct {
BCJ string `json:"bcj"`
}
// BCJOption returns the appropriate xz branch/call/jump (BCJ) filter for the
// given architecture
func BCJOption(arch string) string {
switch arch {
case "x86_64":
return "x86"
case "aarch64":
return "arm"
case "ppc64le":
return "powerpc"
}
return ""
}
func (BootISOMonoStageOptions) isStageOptions() {}
type BootISOMonoStageInputs struct {