From 77aeaad2f532fe1258cabb36ce5bbc133efb0f8a Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Mon, 2 Jul 2018 15:55:12 -0700 Subject: [PATCH] swupd: make slim packs across minversions Add an additional fileContentInManifest check to pack creation to exclude full files that are represented in the from manifest even if the version changed in the to manifest. This allows mixer to exclude unchanged files from delta packs over minversion bumps. Signed-off-by: Matthew Johnson --- swupd/manifest.go | 25 +++++++++++++++++++++++++ swupd/packs.go | 2 +- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/swupd/manifest.go b/swupd/manifest.go index 415c20e..1aa631a 100644 --- a/swupd/manifest.go +++ b/swupd/manifest.go @@ -887,6 +887,31 @@ func writeIndexManifest(c *config, ui *UpdateInfo, bundles []*Manifest) (*Manife return idxMan, nil } +func fileContentInManifest(f *File, m *Manifest) bool { + if m == nil { + return false + } + for i := range m.Files { + if f.Name != m.Files[i].Name { + continue + } + if f.Hash != m.Files[i].Hash { + continue + } + if f.Type != m.Files[i].Type { + continue + } + if f.Status != m.Files[i].Status { + continue + } + if f.Modifier != m.Files[i].Modifier { + continue + } + return true + } + return false +} + // this is a hack to allow users to update using swupd-client v3.15.3 which performs a // check on contentsize with a maximum a couple of orders off the intended maximum. // Remove this code (and the caller) when a format bump has occurred in Clear. diff --git a/swupd/packs.go b/swupd/packs.go index 6ec7c77..cd13a69 100644 --- a/swupd/packs.go +++ b/swupd/packs.go @@ -238,7 +238,7 @@ func WritePack(w io.Writer, fromManifest, toManifest *Manifest, outputDir, chroo entry := &info.Entries[i] entry.File = f - if f.Version <= fromVersion { + if f.Version <= fromVersion || fileContentInManifest(f, fromManifest) { entry.Reason = "already in from manifest" continue }