Enable iterative manifests with 0 file count

When a bundle is updated to only modify which bundles are included, an
iterative manifest can be generated with 0 files. This change adds a
type field to the Manifest struct to determine when an iterative
manifest is used and allows the creation of iterative manifests with
a 0 file count.

Fixes #516

Signed-off-by: John Akre <john.w.akre@intel.com>
This commit is contained in:
John Akre
2018-12-06 10:53:40 -08:00
committed by tmarcu
parent 59b24abf8c
commit 6facb4b650
3 changed files with 21 additions and 1 deletions
+2
View File
@@ -82,6 +82,7 @@ func initBundles(ui UpdateInfo, c config, numWorkers int) ([]*Manifest, error) {
TimeStamp: ui.timeStamp,
},
Name: bundleName,
Type: ManifestBundle,
}
if bundleName == "full" {
@@ -459,6 +460,7 @@ func CreateManifests(version uint32, minVersion uint32, format uint, statedir st
Previous: lastVersion,
TimeStamp: timeStamp,
},
Type: ManifestMoM,
}
// if min-version wasn't explicitly set we need to carry the header forward
// from the old MoM
+18 -1
View File
@@ -40,6 +40,19 @@ const IndexBundle = "os-core-update-index"
// this should be done when configuration is in a more stable state
const indexAllBundleDir = "/usr/share/clear/allbundles"
// ManifestType specifies whether the manifest is a MoM, bundle, iterative, or
// delta manifest.
type ManifestType uint8
// Valid values for ManifestType.
const (
ManifestUnset ManifestType = iota
ManifestMoM
ManifestBundle
ManifestIterative
ManifestDelta
)
// ManifestHeader contains metadata for the manifest
type ManifestHeader struct {
Format uint
@@ -59,6 +72,7 @@ type Manifest struct {
Files []*File
DeletedFiles []*File
BundleInfo BundleInfo
Type ManifestType
}
// MoM is a manifest that holds references to bundle manifests.
@@ -183,7 +197,9 @@ func (m *Manifest) CheckHeaderIsValid() error {
if m.Header.Version == 0 {
return errors.New("manifest has version zero, version must be positive")
}
if m.Header.FileCount == 0 {
// Iterative manifests updated to include new bundles can have 0 files.
if m.Header.FileCount == 0 && m.Type != ManifestIterative {
return errors.New("manifest has a zero file count")
}
@@ -310,6 +326,7 @@ func (m *Manifest) createIterativeManifest(fromVersion uint32) *Manifest {
Header: m.Header,
Name: fmt.Sprintf("%s.I.%d", m.Name, m.Header.Previous),
BundleInfo: m.BundleInfo,
Type: ManifestIterative,
}
fm.Header.ContentSize = 0
+1
View File
@@ -237,6 +237,7 @@ func WritePack(w io.Writer, fromManifest, toManifest *Manifest, outputDir, chroo
dManifest = &Manifest{
Header: fromManifest.Header,
Name: fromManifest.Name,
Type: ManifestDelta,
}
dManifest.Header.ContentSize = 0