Commit Graph
37 Commits
Author SHA1 Message Date
Castulo Martinez 381f08dea1 Adding installation status to bundle-list
The "bundle-list" command can be used to show all installed bundles in
the system, however, currently there is no way to know which of those
installed bundles were implicitly or explicitly installed.

This commit implements the "--status" flag for bundle-list which can be
used to show which bundles were explicitly or implicitly installed.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:10:48 -08:00
Castulo Martinez a040496bc5 Implementing tree view for bundle-list --deps
Sometimes is useful to see the list of dependencies in a tree view form,
for example when trying to remove bundles from a system.

This commit adds the ability of listing the dependencies of a bundle in
a tree view when --verbose is used.

Closes #929

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-17 13:36:21 -08:00
Castulo Martinez db033b1d6b Show spinner when loading manifests in bundle-list
For some options of bundle-list, like --deps and --has-dep, we sometimes
need to download a considerable amount of manifests, if that happens
swupd just seems to hang for some time, this time could be considerably
in slow networks.

This commit enables the spinner while the manifests are baing downloaded
during a bundle-list operation so users know swupd is not hung and it is
doing some downloading.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-03 14:29:11 -08:00
Castulo Martinez 946a22a777 Ignoring invalid bundle error if exist in one repo
When listing bundles using the --deps or --has-dep flags which
take a BUNDLE as argument, one or more repositories may not have
the specified BUNDLE, but we should not return a
SWUPD_INVALID_BUNDLE error unless the bundle is not found in any
repository.

This commit enforces that behavior and also modify the output of the
different list options to make them more consistent with one another.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 14:05:12 -08:00
Castulo Martinez 068f52aa6d Making bundle-list output consistent
This commit does two things:
 - makes the output of all options of bundle-list consistent with each
other.
 - makes the ouptut of all bundle-list work properly with the --quiet
flag so it prints the output in a format that is friendly for piping the
output.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-05 15:44:51 -08:00
Otavio Pontes 66ea5fea0f progress: Make progress bar and spinner more similar in style
And protect spinner from printf's during spinner time

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-18 09:27:25 -07:00
Otavio Pontes 3e674a66c7 json: Remove trailing spaces at the end of strings
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-03 15:26:54 -07:00
Castulo Martinez e419e7fa9d Refactor bundle-remove to include improvements
This commit does a major refactor of the bundle-remove command to
include these improvements:

- Adds a "--force" flag that can be used to remove a bundle that is
required by other installed bundles along with all the bundles that
depend on it
- When attempting to remove a bundle which is required by other
installed bundles, swupd used to show the list of dependencies in a tree
view, this list was very large in some cases. This commit changes the
output of such cases from a tree view to a simple deduplicated list of
bundles that require the bundle to be removed. The user can still see
the old tree view by including the --verbose when running the command
- Stops notifying telemetry of user errors, like user trying to remove
an invalid bundle, or a bundle that was not installed, etc
- Consider all bundles provided in the bundle-remove command when
checking for dependencies (required by)
- Instead of removing each bundle in the command one by one, consolidate
all bundles to be removed, validate them and remove them all at once.
This will optimize the tasks to be executed for removing bundles.

One change included in this commit for bundle-remove is propagated to
bundle-list:

- When using "bundle-list -D BUNDLE" to find what bundles depend on
BUNDLE. The list will be presented in a simplified deduplicated list of
dependencies by default instead of the tree view that used to be
default. The user can still see the old tree view by running the command
appending the --verbose flag

Closes #891
Closes #732
Closes #674

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-09-30 14:40:01 -07:00
Castulo Martinez da8dd88837 Test: Fix call to global_setup in tests
There was a bug in the logic of the setup function in testlib which was
causing the globale_teardown to be incorrectly called when tests were
being run using "bats <directory>/". This commit fixs the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-09-16 15:22:08 -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 069af9decf Enabling the --json-output flag as a global option
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>
2019-04-01 12:03:23 -07:00
Castulo Martinez c545a02378 Use logger to print all messages in screen
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 #864
Closes #294
Closes #489
Closes #433

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-03-25 16:07:40 -07:00
Otavio Pontes b6422f89d1 curl: Improve error messages when using fallback SSL certificates
Instead of printing errors and warnings, just print debug information
when we are looking for the right ca path to use. If we couldn't
connect to the server, abort and print a clear error message.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 16:01:03 -08:00
Castulo Martinez acdc0e0d74 bundle-list should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for bundle-list.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez f71b84f22d Renaming existing exit codes for consistency
Renaming codes following these rules:
- All codes should start with SWUPD_ so we never get confused what
code comes from swupd
- Always separate codes that contain multiple words using an underscore
SWUPD_MULTI_WORD_ERROR instead of using SWUPDMULTIWORDERROR
- Code 0 is reserved for SWUPD_SUCCESS (or SWUPD_OK)
- Code 1 is reserved to be used as "no" by commands that return a boolean
state (e.g. swupd autoupdate, check-update)

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Otavio Pontes 8d0556f20d curl: Use functions from log.h instead of printf in curl
This will make outputs a lot better when using --quiet because optional
curl messages wont be printed.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-01-24 13:29:31 -08:00
Otavio Pontes f8f44ee945 curl: Use same error handling from sync downloads in async
The biggest change is handling timeout in a better way. The response
code in a timeout (and some other curl errors) is the response from
the last successful operation, so on timeouts we can get 200 (OK)
response code instead of 206(partial content) in a partial download. So
we should look at curl return and not on http return code to decide if we
are going to try to resume the download or not.

Changing slow-server test because error message has changed

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-01-16 08:42:04 -08:00
Castulo Martinez 23e3393be0 Tests for listing bundles when no disk space left
When listing bundle, if downloading the files fail because of disk
space, swupd should not re-attempt to download the files since it will
fail again for sure.

This commit adds tests that verify this behavior.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-10 14:05:01 -08:00
Otavio Pontes 58ed52d39e curl: Show warnings instead of errors on recoverable SSL problems
When we have SSL connections errors we try to use fallback CA paths added by the
--with-fallback-ca-paths configuration flag.

Instead of printing errors in this case, just print a warning. An error
message will be printed when we fail when trying all fallbacks.

Fixes: #746

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-12-20 08:49:45 -08:00
Castulo Martinez 2e30eb128a Setting upstream server in client cert tests
The tests that attempt to verify the client certificate were using the
swupd -u option to set the url of the "upstream server". Recently a
function was added to the test library to set the default upstream
server.

This commit modifies these tests so they used the new function to set
the upstream server instead of using the -u option. This will provide
the benefit of the test environment being more similar to a prod
environment, also makes the test setup less convoluted and the tests
easier to read.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-12-17 06:19:14 -08:00
Castulo Martinez 6131933d98 Show experimental bundles in installed bundle list
This commit adds the ability to show an identifier in bundles
that are marked as experimental when listing installed bundles
(swupd bundle-list).

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-12-10 14:44:33 -08:00
Castulo Martinez 92fe8acad2 Distinguish experimental bundles in a bundle list
This commit adds the ability to show an identifier in bundles that
are marked as experimental when listing available bundles (swupd
bundle-list --all).

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-12-10 14:44:33 -08:00
Castulo Martinez 6a7b089294 Add ability to parse "experimental" bundles in MoM
Mixer will soon start using a new modifier for bundles in a MoM
that are marked as experimental. These bundles will include a
"e" in the 4th position of the modifiers of a manifest, like shown
here:

M..e 4b91c3122e7e32f1e3edb597c6f89ff32cfffd977afb5e5 10 some-bundle

This commit adds the mechanism to parse that element from the MoM
and store it in memory. In the future this will allow swupd to treat
this experimental bundles differently if required.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-12-03 13:07:03 -08:00
Castulo Martinez 5e438b3831 Adding ID to bundle-list tests
Adding an ID to all bundle-list tests and rewording some of the
test descriptions to make it more readable.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-11-16 10:05:14 -08:00
John Akre 6186a177c8 test: clean up tests when interrupted
Tests will be cleaned up by a trap routine when interrupted early. This
change also moves test web server and certificate store clean up to the
destroy_test_environment function.

Signed-off-by: John Akre <john.w.akre@intel.com>
2018-11-12 14:30:45 -08:00
John Akre 1640fadc8a test: Move test files out of /tmp
Some tests wrote files and directories to /tmp. This change moves the
test certificates directory into the swupd repo's top level directory
and moves other test files into their corresponding test directories.

Fixes #650

Signed-off-by: John Akre <john.w.akre@intel.com>
2018-11-12 14:30:45 -08:00
Otavio Pontes 02546caade test: Fix flag name on certificate tests
sed s/fallback-ca-paths/with-fallback-capaths/g

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2018-10-22 16:34:48 -07:00
Castulo Martinez ad43b4c918 Replacing old bundlelist tests
The old bundlelist tests used the swupdlib.bash library that was
replaced by testlib.bash.

This commit replaces those old bundlelist tests with new versions
of the same tests that now use testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2018-09-27 12:48:14 -07:00
Castulo Martinez 81d616b605 Be consistent in bundle-add/remove error messages
The operations have different command result output styles. Also,
in particular bundle-remove error is a bit redundant.

This commit changes the messages displayed by the bundle-add and
bundle-remove functions so they have consistent messages for their
corresponding operations.

Fixes #475
2018-06-13 14:47:36 -07:00
Matthew Johnson e68a8a6db6 Update tests to remove version download string
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-04-30 14:54:23 -07:00
Icarus Sparry e52ba1e7df Change contentsize in Manifest.MoM to 0
The previous value - 13,805,671,819 is bogus, and we want to be able
to test if the value is reasonable.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2018-03-19 14:42:22 -07:00
Arzhan Kinzhalin feadea96b6 Implement fallback CApath support.
A colon-separated list of alternative CApath options can be passed to
swupd-client at the configuration time using --with-fallback-capaths
option.

In runtime, fallback CApath support is implemented as part of the
connectivity check. The implementation will try the default (built into
curl) and then will iterate through the list in the order they were
specified. It is done only once on the first call.

The code is reorganized to keep the connectivity check inside curl
wrapper:

* Deleted check_network implementation from version.c
* Removed have_network global (globals.c)
* Scoped swupd_curl_test_resume to curl.c
* Change use of check_network to swupd_curl_check_network

Also:

* Fixed an issue where SSL was only enabled if a URL was matching the
  content URL
2017-10-02 11:30:48 -07:00
Matthew Johnson ac7345318c Add functional tests for bundle-list --deps
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson c83c4ce78f Add functional tests for bundle-list --has-deps
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson ae011954f4 Add status checks for test swupd commands
Adds status checks for each swupd command called in the functional
tests. At this point several of these tests fail due to some successful
commands returning error statuses.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-10 15:33:59 -07:00
Mario Alfredo Carrillo Arevalo 504000ec3a Fix swupd options for bundle-list --all unit test
The swupd unit tests need a group of
options for execution environment.

Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
2017-02-01 11:03:43 -08:00
Mario Alfredo Carrillo Arevalo b49fb6419b Update swupd unit test
"bundle-add" sub-command used to validate "list" option in a unit test,
now that option is part of "bundle-list" sub-command with a new
name: [-a, all], for this reason the test has been updated in order to
validate it using "bundle-list" sub-command.

Furthermore this test has been moved to new directory called
"bundlelist/all" this in order to keep source code integrity.

Signed-off-by: Mario Alfredo Carrillo Arevalo <mario.alfredo.c.arevalo@intel.com>
2017-01-31 12:38:29 -08:00