mirror of
https://github.com/clearlinux/mixer-tools.git
synced 2026-09-05 13:11:31 +00:00
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:
@@ -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
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user