diff --git a/swupd/create_manifests.go b/swupd/create_manifests.go index 2f6a111..6e00592 100644 --- a/swupd/create_manifests.go +++ b/swupd/create_manifests.go @@ -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 diff --git a/swupd/manifest.go b/swupd/manifest.go index 1cd7e4b..9fe8e63 100644 --- a/swupd/manifest.go +++ b/swupd/manifest.go @@ -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 diff --git a/swupd/packs.go b/swupd/packs.go index 484b3c2..8b44f63 100644 --- a/swupd/packs.go +++ b/swupd/packs.go @@ -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