Documentation
¶
Index ¶
- Constants
- Variables
- func CloseLogFile()
- func Dprintf(format string, a ...interface{})
- func Errorf(err error, format string, a ...interface{})
- func Fatalf(err error, format string, a ...interface{})
- func InitLogFile()
- func Logf(category int, format string, a ...interface{})
- func NewErrorf(format string, a ...interface{}) error
- func OpenKeyRing(path string) (openpgp.KeyRing, error)
- func PanicOn(err error)
- func Printf(format string, a ...interface{})
- func ValidateChecksum(r io.Reader, checksum string, checksum_type string) error
- func ValidateFileChecksum(name string, checksum string, checksum_type string) error
- type Cache
- type PackageEntries
- type PackageEntry
- func (c *PackageEntry) Architecture() string
- func (c *PackageEntry) ArchiveSize() int64
- func (c *PackageEntry) BuildTime() time.Time
- func (c *PackageEntry) Checksum() (string, error)
- func (c *PackageEntry) ChecksumType() string
- func (c *PackageEntry) Epoch() int
- func (c *PackageEntry) InstallSize() int64
- func (c *PackageEntry) LocationHref() string
- func (c *PackageEntry) Name() string
- func (c *PackageEntry) PackageSize() int64
- func (c *PackageEntry) Release() string
- func (c PackageEntry) String() string
- func (c *PackageEntry) Version() string
- type PackageEntryChecksum
- type PackageEntryLocation
- type PackageEntrySize
- type PackageEntryTime
- type PackageEntryVersion
- type PrimaryDatabase
- func (c *PrimaryDatabase) Begin() (*sql.Tx, error)
- func (c *PrimaryDatabase) Close() error
- func (c *PrimaryDatabase) DependenciesByPackage(pkgKey int, typ string) (rpm.Dependencies, error)
- func (c *PrimaryDatabase) FilesByPackage(pkgKey int) ([]string, error)
- func (c *PrimaryDatabase) InsertPackage(packages ...*rpm.PackageFile) error
- func (c *PrimaryDatabase) Packages() (PackageEntries, error)
- type PrimaryDatabaseWriter
- type PrimaryMetadata
- type Repo
- type RepoCache
- type RepoDatabase
- type RepoDatabaseChecksum
- type RepoDatabaseLocation
- type RepoMetadata
Constants ¶
const ( LOG_CAT_ERROR = iota LOG_CAT_WARN LOG_CAT_INFO LOG_CAT_DEBUG )
Variables ¶
var ( QuietMode bool DebugMode bool YumfilePath string LogFilePath string TmpBasePath string TmpYumConfPath string TmpYumLogFile string TmpYumCachePath string DownloadThreads int )
var ErrChecksumMismatch = fmt.Errorf("Checksum mismatch")
ErrChecksumMismatch indicates that the checksum value of two items does not match.
Functions ¶
func CloseLogFile ¶
func CloseLogFile()
CloseLogFile cleans up any file handles associates with the log file.
func Dprintf ¶
func Dprintf(format string, a ...interface{})
Dprintf prints verbose output only if debug mode is enabled
func Fatalf ¶
Fatalf prints an error message to log or STDOUT and exits the program with a non-zero exit code
func InitLogFile ¶
func InitLogFile()
func OpenKeyRing ¶
OpenKeyRing returns the GPG keyring for the given gpgkey file.
func Printf ¶
func Printf(format string, a ...interface{})
Printf prints output to STDOUT or the logfile
func ValidateChecksum ¶
ValidateChecksum creates a checksum of the given io.Reader content and compares it the the given checksum value. If the checksums match, nil is returned. If the checksums do not match, ErrChecksumMismatch is returned. If any other error occurs, the error is returned.
func ValidateFileChecksum ¶
ValidateChecksum creates a checksum of the given file content and compares it the the given checksum value. If the checksums match, nil is returned. If the checksums do not match, ErrChecksumMismatch is returned. If any other error occurs, the error is returned.
Types ¶
type PackageEntries ¶
type PackageEntries []PackageEntry
PackageEntries is a slice of PackageEntry structs.
func FilterPackages ¶
func FilterPackages(repo *Repo, packages PackageEntries) PackageEntries
FilterPackages returns a list of packages filtered according the repo's settings.
type PackageEntry ¶
type PackageEntry struct { Key int Arch string `xml:"arch"` Size PackageEntrySize `xml:"size"` Checksums PackageEntryChecksum `xml:"checksum"` Location PackageEntryLocation `xml:"location"` PackageName string `xml:"name"` Versions PackageEntryVersion `xml:"version"` Time PackageEntryTime `xml:"time"` Summary string `xml:"summary"` Url string `xml:"url"` Packager string `xml:"packager"` // contains filtered or unexported fields }
PackageEntry is a RPM package as defined in a yum repository database.
func (*PackageEntry) Architecture ¶
func (c *PackageEntry) Architecture() string
func (*PackageEntry) ArchiveSize ¶
func (c *PackageEntry) ArchiveSize() int64
func (*PackageEntry) BuildTime ¶
func (c *PackageEntry) BuildTime() time.Time
func (*PackageEntry) Checksum ¶
func (c *PackageEntry) Checksum() (string, error)
func (*PackageEntry) ChecksumType ¶
func (c *PackageEntry) ChecksumType() string
func (*PackageEntry) Epoch ¶
func (c *PackageEntry) Epoch() int
func (*PackageEntry) InstallSize ¶
func (c *PackageEntry) InstallSize() int64
func (*PackageEntry) LocationHref ¶
func (c *PackageEntry) LocationHref() string
LocationHref is the location of the package, relative to the parent repository.
func (*PackageEntry) Name ¶
func (c *PackageEntry) Name() string
func (*PackageEntry) PackageSize ¶
func (c *PackageEntry) PackageSize() int64
func (*PackageEntry) Release ¶
func (c *PackageEntry) Release() string
func (PackageEntry) String ¶
func (c PackageEntry) String() string
String reassembles package metadata to form a standard rpm package name; including the package name, version, release and architecture.
func (*PackageEntry) Version ¶
func (c *PackageEntry) Version() string
type PackageEntryChecksum ¶
type PackageEntryChecksum struct { Type string `xml:"type,attr"` Pkgid string `xml:"pkgid,attr"` Hash string `xml:",chardata"` }
PackageEntryChecksum is the XML element of a package metadata file which describes the checksum required to validate a package.
type PackageEntryLocation ¶
type PackageEntryLocation struct {
Href string `xml:"href,attr"`
}
RepoDatabaseLocation represents the URI, relative to a package repository, of a repository database.
type PackageEntrySize ¶
type PackageEntryTime ¶
PackageEntryChecksum is the XML element of a package metadata file which describes the checksum required to validate a package.
type PackageEntryVersion ¶
type PrimaryDatabase ¶
type PrimaryDatabase struct {
// contains filtered or unexported fields
}
PrimaryDatabase is an SQLite database which contains package data for a yum package repository.
func CreatePrimaryDB ¶
func CreatePrimaryDB(path string) (*PrimaryDatabase, error)
CreatePrimaryDB initializes a new and empty primary_db SQLite database on disk. Any existing path is deleted.
func OpenPrimaryDB ¶
func OpenPrimaryDB(path string) (*PrimaryDatabase, error)
OpenPrimaryDB opens a primary_db SQLite database from file and return a pointer to the resulting struct.
func (*PrimaryDatabase) Close ¶
func (c *PrimaryDatabase) Close() error
func (*PrimaryDatabase) DependenciesByPackage ¶
func (c *PrimaryDatabase) DependenciesByPackage(pkgKey int, typ string) (rpm.Dependencies, error)
DependenciesByPackage returns all package dependencies of the given type for the given package key. The dependency type may be one of 'requires', 'provides', 'conflicts' or 'obsoletes'.
func (*PrimaryDatabase) FilesByPackage ¶
func (c *PrimaryDatabase) FilesByPackage(pkgKey int) ([]string, error)
FilesByPackage returns all known files included in the package of the given package key.
func (*PrimaryDatabase) InsertPackage ¶
func (c *PrimaryDatabase) InsertPackage(packages ...*rpm.PackageFile) error
func (*PrimaryDatabase) Packages ¶
func (c *PrimaryDatabase) Packages() (PackageEntries, error)
Packages returns all packages listed in the primary_db.
type PrimaryDatabaseWriter ¶
type PrimaryDatabaseWriter chan<- *rpm.PackageFile
PrimaryDatabaseWriter writes packages to a Primary Database. It is the callers responsibility to close the channel when all packages have been sent.
func (PrimaryDatabaseWriter) Close ¶
func (w PrimaryDatabaseWriter) Close()
func (PrimaryDatabaseWriter) Write ¶
func (w PrimaryDatabaseWriter) Write(p *rpm.PackageFile)
type PrimaryMetadata ¶
type PrimaryMetadata struct { XMLName xml.Name `xml:"metadata"` XMLNS string `xml:"xmlns,attr"` PackagesCount int `xml:"packages,attr"` Packages PackageEntries `xml:"package"` }
PrimaryMetadata represents the metadata XML file for a RPM/Yum repository. It contains packages available in the repository.
func ReadPrimaryMetadata ¶
func ReadPrimaryMetadata(r io.Reader) (*PrimaryMetadata, error)
ReadPrimaryMetadata loads a primary.xml file from the given io.Reader and returns a pointer to the resulting PrimaryMetadata struct.
type Repo ¶
type Repo struct { ID string Name string Architecture string BaseURL string CachePath string Checksum string DeleteRemoved bool GPGCheck bool GPGKey string Groupfile string IncludeSources bool LocalPath string MirrorURL string NewOnly bool MaxDate time.Time MinDate time.Time YumfileLineNo int YumfilePath string }
Repo is a package repository defined in a Yumfile
func NewRepo ¶
func NewRepo() *Repo
NewRepo initializes a new Repo struct and returns a pointer to it.
func (*Repo) CacheLocal ¶
CacheLocal caches a copy of a Repo's metadata and databases to the given cache directory. If the Repo is already cached, the cache is validated and updated if the source repository has been updated.
type RepoCache ¶
func (*RepoCache) PrimaryDB ¶
func (c *RepoCache) PrimaryDB() (*PrimaryDatabase, error)
type RepoDatabase ¶
type RepoDatabase struct { Type string `xml:"type,attr"` Location RepoDatabaseLocation `xml:"location"` Timestamp int `xml:"timestamp"` Size int `xml:"size"` Checksum RepoDatabaseChecksum `xml:"checksum"` OpenSize int `xml:"open-size"` OpenChecksum RepoDatabaseChecksum `xml:"open-checksum"` DatabaseVersion int `xml:"database_version"` }
RepoDatabase represents an entry in a repository metadata file for an individual database file such as primary_db or filelists_db.
func (*RepoDatabase) String ¶
func (c *RepoDatabase) String() string
type RepoDatabaseChecksum ¶
RepoDatabaseChecksum is the XML element of a repo metadata file which describes the checksum required to validate a repository database.
func (*RepoDatabaseChecksum) Check ¶
func (c *RepoDatabaseChecksum) Check(r io.Reader) error
Check creates a checksum of the given io.Reader content and compares it the the expected checksum value. If the checksums match, nil is returned. If the checksums do not match, ErrChecksumMismatch is returned. If any other error occurs, the error is returned.
func (*RepoDatabaseChecksum) CheckFile ¶
func (c *RepoDatabaseChecksum) CheckFile(name string) error
CheckFile creates a checksum of the given file content and compares it the the expected checksum value. If the checksums match, nil is returned. If the checksums do not match, ErrChecksumMismatch is returned. If any other error occurs, the error is returned.
type RepoDatabaseLocation ¶
type RepoDatabaseLocation struct {
Href string `xml:"href,attr"`
}
RepoDatabaseLocation represents the URI, relative to a package repository, of a repository database.
type RepoMetadata ¶
type RepoMetadata struct { XMLName xml.Name `xml:"repomd"` XMLNS string `xml:"xmlns,attr"` XMLNSRPM string `xml:"xmlns:rpm,attr"` Revision int `xml:"revision"` Databases []RepoDatabase `xml:"data"` }
RepoMetadata represents the metadata XML file for a RPM/Yum repository. It contains pointers to database files which describe the packages available in the repository.
func ReadRepoMetadata ¶
func ReadRepoMetadata(r io.Reader) (*RepoMetadata, error)
ReadRepoMetadata loads a repomd.xml file from the given io.Reader and returns a pointer to the resulting RepoMetadata struct.