Now, we have global option
and info_verbose logging level.
For this PR, we have verbose for info,
check-update which shows format versions.
This also helps future implementations leverage
the use of a verbose option for their own need.
commands:
swupd check-update --verbose
swupd info --verbose
Fixes#1066
Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
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>
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>
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>
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>
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>
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>
The json tests had been disabled because they were unstable. This issue
was fixed in a previous commit, so these tests should be enabled again.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Disabling json tests that checks for progress because tests are unstable.
If we have any minor changes in the code that could affect how curl is called
we could have different progress reports and because of that we would have false
negatives.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
The --json-output flag can be enabled for every swupd command.
This commit converts it to be a global flag, and enables it in every
swupd command.
Closes#869
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
swupd prints some messages to stdout and others to stderr, this makes
the code somewhat confusing and also it creates a mess regarding which
messages go where. Messages are usually printed using fprintf() and
printf().
This commit replaces all calls to printf and fprintf with one of the
functions that are part of the logger. This will bring many advantages
to the code:
- readability, it is straightforward to identify where a message needs
to go based on the name of the logger functions.
- consistency, the output will go to either stderr or stdout depending
on the type of message being printed.
- the format of the messages will also be consistent, so for example,
if the message is an error the message will automatically include the
"Error: " label in the beginning of the message, this way we avoid
having things like "ERROR:", "error - ", etc...
Closes#864Closes#294Closes#489Closes#433
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
There are a couple of problems when the user has a mirror set up,
and tries to update. The first one is that in the case where the
user is using the -p option and a mirror, the version of the mirror
was failing to be retrieved since the path_prefix was being added
to the path twice. The second problem was that when the mirror being
used by the user was stale, the mirror was being unset but some values
had already being cached, causing the update function to fail.
This commit fixes the issues and add a few tests to validate the
correct behavior.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
The versionurl and contenturl files are used by swupd to see where
the upstream server is.
This commit adds those files into the test environment and sets
them up so they point to the appropriate content in the test
environment, this way we can get rid of the -u option for most of
the tests, also this resembles closer a real environment.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Shellcheck is a shell script static analysis tool that looks for errors and
programming pitfalls in shell scripts.
Fixing errors reported by running that tool on bats scripts
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
The old mirror tests used the swupdlib.bash library that was
replaced by testlib.bash.
This commit replaces those old mirror tests with new versions
of the same tests that now use testlib.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Set /etc/swupd permissions to 0777 to let the default umask policy
handle stripping bits appropriately.
If we can write files to /etc/swupd, do it, making the directory first,
if necessary. If not, bail out cleanly. Only delete the
mirror_contenturl and mirror_versionurl files from the directory, not
the directory itself.
Add tests to verify normal behavior and corner cases.