Commit Graph

1756 Commits

Author SHA1 Message Date
Karthik Prabhu Vinod e748685d33 Adding Swupd performance monitoring scripts
Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
2020-02-05 08:54:59 -08:00
Castulo Martinez 5c539101d8 Restoring original global values in 3rd-party
Instead of storing a local copy of a global variable to restore it as
needed in 3rd-party operations, use the backup of the global variables
stored during swupd initialization.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-30 08:52:51 -08:00
Castulo Martinez 51af21e3d5 Backup global variables used by 3rd-party ops
When running 3rd-party operations, most of the times these need to
overwrite some of the global variables in order to reuse the code
use for normal swupd operations.

This commit add means to backup those global variables, so they can be
recovered as necessary.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-30 08:52:51 -08:00
Castulo Martinez 56ecb7f997 Add support for 'x' in the manifest parser
Add the 'x' to the manifest parser in the 4th column of file attributes,
this will indicate a file should be "exported".

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-29 16:01:07 -08:00
Castulo Martinez 3319a4eb4e testlib: Adding support for exported files
This commit makes possible the creation of bundles with exported files
in test environments. These bundles will have the 'x' in the appropriate
place in the manifest plus those bundles that are to be installed in the
environment will have the "exporting script" created in the 3rd-party
bin directory.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-29 15:58:02 -08:00
Castulo Martinez c6fdf51f39 Rebalancing tests for github actions
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-29 12:03:28 -08:00
Castulo Martinez 727797a051 Removing legacy verify command from autocompletion
The "verify" command was superceded many months ago. The command
still works and will continue to work for backward compatibility, but
users are discouraged to use it. To motivate users to use the newer
commands, all references to the legacy command has now been removed
from the swupd man page and the help menus.

This commit removes the command from the bash autocompletion script too.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-28 15:02:20 -08:00
Castulo Martinez a562fb4fd3 Implement --file option for diagnose/repair
When diagnosing/repairing a system, sometimes is useful to only
diagnose/repair a specific file or path.

This commit implements the --file option for diagnose/repair so a file
or path can be diagnosed only instead of doing it to the whole OS or a
whole bundle.

Closes #1150

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-28 15:01:47 -08:00
Castulo Martinez ade1f3f75e Adding functions to log without a label
All messages that are printed by swupd are printed using one of the
existing log functions: print, error, warn, info, info_verbose or debug.
The error() and warn() functions always print a label "Error:" and
"Warning:" respectively and the output is directed to stderr.

Sometimes it is necessary to print a message that should behave like a
normal error() or warning() with the exception of not adding a label,
this provides flexibility when creating messages because a message can
be constructed by mulitple calls to the function.

This commit adds that warn_unmarked, and error_unmarked functions to add
that capability.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-28 15:01:47 -08:00
Castulo Martinez 8cb1fd5ed8 Force to run all 3rd-party commands with root
Some of the regular swupd commands can be run with a regular user, for
example check-update, however this is not the case for 3rd-party
commands, all of them require root privileges since they all need to at
least read data from root owned directories.

This commit enables swupd to require root privileges for all 3rd-party
commands at initialization time.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-28 10:20:01 -08:00
Otavio Pontes b068fb845e docs: Explicitly adding a list of files in the doc check exclude list
We have a list of header files that weren't documented yet. Add them explicitly
to the check to prevent us to lower the quality of the documentation of headers
that are well documented.

Also fixing some documentation that weren't included because of incorrect style.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-01-28 09:21:40 -08:00
Castulo Martinez 3af3fb76df Fix return value overwriting during bundle-list
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-23 10:20:29 -08:00
Castulo Martinez a9e4cfa652 Adding 3rd-party to swupd man page
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:22:37 -08:00
Castulo Martinez 896cd20d48 Updating the existing man to be consistent
This commit updates the swupd man pages to have a better looking
formatting, it fixes some omissions in the documentation and also
rewords a few sentences to make the information more digestable.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:22:09 -08:00
Castulo Martinez 799a571d72 Adding missing "clean" command to man page
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:21:27 -08:00
Castulo Martinez 665bf89bab Reordering the man page to be consistent with help
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:21:25 -08:00
Castulo Martinez ad32cb2111 Updating the year of the copyright in the man page
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:20:55 -08:00
Castulo Martinez 3e1167e4ec Expand bundle-info install status with explicit
bundle-info currently shows the installation status of a bundle, but
this one is restricted to "installed" or "not installed", it doesn't
show if a bundle was explicitly or implicitly installed.

This commit adds this information to the installation status during a
bundle-info.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:10:48 -08:00
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 86786b94ca Organizing compare like functions
We used compare-like functions as arguments to other functions that
filter, sort, compare data. These functions are scattered accros the
code and they are sometimes difficult to identify so there is a lot of
code duplication.

This commit organizes all the compare like functions throughout the code
in the same place and with standard naming so it is easier to find them
and reuse them.

Closes #1167

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:08:17 -08:00
Castulo Martinez 355edf2b61 Do not run scripts after updating from 3rd-party
Swupd should not run post-update scripts after updating content from a
3rd-party repo since it may threaten the security of the system.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-22 13:06:47 -08:00
Karthik Prabhu Vinod 6caae35301 autoupdate: adding auto-update test back
This PR re-enables the failing auto-update
tests while moving from travis to github actions

Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
2020-01-22 13:01:52 -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 15c8cfd81f Remove unecessary processing from bundle-list
This commit removes some extra processing from bundle-list --deps.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-17 13:36:21 -08:00
Castulo Martinez 29a2e1fbe4 Showing how much space was freed when cleaning
Closes #1107

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-17 09:45:18 -08:00
Castulo Martinez e3134ad17b Moving the content from 3rd-party bundles
This commit moves the path where the content from 3rd-party bundles is
going to be installed from opt/3rd-party/<bundle_name> to
/opt/3rd-party/bundles/<bundle_name> so bundle directories are separated
from other top level directories like bin.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-16 15:43:29 -08:00
Castulo Martinez 8eb8e8264b Improving diagnose/repair --picky documentation
This commit improves the diagnose/repair --picky documentation in an
attempt to make it clearer for the user.

Closes #1205

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-16 15:37:15 -08:00
Castulo Martinez c61c396991 Adding command descriptions
This commit adds a shoort description for the help menu of all swupd
commands.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-16 15:37:15 -08:00
Castulo Martinez ed23d46a6d Show optional includes with bundle-list --has-dep
Using the "bundle-list --has-dep BUNDLE" command shows a list of bundles
that have BUNDLE as a dependency. However this list is not considering
the bundles that have BUNDLE as an optional dependency.

This commit completes the list by including these bundles.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-16 15:28:23 -08:00
Castulo Martinez 823836550e Show what indirect dependencies are optional
When using "bundle-info BUNDLE --dependencies", information regarding
BUNDLE is presented to the user, this information includes the list of
direct and indirect dependencies BUNDLE has. All direct includes that
are optional (also-add) are marked as such, while there is no way to
distiguish what indirect dependencies are optional with the provided
information.

This commit expands the information shown by the command so indirect
dependencies that are optional are shown as such along with info about
the status of that dependency.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-16 13:40:50 -08:00
Castulo Martinez 81b4401509 Renaming the 3rd-party repository
The 3rd-party repository directory is currently 3rd_party, this name is
incorrect and needs to be changed to 3rd-party.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-10 16:14:01 -08:00
Karthik Prabhu Vinod 79c33d1957 Swupd info: Add functional tests
Closes: #1124

Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
2020-01-10 15:25:09 -08:00
Castulo Martinez 3f3ff08c8f Add ability to search files in specific version
The search-file command is restricted to looking for files in the
current version. This commit adds the --version option to the command
that can be used to seach for files in specific versions of Clear.

Closes #1155

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-08 11:36:48 -08:00
Castulo Martinez f90a9b3c65 Testlib option to create a replica of a test env
Sometimes when a test finds a problem in the source code it is difficult
to determine what is the problem in the code, so the code needs to be
debugged. In order to do this, the test environment of the particular
test has to be created but without running the test, so we can run the
command executed by the test with the debugger.

This commit adds a function (create_test_environment_only) to create a
specific test environment based on a bats file, but without running the
test.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-04 18:43:58 -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 2fa8d60816 Function to print a header
This commit adds a function to print a header in a consistent manner
accross different swupd functions.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-03 13:59:46 -08:00
Castulo Martinez febda7b57f Fix an error showing the size during bundle-info
When showing the information of a large bundle, there was a variable
that was incorrectly declared so it was overflowing, turning the size of
the bundle into a negative number.

This commit fixes the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-01-03 13:13:46 -08:00
Castulo Martinez 941455d334 Incraese the total steps if inaccurate
When performing a swupd operation, if the progress steps are defined
incorrectly, a buffer overflow may be triggered. This commit makes sure
the steps are still within the specified range by redefining the total
number of steps to avoid the memory problem.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-27 17:29:49 -08:00
Castulo Martinez b5bd920611 Fix the number of steps in swupd functions
In order to report progress accuratelly, currently swupd requires a
hardcoded number of steps per operation so we can report how far in the
operation we are. Most of these step totals are wrong.

This commit fixes the number of steps in many swupd functions.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-27 17:28:53 -08:00
Castulo Martinez 40d56a6241 Fix line breaks on os-install, diagnose and repair
The line breaks in the commands previously mentioned were off, this
commit fixes the spacing between lines in the output for those commands.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-26 14:10:16 -08:00
Castulo Martinez fa749bc354 Cleaning the spinner once download completes
A spinner was added to swupd to show some kind of progress while
downloading content which its amount is unknown. Once the content is
downloaded the stopped spinner should be removed from the screen. This
commit does that.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-26 14:10:16 -08:00
Castulo Martinez 3856976b49 Formating 3rd-party add,list,remove command output
This commit makes a few small changes to the output of the commands to
make it look cleaner and to be consistent with the output of other swupd
commands.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-24 09:57:09 -08:00
Castulo Martinez 37b31dc53a Fix buffer overflow when adding 3rd-party repos
This commit fixes a buffer overflow that was being triggered when adding
3rd-party repositories.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-23 16:17:02 -08:00
Castulo Martinez 91d56b9cc4 Remove the state dir when removing 3rd-party repo
When we remove a 3rd-party repo from the system, we remove the directory
where all its contents got installed, but we don't remove its state
directory.

This commit removes it since we no longer need that state directory.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-23 10:52:13 -08:00
Castulo Martinez 5efb9077ec Filter messages from signature failures
When performing signature verification to the MoM or to the version
file, if there is any error during the process, a series of errors are
printed to stderr. Many of these error messages are duplicated and most
of them are too detailed.

This commit filters those detailed messages so they are only seen if the
user is using the --debug flag, showing only a few more general
error messages about the signature failure.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-23 09:43:09 -08:00
Castulo Martinez 140dba9a98 Consistency with signature verification messages
This commit enhance the consistency and readability, of the messages
shown when the signature verification is skipped or fails.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-23 09:43:09 -08:00
Castulo Martinez ca98b3a7db Adding "3rd-party clean" command
This commit implements the swupd clean command for the 3rd-party bundles
so users are able to clean the cache on their state directories.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 16:38:41 -08:00
Castulo Martinez 53f502e141 Check 3rd-party repo certificate with operations
When running an operation, swupd uses a certificate to validate things
ilke the MoM and the version file. The certificate that needs to be used
for 3rd-party repos is different than the one that has to be used for
upstream.

This commit enables the use of the 3rd-party repo certificate that will
be installed in the repo's directory with all swupd operations, except
when adding the repository, in those cases, since the os-core bundle
hasn't been installed yet, we need to provide the cert path through
other means, like using the -C flag..

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 16:08:04 -08:00
Karthik Prabhu Vinod f9c56f4faa Prevent memory leak
This makes sure we always deallocate memory if there was an
error after the initial global_init

fix: #1165

Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
2019-12-20 15:35:11 -08:00
Castulo Martinez 806ca3ee94 Verifying the URL of a repo doesn't exist already
When adding a 3rd-party repository we need to make sure that the URL
provided by the user is not already assigned to another 3rd-arty
repository, otherwise we can end up having the same repository multiple
times, just with different names.

This commit checks the URL doesn't already exists.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 14:52:34 -08:00