420 Commits
Author SHA1 Message Date
John Akre aa544293c2 Add functional tests for statedir-cache
This change adds tests for the statedir-cache with and without a network
connection.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-20 14:45:34 -07:00
Otavio Pontes 0696de4435 curl: Initialize curl as needed
Instead of initializing curl library on start, initialize it only when needed.
The advantage of this approach is that we can run some commands offline, if
there's no file to download.

Fixes #801
Fixes #895
Fixes #277

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-20 10:48:20 -07:00
Castulo Martinez a41bea9fd5 Show the real latest version using check-update
When running the check-update command we get the latest version for the
format we are currently in, but we really want to get the latest version
regardless of the format.

This commit fixes the issue.

Closes #482

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-14 14:31:33 -07:00
Otavio Pontes f19e8dce06 search-file: Don't estimate the total download size for manifest
Estimating the total download size is almost as slow as downloading the
manifests. So just don't do it.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 13:04:23 -07:00
Otavio Pontes 299977fec4 update: Download search-files indexes on update
If --update-search-file-index flag is used on update, all search-file indexes, i.e.
all Manifests will be downloaded on update. This shouldn't be used if you have
disk or network restrictions, but it shouldn't be very download intensive after the
first usage because delta manifests are going to be used.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-14 13:04:23 -07:00
John Akre 970f3a257a bundle.c: Return included manifest loading errors
Previously, when adding included manifests errors were thrown away which
resulted in swupd operations that could succeed, even when failing to
load an included manifest. Now when an included manifest fails to load,
swupd will return a failure.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-12 14:38:34 -07:00
John Akre 031c06776e os-install: Add download flag
When the --download flag is set for the os-install command, update
content will be downloaded to the statedir and no content will be
installed.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-07 14:12:34 -07:00
John Akre 30cb21260a testlib: Enable validate_item to check statedir
Sudo is needed to validate items in the statedir.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-07 14:12:34 -07:00
Castulo Martinez 6a4b15b430 Fixing message when using repair and --picky
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-07 09:43:41 -07:00
Otavio Pontes a22f621a5e log: Print download sizes in MB and not Mb
MB stands for Megabyte and Mb stands for Megabit, so use the correct
unit.

Fixes #1044

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-08-05 16:10:02 -07:00
Castulo Martinez 5608930be5 Fixing a bug using ignore-ilst files in tests
When using testlib to create tests, ignore lists can be used which
include lines of output that should be ignored when running tests.

The ignore lists can exist at three different levels:
- an ignore file that applies to all tests
- an ignore file that applies to all files of one theme
- an ignore file that applies to all tests within the same file

There was a bug in this last one that was causing ignore-list files to
be unrecognized unless the test number was also used as part of the
ignore-list name. This was causing issues because the test number
can change depending on how you run the test.

This commit fixes the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-08-02 14:17:19 -07:00
Castulo Martinez 476cfe14f6 Warn users when using "swupd verify -B"
Using the -B option with verify can have some undesired side effects
since the option is usually missused by users.

This commit adds a warning explaining what are the possible side effects
of using the "-B" option.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 93662e4d81 Improve the flag restrictions for repair
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez a65fe6804e Print only one warning for verify
When using the "verify" command, we show a warning saying the command
has been superseded by "diagnose". But if the user also uses the
"--install" or "--fix" options with "verify" we show another warning
saying those options have been superseded.

We only want to show one warning depending on the options chosen by the
user so we suggest them to either use "diagnose", "repair" or
"os-install" instead.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez b81a3edaae Improve the flag restrictions for verify/diagnose
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez 2e3a584558 Removing --bundle flag from repair
The -B/--bundle option is confusing and causing users to wipe out their
systems. This option was really just meant for os-install, so this
commit removes it from "swupd repair".

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 15:20:56 -07:00
Castulo Martinez c0b340bbd2 Fixes a bug when deleting extra files
When swupd repair is run with --picky or --extra-files-only it attempts
to remove all those files that are in the picky tree and that are not
mentioned in any manifest (from installed bundles). If swupd
encounters an error removing any of these files or directories, it
prints a message showing the failure. This message was wrong since it
was not showing the whole path to the file being deleted when the path
included a prefix.

This commit fixes the issue by appending the prefix to the path so it
shows correctly.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-29 13:43:49 -07:00
Otavio Pontes 277fc0284e mirror: Handle global parameters properly on mirror set
We have 2 global parameters to change content and version url that
were confusing when using mirror. For example user's didn't know what
to expect from:

$ swupd mirror --content-url https://new_url

or

$ swupd mirror --set https://new_url1 --content-url https://new_url2

Fix #941

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-25 14:06:27 -07:00
Otavio Pontes 0968948389 test: Rename the name of the distro for tests
We don't need to have a real distribution name for tests. Use a swupd
specific value.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-19 14:20:00 -07:00
Castulo Martinez 6a0849646d Adding --extra-files-only flag to diagnose/repair
Since --picky was made a superset of diagnose/repair, there is the need
of a new flag that only finds/repairs the extra files that are not in
any manifest.

Many things were included in this commit:
- This commit adds the new flag --extra-files-only for this purpose.
- The commit also refactors the verify function to simplify its workflow
and remove code duplication
- It also adds some validations for flags that are mutually exclusive in
verify/diagnose/repair
- Updates the documentation

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-19 10:46:20 -07:00
Castulo Martinez e0256bee24 Make "diagnose --picky" a superset of "diagnose"
Running "swupd diagnose --picky" result in only identifying the extra
files in the system, but doesn't run the other standard checks that a
"swupd diagnose" do. "swupd diagnose --picky" should do everything
"swupd diagnose" does plus searching for the extra files.

This commit fixes the issue by making diagnose --picky a superset of
diagnose. The commit also makes some changes in the output of --picky so
it is consistent with the rest of the diagnose output.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-19 10:46:20 -07:00
Brandon Hong d0494ba47e Update test case MIR008 for the new swupd info output
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
2019-07-19 10:10:10 -07:00
Brandon Hong b09bdddabe Update testcases to reflect new info format
Signed-off-by: Brandon Hong <brandon.hong@intel.com>
2019-07-19 10:10:10 -07:00
Otavio Pontes 0a84e15aac test: Don't run config file tests on developers machine
config file tests require one special configuration on build time, so
skiping this unless we are running on travis.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-18 14:56:32 -07:00
Castulo Martinez 069ec11ca8 Fix format of do_staging when reporting progress
The function do_staging is regularly used within a loop to stage all the
files for a given bundle-add or update, repair, etc. However when the
loop contains a progress report (with a percentage), if there are errors
in the do_staging function, they get printed in the same line as the
percentage, messing up the output. Like this:

...22%Warning: Update target directory does not exist: some_file...

This commit fixes that output by adding a carriage return at the
beginning of each message do_staging could print so it would overlap
with the percentage value effectively deleting it.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-17 14:24:01 -07:00
Otavio Pontes cd1aac63f1 style: Removing all prints that ends with a '.'
It was defined to not use period at the end of output messages.
Removing the left over cases

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-17 14:16:56 -07:00
Castulo Martinez a6f03caf2e Include also-add circular reference in test
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-15 17:24:12 -07:00
Otavio Pontes 7f0bee1f6f bundle: Support circular includes/also-adds
Circular includes shoudn't exist, but we can handle that without crashing.
Also-add circular includes are common and expected. So we just add the
first occurence found.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-15 17:24:12 -07:00
Otavio Pontes 43034997f5 test: Fix test name
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-15 16:23:50 -07:00
Otavio Pontes 382c1d782f also-add: Update, diagnose and repair shoudn't consider the also-add bundles
In the case that we have a bundle installed as also-add and removed later,
repair shouldn't reinstall that bundle. The same is valid for diagnose and update.
Os-install is the only exception. We should always install all bundles that are
listed as also-add in os-install.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-12 15:44:25 -07:00
Castulo Martinez a61eed9bb7 Fix bug in mirror-allow-http.bats test
This test is yielding different results depending on if it is being run
in a system that has a proxy set up o there is no proxy.
This is happening because when usnig a non existing  server, if
there is a proxy set up, the proxy does respond during curl
initialization instead of the specified server, which allows swupd to
initialize only to fail further down the process when requesting the MoM
to the server. If the system where the test is run doesn't have a proxy
set up, curl fails to initialize since it gets no reply from the server,
which causes swupd to fail initialization, so swupd exits earlier in the
process and with different exit code.

This commit fixes the ambiguity of the test by not checking for an exit
code explicitelly but only making sure it does get an error code.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-10 13:37:01 -07:00
Otavio Pontes f337da5b9c bundleadd: Rename flag from optional to also-add
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-08 13:58:24 -07:00
Castulo Martinez 515c7c71fe Checking mirror status only if necessary
When doing an update, we check to see if a mirror is stale, this only
needs to be done if there is a mirror set and if the upstream server is
up and reachable.

This commit checks to see if a mirror is set and there is an upstream
server to compare against, and only then it checks to see if it is stale.

Closes #922

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-03 16:10:46 -07:00
Otavio Pontes 659d12aa82 test: Fix typo in test
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-03 15:05:42 -07:00
Castulo Martinez c5ba016331 bundle-add skips optional bundles if specified
Swupd will install optional bundles on bundle-add by default,
but will skip them if specified by the user by using the
--skip-optional / -o flag..

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-03 14:59:47 -07:00
Castulo Martinez 9924bf7ee2 bundle-add installs optional bundles by default
An optional bundle is not required to be installed in the system while
included bundles are. Swupd will install optional bundles on bundle-add
by default.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-03 14:59:47 -07:00
Castulo Martinez 2f45cf4c55 Warn user setting mirror to http
If a user sets a mirror that uses http, it is going to cause autoupdates
to stop working since autoupdate would need the --allow-insecure-http
flag to continue with the insecure connection. In order for autoupdate
to work the user will need to add the key/value allow-insecure-http=true
in the swupd config file.

This commit warns the user about this when setting up a mirror with http
so they can take steps to re-enable autoupdate.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-01 17:18:50 -07:00
Castulo Martinez a9acd78753 Wait until the config file is deleted in tests
When running tests that use the config file, it is important to make
sure the config file from the previous test is deleted before the next
test is run. This is necessary since config files are not contained to
the test environment of each test as the rest of the test resources. So
a config file from one test can affect the output of another test if we
don't wait.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-07-01 16:28:26 -07:00
Otavio Pontes 4e1968165e test: Adding extra allow-insecure-http tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-01 16:12:08 -07:00
Otavio Pontes db7701bf73 test: Use https instead of http on mirror tests
This tests aren't testing the insecure http flag, so prefer to use https here

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-01 16:12:08 -07:00
Otavio Pontes ac210d375d test: Remove a swupd option specific for mirror
We shouldn't use a swupd without setting without -S and there's no reason to
have a custom option for mirror anymore

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-01 16:12:08 -07:00
Otavio Pontes feeab71614 test: Fix test description
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-07-01 14:33:30 -07:00
Otavio Pontes cf92789ca6 test: Add a key rotation test
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-06-28 14:49:13 -07:00
Otavio Pontes 8068e3e422 testlib: Improve udpate_bundle --add command
When --add is used on update_bundle we can inform the file to be installed in
the system. But the function doesn't rename the file to the correct name, using
the file hash and it doesn't create the tarball automatically. That's because
it wasn't needed for other usages of --add. But not we are willing to add files
that were not present in content, so adding a feature to rename the file to
the correct hash and to create the tarball if it didn't exist.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-06-28 14:49:13 -07:00
Otavio Pontes 57cf54a6fb test: Adding certificate chain signature checks
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-06-28 14:49:13 -07:00
Otavio Pontes ccbf2620b5 test: Adding signature checking tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-06-28 14:49:13 -07:00
Castulo Martinez c2a4763ff3 Adding configuration file parser for swupd
swupd has many flags that can be used for fine tunning its
functionality. In some cases users may want to include a flag with every
swupd command they run.

This commit gives the ability to provide swupd flags via options in a
configuration file that swupd will read before running the command.

The configuration file is an INI style file tha  can include sections
so users can specify options that should only apply to a specific
command. The biggest advantage of this is to be able to fine tune the
flags that should apply for each command.

For example a user could set a global flag that would apply to every
swupd command, and then turn that flag off for a specific command by
unsetting it in the command's section.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-06-28 13:06:11 -07:00
Castulo Martinez 43ba5def2a Require a force flag to continue with insecure URL
Currently users can set content and version urls based on http or https
protocols. This pose a security risk if users decide to use http.

This commit blocks swupd from working with http unless is specifically
allowed by using the --allow-insecure-http flag.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-06-27 14:48:50 -07:00
Castulo Martinez c521417205 Including a few more cosmetic changes for "verify"
This commit adds a few more cosmetic changes to the commands that run
verify in the back for consistency.
- Different steps in the update process are separated by a blank line.
- Messages from swupd should not finish with a '.'

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-06-14 14:50:09 -07:00
Castulo Martinez 7d295f3ec5 Fix the output when diagnosing a system
Currently when running diagnose, and a problem is found (a missing
file, a corrupt file, or an extraneous file), swupd shows the output
like this:

Verifying files
	...12%
Hash mismatch for file: /usr/bin/somefile
	...100%
Inspected 632545 files

So it splits the percentage that shows the progress of the action in two
lines. This commit fixes the output so it looks like this instead:

Checking for missing files
	...100%

Checking for corrupt files
 -> Hash mismatch for file: /usr/bin/mixer
 -> Hash mismatch for file: /usr/bin/mixin
 -> Hash mismatch for file: /usr/bin/swupd-extract
 -> Hash mismatch for file: /usr/bin/swupd-inspector
 -> Hash mismatch for file: /usr/share/zsh/site-functions/_mixer
	...100%

Checking for extraneous files
	...100%

Inspected 632545 files

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-06-06 15:37:21 -07:00