debian-forge-composer/vendor/github.com/osbuild/images/pkg/image/disk.go
Achilleas Koutsou 23ba0d8ded go.mod: update osbuild/images to v0.134.1-0.20250416092909-a1ca7f
Includes

tag v0.129.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.129.0

----------------
  * Update osbuild dependency commit ID to latest (osbuild/images#1347)
    * Author: SchutzBot, Reviewers: Achilleas Koutsou, Ondřej Budai
  * distro: move fedora partition tables into YAML (osbuild/images#1362)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * osbuild: create .mount and .swap units in /etc/systemd (osbuild/images#1366)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Simon de Vlieger

— Somewhere on the Internet, 2025-03-28

---

tag v0.130.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.130.0

----------------
  * Imageconfig no osbuild (osbuild/images#1350)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * osbuild: add insights-client config stage (HMS-5670) (osbuild/images#1274)
    * Author: rverdile, Reviewers: Achilleas Koutsou, Simon de Vlieger

— Somewhere on the Internet, 2025-04-01

---

tag v0.131.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.131.0

----------------
  * Update snapshots to 20250401 (osbuild/images#1374)
    * Author: SchutzBot, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * disk: add missing json/yaml keys for disk structs (osbuild/images#1378)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * distro/fedora: move defaultImageConfig into YAML (osbuild/images#1337)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * distro: add `ImageType.BasePartitionTable()` (osbuild/images#1376)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * gen-manifests: show depsolve config in mock depsolve (osbuild/images#1379)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Simon de Vlieger
  * tools: make gen-manifests-diff run against the merge base (osbuild/images#1356)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Tomáš Hozza

— Somewhere on the Internet, 2025-04-03

---

tag v0.132.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.132.0

----------------
  * Manifest checksums: detect manifest changes in PRs (osbuild/images#1380)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Simon de Vlieger
  * manifest,image: stop embedding `OSCustomizations` in `manifest.OS` (osbuild/images#1386)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Tomáš Hozza
  * manifest: addInlineDataAndStages() helper method for the OS and OSTreeDeployment pipelines (osbuild/images#1353)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Simon de Vlieger
  * osbuild: add new stage org.osbuild.hmac (HMS-5924) (osbuild/images#1369)
    * Author: Achilleas Koutsou, Reviewers: Brian C. Lane, Tomáš Hozza
  * rhel{7,10}: move partition table into yaml (osbuild/images#1367)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger

— Somewhere on the Internet, 2025-04-07

---

tag v0.133.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.133.0

----------------
  * Update snapshots to 20250404 (osbuild/images#1389)
    * Author: SchutzBot, Reviewers: Simon de Vlieger, Tomáš Hozza
  * dnfjson: provide details if subscription cannot be found (osbuild/images#1393)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Lukáš Zapletal, Simon de Vlieger
  * manifestgen: extra io.Writer for depsolver (osbuild/images#1384)
    * Author: Simon de Vlieger, Reviewers: Michael Vogt, Tomáš Hozza

— Somewhere on the Internet, 2025-04-08

---

tag v0.134.0
Tagger: imagebuilder-bot <imagebuilder-bots+imagebuilder-bot@redhat.com>

Changes with 0.134.0

----------------
  * Distro/el10/ec2/modprobe: blacklist 'i2c_piix4' (RHEL-71926) (osbuild/images#1395)
    * Author: Tomáš Hozza, Reviewers: Achilleas Koutsou, Michael Vogt
  * Update osbuild dependency commit ID to latest (osbuild/images#1391)
    * Author: SchutzBot, Reviewers: Achilleas Koutsou, Tomáš Hozza
  * distro/rhel9/azure: blacklist more modules on 9.6+ (RHEL-79065) (osbuild/images#1394)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Simon de Vlieger
  * distro/rhel9/azure: exclude microcode_ctl on 9.6+ (RHEL-79065) (osbuild/images#1405)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Tomáš Hozza
  * test: add configs for Azure that match official builds (osbuild/images#1411)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Tomáš Hozza
  * test: fix description of `build-image` (osbuild/images#1420)
    * Author: Michael Vogt, Reviewers: Achilleas Koutsou, Simon de Vlieger
  * tools/gen-manifest-checksums: sort by image name (osbuild/images#1406)
    * Author: Achilleas Koutsou, Reviewers: Michael Vogt, Simon de Vlieger

— Somewhere on the Internet, 2025-04-14

---

commit a1ca7f34c770ac869387213923fa64ec36180084
Changes with a1ca7f34c770ac869387213923fa64ec36180084

----------------
  * RHEL 9.6+/Azure: systemd service and script for dataloss warning on temporary resource disk (osbuild/images#1434)
    * Author: Achilleas Koutsou, Reviewers: Tomáš Hozza
  * Set refclock in chrony config for Azure images on RHEL 9.6+ (RHEL-79065) (osbuild/images#1400)
    * Author: Achilleas Koutsou, Reviewers: Tomáš Hozza
  * Update snapshots to 20250415 (osbuild/images#1431)
    * Author: SchutzBot, Reviewers: Achilleas Koutsou
  * WSL: add packages for podman and proc utilities (COMPOSER-2455) (osbuild/images#1425)
    * Author: Sanne Raymaekers, Reviewers: Tomáš Hozza
  * [RHEL-9.6+/Azure]: update waagent.conf and add nvme_core.io_timeout kernel arg (osbuild/images#1430)
    * Author: Achilleas Koutsou, Reviewers: Ondřej Budai, Sanne Raymaekers
  * [RHEL/Azure RHUI] Disable `auto_enable_yum_plugins` in the RHSM config as a BP customization (osbuild/images#1415)
    * Author: Tomáš Hozza, Reviewers: Achilleas Koutsou
  * ci: dependency updater gobump golang fix (osbuild/images#1441)
    * Author: Lukáš Zapletal, Reviewers: Ondřej Budai
  * ci: dependency updater gobump typo (osbuild/images#1439)
    * Author: Lukáš Zapletal, Reviewers: Achilleas Koutsou
  * ci: dependency updater via gobump (osbuild/images#1385)
    * Author: Lukáš Zapletal, Reviewers: Achilleas Koutsou
  * distro: almalinux and almalinux_kitten (osbuild/images#1375)
    * Author: Simon de Vlieger, Reviewers: Neal Gompa (ニール・ゴンパ), Ondřej Budai
  * fedora: bump branched and rawhide (osbuild/images#1440)
    * Author: Simon de Vlieger, Reviewers: Achilleas Koutsou, Ondřej Budai
  * github: don't run manifest checksum validation on main (osbuild/images#1437)
    * Author: Achilleas Koutsou, Reviewers: Ondřej Budai, Simon de Vlieger
  * manifesttest: add helper to find stages in a pipeline (osbuild/images#1418)
    * Author: Michael Vogt, Reviewers: Lukáš Zapletal, Simon de Vlieger
  * rhsm: support for podman secrets (osbuild/images#1414)
    * Author: Lukáš Zapletal, Reviewers: Simon de Vlieger

---
2025-04-18 13:36:12 +02:00

131 lines
4.2 KiB
Go

package image
import (
"fmt"
"math/rand"
"path/filepath"
"strings"
"github.com/osbuild/images/internal/environment"
"github.com/osbuild/images/internal/workload"
"github.com/osbuild/images/pkg/artifact"
"github.com/osbuild/images/pkg/disk"
"github.com/osbuild/images/pkg/manifest"
"github.com/osbuild/images/pkg/osbuild"
"github.com/osbuild/images/pkg/platform"
"github.com/osbuild/images/pkg/rpmmd"
"github.com/osbuild/images/pkg/runner"
)
type DiskImage struct {
Base
Platform platform.Platform
PartitionTable *disk.PartitionTable
OSCustomizations manifest.OSCustomizations
Environment environment.Environment
Workload workload.Workload
Filename string
Compression string
// Control the VPC subformat use of force_size
VPCForceSize *bool
PartTool osbuild.PartTool
NoBLS bool
OSProduct string
OSVersion string
OSNick string
// InstallWeakDeps enables installation of weak dependencies for packages
// that are statically defined for the payload pipeline of the image.
InstallWeakDeps *bool
}
func NewDiskImage() *DiskImage {
return &DiskImage{
Base: NewBase("disk"),
PartTool: osbuild.PTSfdisk,
}
}
func (img *DiskImage) InstantiateManifest(m *manifest.Manifest,
repos []rpmmd.RepoConfig,
runner runner.Runner,
rng *rand.Rand) (*artifact.Artifact, error) {
buildPipeline := addBuildBootstrapPipelines(m, runner, repos, nil)
buildPipeline.Checkpoint()
osPipeline := manifest.NewOS(buildPipeline, img.Platform, repos)
osPipeline.PartitionTable = img.PartitionTable
osPipeline.OSCustomizations = img.OSCustomizations
osPipeline.Environment = img.Environment
osPipeline.Workload = img.Workload
osPipeline.OSProduct = img.OSProduct
osPipeline.OSVersion = img.OSVersion
osPipeline.OSNick = img.OSNick
if img.InstallWeakDeps != nil {
osPipeline.OSCustomizations.InstallWeakDeps = *img.InstallWeakDeps
}
rawImagePipeline := manifest.NewRawImage(buildPipeline, osPipeline)
rawImagePipeline.PartTool = img.PartTool
var imagePipeline manifest.FilePipeline
switch img.Platform.GetImageFormat() {
case platform.FORMAT_RAW:
imagePipeline = rawImagePipeline
case platform.FORMAT_QCOW2:
qcow2Pipeline := manifest.NewQCOW2(buildPipeline, rawImagePipeline)
qcow2Pipeline.Compat = img.Platform.GetQCOW2Compat()
imagePipeline = qcow2Pipeline
case platform.FORMAT_VHD:
vpcPipeline := manifest.NewVPC(buildPipeline, rawImagePipeline)
vpcPipeline.ForceSize = img.VPCForceSize
imagePipeline = vpcPipeline
case platform.FORMAT_VMDK:
imagePipeline = manifest.NewVMDK(buildPipeline, rawImagePipeline)
case platform.FORMAT_OVA:
vmdkPipeline := manifest.NewVMDK(buildPipeline, rawImagePipeline)
ovfPipeline := manifest.NewOVF(buildPipeline, vmdkPipeline)
tarPipeline := manifest.NewTar(buildPipeline, ovfPipeline, "archive")
tarPipeline.Format = osbuild.TarArchiveFormatUstar
tarPipeline.SetFilename(img.Filename)
extLess := strings.TrimSuffix(img.Filename, filepath.Ext(img.Filename))
// The .ovf descriptor needs to be the first file in the archive
tarPipeline.Paths = []string{
fmt.Sprintf("%s.ovf", extLess),
fmt.Sprintf("%s.mf", extLess),
fmt.Sprintf("%s.vmdk", extLess),
}
imagePipeline = tarPipeline
case platform.FORMAT_GCE:
// NOTE(akoutsou): temporary workaround; filename required for GCP
// TODO: define internal raw filename on image type
rawImagePipeline.SetFilename("disk.raw")
tarPipeline := newGCETarPipelineForImg(buildPipeline, rawImagePipeline, "archive")
tarPipeline.SetFilename(img.Filename) // filename extension will determine compression
imagePipeline = tarPipeline
default:
panic("invalid image format for image kind")
}
switch img.Compression {
case "xz":
xzPipeline := manifest.NewXZ(buildPipeline, imagePipeline)
xzPipeline.SetFilename(img.Filename)
return xzPipeline.Export(), nil
case "zstd":
zstdPipeline := manifest.NewZstd(buildPipeline, imagePipeline)
zstdPipeline.SetFilename(img.Filename)
return zstdPipeline.Export(), nil
case "":
// don't compress, but make sure the pipeline's filename is set
imagePipeline.SetFilename(img.Filename)
return imagePipeline.Export(), nil
default:
// panic on unknown strings
panic(fmt.Sprintf("unsupported compression type %q", img.Compression))
}
}