Documentation
¶
Overview ¶
Package files provides unified file system operations for package building.
Package files provides unified file system operations for package building.
Package files provides unified file system operations for package building.
Index ¶
- Constants
- func CalculateDataHash(baseDir string, skipPatterns []string) (string, error)
- func CheckWritable(path string) error
- func Chmod(path string, perm os.FileMode) error
- func Create(path string) (*os.File, error)
- func CreateWrite(path, data string) error
- func Exists(path string) bool
- func ExistsMakeDir(path string) error
- func GetDirSize(path string) (int64, error)
- func GetFileType(path string) string
- func IsEmptyDir(path string, dirEntry os.DirEntry) bool
- func IsStaticLibrary(path string) bool
- func Open(path string) (*os.File, error)
- func ResolveSourceDateEpoch(pkgbuildDir string) (time.Time, error)
- func SourceDateEpochFromEnv() time.Time
- type Entry
- type WalkOptions
- type Walker
Constants ¶
const ( TagLink = 0o120000 TagDirectory = 0o40000 TypeFile = "file" TypeDir = "dir" TypeImplicitDir = "implicit dir" TypeSymlink = "symlink" TypeTree = "tree" TypeConfig = "config" TypeConfigNoReplace = "config|noreplace" )
File type constants
Variables ¶
This section is empty.
Functions ¶
func CalculateDataHash ¶
CalculateDataHash calculates a hash of all data files for package metadata. This is used by formats like APK that need a hash of the entire data payload.
func CheckWritable ¶
CheckWritable checks if a file is writable.
func CreateWrite ¶
CreateWrite creates a file and writes data to it.
func ExistsMakeDir ¶
ExistsMakeDir creates a directory if it doesn't exist.
func GetDirSize ¶
GetDirSize calculates the total size of a directory.
func GetFileType ¶
GetFileType returns the ELF type of a file, or empty string for non-ELF files.
func IsEmptyDir ¶
IsEmptyDir checks if a directory is empty.
func IsStaticLibrary ¶
IsStaticLibrary checks if a file is a static library (.a file or archive).
func ResolveSourceDateEpoch ¶
ResolveSourceDateEpoch returns a deterministic build timestamp for reproducible builds.
Resolution order:
- If SOURCE_DATE_EPOCH is already set in the environment, parse and return it (honouring explicit user/CI override).
- Otherwise, use the modification time of the PKGBUILD file located in pkgbuildDir (matching makepkg behaviour).
The resolved value is also exported into the process environment so that child processes (gcc, tar, gzip, …) that natively support SOURCE_DATE_EPOCH will use it.
func SourceDateEpochFromEnv ¶
SourceDateEpochFromEnv reads SOURCE_DATE_EPOCH from the environment and returns the corresponding time. If the variable is absent or invalid, it returns time.Now(). This is a lightweight reader for use in packaging code that runs after ResolveSourceDateEpoch has already been called.
Types ¶
type Entry ¶
type Entry struct {
Source string // Absolute path to the source file
Destination string // Relative path in the package (starts with /)
Type string // File type (file, dir, symlink, config, etc.)
Mode os.FileMode // File permissions
Size int64 // File size in bytes
ModTime time.Time // Last modification time
LinkTarget string // Target path for symlinks
SHA256 []byte // SHA256 hash for regular files
IsBackup bool // Whether this file should be treated as a config backup
}
Entry represents a file or directory entry in a package. This consolidates the various file entry types used across package formats.
func (*Entry) IsConfigFile ¶
IsConfigFile returns true if this entry represents a configuration file.
func (*Entry) IsDirectory ¶
IsDirectory returns true if this entry represents a directory.
func (*Entry) IsRegularFile ¶
IsRegularFile returns true if this entry represents a regular file.
type WalkOptions ¶
type WalkOptions struct {
SkipDotFiles bool // Skip files starting with '.'
BackupFiles []string // List of backup/config files
SkipPatterns []string // File patterns to skip
}
WalkOptions configures the behavior of directory walking.
type Walker ¶
type Walker struct {
BaseDir string
Options WalkOptions
}
Walker provides unified directory walking functionality for all package managers.
func NewWalker ¶
func NewWalker(baseDir string, options WalkOptions) *Walker
NewWalker creates a new filesystem walker.