ditro/rhel86: set volid like in rhel9.0
This is only required in RHEL9.0, but best practice is to always pin these things down. Also increases uniformity between distros. Simplify a bit the volid generator by making it require `rand.Rand` rather than `io.Reader`, and hence eliminating the need for error handling.
This commit is contained in:
parent
154e966cda
commit
973b5141b3
7 changed files with 18 additions and 22 deletions
|
|
@ -151,10 +151,13 @@ func newRandomUUIDFromReader(r io.Reader) (uuid.UUID, error) {
|
||||||
return id, nil
|
return id, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRandomVolIDFromReader creates a random 32 bit hex string to use as a
|
// NewVolIDFromRand creates a random 32 bit hex string to use as a
|
||||||
// volume ID for FAT filesystems
|
// volume ID for FAT filesystems
|
||||||
func NewRandomVolIDFromReader(r io.Reader) (string, error) {
|
func NewVolIDFromRand(r *rand.Rand) string {
|
||||||
volid := make([]byte, 4)
|
volid := make([]byte, 4)
|
||||||
_, err := r.Read(volid)
|
len, _ := r.Read(volid)
|
||||||
return hex.EncodeToString(volid), err
|
if len != 4 {
|
||||||
|
panic("expected four random bytes")
|
||||||
|
}
|
||||||
|
return hex.EncodeToString(volid)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -693,7 +693,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu
|
||||||
installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO())
|
installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO())
|
||||||
isolabel := fmt.Sprintf(d.isolabelTmpl, archName)
|
isolabel := fmt.Sprintf(d.isolabelTmpl, archName)
|
||||||
efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO())
|
efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO())
|
||||||
bootISOTreePipeline := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer)
|
bootISOTreePipeline := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer, rng)
|
||||||
|
|
||||||
pipelines = append(pipelines, *installerTreePipeline, *efibootTreePipeline, *bootISOTreePipeline)
|
pipelines = append(pipelines, *installerTreePipeline, *efibootTreePipeline, *bootISOTreePipeline)
|
||||||
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), false))
|
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), false))
|
||||||
|
|
@ -701,7 +701,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu
|
||||||
return pipelines, nil
|
return pipelines, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *osbuild.Pipeline {
|
func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rng *rand.Rand) *osbuild.Pipeline {
|
||||||
p := new(osbuild.Pipeline)
|
p := new(osbuild.Pipeline)
|
||||||
p.Name = "bootiso-tree"
|
p.Name = "bootiso-tree"
|
||||||
p.Build = "name:build"
|
p.Build = "name:build"
|
||||||
|
|
@ -741,6 +741,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string) *o
|
||||||
Payload: &disk.Filesystem{
|
Payload: &disk.Filesystem{
|
||||||
Type: "vfat",
|
Type: "vfat",
|
||||||
Mountpoint: "/",
|
Mountpoint: "/",
|
||||||
|
UUID: disk.NewVolIDFromRand(rng),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -692,10 +692,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu
|
||||||
installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO())
|
installerTreePipeline := simplifiedInstallerTreePipeline(repos, installerPackages, kernelVer, archName, d.product, d.osVersion, "edge", customizations.GetFDO())
|
||||||
isolabel := fmt.Sprintf(d.isolabelTmpl, archName)
|
isolabel := fmt.Sprintf(d.isolabelTmpl, archName)
|
||||||
efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO())
|
efibootTreePipeline := simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, archName, d.vendor, d.product, d.osVersion, isolabel, customizations.GetFDO())
|
||||||
bootISOTreePipeline, err := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer, rng)
|
bootISOTreePipeline := simplifiedInstallerBootISOTreePipeline(imgPipelineName, kernelVer, rng)
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
|
|
||||||
pipelines = append(pipelines, *installerTreePipeline, *efibootTreePipeline, *bootISOTreePipeline)
|
pipelines = append(pipelines, *installerTreePipeline, *efibootTreePipeline, *bootISOTreePipeline)
|
||||||
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), false))
|
pipelines = append(pipelines, *bootISOPipeline(t.Filename(), d.isolabelTmpl, t.Arch().Name(), false))
|
||||||
|
|
@ -703,7 +700,7 @@ func edgeSimplifiedInstallerPipelines(t *imageType, customizations *blueprint.Cu
|
||||||
return pipelines, nil
|
return pipelines, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rng *rand.Rand) (*osbuild.Pipeline, error) {
|
func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rng *rand.Rand) *osbuild.Pipeline {
|
||||||
p := new(osbuild.Pipeline)
|
p := new(osbuild.Pipeline)
|
||||||
p.Name = "bootiso-tree"
|
p.Name = "bootiso-tree"
|
||||||
p.Build = "name:build"
|
p.Build = "name:build"
|
||||||
|
|
@ -733,11 +730,6 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
|
|
||||||
// TODO: handle error
|
|
||||||
volid, err := disk.NewRandomVolIDFromReader(rng)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
pt := disk.PartitionTable{
|
pt := disk.PartitionTable{
|
||||||
Size: 20971520,
|
Size: 20971520,
|
||||||
Partitions: []disk.Partition{
|
Partitions: []disk.Partition{
|
||||||
|
|
@ -747,7 +739,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
|
||||||
Payload: &disk.Filesystem{
|
Payload: &disk.Filesystem{
|
||||||
Type: "vfat",
|
Type: "vfat",
|
||||||
Mountpoint: "/",
|
Mountpoint: "/",
|
||||||
UUID: volid,
|
UUID: disk.NewVolIDFromRand(rng),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
@ -798,7 +790,7 @@ func simplifiedInstallerBootISOTreePipeline(archivePipelineName, kver string, rn
|
||||||
copyInputs,
|
copyInputs,
|
||||||
))
|
))
|
||||||
|
|
||||||
return p, nil
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
func simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel string, fdo *blueprint.FDOCustomization) *osbuild.Pipeline {
|
func simplifiedInstallerEFIBootTreePipeline(installDevice, kernelVer, arch, vendor, product, osVersion, isolabel string, fdo *blueprint.FDOCustomization) *osbuild.Pipeline {
|
||||||
|
|
|
||||||
|
|
@ -1315,7 +1315,7 @@
|
||||||
{
|
{
|
||||||
"type": "org.osbuild.mkfs.fat",
|
"type": "org.osbuild.mkfs.fat",
|
||||||
"options": {
|
"options": {
|
||||||
"volid": ""
|
"volid": "a178892e"
|
||||||
},
|
},
|
||||||
"devices": {
|
"devices": {
|
||||||
"device": {
|
"device": {
|
||||||
|
|
|
||||||
|
|
@ -1358,7 +1358,7 @@
|
||||||
{
|
{
|
||||||
"type": "org.osbuild.mkfs.fat",
|
"type": "org.osbuild.mkfs.fat",
|
||||||
"options": {
|
"options": {
|
||||||
"volid": ""
|
"volid": "a178892e"
|
||||||
},
|
},
|
||||||
"devices": {
|
"devices": {
|
||||||
"device": {
|
"device": {
|
||||||
|
|
|
||||||
|
|
@ -1312,7 +1312,7 @@
|
||||||
{
|
{
|
||||||
"type": "org.osbuild.mkfs.fat",
|
"type": "org.osbuild.mkfs.fat",
|
||||||
"options": {
|
"options": {
|
||||||
"volid": ""
|
"volid": "a178892e"
|
||||||
},
|
},
|
||||||
"devices": {
|
"devices": {
|
||||||
"device": {
|
"device": {
|
||||||
|
|
|
||||||
|
|
@ -1355,7 +1355,7 @@
|
||||||
{
|
{
|
||||||
"type": "org.osbuild.mkfs.fat",
|
"type": "org.osbuild.mkfs.fat",
|
||||||
"options": {
|
"options": {
|
||||||
"volid": ""
|
"volid": "a178892e"
|
||||||
},
|
},
|
||||||
"devices": {
|
"devices": {
|
||||||
"device": {
|
"device": {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue