Documentation ¶
Index ¶
- Variables
- func FindBundlesToPack(from *Manifest, to *Manifest) (map[string]*BundleToPack, error)
- func GetHashForBytes(info *HashFileInfo, data []byte) (string, error)
- func GetHashForFile(filename string) (string, error)
- func GetPackFilename(name string, fromVersion uint32) string
- func HashEquals(h1 Hashval, h2 Hashval) bool
- type BundleToPack
- type Delta
- type ExternalReader
- type ExternalWriter
- type File
- type FullfilesInfo
- type Hash
- type HashFileInfo
- type Hashval
- type Manifest
- type ManifestHeader
- type MoM
- type ModifierFlag
- type PackEntry
- type PackInfo
- type PackState
- type RenameFlag
- type StatusFlag
- type TypeFlag
- type UpdateInfo
Constants ¶
This section is empty.
Variables ¶
var AllZeroHash = "0000000000000000000000000000000000000000000000000000000000000000"
AllZeroHash is the string representation of a zero value hash
var Hashes = []*string{&AllZeroHash}
Hashes is a global map of indices to hashes
Functions ¶
func FindBundlesToPack ¶
func FindBundlesToPack(from *Manifest, to *Manifest) (map[string]*BundleToPack, error)
FindBundlesToPack will read two MoM manifests and return a set of bundles that must be packed (and their corresponding versions).
Note that a MoM can contain bundles in an old version, so each bundle needs its own From/To version pair.
func GetHashForBytes ¶
func GetHashForBytes(info *HashFileInfo, data []byte) (string, error)
GetHashForBytes calculate the hash for data already in memory and the associated metadata.
func GetHashForFile ¶
GetHashForFile calculate the swupd hash for a file in the disk.
func GetPackFilename ¶
GetPackFilename returns the filename used for a pack of a bundle from a specific version.
func HashEquals ¶
HashEquals trivial equality function for Hashval
Types ¶
type BundleToPack ¶
BundleToPack contains a bundle and the to/from versions to pack.
type Delta ¶
Delta represents a delta file between two other files. If Error is present, it indicates that the delta couldn't be created.
func CreateDeltas ¶
CreateDeltas creates all delta files between the previous and current version of the supplied manifest. Returns a list of deltas (which contains information about individual delta errors). Returns error (and no deltas) if it can't assemble the delta list. If number of workers is zero or less, 1 worker is used.
type ExternalReader ¶
type ExternalReader struct {
// contains filtered or unexported fields
}
ExternalReader filters a Reader with an external program. Every time a Read is called, it will read from the output of the program, that reads from the underlying reader.
func NewExternalReader ¶
NewExternalReader creates an ExternalReader with the passed underlying Reader and the program to execute as filter.
func (*ExternalReader) Close ¶
func (er *ExternalReader) Close() error
Close properly finish the execution of an ExternalReader.
type ExternalWriter ¶
type ExternalWriter struct {
// contains filtered or unexported fields
}
ExternalWriter filters a Writer with an external program. Every time Write is called, it will write to the program, and then the result written to the underlying Writer.
func NewExternalWriter ¶
NewExternalWriter creates an ExternalWriter with the passed underlying Writer and the program to execute as filter.
func (*ExternalWriter) Close ¶
func (ew *ExternalWriter) Close() error
Close properly finish the execution of an ExternalWriter.
type File ¶
type File struct { Name string Hash Hashval Version uint32 // flags Type TypeFlag Status StatusFlag Modifier ModifierFlag Rename RenameFlag // renames RenameScore uint16 RenamePeer *File Info os.FileInfo DeltaPeer *File }
File represents an entry in a manifest
func (*File) GetFlagString ¶
GetFlagString returns the flags in a format suitable for the Manifest
type FullfilesInfo ¶
FullfilesInfo holds statistics about a fullfile generation.
func CreateFullfiles ¶
func CreateFullfiles(m *Manifest, chrootDir, outputDir string, numWorkers int) (*FullfilesInfo, error)
CreateFullfiles creates full file compressed tars for files in chrootDir and places them in outputDir. It doesn't regenerate full files that already exist. If number of workers is zero or less, 1 worker is used.
type Hash ¶
type Hash struct {
// contains filtered or unexported fields
}
Hash is used to calculate the swupd Hash of a file. Create one with NewHash, use Write method to fill the contents (for regular files), and use Sum to get the final hash.
func NewHash ¶
func NewHash(info *HashFileInfo) (*Hash, error)
NewHash creates a struct that can be used to calculate the "swupd Hash" of a given file. For historical reasons, the hash is constructed as
stat := file metadata contents := file contents HMAC(key, data) swupd hash = HMAC(HMAC(stat, nil), contents)
The data for the inner HMAC was used for file xattrs, but is not used at the moment.
type HashFileInfo ¶
HashFileInfo contains the metadata of a file that is included as part of the swupd hash.
type Hashval ¶
type Hashval int
Hashval is the integer index of the interned hash
type Manifest ¶
type Manifest struct { Name string Header ManifestHeader Files []*File DeletedFiles []*File // contains filtered or unexported fields }
Manifest represents a bundle or list of bundles (MoM)
func ParseManifest ¶
ParseManifest creates a Manifest from an io.Reader.
func ParseManifestFile ¶
ParseManifestFile creates a Manifest from file in path.
func (*Manifest) CheckHeaderIsValid ¶
CheckHeaderIsValid verifies that all header fields in the manifest are valid.
func (*Manifest) WriteManifest ¶
WriteManifest writes manifest to a given io.Writer.
func (*Manifest) WriteManifestFile ¶
WriteManifestFile writes manifest m to a new file at path.
type ManifestHeader ¶
type ManifestHeader struct { Format uint Version uint32 Previous uint32 FileCount uint32 TimeStamp time.Time ContentSize uint64 Includes []*Manifest }
ManifestHeader contains metadata for the manifest
type MoM ¶
type MoM struct { Manifest // UpdatedBundles has the manifests of bundles that are new to this // version. To get a list of all the bundles, use Files from embedded // Manifest struct. UpdatedBundles []*Manifest // FullManifest contains information about all the files in this version. FullManifest *Manifest }
MoM is a manifest that holds references to bundle manifests.
type ModifierFlag ¶
type ModifierFlag uint8
ModifierFlag describes specific characteristics of a file, used later by swupd client when deciding how to update it. It matches the third byte in the flags field.
const ( ModifierUnset ModifierFlag = iota ModifierConfig ModifierState ModifierBoot )
Valid values for ModifierFlag.
type PackInfo ¶
type PackInfo struct { FullfileCount uint64 DeltaCount uint64 // Entries contains all the files considered for packing and details about its presence in // the pack. Entries []PackEntry // Warnings contains the issues found. These are not considered errors since the pack could // finish by working around the issue, e.g. if file not found in chroot, try to get it from // the fullfiles. Warnings []string }
PackInfo contains detailed information about a pack written.
func CreatePack ¶
func CreatePack(name string, fromVersion, toVersion uint32, outputDir, chrootDir string, numWorkers int) (*PackInfo, error)
CreatePack creates the pack file for a specific bundle between two versions. The pack is written in the TO version subdirectory of outputDir (e.g. a pack from 10 to 20 is written to "www/20"). Empty packs will lead to not creating the pack. Multiple workers are used to parallelize delta creation. If number of workers is zero or less, 1 worker is used.
func WritePack ¶
func WritePack(w io.Writer, fromManifest, toManifest *Manifest, outputDir, chrootDir string, numWorkers int) (info *PackInfo, err error)
WritePack writes the pack between two Manifests, or a zero pack if fromManifest is nil. The toManifest should always be non nil. The outputDir is used to pick deltas and fullfiles. If not empty, chrootDir is tried first as a fast alternative to decompressing the fullfiles. Multiple workers are used to parallelize delta creation. If number of workers is zero or less, 1 worker is used.
type PackState ¶
type PackState int
PackState describes whether and how a file was packed.
Files can be not packed, packed as a delta or packed as a fullfile.
type RenameFlag ¶
type RenameFlag uint8
RenameFlag describes the third position in the flag string and was used to represent a rename flag (deprecated) and is now used to represent a mixer-generated manifest to be merged with an upstream manifest via client-side mixer integration
const ( RenameUnset RenameFlag = iota RenameSet MixManifest )
Valid values for RenameFlag
type StatusFlag ¶
type StatusFlag uint8
StatusFlag describes whether a manifest entry is present or not. It matches the second byte in the flags field.
const ( StatusUnset StatusFlag = iota StatusDeleted StatusGhosted )
Valid values for StatusFlag.
func (StatusFlag) String ¶
func (s StatusFlag) String() string
type TypeFlag ¶
type TypeFlag uint8
TypeFlag describes the file type of a manifest entry. It matches the first byte in the flags field.
Valid values for TypeFlag.
type UpdateInfo ¶
type UpdateInfo struct {
// contains filtered or unexported fields
}
UpdateInfo contains the meta information for the current update