609 Commits
Author SHA1 Message Date
Castulo Martinez 44e595691c Bug fix: os-install --bundles with os-core fails
When doing a system install with "os-install --bundles" if the list of
bundles to install includes only "os-core" the install fails.

This commit fixes the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-13 10:03:32 -07:00
Castulo Martinez 4d10f19459 Updating testlib README
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-10 12:12:00 -07:00
Castulo Martinez e9b229bcde Remove iterative manifest support from testlib
The iterative manifest effort was droped so this commit removes the
iterative manifest support from testlib.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-10 11:09:46 -07:00
Otavio Pontes 84e507d3f5 service: Remove check-update service
Clear Linux isn't using the check-update service anymore for a long time
and there's no other known uses for those scripts. So there's no reason to
keep them.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-09 14:10:51 -07:00
Castulo Martinez 68de707c04 Implementing the 3rd-party info command
Implementation of the 3rd-party info command to show the version of the
3rd-party repository along with the update URL.

Closes #1354

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-06 14:54:23 -08:00
Castulo Martinez 22f31365e7 Forcing the removal of corrupt 3rd-party repos
This commit allow users to force the deletion of corrupt 3rd-party repos
which will end up deleting most of the repo's files, except for the
scripts that exported files from that repo.

Closes #1343

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-04 16:03:23 -08:00
Castulo Martinez 215daa49b3 Do not apply heuristics to 3rd-party files
When adding an upstream bundle, we apply some heuristics to the bundle
files and based on that some files are skipped from being installed.
These heuristics don't apply to 3rd-party bundles.

This commit skips running heuristics when adding 3rd-party bundles.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-03 16:40:14 -08:00
Otavio Pontes 64872d13d9 tests: Remove test leftovers when the directory is incomplete
Sometimes a test fails before finisihing to create all the required
directories under the testdir. So destroy_environment thinks this is
not a valid test environment.
Touching a dot file to show that the directory is a test environment
instead on counting on its content.

Fixes bug #1135

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-02 15:22:00 -08:00
Otavio Pontes bca954ee6e 3rd-party: Support adding symlinks to 3rd party repositories
When a symlink is added to a 3rd-party repository it will be broken
on the statedir and stat command will fail. We need to use lstat, to
get information about the symlink and not the file that it's pointing
to.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-02-27 15:35:52 -08:00
Castulo Martinez 662f7621cb Move 3rd-party repo.ini out of the state directory
The repo.ini file was being created in the swupd state directory, this
was not ideal since it prevented the state directory from being used for
multiple target paths.

This commit moves the repo.ini file out of the state directory and into
the 3rd-party content directory.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-27 09:32:15 -08:00
Castulo Martinez 89fac2b938 Testlib: Merge functions to create 3rd-party repos
The testlib had two functions to create 3rd-party repositories that were
very similar but with only one difference, one function only created the
3rd-party repo, the other one created the repo and also added it as if
the user had already done a "swupd 3rd-party add" on it.

This commit merges both functions into one to avoid code duplication,
make the test library easier to maintain, and make it less confusing.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-27 09:32:15 -08:00
Castulo Martinez 857ac443ff Handle conflicting 3rd-party binaries
When in a 3rd-party repository one bundle has one binary file that
is exported, and the same file is included in another bundle, only
it is not exported in this bundle, when we remove the bundle that
exports the file, the file should be unexported regardless of the file
still being installed since the bundle that is still in the system is
not exporting it.

Closes #1322

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-26 12:52:57 -08:00
Otavio Pontes 8fdb10efd2 3rd-party: Import certificate from 3rd-party repository on repo add
When trying to add the repository for the first time, download the public
certificate published by the 3rd party repository and with a user confirmation,
use it to install the 3rd-party os-core. After that the official certificate will
be installed for future commands.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-02-21 13:17:04 -08:00
Castulo Martinez 5a957cfd18 Add --non-interactive flag
Some commands were recently added to swupd which require user
interaction under certain circumstances, when this happens the user has
to manually enter either Y/N to continue or abort the current process.
This commit provides a --non-interactive=<yes/no> flag that can be used
to avoid getting this interactive prompts.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-21 12:57:28 -08:00
Castulo Martinez b0357b1b5a Don't allow 3rd-party updates with dangerous flags
If an update of 3rd-party content includes files with dangerous flags,
the user should be notified and the update should only continue if the
user accepts the risk, otherwise the update should be aborted.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-21 12:57:28 -08:00
Otavio Pontes 4a67f4443e Rename variable used to identify if tests are running in a CI
Rename from TRAVIS to RUNNING_IN_CI

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-02-20 14:34:44 -08:00
Castulo Martinez 4251024f95 Dont install dangerous files from 3rd-party repos
If a 3rd-party bundle include files that have either the setuid, setgid
or sticky bits set, then it should not be installed since they could
compromise the security of the system. In this case the user should be
asked to see if they want to assume the risk and continue, or abort the
process.

Closes #1281
Closes #1282

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-20 14:01:29 -08:00
Otavio Pontes d61288464d tests: Auto rebalance tests based on how long they take to long
This patch adds 2 scripts used to balance test execution. The weight_tests.bash
runs all tests and sets a weight to them based on how long they take to run. The
other, filter_bats_list.bash, use this information to split the tests in groups to
be executed by github actions.
When a new test is added the script will consider it with an average weight, so this
shouldn't unbalance the system right away. After some time, if we notice that the
system is not balanced anymore we can just run the weight_tests.bash again to rebalance.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-02-20 13:22:31 -08:00
Castulo Martinez d0926942d1 Update exported binaries during an update
When a 3rd-party repository is updated, if one of the updated bundles
has updated binaries, the scripts that export those binaries should also
be updated. This commit implements that update.

Closes #1279

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-12 16:22:11 -08:00
Castulo Martinez c0071730fd Remove all exported binaries when removing a repo
When a 3rd-party repository is removed, all the content installed from
it must be removed from the system. But also those exported binaries
from the repo being deleted should also be deleted.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-11 09:59:29 -08:00
Castulo Martinez b413f492e1 Remove exported binaries after bundle-remove
When removing a 3rd-party bundle, all scripts that export the binaries of
the bundle should be removed from the target system unless they are still
required by another installed 3rd-party bundle.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-10 10:18:36 -08:00
Castulo Martinez 691f4b45e4 Export binaries of 3rd-party bundles after install
When a 3rd-party bundle is installed, in order for the user to be able
to use the binaries the bundle provides, it needs to have them exported.
This commit exports those binaries after they have been successfully
installed.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-06 09:18:00 -08:00
Castulo Martinez db81471dba Fix name of functional test
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-02-05 14:20:47 -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 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 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 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 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 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 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 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 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 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
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
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 24de99dfcc Housekeeping on 3rd-party commands
This commit does some housekeeping in the 3rd-party commands:
 - Initialize the function "progress" only after swupd has initialized
   successfully.
 - Make functions that are not used outside of a file static.
 - Avoid using regex or partial verifications on tests when possible.
 - Add 3rd-party command flags to the default config file.
 - Don't use "repo" in help menus, use the whole "repository" word.
 - Add 3rd-party sub-commands to the flag_validator script.
 - Add missing values from the autocompletion scripts.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 12:14:08 -08:00
Castulo Martinez cb67bf7b67 Implementing the "3rd-party check-update" command
This commit adds the ability to check for updates on 3rd-party repos.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 11:50:33 -08:00
Castulo Martinez 11ddfefc88 Implementing the "3rd-party repair" command
This commit adds the ability to repair bundles from 3rd-party repos.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 11:23:37 -08:00
Castulo Martinez d96b6f6d92 Implementing the "3rd-party diagnose" command
This commit adds the ability to diagnose bundles from 3rd-party repos.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-20 10:57:37 -08:00