imagecustomizerlib

package
v0.0.0-...-120377d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 17, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PxeDracutMinVersion        = 102
	PxeDracutMinPackageRelease = 7
	PxeDracutDistroName        = "azl"
	PxeDracutMinDistroVersion  = 3
)
View Source
const (
	SkippableFrameMagicNumber uint32 = 0x184D2A50
	SkippableFramePayloadSize uint32 = UuidSize
	SkippableFrameHeaderSize  int    = 8
)
View Source
const (

	// supported input formats
	ImageFormatVhd      = "vhd"
	ImageFormatVhdFixed = "vhd-fixed"
	ImageFormatVhdx     = "vhdx"
	ImageFormatQCow2    = "qcow2"
	ImageFormatIso      = "iso"
	ImageFormatRaw      = "raw"

	// qemu-specific formats
	QemuFormatVpc = "vpc"

	BaseImageName                = "image.raw"
	PartitionCustomizedImageName = "image2.raw"
)
View Source
const (
	UuidSize uint32 = 16
)

Variables

View Source
var (
	// Version specifies the version of the Azure Linux Image Customizer tool.
	// The value of this string is inserted during compilation via a linker flag.
	ToolVersion = ""
)

Functions

func AddOrUpdateUsers

func AddOrUpdateUsers(users []imagecustomizerapi.User, baseConfigPath string, imageChroot safechroot.ChrootInterface) error

func CustomizeImage

func CustomizeImage(buildDir string, baseConfigPath string, config *imagecustomizerapi.Config, imageFile string,
	rpmsSources []string, outputImageFile string, outputImageFormat string, outputSplitPartitionsFormat string,
	outputPXEArtifactsDir string, useBaseImageRpmRepos bool, enableShrinkFilesystems bool,
) error

func CustomizeImageWithConfigFile

func CustomizeImageWithConfigFile(buildDir string, configFile string, imageFile string,
	rpmsSources []string, outputImageFile string, outputImageFormat string,
	outputSplitPartitionsFormat string, outputPXEArtifactsDir string,
	useBaseImageRpmRepos bool, enableShrinkFilesystems bool,
) error

func FindLinuxLine

func FindLinuxLine(inputGrubCfgContent string) (grub.Line, error)

Find the linux command within the grub config file.

func FindNonRecoveryLinuxLine

func FindNonRecoveryLinuxLine(inputGrubCfgContent string) ([]grub.Line, error)

Find the linux command within non-recovery mode menuentry block in the grub config file.

func GetDefaultGrubFileLinuxArgs

func GetDefaultGrubFileLinuxArgs(defaultGrubFileContent string, varName defaultGrubFileVarName,
) (defaultGrubFileVarAssign, []grubConfigLinuxArg, int, error)

Takes the string contents of a /etc/default/grub file and the name of the command-line args variable (either "GRUB_CMDLINE_LINUX" or "GRUB_CMDLINE_LINUX_DEFAULT") and returns a list of kernel command-line args.

Params:

  • defaultGrubFileContent: The string contents of the /etc/default/grub file.
  • varName: The name of variable that contains kernel command-line args. Either "GRUB_CMDLINE_LINUX" or "GRUB_CMDLINE_LINUX_DEFAULT".

Returns:

  • cmdLineVarAssign: The variable assignment that matches 'varName'.
  • args: The list of kernel command-line args.
  • insertAt: An index that new kernel command-line args can be inserted at.

func GrubArgsToString

func GrubArgsToString(args []string) string

Takes a list of unescaped and unquoted kernel command-line args and combines them into a single string with appropriate quoting for a grub.cfg file.

func ParseCommandLineArgs

func ParseCommandLineArgs(argTokens []grub.Token) ([]grubConfigLinuxArg, error)

Takes a tokenized grub.cfg file and makes a best effort to extract the kernel command-line args.

func ReadGrub2ConfigFile

func ReadGrub2ConfigFile(imageChroot safechroot.ChrootInterface) (string, error)

Reads the /boot/grub2/grub.cfg file.

func UpdateDefaultGrubFileVariable

func UpdateDefaultGrubFileVariable(defaultGrubFileContent string, varName string, newValue string) (string, error)

Sets the value of a variable in the /etc/default/grub file, either replacing the existing variable value (if one exists) or adding a new one.

func UpdateHostname

func UpdateHostname(hostname string, imageChroot safechroot.ChrootInterface) error

func UpdateSELinuxModeInConfigFile

func UpdateSELinuxModeInConfigFile(selinuxMode imagecustomizerapi.SELinuxMode, imageChroot safechroot.ChrootInterface) error

func WriteDefaultGrubFile

func WriteDefaultGrubFile(grub2Config string, imageChroot safechroot.ChrootInterface) error

Writes the string contents of the /etc/default/grub file.

Types

type BootCustomizer

type BootCustomizer struct {
	// contains filtered or unexported fields
}

func NewBootCustomizer

func NewBootCustomizer(imageChroot safechroot.ChrootInterface) (*BootCustomizer, error)

func (*BootCustomizer) AddKernelCommandLine

func (b *BootCustomizer) AddKernelCommandLine(extraCommandLine string) error

Inserts new kernel command-line args into the grub config file.

func (*BootCustomizer) GetSELinuxMode

func (*BootCustomizer) IsGrubMkconfigImage

func (b *BootCustomizer) IsGrubMkconfigImage() bool

Returns whether or not the OS uses grub-mkconfig.

func (*BootCustomizer) PrepareForVerity

func (b *BootCustomizer) PrepareForVerity() error

Makes changes to the /etc/default/grub file that are needed/useful for enabling verity.

func (*BootCustomizer) SetRootDevice

func (b *BootCustomizer) SetRootDevice(rootDevice string) error

func (*BootCustomizer) UpdateKernelCommandLineArgs

func (b *BootCustomizer) UpdateKernelCommandLineArgs(defaultGrubFileVarName defaultGrubFileVarName,
	argsToRemove []string, newArgs []string,
) error

func (*BootCustomizer) UpdateSELinuxCommandLine

func (b *BootCustomizer) UpdateSELinuxCommandLine(selinuxMode imagecustomizerapi.SELinuxMode) error

Update the image's SELinux kernel command-line args.

func (*BootCustomizer) WriteToFile

func (b *BootCustomizer) WriteToFile(imageChroot safechroot.ChrootInterface) error

type DracutPackageInformation

type DracutPackageInformation struct {
	PackageVersion uint32 `yaml:"packageVersion"`
	PackageRelease uint32 `yaml:"packageRelease"`
	DistroName     string `yaml:"distroName"`
	DistroVersion  uint32 `yaml:"distroVersion"`
}

type ImageConnection

type ImageConnection struct {
	// contains filtered or unexported fields
}

func NewImageConnection

func NewImageConnection() *ImageConnection

func (*ImageConnection) Chroot

func (c *ImageConnection) Chroot() *safechroot.Chroot

func (*ImageConnection) CleanClose

func (c *ImageConnection) CleanClose() error

func (*ImageConnection) Close

func (c *ImageConnection) Close()

func (*ImageConnection) ConnectChroot

func (c *ImageConnection) ConnectChroot(rootDir string, isExistingDir bool, extraDirectories []string,
	extraMountPoints []*safechroot.MountPoint, includeDefaultMounts bool,
) error

func (*ImageConnection) ConnectLoopback

func (c *ImageConnection) ConnectLoopback(diskFilePath string) error

func (*ImageConnection) Loopback

func (c *ImageConnection) Loopback() *safeloopback.Loopback

type ImageCustomizerParameters

type ImageCustomizerParameters struct {
	// contains filtered or unexported fields
}

type IsoArtifacts

type IsoArtifacts struct {
	// contains filtered or unexported fields
}

`IsoArtifacts` holds the extracted/generated artifacts necessary to build a LiveOS ISO image.

type IsoSavedConfigs

type IsoSavedConfigs struct {
	KernelCommandLine imagecustomizerapi.KernelCommandLine `yaml:"kernelCommandLine"`
}

func (*IsoSavedConfigs) IsValid

func (i *IsoSavedConfigs) IsValid() error

type IsoWorkingDirs

type IsoWorkingDirs struct {
	// contains filtered or unexported fields
}

type LiveOSIsoBuilder

type LiveOSIsoBuilder struct {
	// contains filtered or unexported fields
}

type OSSavedConfigs

type OSSavedConfigs struct {
	DracutPackageInfo *DracutPackageInformation `yaml:"dracutPackage"`
}

func (*OSSavedConfigs) IsValid

func (i *OSSavedConfigs) IsValid() error

type PxeSavedConfigs

type PxeSavedConfigs struct {
	IsoImageBaseUrl string `yaml:"isoImageBaseUrl"`
	IsoImageFileUrl string `yaml:"isoImageFileUrl"`
}

func (*PxeSavedConfigs) IsValid

func (p *PxeSavedConfigs) IsValid() error

type SavedConfigs

type SavedConfigs struct {
	Iso IsoSavedConfigs `yaml:"iso"`
	Pxe PxeSavedConfigs `yaml:"pxe"`
	OS  OSSavedConfigs  `yaml:"os"`
}

func (*SavedConfigs) IsValid

func (c *SavedConfigs) IsValid() (err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL