kmpkg

package
v0.6.25 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2025 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SerializePkgVersion

func SerializePkgVersion(config *PkgVersionConfig, indent bool) ([]byte, error)

SerializePkgVersion - Final serialization function (no duplicate structs, exclusive version fields) Enforces: Only one version field is serialized (priority: version > version-date > version-string) Ensures no coexisting version fields in output JSON

func TransPortNameFromVcpkg

func TransPortNameFromVcpkg(port string) string

Types

type BaselineConfig

type BaselineConfig struct {
	Default map[string]PackageInfo `json:"default"` // Key: package name, Value: package details
}

BaselineConfig represents the top-level JSON structure

func NewBaselineConfig

func NewBaselineConfig() *BaselineConfig

NewBaselineConfig creates a new empty BaselineConfig instance

func (*BaselineConfig) AddPackage

func (c *BaselineConfig) AddPackage(name string, info PackageInfo)

AddPackage adds a new package to the config (deduplication: overwrites if exists) Automatically maintains lexicographical order when serialized

func (*BaselineConfig) DeletePackage

func (c *BaselineConfig) DeletePackage(name string) bool

DeletePackage removes a package from the config by name Returns true if package existed and was deleted, false otherwise

func (*BaselineConfig) GetPackage

func (c *BaselineConfig) GetPackage(name string) (PackageInfo, bool)

GetPackage retrieves package information by name Returns PackageInfo and boolean indicating if package exists

func (*BaselineConfig) LoadFromFile

func (c *BaselineConfig) LoadFromFile(filePath string) error

LoadFromFile reads JSON file and parses it into BaselineConfig Returns error if file reading or JSON parsing fails

func (*BaselineConfig) SaveToFile

func (c *BaselineConfig) SaveToFile(filePath string) error

SaveToFile serializes config and writes to specified file Returns error if serialization or file writing fails

func (*BaselineConfig) Serialize

func (c *BaselineConfig) Serialize() ([]byte, error)

Serialize converts BaselineConfig to human-readable JSON bytes with: 1. Strict lexicographical order of package names (guaranteed) 2. 4-space indentation for readability Uses open-source orderedmap to avoid wheel-reinventing

func (*BaselineConfig) UpdatePackage

func (c *BaselineConfig) UpdatePackage(name string, info PackageInfo) bool

UpdatePackage modifies an existing package's information Returns true if package existed and was updated, false otherwise

type DepNode

type DepNode struct {
	Name     string
	Children map[string]*DepNode
	Parents  map[string]*DepNode
}

func NewDepNode

func NewDepNode(name string) *DepNode

type DepTree

type DepTree struct {
	// Root.DepNode means no one deps them
	Root    DepNode
	NodeSet map[string]*DepNode
	// root is first
	List []*DepNode
}

func NewDepTree

func NewDepTree() *DepTree

func (*DepTree) Append

func (d *DepTree) Append(pkgDeps string) error

func (*DepTree) Size

func (d *DepTree) Size() int

type PackageInfo

type PackageInfo struct {
	Baseline    string `json:"baseline"`
	PortVersion int    `json:"port-version"` // Corresponding to "port-version" in JSON
}

PackageInfo represents version information for a single package

type PkgVersionConfig

type PkgVersionConfig struct {
	Versions []VersionEntry `json:"versions"` // Ordered list of version entries
}

PkgVersionConfig represents the top-level JSON structure for pkgversion

func NewPkgVersionConfig

func NewPkgVersionConfig() *PkgVersionConfig

NewPkgVersionConfig creates a new empty PkgVersionConfig instance

func (*PkgVersionConfig) AddEntry

func (c *PkgVersionConfig) AddEntry(entry VersionEntry) bool

AddEntry adds a new version entry to the list (prevents duplicates) Duplicate definition: Same "git-tree" value (unique identifier) Maintains insertion order (appends to the end if not duplicate) Returns true if added successfully, false if duplicate

func (*PkgVersionConfig) DeleteEntry

func (c *PkgVersionConfig) DeleteEntry(gitTree string) bool

DeleteEntry removes a version entry by git-tree identifier Maintains order of remaining entries Returns true if entry existed and was deleted, false otherwise

func (*PkgVersionConfig) GetEntry

func (c *PkgVersionConfig) GetEntry(gitTree string) (VersionEntry, bool)

GetEntry retrieves a version entry by git-tree identifier Returns VersionEntry and boolean indicating if entry exists

func (*PkgVersionConfig) InsertEntry

func (c *PkgVersionConfig) InsertEntry(index int, entry VersionEntry) bool

InsertEntry inserts a version entry at the specified index (prevents duplicates) Returns true if inserted successfully, false if duplicate or index out of range

func (*PkgVersionConfig) LoadFromFile

func (c *PkgVersionConfig) LoadFromFile(filePath string) error

LoadFromFile reads JSON file and parses it into PkgVersionConfig Returns error if file reading or JSON parsing fails

func (*PkgVersionConfig) ReorderEntry

func (c *PkgVersionConfig) ReorderEntry(oldIndex, newIndex int) bool

ReorderEntry moves an entry from oldIndex to newIndex Maintains order of other entries Returns true if reordering was successful, false if indices are invalid

func (*PkgVersionConfig) SaveToFile

func (c *PkgVersionConfig) SaveToFile(filePath string, indent bool) error

SaveToFile persists PkgVersionConfig to file using the final serializer indent: Enable human-readable pretty-printed output if true

func (*PkgVersionConfig) UpdateEntry

func (c *PkgVersionConfig) UpdateEntry(gitTree string, newEntry VersionEntry) bool

UpdateEntry modifies an existing version entry (identified by git-tree) Preserves the entry's position in the list Returns true if entry existed and was updated, false otherwise

type RepositoryLayout

type RepositoryLayout struct {
	Root     string
	Vcpkg    bool
	MetaFile string
}

func NewRepositoryLayout

func NewRepositoryLayout(root string, vc bool) *RepositoryLayout

func (*RepositoryLayout) BaselineFile

func (r *RepositoryLayout) BaselineFile() string

func (*RepositoryLayout) DependAll

func (r *RepositoryLayout) DependAll() (*DepTree, error)

func (*RepositoryLayout) DependInfo

func (r *RepositoryLayout) DependInfo(port string) (string, error)

DependInfo executes "ExecCmd() depend-info port" and returns stderr output

func (*RepositoryLayout) DependInfoBatch

func (r *RepositoryLayout) DependInfoBatch(ports []string) (string, error)

func (*RepositoryLayout) DependTree

func (r *RepositoryLayout) DependTree(ports []string) (*DepTree, error)

func (*RepositoryLayout) ExecCmd

func (r *RepositoryLayout) ExecCmd() string

func (*RepositoryLayout) ListPorts

func (r *RepositoryLayout) ListPorts() ([]string, error)

func (*RepositoryLayout) PkgFile

func (r *RepositoryLayout) PkgFile(p string) string

func (*RepositoryLayout) PortDir

func (r *RepositoryLayout) PortDir(p string) string

func (*RepositoryLayout) PortFile

func (r *RepositoryLayout) PortFile(p string) string

func (*RepositoryLayout) PortRoot

func (r *RepositoryLayout) PortRoot() string

func (*RepositoryLayout) VersionFile

func (r *RepositoryLayout) VersionFile(p string) string

type VersionEntry

type VersionEntry struct {
	GitTree       string `json:"git-tree"`                 // Git tree hash identifier (unique key)
	Version       string `json:"version,omitempty"`        // Semantic version (e.g., "8.0.1") - omitempty to exclude empty field
	VersionString string `json:"version-string,omitempty"` // Custom string version (e.g., "beta-2025") - omitempty to exclude empty field
	VersionDate   string `json:"version-date,omitempty"`   // Date format version (e.g., "2025-12-01") - New: Supports date-type version
	VersionSemver string `json:"version-semver,omitempty"` //  Semantic version (e.g., "8.0.1") - omitempty to exclude empty field
	PortVersion   int    `json:"port-version"`             // Port-specific version increment
}

VersionEntry supports three version types: 1. version: Semantic version (e.g., "8.0.1") 2. version-string: Custom string version (e.g., "beta-2025") 3. version-date: Date format version (e.g., "2025-12-01") Only one version field is serialized (priority: version > version-date > version-string) Unmarshals compatible with all three fields

func FindMatchedVersionEntry

func FindMatchedVersionEntry(config *PkgVersionConfig, baselineInfo PackageInfo) (VersionEntry, bool)

FindMatchedVersionEntry searches for VersionEntry in PkgVersionConfig that matches BaselineInfo Matching rule: (Version == Baseline OR VersionString == Baseline OR VersionDate == Baseline) AND PortVersion == PortVersion Adapts to three version types: semantic, custom string, date format

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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