From 520eb200282573e2ffdd2570667a149bc6c3ffd1 Mon Sep 17 00:00:00 2001 From: Matthew Johnson Date: Mon, 25 Jun 2018 11:18:57 -0700 Subject: [PATCH] swupd: read *-extra-files from persistent location Instead of reading the bundle-extra-files configuration file from the bundle directory under /image/ (which does not exist until mixer build bundles is run) read from the persistent mixer workspace. This means users no longer have to copy these files into place after building bundles. Signed-off-by: Matthew Johnson --- swupd/bundleinfo.go | 4 ++-- swupd/create_manifests.go | 2 +- swupd/helpers_test.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/swupd/bundleinfo.go b/swupd/bundleinfo.go index ec49d4f..27569e1 100644 --- a/swupd/bundleinfo.go +++ b/swupd/bundleinfo.go @@ -32,7 +32,7 @@ type bundleInfo struct { Files map[string]bool } -func (m *Manifest) getBundleInfo(path string) error { +func (m *Manifest) getBundleInfo(c config, path string) error { var err error if _, err = os.Stat(path); os.IsNotExist(err) { basePath := filepath.Dir(path) @@ -65,7 +65,7 @@ func (m *Manifest) getBundleInfo(path string) error { return err } - extraFilesPath := filepath.Join(filepath.Dir(path), m.Name+"-extra-files") + extraFilesPath := filepath.Join(c.stateDir, m.Name+"-extra-files") if _, err = os.Stat(extraFilesPath); err == nil { extraFilesBytes, err := ioutil.ReadFile(extraFilesPath) if err != nil { diff --git a/swupd/create_manifests.go b/swupd/create_manifests.go index 8d3bc90..6ccf853 100644 --- a/swupd/create_manifests.go +++ b/swupd/create_manifests.go @@ -84,7 +84,7 @@ func initBundles(ui UpdateInfo, c config) ([]*Manifest, error) { useBundleInfo = false } - err = bundle.getBundleInfo(biPath) + err = bundle.getBundleInfo(c, biPath) if err != nil { return nil, err } diff --git a/swupd/helpers_test.go b/swupd/helpers_test.go index e40f67c..1329112 100644 --- a/swupd/helpers_test.go +++ b/swupd/helpers_test.go @@ -504,7 +504,7 @@ func (fs *testFileSystem) addDir(version uint32, bundle, dir string) { func (fs *testFileSystem) addExtraFile(version uint32, bundle, file, content string) { fs.t.Helper() - path := filepath.Join(fs.Dir, "image", fmt.Sprint(version), bundle+"-extra-files") + path := filepath.Join(fs.Dir, bundle+"-extra-files") f, err := os.OpenFile(path, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0644) if err != nil { fs.t.Fatal(err)