From 25d3b0bdf64bb49098c4191fc850bda47c8085de Mon Sep 17 00:00:00 2001 From: "Kevin C. Wells" Date: Tue, 27 Feb 2018 18:54:23 -0800 Subject: [PATCH] Add an "offline" mode for mixer This patch adds a persistent "--offline" flag to the top-level mixer command, which means every command can pass this flag to make mixer work offline. When mixer works offline, it skips caching upstream bundle definition files. This has the implication that every bundle in the user's mix must be available in local-bundles. Signed-off-by: Kevin C. Wells --- builder/builder.go | 13 ++++++++++++- mixer/cmd/root.go | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/builder/builder.go b/builder/builder.go index dd8d366..3d1e49b 100644 --- a/builder/builder.go +++ b/builder/builder.go @@ -51,6 +51,10 @@ var UseNewSwupdServer = false // building the chroots. This is an experimental feature. var UseNewChrootBuilder = false +// Offline controls whether mixer attempts to automatically cache upstream +// bundles. In offline mode, all necessary bundles must exist in local-bundles. +var Offline = false + // A Builder contains all configurable fields required to perform a full mix // operation, and is used to encapsulate life time data. type Builder struct { @@ -498,6 +502,10 @@ func getUpstreamBundlesPath(ver string) string { } func (b *Builder) getUpstreamBundles(ver string, prune bool) error { + if Offline { + return nil + } + // Make the folder to store upstream bundles if does not exist if err := os.MkdirAll(upstreamBundlesBaseDir, 0777); err != nil { return errors.Wrap(err, "Failed to create upstream-bundles dir.") @@ -946,7 +954,10 @@ func (b *Builder) ListBundles(listType listType, tree bool) error { } upstreamBundles, err := b.getDirBundlesListAsSet(getUpstreamBundlesPath(b.UpstreamVer)) if err != nil { - return err + if !Offline { + return err + } + upstreamBundles = make(bundleSet) } // Assign "top level" bundles diff --git a/mixer/cmd/root.go b/mixer/cmd/root.go index b451526..a98f0e8 100644 --- a/mixer/cmd/root.go +++ b/mixer/cmd/root.go @@ -146,6 +146,8 @@ func init() { // TODO: Remove this once we migrate to new implementation. RootCmd.PersistentFlags().BoolVar(&builder.UseNewSwupdServer, "new-swupd", false, "EXPERIMENTAL: Use new implementation of swupd-server when possible") + RootCmd.PersistentFlags().BoolVar(&builder.Offline, "offline", false, "Skip caching upstream-bundles; work entirely with local-bundles") + RootCmd.AddCommand(initCmd) RootCmd.Flags().BoolVar(&rootCmdFlags.version, "version", false, "Print version information and quit") RootCmd.Flags().BoolVar(&rootCmdFlags.check, "check", false, "Check all dependencies needed by mixer and quit")