repository

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 31, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Index

Constants

View Source
const (
	HostWindowsX86   = "windows_x86"
	HostWindowsARM64 = "windows_arm64"
	HostLinuxX64     = "linux_x64"
	HostLinuxARM64   = "linux_arm64"
	HostMacX64       = "mac_x64"
)

Recognized host platform identifiers for Qt repositories.

View Source
const (
	TargetDesktop = "desktop"
	TargetAndroid = "android"
	TargetIOS     = "ios"
	TargetWASM    = "wasm"
)

Recognized Qt target platform identifiers.

View Source
const MaxCacheAge = 30 * 24 * time.Hour

MaxCacheAge is the maximum age of cached metadata that may be served when all mirrors are unreachable. Older cached copies are refused to avoid silently installing stale Qt versions.

View Source
const MirrorListURL = "https://download.qt.io/static/mirrorlist/"

MirrorListURL is the Qt project page that lists community download mirrors.

Variables

ValidHosts lists the recognized host platform identifiers for Qt repositories.

ValidTargets lists the recognized Qt target platform identifiers. WinRT is intentionally absent: it was removed from Qt 6.

Functions

func ExtensionModuleNames

func ExtensionModuleNames() []string

ExtensionModuleNames returns the list of known Qt extension modules. Starting from Qt 6.8.0, these modules are served from a separate extensions/ repository path instead of the main desktop Updates.xml.

func FetchMirrorList

func FetchMirrorList(ctx context.Context, timeoutSeconds int) ([]string, error)

FetchMirrorList downloads Qt's mirror list page and returns the mirror base URLs. Each returned URL ends with "/" and is suitable as a mirror base (no online/qtsdkrepository/ suffix).

func ParseMirrorListHTML

func ParseMirrorListHTML(body []byte) []string

ParseMirrorListHTML extracts HTTPS mirror base URLs from Qt's mirrorlist HTML page. It skips Qt's own infrastructure domains and normalizes URLs to end with "/".

func PlatformHost

func PlatformHost() string

PlatformHost returns the repository host path component for the current OS/arch.

Types

type Arch

type Arch struct {
	Name             string   `json:"name"`                        // e.g. "win64_msvc2022_64"
	DisplayName      string   `json:"display_name"`                // e.g. "MSVC 2022, 64-bit"
	IsDefault        bool     `json:"is_default,omitempty"`        // true = recommended for the current host
	EssentialModules []string `json:"essential_modules,omitempty"` // module names derived from this arch's DownloadableArchives
}

Arch describes a build arch (OS + compiler combination).

type ArchiveEntry

type ArchiveEntry struct {
	Filename         string
	CompressedSize   int64
	UncompressedSize int64
	SHA1             string
}

ArchiveEntry holds SHA1+size info for a single archive within a PackageUpdate.

type ArchiveRef

type ArchiveRef struct {
	URL      string `json:"url"`
	Filename string `json:"filename"`       // e.g. "qtbase-Windows-...7z"
	SHA1     string `json:"sha1"`           // Expected SHA1 hex digest
	Size     int64  `json:"size,omitempty"` // Compressed size in bytes (may be 0 if unknown)
}

ArchiveRef describes a single downloadable archive within a package.

type Cache

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

Cache manages on-disk gzip-compressed XML metadata files.

func NewCache

func NewCache() (*Cache, error)

NewCache creates a Cache using the OS cache directory.

func (*Cache) Age

func (c *Cache) Age(key string) time.Duration

Age returns the age of the cached entry for key, or 0 if no entry exists.

func (*Cache) Dir

func (c *Cache) Dir() string

Dir returns the cache directory path.

func (*Cache) ETag

func (c *Cache) ETag(key string) string

ETag returns the stored ETag for key, or "" if none.

func (*Cache) IsStale

func (c *Cache) IsStale(key string, maxAge time.Duration) bool

IsStale reports whether the cached entry for key is older than maxAge.

func (*Cache) Load

func (c *Cache) Load(key string) ([]byte, error)

Load returns the cached XML body for key, decompressed. Returns nil, nil if no cache entry exists.

func (*Cache) LoadStale

func (c *Cache) LoadStale(key string) ([]byte, error)

LoadStale returns the cached XML body regardless of staleness.

func (*Cache) Store

func (c *Cache) Store(key string, body []byte, etag string) error

Store saves body (XML) compressed with gzip and the etag.

type Client

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

Client wraps an HTTP client with retry logic and ETag support.

func NewClient

func NewClient(timeoutSeconds int) *Client

NewClient creates a new repository HTTP client.

func (*Client) FetchBytes

func (c *Client) FetchBytes(ctx context.Context, url string) ([]byte, error)

FetchBytes fetches a URL and returns its body.

func (*Client) FetchWithETag

func (c *Client) FetchWithETag(ctx context.Context, url, etag string) ([]byte, string, error)

FetchWithETag fetches a URL, sending If-None-Match if etag is non-empty. Returns (body, newETag, error). If the server returns 304, body is nil.

func (*Client) Head

func (c *Client) Head(ctx context.Context, url string) (int, error)

Head performs an HTTP HEAD request and returns the status code.

type MetadataFetcher

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

MetadataFetcher fetches and parses Qt repository metadata.

func NewMetadataFetcher

func NewMetadataFetcher(client *Client, cache *Cache, mirrors *MirrorList) *MetadataFetcher

NewMetadataFetcher creates a MetadataFetcher.

func (*MetadataFetcher) FetchAllQtVersions

func (f *MetadataFetcher) FetchAllQtVersions(ctx context.Context) ([]QtVersionInfo, error)

FetchAllQtVersions fetches the list of available Qt versions by parsing the HTML directory listing at the repository base URL. The response is cached on disk (with ETag revalidation) and all configured mirrors are tried in order before falling back to stale cache.

func (*MetadataFetcher) FetchQtVersion

func (f *MetadataFetcher) FetchQtVersion(ctx context.Context, version string) (*RepoIndex, error)

FetchQtVersion fetches metadata for a specific Qt version. For Qt 6.8+, it also fetches extension modules (qtwebengine, qtpdf) and merges them into the result as regular add-on modules. Returns an error for preview versions that have no published metadata.

type Mirror

type Mirror struct {
	URL string
}

Mirror holds a base URL for the Qt repository.

type MirrorList

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

MirrorList manages the ordered list of mirrors to try.

func NewMirrorList

func NewMirrorList(primary string, fallbacks []string, host, target string) *MirrorList

NewMirrorList creates a MirrorList from a primary URL, fallbacks, host, and target platform. An empty target defaults to desktop.

func (*MirrorList) DirectoryURLs

func (m *MirrorList) DirectoryURLs() []string

DirectoryURLs returns directory listing URLs for all mirrors in order.

func (*MirrorList) ExtensionURLsFor

func (m *MirrorList) ExtensionURLsFor(moduleName, version string, major int, arch string) []string

ExtensionURLsFor returns URLs for an extension module's Updates.xml. Extension repos live at:

{base}online/qtsdkrepository/{host}/extensions/{module}/{compactVer}/{archSubdir}/Updates.xml

func (*MirrorList) PerArchURL

func (m *MirrorList) PerArchURL(version string, major int, archFolder string) []string

PerArchURL returns the Updates.xml URL for a specific arch subfolder.

func (*MirrorList) ProbeURL

func (m *MirrorList) ProbeURL(version string, major int) string

ProbeURL returns a URL used to detect whether a version is released or preview. For Qt 6.11+ it probes the version directory listing (which exists for released versions); for Qt 6.8-6.10 it probes the combined Updates.xml. Returns "" for pre-6.8 versions.

func (*MirrorList) SrcDocExURLsFor

func (m *MirrorList) SrcDocExURLsFor(version string, major int) []string

SrcDocExURLsFor returns URLs for the src/doc/examples repository Updates.xml. Qt 6.8+ moved these packages to a separate all_os repository:

{base}online/qtsdkrepository/all_os/qt/qt6_{ver}_unix_line_endings_src/Updates.xml

Pre-6.8 Qt 6 versions used per-platform directories:

{base}online/qtsdkrepository/{host}/desktop/qt6_{ver}_src_doc_examples/Updates.xml

func (*MirrorList) URLsFor

func (m *MirrorList) URLsFor(version string, major int) []string

URLsFor returns an ordered list of URLs to try for the given Qt SDK parameters. base is the mirror base URL, host is "windows_x86"/"linux_x64"/"mac_x64", etc.

func (*MirrorList) URLsForMasterList

func (m *MirrorList) URLsForMasterList() []string

URLsForMasterList returns URLs for the master list of available Qt versions. This fetches a listing that enumerates available versions.

func (*MirrorList) VersionDirURLs

func (m *MirrorList) VersionDirURLs(version string, major int) []string

VersionDirURLs returns URLs for the version directory listing. Used to discover per-arch subfolders for Qt 6.11+ on platforms that use them.

type MirrorListCache

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

MirrorListCache manages the on-disk cache of Qt mirrors fetched from MirrorListURL. The cache is only refreshed when the caller explicitly calls Save.

func NewMirrorListCache

func NewMirrorListCache() (*MirrorListCache, error)

NewMirrorListCache creates a MirrorListCache stored in the OS cache directory.

func NewMirrorListCacheAt

func NewMirrorListCacheAt(path string) *MirrorListCache

NewMirrorListCacheAt creates a MirrorListCache at a specific path. Intended for testing.

func (*MirrorListCache) Exists

func (c *MirrorListCache) Exists() bool

Exists reports whether a cached mirror list is present on disk.

func (*MirrorListCache) Load

func (c *MirrorListCache) Load() ([]string, error)

Load returns the cached mirror list. Returns nil, nil if no cache exists yet.

func (*MirrorListCache) Path

func (c *MirrorListCache) Path() string

Path returns the path to the cache file.

func (*MirrorListCache) Save

func (c *MirrorListCache) Save(mirrors []string) error

Save writes mirrors to the cache file, overwriting any previous contents.

type Module

type Module struct {
	Name        string       `json:"name"`                   // e.g. "qtcharts"
	DisplayName string       `json:"display_name"`           // e.g. "Qt Charts"
	IsEssential bool         `json:"is_essential,omitempty"` // true = always installed (set when building an arch-specific list)
	Archives    []ArchiveRef `json:"archives,omitempty"`     // archives for this module (may depend on arch)
}

Module describes an installable Qt module.

type PackageUpdate

type PackageUpdate struct {
	Name                 string
	DisplayName          string
	Description          string
	Version              string
	ReleaseDate          time.Time
	DownloadableArchives []string
	ArchiveSHA1          []string // parallel to DownloadableArchives
	Dependencies         []string
	Virtual              bool
	SizeCompressed       int64
	SizeUncompressed     int64
}

PackageUpdate mirrors one <PackageUpdate> element from Updates.xml.

type ProbeResult

type ProbeResult struct {
	URL       string
	Latency   time.Duration
	Reachable bool
}

ProbeResult holds the outcome of probing a single mirror.

func ProbeURLs

func ProbeURLs(ctx context.Context, urls []string, timeoutSeconds int, host string) []ProbeResult

ProbeURLs measures response latency to each base URL concurrently. Each URL is probed by fetching the platform-specific desktop directory listing. Returns results sorted fastest-first; unreachable mirrors are appended last.

type QtVersionInfo

type QtVersionInfo struct {
	Version      string    `json:"version"`
	Major        int       `json:"major"`
	IsLTS        bool      `json:"is_lts,omitempty"`
	IsPreview    bool      `json:"is_preview,omitempty"`
	ReleaseDate  time.Time `json:"release_date,omitzero"`
	Archs        []Arch    `json:"archs,omitempty"`
	Modules      []Module  `json:"modules,omitempty"` // Add-on modules only (not essentials; those are per-arch)
	HasDocs      bool      `json:"has_docs,omitempty"`
	HasExamples  bool      `json:"has_examples,omitempty"`
	HasSources   bool      `json:"has_sources,omitempty"`
	HasDebugInfo bool      `json:"has_debug_info,omitempty"`
	// PackageArchives maps Qt package name -> archive list (internal; not exposed in JSON output).
	// Keys follow the Updates.xml package naming convention, e.g.:
	//   "qt.qt6.6101.win64_msvc2022_64"             (essential bundle)
	//   "qt.qt6.6101.addons.qtcharts.win64_msvc2022_64" (addon module)
	//   "qt.qt6.6101.doc.qtcharts"                   (documentation)
	PackageArchives map[string][]ArchiveRef `json:"-"`
}

QtVersionInfo describes an available Qt SDK version.

func (*QtVersionInfo) ModulesForArch

func (vi *QtVersionInfo) ModulesForArch(archName string) []Module

ModulesForArch returns the full module list for a specific arch: the arch's essential modules (as Module{IsEssential: true}) followed by all add-on modules. Returns only add-ons if the arch is not found.

func (*QtVersionInfo) SetDefaultArch

func (vi *QtVersionInfo) SetDefaultArch(name string)

SetDefaultArch marks the named arch as IsDefault (and clears the flag on all others). Call this after fetching metadata, once the platform default is known.

type RepoIndex

type RepoIndex struct {
	QtVersions []QtVersionInfo `json:"qt_versions,omitempty"`
}

RepoIndex holds the full parsed repository state.

type ResolveOptions

type ResolveOptions struct {
	Version        string
	Arch           string   // e.g. "win64_msvc2022_64"
	Modules        []string // add-on module names to install (delta - only new ones)
	AllModules     []string // all module names (existing + new) for scoping docs/examples
	Docs           bool
	Examples       bool
	Sources        bool
	DebugInfo      bool
	SkipEssentials bool // true when the essential bundle is already installed
}

ResolveOptions configures what archives to resolve for a Qt install. The target platform (desktop/android/ios/wasm) is configured on the underlying MetadataFetcher's MirrorList, not here, since it only affects URL construction.

type ResolvedArchive

type ResolvedArchive struct {
	Name string // package name, e.g. "qt.qt6.6100.win64_msvc2022_64"
	Ref  ArchiveRef
}

ResolvedArchive is a single archive selected for download.

type Resolver

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

Resolver translates user intent into a concrete list of archives to download.

func NewResolver

func NewResolver(fetcher *MetadataFetcher) *Resolver

NewResolver creates a Resolver backed by the given MetadataFetcher.

func (*Resolver) FetchChecksums added in v0.1.3

func (r *Resolver) FetchChecksums(ctx context.Context, archives []ResolvedArchive)

FetchChecksums populates each archive's Ref.SHA1 from its ".sha1" sidecar file, fetched concurrently. Qt does not embed data-archive digests in Updates.xml, so this is how integrity verification is enabled. Archives whose sidecar is missing or unreadable are left with an empty SHA1 (and will be downloaded unverified).

func (*Resolver) Resolve

func (r *Resolver) Resolve(ctx context.Context, opts ResolveOptions) ([]ResolvedArchive, error)

Resolve returns the archives needed for the given options.

Jump to

Keyboard shortcuts

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