constants

package
v2.0.2 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Overview

Package constants provides centralized constants and mappings for all package formats.

Package constants defines global constants and configuration values used throughout YAP.

Package constants provides centralized constants and mappings for all package formats.

Package constants defines global constants and configuration values used throughout YAP.

Package constants provides centralized constants and mappings for all package formats.

Index

Constants

View Source
const (
	// ArchX86_64 represents 64-bit x86 architecture (canonical name).
	ArchX86_64 = "x86_64"
	// ArchI686 represents 32-bit x86 architecture (canonical name).
	ArchI686 = "i686"
	// ArchAarch64 represents 64-bit ARM architecture (canonical name).
	ArchAarch64 = "aarch64"
	// ArchArmv7 represents 32-bit ARMv7 architecture (canonical name).
	ArchArmv7 = "armv7"
	// ArchArmv6 represents 32-bit ARMv6 architecture (canonical name).
	ArchArmv6 = "armv6"
	// ArchPpc64le represents 64-bit PowerPC little-endian architecture (canonical name).
	ArchPpc64le = "ppc64le"
	// ArchS390x represents 64-bit IBM System z architecture (canonical name).
	ArchS390x = "s390x"
	// ArchRiscv64 represents 64-bit RISC-V architecture (canonical name).
	ArchRiscv64 = "riscv64"
)

Canonical Architecture Names

YAP uses a consistent set of canonical architecture names internally. These names are used in toolchain definitions and cross-compilation logic. External architecture names (aliases) are normalized to these canonical names.

Canonical Names:

  • x86_64 : 64-bit x86 (also known as amd64, x86-64)
  • i686 : 32-bit x86 (also known as i386, i586, x86)
  • aarch64 : 64-bit ARM (also known as arm64)
  • armv7 : 32-bit ARMv7 (also known as armv7h, armv7l, armhf)
  • armv6 : 32-bit ARMv6 (also known as armv6h, armv6l, arm)
  • ppc64le : 64-bit PowerPC little-endian
  • s390x : 64-bit IBM System z
  • riscv64 : 64-bit RISC-V

Format-Specific Translations: These canonical names are translated to format-specific names when building packages:

  • APK: x86_64, x86, aarch64, armv7, armhf
  • DEB: amd64, i386, arm64, armhf, armel
  • RPM: x86_64, i686, aarch64, armv7hl
  • Pacman: x86_64, i686, aarch64, armv7h, armv6h
View Source
const (
	// ArchAmd64 is the Debian/Go alias for x86_64.
	ArchAmd64 = "amd64"
	// ArchI386 is the Debian alias for i686.
	ArchI386 = "i386"
	// ArchArm64 is the Debian/Go alias for aarch64.
	ArchArm64 = "arm64"
	// ArchArm is the bare ARM identifier (used as armv6 alias in many places).
	ArchArm = "arm"
	// ArchArmel is the Debian alias for armv6 (soft-float).
	ArchArmel = "armel"
	// ArchArmhf is the Debian alias for armv7 (hard-float).
	ArchArmhf = "armhf"
	// ArchArmv7h is the Pacman/RPM alias for armv7.
	ArchArmv7h = "armv7h"
	// ArchArmv6h is the Pacman alias for armv6.
	ArchArmv6h = "armv6h"
	// ArchArmv7l is the Linux uname alias for armv7.
	ArchArmv7l = "armv7l"
	// ArchArmv7hl is the RPM alias for armv7.
	ArchArmv7hl = "armv7hl"
	// ArchArmv6l is the Linux uname alias for armv6.
	ArchArmv6l = "armv6l"
	// ArchAny represents architecture-independent packages.
	ArchAny = "any"
	// ArchAll is the Debian/APK alias for "any".
	ArchAll = "all"
	// ArchNoarch is the RPM alias for "any".
	ArchNoarch = "noarch"
	// ArchX8664Dash is the dashed alias for x86_64 (used by some tools).
	ArchX8664Dash = "x86-64"
	// ArchX64 is a short alias for x86_64.
	ArchX64 = "x64"
	// ArchX86 is the i686 alias used by APK and others.
	ArchX86 = "x86"
	// ArchI586 is an i686 alias.
	ArchI586 = "i586"
	// ArchI486 is an i686 alias.
	ArchI486 = "i486"
	// ArchIa32 is an i686 alias.
	ArchIa32 = "ia32"
	// ArchPowerpc64le is a long alias for ppc64le.
	ArchPowerpc64le = "powerpc64le"
	// ArchPpc64el is the Debian alias for ppc64le.
	ArchPpc64el = "ppc64el"
	// ArchPpc64 is the big-endian PowerPC 64.
	ArchPpc64 = "ppc64"
	// ArchRiscv64gc is an alias for riscv64 with general+compressed extension.
	ArchRiscv64gc = "riscv64gc"
	// ArchMips is 32-bit big-endian MIPS.
	ArchMips = "mips"
	// ArchMipsle is 32-bit little-endian MIPS.
	ArchMipsle = "mipsle"
)

Architecture alias constants (non-canonical names used by various distros).

These are the format-specific or distro-specific spellings of architectures that get translated to canonical names via NormalizeArchitecture.

View Source
const (
	// TripletAarch64Linux is the GNU triplet for aarch64-linux-gnu.
	TripletAarch64Linux = "aarch64-linux-gnu"
	// TripletArmLinuxHf is the GNU triplet for arm-linux-gnueabihf (armv7).
	TripletArmLinuxHf = "arm-linux-gnueabihf"
	// TripletI686Linux is the GNU triplet for i686-linux-gnu.
	TripletI686Linux = "i686-linux-gnu"
	// TripletX8664Linux is the GNU triplet for x86_64-linux-gnu.
	TripletX8664Linux = "x86_64-linux-gnu"
	// TripletPpc64leLinux is the GNU triplet for powerpc64le-linux-gnu.
	TripletPpc64leLinux = "powerpc64le-linux-gnu"
	// TripletS390xLinux is the GNU triplet for s390x-linux-gnu.
	TripletS390xLinux = "s390x-linux-gnu"
	// TripletRiscv64Linux is the GNU triplet for riscv64-linux-gnu.
	TripletRiscv64Linux = "riscv64-linux-gnu"
)

Cross-compilation toolchain triplet constants.

These are GNU triplets used to identify cross-compilers and target sysroots.

View Source
const (
	// DockerOrg defines the Docker organization prefix for YAP containers.
	DockerOrg = "docker.io/m0rf30/yap-"
	// Git defines the git command name.
	Git = "git"
	// GoArchiveURL defines the URL for the Go programming language archive.
	GoArchiveURL = "https://go.dev/dl/go1.26.1.linux-amd64.tar.gz"
	// YAPVersion defines the current version of YAP.
	YAPVersion = "v2.0.0"
)
View Source
const (
	// DistroAlmalinux is the os-release ID for AlmaLinux.
	DistroAlmalinux = "almalinux"
	// DistroAlpine is the os-release ID for Alpine Linux.
	DistroAlpine = "alpine"
	// DistroAmzn is the os-release ID for Amazon Linux.
	DistroAmzn = "amzn"
	// DistroArch is the os-release ID for Arch Linux.
	DistroArch = "arch"
	// DistroCentos is the os-release ID for CentOS.
	DistroCentos = "centos"
	// DistroDebian is the os-release ID for Debian.
	DistroDebian = "debian"
	// DistroFedora is the os-release ID for Fedora.
	DistroFedora = "fedora"
	// DistroLinuxmint is the os-release ID for Linux Mint.
	DistroLinuxmint = "linuxmint"
	// DistroOpenSUSELeap is the os-release ID for openSUSE Leap.
	DistroOpenSUSELeap = "opensuse-leap"
	// DistroOpenSUSETumbleweed is the os-release ID for openSUSE Tumbleweed.
	DistroOpenSUSETumbleweed = "opensuse-tumbleweed"
	// DistroOl is the os-release ID for Oracle Linux.
	DistroOl = "ol"
	// DistroPop is the os-release ID for Pop!_OS.
	DistroPop = "pop"
	// DistroRhel is the os-release ID for Red Hat Enterprise Linux.
	DistroRhel = "rhel"
	// DistroRocky is the os-release ID for Rocky Linux.
	DistroRocky = "rocky"
	// DistroUbuntu is the os-release ID for Ubuntu.
	DistroUbuntu = "ubuntu"
)

Canonical distribution name constants.

These are the lowercase ID values from /etc/os-release for the distributions supported by YAP. Use these constants throughout the codebase rather than repeating string literals.

View Source
const (
	// PMApk is the Alpine package manager.
	PMApk = "apk"
	// PMApt is the Debian/Ubuntu package manager.
	PMApt = "apt"
	// PMPacman is the Arch Linux package manager.
	PMPacman = "pacman"
	// PMYum is the legacy RPM-based package manager.
	PMYum = "yum"
	// PMZypper is the openSUSE package manager.
	PMZypper = "zypper"
)

Package manager command name constants.

These are the canonical names of the package manager binaries used by the supported distributions.

View Source
const (
	// DefaultBufferSize is the default buffer size for filesystem operations.
	DefaultBufferSize = 32 * 1024
	// SmallBufferSize is the buffer size for smaller operations.
	SmallBufferSize = 1024

	// DefaultDirPerm is the default permission for directories.
	DefaultDirPerm = 0o755
	// DefaultFilePerm is the default permission for files.
	DefaultFilePerm = 0o644
	// WritePerm is the write permission mask.
	WritePerm = 0o200

	// TimestampFormat is the standard timestamp format used throughout YAP.
	TimestampFormat = "2006-01-02 15:04:05"
	// ProgressUpdateInterval is the interval for updating progress indicators.
	ProgressUpdateInterval = 500 * time.Millisecond
	// TickerInterval is the default ticker interval.
	TickerInterval = 100 * time.Millisecond

	// KBDivisor is the divisor for converting bytes to kilobytes.
	KBDivisor = 1024
)
View Source
const (
	FormatAPK    = "apk"
	FormatDEB    = "deb"
	FormatRPM    = "rpm"
	FormatPacman = "pacman"
)

Package format constants

View Source
const (
	// ExtAPK is the Alpine package file extension.
	ExtAPK = ".apk"
	// ExtDEB is the Debian package file extension.
	ExtDEB = ".deb"
	// ExtRPM is the RPM package file extension.
	ExtRPM = ".rpm"
	// ExtPacmanZst is the Arch Linux zstd-compressed package file extension.
	ExtPacmanZst = ".pkg.tar.zst"
)

Package file extension constants.

Variables

View Source
var (
	// Releases contains the supported Linux distribution IDs as defined in /etc/os-release.
	// These values are not invented, but refer to /etc/os-release ID field values.
	Releases = [...]string{
		DistroAlmalinux,
		DistroAlpine,
		DistroAmzn,
		DistroArch,
		DistroCentos,
		DistroDebian,
		DistroFedora,
		DistroLinuxmint,
		DistroOpenSUSELeap,
		DistroOpenSUSETumbleweed,
		DistroOl,
		DistroPop,
		DistroRhel,
		DistroRocky,
		DistroUbuntu,
	}

	// DistroToPackageManager maps distribution names to their package managers.
	DistroToPackageManager = map[string]string{
		DistroAlmalinux:          PMYum,
		DistroAlpine:             PMApk,
		DistroAmzn:               PMYum,
		DistroArch:               PMPacman,
		DistroCentos:             PMYum,
		DistroDebian:             PMApt,
		DistroFedora:             PMYum,
		DistroLinuxmint:          PMApt,
		DistroOl:                 PMYum,
		DistroOpenSUSELeap:       PMZypper,
		DistroOpenSUSETumbleweed: PMZypper,
		DistroPop:                PMApt,
		DistroRhel:               PMYum,
		DistroRocky:              PMYum,
		DistroUbuntu:             PMApt,
	}

	// Packers defines the supported package managers for different distributions.
	Packers = [...]string{
		PMApk,
		PMApt,
		PMPacman,
		PMYum,
		PMZypper,
	}

	// Distros contains the list of supported distribution names.
	Distros = []string{}
	// DistrosSet contains the set of supported distributions.
	DistrosSet = set.NewSet()
	// DistroPackageManager maps distributions to their package managers.
	DistroPackageManager = map[string]string{}
	// PackagersSet contains the set of supported package managers.
	PackagersSet = set.NewSet()
)

Functions

func DistroFormat

func DistroFormat(distro string) string

DistroFormat returns the package format for a given distribution name. Returns an empty string if the distribution is not recognized.

func GetInstallArgs

func GetInstallArgs(format string) []string

GetInstallArgs returns the package manager install arguments.

func GetReverseMapping

func GetReverseMapping(format string) map[string]string

GetReverseMapping returns a reverse mapping from format-specific architecture names to canonical names for a given package format.

This is useful for converting format-specific architecture names back to canonical names when parsing existing packages or user input.

When multiple canonical names map to the same format-specific name, the canonical architecture name (from the Arch* constants) is preferred over aliases.

Example:

reverseMap := GetReverseMapping("deb")
canonical := reverseMap["amd64"]  // returns "x86_64"

func NormalizeArchitecture

func NormalizeArchitecture(arch string) string

NormalizeArchitecture converts architecture aliases to canonical architecture names. This ensures consistent architecture naming throughout YAP, regardless of input format.

Common aliases supported:

  • amd64, x86-64 → x86_64
  • i386, i586, x86 → i686
  • arm64 → aarch64
  • armv7h, armv7l, armhf, armv7hl → armv7
  • armv6h, armv6l, arm, armel → armv6

If the architecture is already canonical or unknown, it is returned unchanged.

Example:

NormalizeArchitecture("amd64")  // returns "x86_64"
NormalizeArchitecture("arm64")  // returns "aarch64"
NormalizeArchitecture("x86_64") // returns "x86_64" (already canonical)

Types

type ArchitectureMapping

type ArchitectureMapping struct {
	APK    map[string]string
	DEB    map[string]string
	RPM    map[string]string
	Pacman map[string]string
}

ArchitectureMapping provides a unified interface for architecture translations.

func GetArchMapping

func GetArchMapping() *ArchitectureMapping

GetArchMapping returns the unified architecture mappings for all package formats.

func (*ArchitectureMapping) TranslateArch

func (am *ArchitectureMapping) TranslateArch(format, arch string) string

TranslateArch translates an architecture for a specific package format.

type BuildEnvironmentDeps

type BuildEnvironmentDeps struct {
	APK    []string
	DEB    []string
	RPM    []string
	Pacman []string
}

BuildEnvironmentDeps provides build environment dependencies for each package manager.

func GetBuildDeps

func GetBuildDeps() *BuildEnvironmentDeps

GetBuildDeps returns the build environment dependencies for all package formats.

Jump to

Keyboard shortcuts

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