swupd: export BundleInfo struct

This is useful for other projects trying to use the *-info file.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
Matthew Johnson
2018-08-09 15:26:36 -07:00
committed by tmarcu
parent 6be6db5f2c
commit 17261fdeab
3 changed files with 13 additions and 12 deletions
+9 -8
View File
@@ -23,7 +23,8 @@ import (
"strings"
)
type bundleInfo struct {
// BundleInfo describes the JSON object to be read from the *-info files
type BundleInfo struct {
Name string
Filename string
DirectIncludes []string
@@ -41,9 +42,9 @@ func (m *Manifest) getBundleInfo(c config, path string) error {
return err
}
m.bundleInfo.Files = make(map[string]bool)
m.BundleInfo.Files = make(map[string]bool)
for _, f := range m.Files {
m.bundleInfo.Files[f.Name] = true
m.BundleInfo.Files[f.Name] = true
}
var includes []string
@@ -51,7 +52,7 @@ func (m *Manifest) getBundleInfo(c config, path string) error {
if err != nil {
return err
}
m.bundleInfo.DirectIncludes = includes
m.BundleInfo.DirectIncludes = includes
return nil
}
@@ -60,7 +61,7 @@ func (m *Manifest) getBundleInfo(c config, path string) error {
return err
}
err = json.Unmarshal(biBytes, &m.bundleInfo)
err = json.Unmarshal(biBytes, &m.BundleInfo)
if err != nil {
return err
}
@@ -79,7 +80,7 @@ func (m *Manifest) getBundleInfo(c config, path string) error {
if !strings.HasPrefix(f, "/") {
return fmt.Errorf("invalid extra file %s in %s, must start with '/'", f, extraFilesPath)
}
m.bundleInfo.Files[f] = true
m.BundleInfo.Files[f] = true
}
}
@@ -88,7 +89,7 @@ func (m *Manifest) getBundleInfo(c config, path string) error {
func (m *Manifest) addFilesFromBundleInfo(c config, version uint32) error {
chrootDir := filepath.Join(c.imageBase, fmt.Sprint(version), "full")
for fpath := range m.bundleInfo.Files {
for fpath := range m.BundleInfo.Files {
fullPath := filepath.Join(chrootDir, fpath)
fi, err := os.Lstat(fullPath)
if err != nil {
@@ -126,7 +127,7 @@ func (m *Manifest) readIncludesFromBundleInfo(bundles []*Manifest) error {
}
}
for _, bn := range m.bundleInfo.DirectIncludes {
for _, bn := range m.BundleInfo.DirectIncludes {
// just add this one blindly since it is processed later
if bn == IndexBundle {
includes = append(includes, &Manifest{Name: IndexBundle})
+3 -3
View File
@@ -386,7 +386,7 @@ func (fs *testFileSystem) write(subpath, content string) {
}
func (fs *testFileSystem) initBundleInfo(version uint32, bundle string, includes []string) {
bi := bundleInfo{
bi := BundleInfo{
Name: bundle,
DirectIncludes: includes,
DirectPackages: make(map[string]bool),
@@ -434,7 +434,7 @@ func (fs *testFileSystem) addToBundleInfo(version uint32, bundle, file string) {
fs.t.Fatal(err)
}
var bi bundleInfo
var bi BundleInfo
err = json.Unmarshal(biBytes, &bi)
if err != nil {
fs.t.Fatal(err)
@@ -460,7 +460,7 @@ func (fs *testFileSystem) addIncludesToBundleInfo(version uint32, bundle string,
fs.t.Fatal(err)
}
var bi bundleInfo
var bi BundleInfo
err = json.Unmarshal(biBytes, &bi)
if err != nil {
fs.t.Fatal(err)
+1 -1
View File
@@ -61,7 +61,7 @@ type Manifest struct {
Header ManifestHeader
Files []*File
DeletedFiles []*File
bundleInfo bundleInfo
BundleInfo BundleInfo
}
// MoM is a manifest that holds references to bundle manifests.