152 Commits
Author SHA1 Message Date
William Douglas 04eee0d0bb Mass lint cleanups
Two left over that are logic changes to be addressed in the next
commit.

Signed-off-by: William Douglas <william.douglas@intel.com>
2024-01-30 11:42:32 -08:00
Patrick McCarty 0cf05bafc7 Fix setting of log location with custom config
When mixer's -c/--config option was used, the referenced config was read
too late to set a default log location. As a result, the log location
was always set to the empty string (disabling logging), that is, unless
--log VALUE was specified, or if mixer's current working directory
contained a builder.conf with LOG defined.

The root cause of this bug is an order-of-operations issue with cobra
integration; fix the issue by setting the log location in
PersistentPreRunE() instead of init(), ensuring that the command line
arguments have been processed, with `configFile` being set to the
-c/--config value if specified.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2022-08-26 16:04:05 -07:00
Reagan Lopez 9bd384f1ae Show upstream-format command in help
Fixes #751

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2020-05-18 09:38:36 -07:00
Ashlesha Atrey f6dcd44f21 Implement logging for mixer
Implement the logging package for mixer.

A common log file can be set for all the mixer commands in the
builder.conf. E.g. `mixer config set Mixer.LOG <filepath>`

The log file and level can also be set for individual mixer
commands using the `--log` and `--log-level` flags respectively.

The various log levels are:
ERROR (1), WARNING (2), INFO (3), DEBUG (4) and VERBOSE (5).
Default log level is 4.

Fixes #666

Signed-off-by: Ashlesha Atrey ashlesha.atrey@intel.com
2020-04-30 13:57:58 -07:00
Reagan Lopez bbeee932be Remove the --no-publish flag
Mixer will now always update the LAST_VER file after `build update`.
This file is used by `build validate` (MCA) to determine whether
the version in comparison is a +10.

Fixes #735

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2020-04-20 10:15:37 -07:00
John Akre fc1be19d4c Update mix variables when crossing upstream formats
When a downstream mix crossed multiple upstream format bumps, the
upstreamversion and mix state variables were updated in the workspace,
but the changes were not updated in memory. This change reloads the
upstreamversion when it is staged/unstaged and reloads the mix state
after crossing each format boundary. Additionally, this change
increments the format number for each upstream format that the
downstream mix crosses.

Fixes #688

Signed-off-by: John Akre <john.w.akre@intel.com>
2020-03-11 21:27:14 -07:00
John Akre a3e96f8cc6 MCA: Skip format bump check
Fixes #736

Signed-off-by: John Akre <john.w.akre@intel.com>
2020-03-03 16:24:50 -08:00
Ashlesha Atrey 1f21b261e7 Add --local flag in mixer bundle create command
Passing '--local' with mixer bundle create will skip
the upstream check and create a new empty local bundle
if it does not already exist.

fixes #713

Signed-off-by: Ashlesha Atrey <ashlesha.atrey@intel.com>
2020-02-04 15:12:04 -08:00
John Akre 0fdf014167 Always clean mix workspace before building bundles
Existing image and output directories for the current mix version will
be removed when building a mix. This prevents mixer from building on top
of directories contaminated by a prior mix.

Fixes #669

Signed-off-by: John Akre <john.w.akre@intel.com>
2020-01-31 13:46:14 -08:00
John Akre 3df9e11567 build: Add root permission check
The build commands require root in order to run dnf, clr-installer, or
access files in the update folder that are owned by root.

Fixes #690

Signed-off-by: John Akre <john.w.akre@intel.com>
2020-01-13 16:47:06 -08:00
John Akre 77665e5d7c Add repo priority to repo list and add commands
Now the mixer repo list command displays repo priorities and the mixer
repo add command can set the repo's priority with the --priority flag.

Signed-off-by: John Akre <john.w.akre@intel.com>
2020-01-08 18:18:50 -08:00
John Akre ea0bf75463 Add set-priority to the repo command
The set-priority repo command updates the priority value for the
specified repo in the DNF config file. This command uses the following
format:

mixer repo set-priority <repo> <priority>

Fixes #691

Signed-off-by: John Akre <john.w.akre@intel.com>
2020-01-08 18:18:50 -08:00
John Akre 6b2ca23984 MCA: Refactor statistics table
The MCA statistics table replaced the tabwriter implementation with the
tablewriter package. Now the statistics table is a complete box with
line wrapping support for long lines.

This change also adds the --table-width parameter which is used to set the
maximum width of the MCA statistics table. The default value is the
width of the calling terminal and the table can be disabled by providing
a negative number for the table-width.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-12-20 15:20:32 -08:00
Reagan Lopez 8aac35f881 repo: Handle rpms in repo sub directories
Currently, for repos with "file" baseurl scheme, mixer expects the
rpms to be directly within the baseurl path.
But it is possible that rpms can be in sub directories within the repo baseurl.

In order to handle this, if an rpm is not found directly within the repo baseurl,
run repoquery to determine the actual location of the rpm.
This is expensive and it is recommended that rpms are stored directly
within the repo baseurl.

Includes a bat test.
Fixes #674

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2019-12-19 12:04:03 -08:00
Reagan Lopez abff0489f1 Keep repo messages and help consistent
Also, call ListRepos() earlier on during build bundles, to suggest
context.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2019-12-14 23:45:51 -08:00
Ashlesha Atrey 2a68180d93 Setting multiple repos in mixer
Currently mixer allows users to set multiple repos using 'mixer repo set' commands and name them anyhow.
But the code within the mixer is tightly coupled to having only two repos - "clear" and "local".
This inconsistency is fixed.
fixes #654, #659

Signed-off-by: Ashlesha Atrey ashlesha.atrey@intel.com
2019-12-13 17:02:18 -08:00
Reagan Lopez 62423866b0 repo: Fix message while removing repo
Currently, `mixer repo remove` displays incorrect messages if repo does
not exist.

This fix displays the correct message.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2019-12-13 15:29:03 -08:00
Mark D Horn 86c3459378 builder: use clr-installer for image generation
Switch from ister.py to clr-installer for generating OS images.

Will migrate existing ister JSON file if it exist.

Both ISO generate and Raw Image retention enabled by default.

Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
2019-11-22 23:29:49 +00:00
Rodrigo Chiossi bd4b588664 docker: Remove built-in Docker support
Built-in Docker support was originally added to enable auto-format bump.
At that time, mixer could only handle one format version at a time, so
we needed 2 different binaries to cross a format boundary: 1 for the +10
and one for the +20. The docker support would allow us to download an
image with the right version for that given format and simplify the
process.

Mixer now has support for multiple formats and a single binary can
handle the whole format bump process. Built in docker image is no longer
needed.

Note: For Docker usage due to compatibility issues with the host system,
mixer-ci Docker image should be used instead.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-11-08 17:09:06 +01:00
Rodrigo Chiossi 7e589c9dd7 cmd: remove format mismatch check
Format mismatch between the host and upstream was an issue when a given
mixer version could only generate a single format. Since we introduced
multi-format capability, the format of the host doesn't influence the
build anymore and this check can be safely ignored.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-11-08 17:09:06 +01:00
Reagan Lopez 874ee1dfad Introduces option for upstream bundles url
Currently, the bundle defintions are downloaded from the default
clr-bundles repo https://github.com/clearlinux/clr-bundles/archive/.

The user can now specify a different upstream bundles url using a mixer init flag or mixer
config parameter.

E.g. mixer init --upstream-bundles-url=https://github.com/reaganlo/clr-bundles/archive/
E.g. mixer config set Swupd.UPSTREAM_BUNDLES_URL https://github.com/reaganlo/clr-bundles/archive/

Since there is a tight coupling between the --upstream-version and bundles
repo, the user should ensure that the bundles repo has the same structure as the
clr-bundles repo and the tar.gz files should be named after an upstream
version. i.e. If the mix is based on an upstream-version 31300, the bundles repo
should have a file 31300.tar.gz

Fixes #614
Note: Setting this value using `mixer config set` will only update it in builder.conf.
It does not fetch the upstream bundles. A dedicated command for that purpose
will have to be implemented instead.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2019-11-07 17:18:37 +01:00
Ashlesha Atrey 5859424974 Improve performance of rpm extraction
Extracting rpm uisng rpm2archive is faster than dnf and will
improve performace significantly.
Fixes #631

Signed-off-by: Ashlesha Atrey ashlesha.atrey@intel.com
2019-11-05 15:23:01 +00:00
Ashlesha Atrey ca60ef2e53 Fixing bug for command mixer upstream-format
Mixer upstream-format should run with optional flag --new-format. If
--new-format is not set, the default new format should be current
format+1. This default behaviour was not getting set for the current mixer version.
Fixed the behaviour to reflect the default behaviour.

Signed-off-by: Ashlesha Atrey <ashlesha.atrey@intel.com>
2019-10-07 15:45:10 +00:00
Rodrigo Chiossi 01e6ca3e43 lint: Fix errors identified by golangci-lint
golangci-lint identified a couple errors that were not found by
gometalinter. This patch fixes the detected errors.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-09-19 16:57:37 +02:00
Rodrigo Chiossi 6699806e1c Revert "Delete index manifest"
This reverts commit ceb8f5b616.
2019-07-23 06:04:03 -07:00
John Akre ceb8f5b616 Delete index manifest
The os-core-update-index manifest was unused and injected into the mix
by mixer. This change removes support for the index manifest in formats
larger than 28 and deletes the index manifest when a mix passes format
28.

Additionally, this change consolidates the index manifest implementation
into the swupd package so that it can more easily be enabled or disabled.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-07-16 15:52:23 +02:00
John Akre f873574712 MCA: Support repo/baseurl overrides for from and to versions
In some cases a single DNF config file is not sufficient to correctly
download packages for the mix versions specified by the from and to
flags. The --from-repo-url and --to-repo-url flags were added to
temporarily override the baseurl value for the specified repo in the DNF
config when downloading packages for the from and to versions respectively.
Multiple instances of these flags can be used to override additional
repo/baseurl pairs. An example flag format is shown below:

--from-repo-url <repo>=<URL>
--to-repo-url <repo>=<URL>

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-07-02 00:00:50 +02:00
Rodrigo Chiossi 1c4b4a3819 config: Use server state dir when loading MixState
MixState needs to know the server state dir in order to find the value
for previous version since its path will not always be relative to the
execution folder.
With this patch, MixState is always loaded after MixConfig. Since the
conversion of older formats of MixConfig account for format transfer,
changing the order does not prevent the format value to be properly
moved to the state file.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-05-15 19:43:25 +02:00
Rodrigo Chiossi b04762f782 cmd: skip format bump check
When doing manual format bumps, the upstream version for +20 needs to be
updated to the upstream version in the new format, but since the format
differs, the build will fail.
This PR adds a new flag to `mixer versions update` and to `mixer build`
subcommands that allows this check to be skipped.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-05-14 16:56:38 +02:00
Rodrigo Chiossi a448fb8ddc cmd: Improve error message for invalid upstream
The `--clear-version` flag in mixer init accepts a string as parameter
to allow the user to set it to `latest`, which will auto fetch the
upstream version. For all other cases, this flag must be provided an
integer number. This patch clarifies the valid values for this flag both
in the error message and in the help description.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-04-25 19:17:48 +02:00
John Akre 608a9dbc76 Add PREVIOUS_MIX_VERSION field to mixer.state
The mixer.state file now tracks the previous mix version with the
PREVIOUS_MIX_VERSION field. When this value is not set, it will default
to the LAST_VER or 0 when LAST_VER is invalid.

Format bumps create an important exception for the value of
PREVIOUS_MIX_VERSION. During a format bump, PREVIOUS_MIX_VERSION will be
overridden by the LAST_VER which will prevent PREVIOUS_MIX_VERSION from
altering format bump behavior.

Additionally, the mixer.state version was incremented and tests for
state file version conversions were added.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-04-25 18:23:40 +02:00
John Akre 9fea2ce040 Add manifest correctness assurance (MCA) support
MCA compares two versions to validate that the manifest file changes
align with corresponding package changes. All manifest file changes (except
for a few special cases) will be compared against resolved package file
changes. Any mismatches will be reported as errors. When there are no
errors, package statistics will be displayed.

The following command runs the MCA test:

	mixer build validate --from <version> --to <version>

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-04-19 01:09:16 +02:00
William Douglas 623c60999b Enable create Manifest deltas in mixer
swupd-server used to support building bsdiff based deltas of manifest
files. This change adds that ability back for bundle manifests with
the 'mixer build delta-manifests' command.
2019-02-12 13:17:59 -02:00
John Akre 62bf7f6602 builder: Retry RPM downloads
Download failures can occur when downloading large sets of RPMs from a
server with a poor connection. This change adds retry functionality to
attempt RPM downloads multiple times. Also, the retries flag was added to
the following Mixer build commands.
retries:

Fixes: #531

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-01-31 19:12:13 +01:00
John Akre 596899d999 Add clean flag to mixer build all command
The clean flag for the mixer build all command was not exposed to users
to change from the default value. Now the clean flag can be set for the
mixer build all command.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-01-31 18:09:50 +01:00
Otavio Pontes 0c9200fb8c Use cdn to download content on mixer
Use cdn instead of download.clearlinux.org as the standard upstream URL,
because it's more reliable. Other usages of download.clearlinux.org were
also changed with the exception of version number downloads. Downloading
version numbers from download.clearlinux.org is still preferred because
we don't need to be concerned with caching.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-01-24 01:10:48 +01:00
Rodrigo Chiossi 937f62fdb3 cmd: Fail init offline with no clear version
If the --clear-version flag is not used during init, clear version will
default to "latest" which causes build to fetch upstream for the latest
version despite the value of the offline flag. This change makes mixer
fail early and inform the user of the missing parameter on init.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2019-01-18 15:12:10 +01:00
John Akre 525b0dfb64 Deprecate new-swupd and new-config flags
Earlier the new-swupd and new-config flags were incorrectly marked for
deprecation. After correctly deprecating these flags, they are no longer
present in the help message and print a deprecation message when used.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-01-03 20:00:27 +01:00
Reagan Lopez a9b249da53 bundles: Change bundle edit to bundle create
With the removal of the editor feature in `bundle edit`,
the term `edit` is not relevant anymore. Hence, changing it to `create`.
In order to prevent breakage of existing use-cases,
`edit` is aliased to `create`and `--suppress-editor` is made hidden and deprecated.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-11-20 10:54:38 -08:00
Reagan Lopez 7b6d4c22b5 bundles: Remove editor option for bundle edit
`bundle edit` will no longer open the editor. It will just create new bundles or copy existing bundles.
This command will locate the bundle by first looking in local-bundles, and then in upstream-bundles.
If the bundle is only found upstream, the bundle file will be copied to the local-bundles directory.
If the bundle is not found anywhere, a blank template will be created with the correct name.

This commit also fixes issue #448 and increases test coverage for `bundle validate`.

Signed-off-by: Reagan Lopez <reagan.lopez@intel.com>
2018-11-20 10:54:38 -08:00
Rodrigo Chiossi ec17d97d94 cmd: Move init subcommand to its own file
With the exception of init, all other subcommands have their own file.
This patch moves init to a separate file to keep it consistent with the
rest of the code.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-11-16 15:05:06 -08:00
Rodrigo Chiossi ee27092878 cmd: Break root preRun into smaller parts
The root preRun() function accumulated a lot of responsibility over time
that are better located into sub command. This PR deconstructs that
function in order to have a simpler codepath.

Now, the prerun performs only 3 actions:
- Start profiling if needed.
- Check if it is the root command.
- Check if the command should run on a container or not.

The container logic has also been simplified. All commands are not
treated as native commands. During the pre-run, if a command has the
container marker, the current execution is aborted and the command is
re-executed inside a container. This way, the native flag only needs to
be checked once during execution.

Most of the logic in the root preRun() were exclusive to the `build`
subcommand, so they were moved to the build preRun().

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-11-16 15:05:06 -08:00
Rodrigo Chiossi 84653f2386 cmd: make --config a global flag
The --config flag was added to every single subcommand in mixer. Instead
of doing so, make it a global flag.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-11-16 15:05:06 -08:00
Rodrigo Chiossi bd1d4d50f8 cmd: Fix execution of top level mixer command
When mixer is executed without any argument, it should print its usage
message and exit. In order to do so, mixer must skip all it's checks on
the pre-run and just return if the current command is the top level
command alone.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-11-16 15:05:06 -08:00
Tudor Marcu 9d90a2745a Update auto format bump for regular users
Users basing their mixes on upstream Clear and not acting as pure OSV's
need to have the correct mixes automatically generated for them. This
creates the two mixes as needed and then resets their upstreamversion to
the version they were attempting to build.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 15:25:23 -08:00
Tudor Marcu 001ac4b323 Add BAT test for upstream format bump
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 15:25:23 -08:00
Tudor Marcu f3e378381b Break up code and re-order logic better
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 12:18:22 -08:00
Tudor Marcu a9af245c72 Update format bump process
Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2018-11-13 12:18:22 -08:00
John Akre b9313bc370 build: Add increment flag support to build all
Now the 'mixer build all' command supports the --increment flag. When the
--increment flag is passed to 'mixer build all', the mixversion will be
incremented. Otherwise, the mixversion will remain unchanged. This fixes
an issue where delta packs could not be created after using 'mixer build all'.

Fixes #445

Signed-off-by: John Akre <john.w.akre@intel.com>
2018-11-13 12:09:33 -08:00
Rodrigo Chiossi 22f3572d28 init: Always set localrpms
The existence of local repo and local rpms folder has no impact if they
are not used in the mix. This patch removes the `--local-rpms` flag for
`mixer init` and make it always true. This way both folders are always
created and configured in builder.conf during init.

This patch also update the test cases for config convert to address this
change since.

Signed-off-by: Rodrigo Chiossi <rodrigo.chiossi@intel.com>
2018-10-26 19:41:39 +02:00