diff --git a/swupd/packs.go b/swupd/packs.go index f5ed467..6e9db34 100644 --- a/swupd/packs.go +++ b/swupd/packs.go @@ -485,7 +485,9 @@ func FindBundlesToPack(from *Manifest, to *Manifest) (map[string]*BundleToPack, bundles := make(map[string]*BundleToPack, len(to.Files)) for _, b := range to.Files { - bundles[b.Name] = &BundleToPack{b.Name, 0, b.Version} + if b.Type == TypeManifest { + bundles[b.Name] = &BundleToPack{b.Name, 0, b.Version} + } } // If this is not a zero pack, we might be able to skip some bundles. diff --git a/swupd/packs_test.go b/swupd/packs_test.go index b8a0473..1e8ef96 100644 --- a/swupd/packs_test.go +++ b/swupd/packs_test.go @@ -22,6 +22,7 @@ func TestFindBundlesToPack(t *testing.T) { From M ToV uint32 To M + ToIMan M Expected []BundleToPack ShouldFail bool }{ @@ -105,6 +106,19 @@ func TestFindBundlesToPack(t *testing.T) { Expected: []BundleToPack{{"os-core", 100, 200}, {"c-basic", 0, 200}}, }, + + { + Name: "Don't pack Iterative manifests", + + FromV: 10, + From: M{"os-core": 10}, + + ToV: 20, + To: M{"os-core": 20}, + ToIMan: M{"os-core.I.10": 20}, + + Expected: []BundleToPack{{"os-core", 10, 20}}, + }, } addBundle := func(m *Manifest, name string, version uint32) { @@ -116,6 +130,15 @@ func TestFindBundlesToPack(t *testing.T) { m.Files = append(m.Files, bundle) } + addIterativeManifest := func(m *Manifest, name string, version uint32) { + man := &File{ + Name: name, + Type: TypeIManifest, + Version: version, + } + m.Files = append(m.Files, man) + } + sortBundles := func(bundles []BundleToPack) { sort.Slice(bundles, func(i, j int) bool { return bundles[i].Name < bundles[j].Name @@ -143,6 +166,9 @@ func TestFindBundlesToPack(t *testing.T) { for name, v := range tt.To { addBundle(toM, name, v) } + for name, v := range tt.ToIMan { + addIterativeManifest(toM, name, v) + } bundleMap, err := FindBundlesToPack(fromM, toM) failed := err != nil @@ -823,13 +849,13 @@ func TestFindBundlesToPackErrorPaths(t *testing.T) { toMan := &Manifest{ Name: "testto", Files: []*File{ - {Name: "test1", Version: 20}, + {Name: "test1", Version: 20, Type: TypeManifest}, }, } fromMan := &Manifest{ Name: "testfrom", Files: []*File{ - {Name: "test1", Version: 30}, // invalid version greater than toMan version + {Name: "test1", Version: 30, Type: TypeManifest}, // invalid version greater than toMan version }, }