171 Commits

Author SHA1 Message Date
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
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
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
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 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
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 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 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
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 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 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 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
Castulo Martinez d0c2f881cf Update testlib to support 3rd-party bundle updates
This commit modifies some of the functions of the test library so it is
possible to update bundles that belong to 3rd-party repositories.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-12 08:41:45 -08:00
Castulo Martinez 9d59dc068e Implementing the 3rd-party bundle-remove command
This commit adds the ability to remove 3rd-party bundles. If a repo is
not specified the bundle will be searched for in all repositories. All
options from the normal bundle-remove command are supported with
3rd-party bundles.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-11 16:11:35 -08:00
Castulo Martinez 868505b5b9 Install os-core when adding a 3rd-party repo
The os-core file includes the os-release file, which has the
version of a content server. When adding a new 3rd-party repository we
need to install the os-core bundle from that repo so we can track the
current version of the repo.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-05 16:26:31 -08:00
Castulo Martinez e5ec67edf1 Get version from os-release on repos bundle-list
Instead of getting the current version of a 3rd-party repo during a
bundle-list from the repo.ini file, this commit changes the code so it
is gotten from the os-release file in the appropriate path_prefix for
the repo.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-12-05 16:26:31 -08:00
Castulo Martinez b91ecbbc6d Implement --repo flag for 3rd-party bundle-list
This commit adds the --repo flag for the 3rd-party bundle-list command
which can be used to specify the repository from which the bundles are
going to be listed.
2019-12-05 16:05:51 -08:00
Castulo Martinez 8079503cee Adding 3rd-party bundle-add section to config file
This commit adds the section that handles the "3rd-party bundle-add"
options into the default config file. It also enables the use of
the 3rd-party command and its subcommands in the config file.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-11-27 14:56:10 -08:00
Castulo Martinez 8bb471ae40 Enabling the use of 3rd-party repos in the testlib
This commit enables the use of 3rd-party repos in some of the testlib
functions.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-11-26 08:23:47 -08:00
Castulo Martinez 24f60f2673 Rebalancing functional tests
This commit separates the 3rd-party tests in their own job since we will
be adding several tests related to 3rd-party in the upcoming days.

This commit also rebalances the tests in the update groups so they are
better balanced.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-11-25 15:13:17 -08:00
Otavio Pontes e7d4e6900a 3rd_party: Create 3rd_party dir on swupd_init()
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-11-21 13:16:33 -08:00
Karthik Prabhu Vinod fe0cd44e5e Concrete implementation for third-party repo add
sudo swupd 3rd-party add <repo_name> <upstream_url>

With some clean up from Otavio

Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>
2019-11-21 13:16:33 -08:00
Castulo Martinez 6ef7b4ccaf Fix a bug with some tests that are leaving trash
The tests in usa-config-file.bats are leaving trash behind (the old test
environment). This commit fixes the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-11-20 16:53:17 -08:00
Otavio Pontes d175af3fd5 test: Don't conflict config tests with other tests
Always save the config file in another directory so we won't have
problems on running the config tests in parallel. Before this patch
if you run the config tests in parallel with any other tests you could
end up having false-negatives.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-11-12 13:15:24 -08:00
Otavio Pontes 6fa1594392 testlib: Always limit the number of bytes read from urandom
On github actions if you don't limit the number of bytes read from
urandom the system can get stuck in the read command.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-11-11 16:26:46 -08:00
Castulo Martinez 744bd4774a Adding tests for bundle-remove --recursive
Functional tests for the new "--recursive" flag in bundle-remove that
will be used to remove a bundle and its dependencies.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-10-30 13:38:41 -06:00
Otavio Pontes 2bf4169a4a Don't mix tabs with spaces in the same file
And prefer tabs over spaces, because that's the project standard for
source files

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-29 11:54:25 -07:00
Castulo Martinez e84d5874d4 Track bundles specified in os-install
When os-install is used to install an OS and the --bundles option is used
to specify some bundles that should be installed in the system along
with the OS, the bundles specified should be tracked.

Closes #1153

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-10-24 18:22:00 -05:00
Karthik Prabhu Vinod c207c9240c Add --path to swupd autoupdate mechanism
Signed-off-by: Karthik Prabhu Vinod <karthik.prabhu.vinod@intel.com>

Fixes #527
2019-10-21 12:26:48 -07: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
Castulo Martinez f7aeea5cef Implement bundle-info command
The bundle-info command shows detailed data related to a specified
bundle. Among the data currently displayed it includes:
- If the bundle is installed or not
- If the bundle is experimental or not
- If the bundle is installed, it shows if there is an existing update
for the bundle
- The latest available version of the bundle
- The size of the bundle and all its dependencies
- The max size needed in disk to install a bundle if not installed

This commit also adds the following command flags:
--version: so a user can display information for a bundle in a
specific version, not only the current version.
--dependencies: this flag can be used to show all optional and required
bundles that are directly and indirectly included by the specified
bundle.
--files: this flag can be used to show all files that are part of a
given bundle.

All flags can be combined to show specific data.

This is the first of a series of PRs to implement the bundle-info
features referred to at #461.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-10-04 08:42:55 -07:00
Otavio Pontes de3860ea31 testlib: Fix format of the +10 version
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-10-02 12:49:03 -07:00
Castulo Martinez 265983e622 Test: Adding debug messages for some common functs
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-09-16 15:22:08 -07:00
Castulo Martinez dd8e693ad1 Test: Fix a bug in global_teardown call
There was an error in the logic of testlib which was causing the
global_teardown to not be executed when tests were being run with bats
like this "bats <directory>/".
Let's say you have 2 test files with 2 tests each file, if the tests are
run like this "bats my_dir/test1.bats; bats my_dir/test2.bats" (this is
the way make check runs the tests), then the tests are going to be
numbered by bats as 1,2,1,2, and the current logic worked fine. But if
you run the same tests using "bats my_dir/", then the tests are going to be
numbered 1,2,3,4. This difference in the numbering of tests was causing
issues with the library. This commit fixes the issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-09-16 15:22:08 -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
Castulo Martinez 0f463da668 Test: Add --force flag to destroy_test_environment
Sometimes we want to keep a test environment after the test has finished
running so we can see the state directory and target_dir, this is useful
to troubleshoot failing tests. This was being controlled via an
environment variable but it was not always working properly.

This commit des two things:
- Changes the environment variable used to save a test environment from
DEBUG_TEST to KEEP_ENV, that way both env variables can be used
separatelly, the first one to printo more debug info and the second one
to save the test environment.
- Fixes an issue with the tests by adding a --force flag to force the
deletion of the environment even when the environment variable is set.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-09-16 15:22:08 -07:00
Castulo Martinez ed1a4ead65 Test: Add debug messages to testlib
Sometimes it is difficult to figure out why a test starts failing,
so having a lot more messages printed during the test makes it easier.

This commit adds a function to print messages only when the environment
variable DEBUG_TEST is set to true, this way we can print a lot more
information from the functions in testlib without polluting the output
of a test in a normal run.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-09-16 15:22:08 -07:00
Otavio Pontes 69cd7d9395 test: Support running tests in a different directory
All files that are written by tests should be written in the directory
where the tests were executed and not the directory where code is.

Make distcheck now works fine

Fixes #343

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-09-13 15:35:03 -07:00
Karthik Prabhu Vinod 9679835c40 Update: Perform sig check on latest file
Fixes #1051

Signed-off-by: Karthik Prabhu <karthik.prabhu.vinod@intel.com>
2019-09-11 15:25:32 -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 a41bea9fd5 Show the real latest version using check-update
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>
2019-08-14 14:31:33 -07:00
John Akre 30cb21260a testlib: Enable validate_item to check statedir
Sudo is needed to validate items in the statedir.

Signed-off-by: John Akre <john.w.akre@intel.com>
2019-08-07 14:12:34 -07:00
Castulo Martinez 5608930be5 Fixing a bug using ignore-ilst files in tests
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>
2019-08-02 14:17:19 -07:00
Castulo Martinez 2e3a584558 Removing --bundle flag from repair
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>
2019-07-29 15:20:56 -07:00