files

package
v2.37.1 Latest Latest
Warning

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

Go to latest
Published: May 9, 2024 License: MIT Imports: 9 Imported by: 39

Documentation

Index

Constants

View Source
const (
	// TypeFile is the type of a regular file. This is also the type that is
	// implied when no type is specified.
	TypeFile = "file"
	// TypeDir is the type of a directory that is explicitly added in order to
	// declare ownership or non-standard permission.
	TypeDir = "dir"
	/// TypeImplicitDir is the type of a directory that is implicitly added as a
	//parent of a file.
	TypeImplicitDir = "implicit dir"
	// TypeTree is the type of a whole directory tree structure.
	TypeTree = "tree"
	// TypeSymlink is the type of a symlink that is created at the destination
	// path and points to the source path.
	TypeSymlink = "symlink"
	// TypeConfig is the type of a configuration file that may be changed by the
	// user of the package.
	TypeConfig = "config"
	// TypeConfigNoReplace is like TypeConfig with an added noreplace directive
	// that is respected by RPM-based distributions. For all other packages it
	// is handled exactly like TypeConfig.
	TypeConfigNoReplace = "config|noreplace"
	// TypeGhost is the type of an RPM ghost file which is ignored by other packagers.
	TypeRPMGhost = "ghost"
	// TypeRPMDoc is the type of an RPM doc file which is ignored by other packagers.
	TypeRPMDoc = "doc"
	// TypeRPMLicence is the type of an RPM licence file which is ignored by other packagers.
	TypeRPMLicence = "licence"
	// TypeRPMLicense a different spelling of TypeRPMLicence.
	TypeRPMLicense = "license"
	// TypeRPMReadme is the type of an RPM readme file which is ignored by other packagers.
	TypeRPMReadme = "readme"
	// TypeDebChangelog is the type of a Debian changelog archive file which is
	// ignored by other packagers. This type should never be set for a content
	// entry as it is automatically added when a changelog is configred.
	TypeDebChangelog = "debian changelog"
)

Variables

View Source
var ErrContentCollision = fmt.Errorf("content collision")

Functions

func AsExplicitRelativePath added in v2.27.0

func AsExplicitRelativePath(path string) string

As relative path converts a path to an explicitly relative path starting with a dot (e.g. it converts /foo -> ./foo and foo -> ./foo).

func AsRelativePath added in v2.27.0

func AsRelativePath(path string) string

AsRelativePath converts a path to a relative path without a "./" prefix. This function leaves trailing slashes to indicate that the path refers to a directory, and converts the path to Unix path.

func NormalizeAbsoluteDirPath added in v2.27.0

func NormalizeAbsoluteDirPath(path string) string

normalizeFirPath is linke NormalizeAbsoluteFilePath with a trailing slash.

func NormalizeAbsoluteFilePath added in v2.27.0

func NormalizeAbsoluteFilePath(src string) string

NormalizeAbsoluteFilePath returns an absolute cleaned path separated by slashes.

func ToNixPath

func ToNixPath(path string) string

ToNixPath converts the given path to a nix-style path.

Windows-style path separators are considered escape characters by some libraries, which can cause issues.

Types

type Content

type Content struct {
	Source      string           `yaml:"src,omitempty" json:"src,omitempty"`
	Destination string           `yaml:"dst" json:"dst"`
	Type        string           `` /* 148-byte string literal not displayed */
	Packager    string           `yaml:"packager,omitempty" json:"packager,omitempty"`
	FileInfo    *ContentFileInfo `yaml:"file_info,omitempty" json:"file_info,omitempty"`
	Expand      bool             `yaml:"expand,omitempty" json:"expand,omitempty"`
}

Content describes the source and destination of one file to copy into a package.

func (*Content) IsDir

func (c *Content) IsDir() bool

IsDir to part of the os.FileInfo interface

func (*Content) ModTime

func (c *Content) ModTime() time.Time

ModTime to part of the os.FileInfo interface

func (*Content) Mode

func (c *Content) Mode() os.FileMode

Mode to part of the os.FileInfo interface

func (*Content) Name

func (c *Content) Name() string

Name to part of the os.FileInfo interface

func (*Content) Size

func (c *Content) Size() int64

Size to part of the os.FileInfo interface

func (*Content) String added in v2.27.0

func (c *Content) String() string

func (*Content) Sys

func (c *Content) Sys() interface{}

Sys to part of the os.FileInfo interface

func (*Content) WithFileInfoDefaults

func (c *Content) WithFileInfoDefaults(umask fs.FileMode, mtime time.Time) *Content

type ContentFileInfo

type ContentFileInfo struct {
	Owner string      `yaml:"owner,omitempty" json:"owner,omitempty"`
	Group string      `yaml:"group,omitempty" json:"group,omitempty"`
	Mode  os.FileMode `yaml:"mode,omitempty" json:"mode,omitempty"`
	MTime time.Time   `yaml:"mtime,omitempty" json:"mtime,omitempty"`
	Size  int64       `yaml:"-" json:"-"`
}

type Contents

type Contents []*Content

Contents list of Content to process.

func PrepareForPackager added in v2.27.0

func PrepareForPackager(
	rawContents Contents,
	umask fs.FileMode,
	packager string,
	disableGlobbing bool,
	mtime time.Time,
) (Contents, error)

PrepareForPackager performs the following steps to prepare the contents for the provided packager:

  • It filters out content that is irrelevant for the specified packager
  • It expands globs (if enabled) and file trees
  • It adds implicit directories (parent directories of files)
  • It adds ownership and other file information if not specified directly
  • It applies the given umask if the file does not have a specific mode
  • It normalizes content source paths to be unix style paths
  • It normalizes content destination paths to be absolute paths with a trailing slash if the entry is a directory

If no packager is specified, only the files that are relevant for any packager are considered.

func (Contents) ContainsDestination added in v2.9.0

func (c Contents) ContainsDestination(dst string) bool

func (Contents) Len

func (c Contents) Len() int

func (Contents) Less

func (c Contents) Less(i, j int) bool

func (Contents) Swap

func (c Contents) Swap(i, j int)

Jump to

Keyboard shortcuts

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