Documentation ¶
Index ¶
- Constants
- Variables
- func RegisterFunc(dbType, name string, impl interface{}, pure bool) error
- type DBBundle
- type Depot
- func (d *Depot) AddPackage(rpmFile string) error
- func (d *Depot) CacheDB(dbType string) error
- func (d *Depot) CheckCache() error
- func (d *Depot) GetDB(dbType string) (*sql.DB, error)
- func (d *Depot) GetDBFilePath(dbType string) string
- func (d *Depot) GetMetaIndex() (*meta.Index, error)
- func (d *Depot) GetMetaIndexPath() string
- func (d *Depot) GetPackagePath(rpmFileRelPath string) string
- func (d *Depot) HasPackage(rpmFileName string) bool
- func (d *Depot) InvalidateCache() error
- func (d *Depot) IsCacheValid() bool
- func (d *Depot) IsDBCached(dbType string) bool
- func (d *Depot) IsEmpty() bool
- func (d *Depot) OpenDB(dbType string) error
- func (d *Depot) Reindex(full bool) error
- func (d *Depot) RemovePackage(rpmFile string) error
- type DepotBundle
- type Options
- type Storage
- func (s *Storage) AddPackage(repo, rpmFilePath string) error
- func (s *Storage) CopyPackage(fromRepo, toRepo, arch, rpmFileRelPath string) error
- func (s *Storage) GetBinDepot(repo string) *Depot
- func (s *Storage) GetDB(repo, arch, dbType string) (*sql.DB, error)
- func (s *Storage) GetDepot(repo, arch string) *Depot
- func (s *Storage) GetModTime(repo, arch string) (time.Time, error)
- func (s *Storage) GetPackagePath(repo, arch, rpmFileRelPath string) string
- func (s *Storage) HasArch(repo, arch string) bool
- func (s *Storage) HasPackage(repo, arch, rpmFileName string) bool
- func (s *Storage) HasRepo(repo string) bool
- func (s *Storage) Initialize(repoList, archList []string) error
- func (s *Storage) InvalidateCache() error
- func (s *Storage) IsCacheValid(repo, arch string) bool
- func (s *Storage) IsEmpty(repo, arch string) bool
- func (s *Storage) IsInitialized() bool
- func (s *Storage) PurgeCache() error
- func (s *Storage) Reindex(repo, arch string, full bool) error
- func (s *Storage) RemovePackage(repo, arch, rpmFileRelPath string) error
- func (s *Storage) WarmupCache(repo, arch string) error
Constants ¶
const ( PERMS_DIR os.FileMode = 0755 // Default permissions for directories PERMS_FILE os.FileMode = 0644 // Default permissions for files )
Variables ¶
var ( ErrNotInitialized = fmt.Errorf("Repository storage is not initialized") ErrEmptyRepoName = fmt.Errorf("Repository name can't be empty") ErrEmptyPath = fmt.Errorf("Path to file can't be empty") ErrEmptyArchName = fmt.Errorf("Arch name can't be empty") ErrUnknownArch = fmt.Errorf("Unknown or unsupported architecture") ErrPseudoArch = fmt.Errorf("Noarch is pseudo architecture and can't be used") ErrNilDepot = fmt.Errorf("Can't find depot for given repository or architecture") )
var DirNameValidatorRegex = regexp.MustCompile(`[a-zA-Z0-9]+`)
DirNameValidatorRegex is directory name validation regexp
Functions ¶
func RegisterFunc ¶
RegisterFunc registers new custom function for given DB type Notice that you can not register new functions after creating new storage
Types ¶
type Depot ¶
type Depot struct {
// contains filtered or unexported fields
}
Depot is storage for specific repository (type + arch)
func (*Depot) AddPackage ¶
AddPackage adds package to depot
func (*Depot) CheckCache ¶
CheckCache checks if cache is valid and healthy
func (*Depot) GetDBFilePath ¶
GetDBFilePath returns path to SQLite DB file
func (*Depot) GetMetaIndex ¶
GetMetaIndex reads repository metadata
func (*Depot) GetMetaIndexPath ¶
GetMetaIndexPath returns path to metadata index file (repomd.xml)
func (*Depot) GetPackagePath ¶
GetPackagePath returns full path to package RPM file
func (*Depot) HasPackage ¶
HasPackage checks if depot contains file with given name
func (*Depot) InvalidateCache ¶
InvalidateCache invalidates repository cache
func (*Depot) IsCacheValid ¶
IsCacheValid checks if database files was updated and depot contains outdated metadata info and keeps connection to outdated SQL databases
func (*Depot) IsDBCached ¶
IsDBCached returns true if SQLite DB is cached
func (*Depot) RemovePackage ¶
RemovePackage removes package from depot
type DepotBundle ¶
RepoStorageBundle is map [repo name] → [repo storage]
type Options ¶
type Options struct { DataDir string // Path to directory with RPM files CacheDir string // Path to directory for cached data SplitFiles bool // Split files to separate directories User string // Repository data directory owner username Group string // Repository data directory owner group DirPerms os.FileMode // Permissions for directories FilePerms os.FileMode // Permissions for files }
Options is storage options
func (*Options) GetDirPerms ¶
GetDirPerms returns permissions for directories
func (*Options) GetFilePerms ¶
GetFilePerms returns permissions for files
type Storage ¶
type Storage struct {
// contains filtered or unexported fields
}
Storage is repository storage
func NewStorage ¶
NewStorage creates new FS storage
func (*Storage) AddPackage ¶
AddPackage adds package file to the given repository Important: This method DO NOT run repository reindex
func (*Storage) CopyPackage ¶
CopyPackage copies file from one repository to another Important: This method DO NOT run repository reindex
func (*Storage) GetBinDepot ¶
GetBinDepot returns any depot with binary packages (useful for working with noarch packages)
func (*Storage) GetModTime ¶
GetModTime returns date of repository index modification
func (*Storage) GetPackagePath ¶
GetPackagePath returns full path to package RPM file
func (*Storage) HasArch ¶
HasArch returns true if repository storage contains directory for specific arch
func (*Storage) HasPackage ¶
HasPackage checks if repository contains file with given name
func (*Storage) Initialize ¶
Initialize initializes the new repository storage and creates all required directories
func (*Storage) InvalidateCache ¶
InvalidateCache invalidates cache and removes SQLite files from cache directory
func (*Storage) IsCacheValid ¶
IsCacheValid returns true if cache is valid
func (*Storage) IsInitialized ¶
IsInitialized returns true if repository already initialized and ready for work
func (*Storage) PurgeCache ¶
PurgeCache deletes all SQLite files from cache directory
func (*Storage) RemovePackage ¶
RemovePackage removes package with given relative path from the given repository Important: This method DO NOT run repository reindex
func (*Storage) WarmupCache ¶
WarmupCache warmups cache