Help us shape the future of Go! Take the 2026 Go Developer Survey

diskimage

package
v0.11.2 Latest Latest
Warning

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

Go to latest
Published: Oct 22, 2026 License: Apache-2.0, MIT Imports: 24 Imported by: 0

Documentation

Overview

Package diskimage reads selected installer payloads from portable HFS+ and APFS DMGs and writes application DMGs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Extract

func Extract(ctx context.Context, input, destination, selection string, keep archive.Leaves) (result string, err error)

Extract writes the app, flat PKG or nested disk image at an exact path in the image under a new destination directory, returning its path. keep names the files of a selected app to write, relative to it, and nil writes them all; only directories leading to a kept file are listed. Partial output is removed on failure. Images are read without mounting them.

The result is an inspection copy: file bytes, modes, times and confined symlinks. Filesystem metadata remains in the original DMG, which is the installer artifact. This copy must not be used to repackage an application.

func HasTrailer added in v0.9.0

func HasTrailer(source io.ReaderAt, size int64) bool

HasTrailer recognizes a UDIF disk image independently of its filename. Open validates the complete image before exposing its contents.

func WriteApplication added in v0.3.0

func WriteApplication(ctx context.Context, source fs.ReadLinkFS, app, output string, compression Compression, timestamp time.Time) (err error)

WriteApplication writes a new DMG holding one application bundle at the root of an HFS+ volume named after it, with its chunks compressed by compression. The image carries the bundle's bytes, attributes, permission bits and confined relative symlinks, owned by root, with every date set to timestamp, so the same bundle, compression and timestamp produce the same bytes on every host. The bundle is never mounted or executed. Source names and symlink targets use POSIX paths, independent of the host.

Types

type Compression added in v0.6.0

type Compression string

Compression names the codec that compresses a disk image's data chunks.

const (
	LZFSE Compression = "lzfse"
	Zlib  Compression = "zlib"
	LZMA  Compression = "lzma"
)

Chunk codecs, as hdiutil's ULFO, UDZO and ULMO formats use them.

type Image added in v0.3.0

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

Image is an open, read-only filesystem in a DMG. Files remain valid until Close. The source and the selected payload are never mounted or executed.

func Open added in v0.3.0

func Open(ctx context.Context, filename string) (*Image, error)

Open reads DMG metadata and opens its single filesystem. Data chunks are decompressed by filesystem reads, without creating a raw filesystem image.

func (*Image) Close added in v0.3.0

func (image *Image) Close() error

Close releases the volume and source file.

func (*Image) Extract added in v0.3.0

func (image *Image) Extract(ctx context.Context, destination, selection string, keep archive.Leaves) (result string, err error)

Extract copies a payload from the open image into a new directory.

func (*Image) Lstat added in v0.3.0

func (image *Image) Lstat(name string) (fs.FileInfo, error)

Lstat describes the named entry. Volumes never follow symlinks, so it is Stat.

func (image *Image) ReadLink(name string) (string, error)

ReadLink returns a symlink's target, making an image an fs.ReadLinkFS.

Jump to

Keyboard shortcuts

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