Write update metadata to output directory

Instead of requiring the new swupd code to create the "format" and
"swupd-server-src-version" metadata files enable BuildUpdate to do so.

Because the mixer version is now used instead of a swupd-server version
write the mixer-tools version to a "mixer-src-version" file. Move the
Version const to builder.go so it can be accessed trivially. Update the
Makefile parsing to point to builder.go and update the access method in
the top-level mixer/cmd/root.go.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
This commit is contained in:
Matthew Johnson
2018-01-17 13:02:15 -08:00
committed by tmarcu
parent 8a1e71e5e8
commit 90693da8fe
3 changed files with 24 additions and 5 deletions
+1 -1
View File
@@ -77,7 +77,7 @@ release:
echo "Release needs to be used from a git repository"; \
exit 1; \
fi
@VERSION=$$(grep -e 'const Version' mixer/cmd/root.go | cut -d '"' -f 2) ; \
@VERSION=$$(grep -e 'const Version' builder/builder.go | cut -d '"' -f 2) ; \
if [ -z "$$VERSION" ]; then \
echo "Couldn't extract version number from the source code"; \
exit 1; \
+22
View File
@@ -35,6 +35,9 @@ import (
"github.com/pkg/errors"
)
// Version of Mixer. Also used by the Makefile for releases.
const Version = "3.2.1"
// UseNewSwupdServer controls whether to use the new implementation of
// swupd-server (package swupd) when possible. This is an experimental feature.
var UseNewSwupdServer = false
@@ -643,6 +646,10 @@ func (b *Builder) BuildUpdate(prefixflag string, minVersion int, format string,
func (b *Builder) buildUpdateWithNewSwupd(timer *stopWatch, mixVersion uint32, minVersion uint32, format uint32, skipSigning bool) error {
var err error
err = writeMetaFiles(filepath.Join(b.Statedir, "www", b.Mixver), b.Format, Version)
if err != nil {
return errors.Wrapf(err, "failed to write update metadata files")
}
timer.Start("CREATE MANIFESTS")
mom, err := swupd.CreateManifests(mixVersion, minVersion, uint(format), b.Statedir)
if err != nil {
@@ -1062,3 +1069,18 @@ func createDeltaPacks(from *swupd.Manifest, to *swupd.Manifest, outputDir, chroo
}
return nil
}
// writeMetaFiles writes mixer and format metadata to files
func writeMetaFiles(path, format, version string) error {
err := os.MkdirAll(path, 0777)
if err != nil {
return err
}
err = ioutil.WriteFile(filepath.Join(path, "format"), []byte(format), 0644)
if err != nil {
return err
}
return ioutil.WriteFile(filepath.Join(path, "mixer-src-version"), []byte(version), 0644)
}
+1 -4
View File
@@ -29,9 +29,6 @@ import (
"github.com/spf13/cobra"
)
// Version of Mixer. Also used by the Makefile for releases.
const Version = "3.2.1"
var config string
// RootCmd represents the base command when called without any subcommands
@@ -54,7 +51,7 @@ var RootCmd = &cobra.Command{
// check for external programs.
if cmd.Parent() == nil { // This is RootCmd.
if rootCmdFlags.version {
fmt.Printf("Mixer %s\n", Version)
fmt.Printf("Mixer %s\n", builder.Version)
os.Exit(0)
}
if rootCmdFlags.check {