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#801Fixes#895Fixes#277
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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_url2Fix#941
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>