207 Commits
Author SHA1 Message Date
Castulo Martinez 8e4c017365 Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-15 11:47:33 -07:00
Otavio Pontes d5d3c599d2 Revert "Moving downloaded manifests to their own directory"
This reverts commit 336fee7a9d.
2020-05-15 08:18:37 -07:00
Castulo Martinez 336fee7a9d Moving downloaded manifests to their own directory
When swupd downloads manifests to the statedir they are downloaded in
directories that represent the version of clear that the manifests
belong to. However those version directories are stored in the statedir,
root directory. This commit moves them into their own "manifest"
directory so there is more consistency with the downloaded files.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 11:03:51 -07:00
Castulo Martinez 86ef6bfde5 Testlib: Fixing functions that use a test ID
Instead of relying on all tests of the same group to exist in the same
directory, testlib should assume those tests could be scattered across
multiple directories.

Closes #1485

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-01 13:02:21 -07:00
Otavio Pontes d2c053cdb3 test: Create test to validate if we can repair files that have type change
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 12:26:29 -07:00
Otavio Pontes ce0943982a shellcheck: Error SC2119 doesn't apply to our use cases
Ignoring error SC2119 because they are false positives and I don't see cases
where that would return anything useful for us.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-30 08:50:48 -07:00
Castulo Martinez e57b9e6948 Testlib: adding help with description for all funcs
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 10:56:39 -07:00
Castulo Martinez 8a6eb85efe Testlib: function to print help menus of commands
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-28 10:56:39 -07:00
Castulo Martinez 5e3164523d Testlib: function to add os-core-update to an env
For some tests is useful to have a minimal version of the os-core-update
bundle since some system files are tracked there.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-24 09:32:28 -07:00
Otavio Pontes 4a711d2821 test: Add test to install files with unusual characters
Make sure files with unsual characters are successfully installed. Most
characters used in test are filtered by mixer, but there's no reason to
not support them in swupd

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-17 15:20:10 -07:00
Otavio Pontes 669dfe09cf test: Preserve attributes on copy
When creating the fullfile and installing the bundle in targetfs we
need to preserve the owner and mode of file

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-16 13:52:29 -07:00
Otavio Pontes 9edb70023c 3rd-party: xdg env variable has a wrong name
XDG_CONFIG_DIRS variable was added with an incorrect name. XDG_CONF_DIRS was used instead.
Fixing that.

Fix #1443

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-16 13:25:04 -07:00
Castulo Martinez 7c5c6417d0 Testlib: fix bug regenerating hashes in MoM
When a MoM contains an experimental bundle and the hashes in the MoM are
regenerated, the experimental bundles are being skipped. This commit
fixes that issue.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-13 15:29:46 -07:00
Castulo Martinez 14ba906dd1 Testlib: including os-core in test bundles
When creating test bundles, we are not including os-core in them by
default. This is how it works in production so we should do it so it
resembles the real production environment more accurately.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-13 10:16:17 -07:00
Castulo Martinez addd14013b Testlib: fix help menu from function
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-10 16:01:11 -07:00
Castulo Martinez d677c42fce 3rd-party: Regenerate wrapper on template change
When the template used for creating the wrapper scripts changes, all
exported binaries should have the scripts regenerated during updates
regardless of if the binary changed.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-10 11:08:16 -07:00
Castulo Martinez 8d6f2f815e Testlib: enable scripts template in the test repos
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-10 11:08:16 -07:00
Castulo Martinez 830aa75895 Testlib: support update_bundle --header-only REPO
The update_bundle() function of testlib has many different options to
create updates for test bundles, all of those supported the creation of
the update in a 3rd-party repository except for the --header-only
option. This commit adds that support do --header-nly flag can also be
used for 3rd-party repos.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-10 11:08:16 -07:00
Castulo Martinez f3bb9765da API: output for autoupdate
This commit provides a minimal output to be displayed when the --quiet
flag is used for this command:
- swupd autoupdate

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-08 15:47:31 -07:00
Castulo Martinez b62aae3c8c API: output for [3rd-party] info
This commit provides a minimal output to be displayed when the --quiet
flag is used for these commands:
- swupd info
- swupd 3rd-party info

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-08 15:02:40 -07:00
Otavio Pontes eeb3d61fea testlib: Always remove test enviroment implicitly at the end of tests
Current implementation was only removing test enviroment for envs created
on test setup. And test_teardown function needed to be overriden in case
global_setup() was used.

Now always cleaning the enviroment for both use cases, test_setup() and
global_setup(). The user doesn't have the control anymore on that and
if the user wants to keep the env KEEP_ENV variable should be used.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-07 13:52:49 -07:00
Otavio Pontes b1e849327d testlib: never create test enviroment for the user
Test environment can be created on global_setup() or test_setup() and that
change the behavior of several operations on testlib.

Because of that, let the user create the test environment as desired instead
of forcing it on test_setup()

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-07 13:52:49 -07:00
Castulo Martinez 8d15b4dc56 Testlib: do not print the result of openssl
When generating the certificate for tests, openssl is printing messages
to the terminal, we are already selecting what to print by using the
debug_msg() function, so these unwanted messages shouldnot be printed.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-03 08:09:04 -07:00
Otavio Pontes 79d0c712aa testlib: Generate swupd certificates for each test to be execute
Instead of requiring an external script (.prereq) to generate the certificates
we can regenerate them before running each test.

Also removes completly the .prereq script

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-04-02 10:35:54 -07:00
Castulo Martinez 238e7d8fe4 Testlib: keep the current status on type change
When updating a bundle using testlib, if the file is updated, and the
update includes a file type change, testlib was updating the manifest
with the correct type but was overwriting the other status flags, so if
a file was marked as 'x' (exported) before, that flag was being removed.

This commit fixes the issue by only updating the flag that relates to
the file type.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-02 08:00:30 -07:00
Castulo Martinez 5ab3b8b9e9 Testlib: add function to print the test target fs
When running tests sometimes is useful to see how the filesystem of the
test target system looks like before and after a test. This commit adds
a function to show that chroot fs in a tree view, and it calls that
function in the setup and teardown of tests if DEBUG_TESTS is set.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 13:28:20 -07:00
Castulo Martinez 6f86afbfa3 Testlib: Func to update a bundle based on content
This commit provides a function that can be used to generate update
content based on the content from a directory specified by the user.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 13:28:20 -07:00
Castulo Martinez 57d544384b Testlib: Functions to get entries from manifest
This commit adds a function that retrieve the matching entry from a
manifest or all entries if no key is provided.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 13:28:20 -07:00
Castulo Martinez 9e3dd33247 Testlib: function to create a bundle from content
This commit adds a function to create a bundle based on the content form
a directory specified by the user.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 13:28:20 -07:00
Castulo Martinez a47d8bfa17 Testlib: small corrections in the library
This commit has a few small corrections in testlib:
 - it removes some code that was used for iterative manifests
 - it correct some help menus
 - favors the use of debug_msg over an if statement for filtering
   messages
 - do not follow links in the function that creates tars from
   fullfiles

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 13:28:20 -07:00
Castulo Martinez a55c0cdb2e Testlib: don't follow links adding to manifest
When a test is adding a symlink to a manifest, the file the link is
pointing to is also added to the manifest. This commit prevents the file
pointed by the link to be added, if the user wants to add this file they
can do it explicitely.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 13:28:20 -07:00
Castulo Martinez 8ed40ee2ce Testlib: support file type changes
This commit adds support for file type changes when using bundle_update,
so the correct type is added to the manifest.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-04-01 13:28:20 -07:00
Castulo Martinez c43d612894 Testlib: Fixing the absolute path of a mirror test
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-03-24 11:48:43 -07:00
Otavio Pontes 7eb63ae3ad test: Add tests to validate if a mirror is unset if latest signature is invalid
When trying to update if the mirror has an invalid signature file we should
try to use the default source url instead.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-23 14:51:58 -07:00
Otavio Pontes 233d4c7e9d Staging: Don't create hardlinks when installing symlinks
Alternative solution to solution proposed on #1318

Instead of trying to create a link just don't try to link symlinks.
Tested patch using bsdtar and implemented automated testing to
validate solution.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-03-19 12:52:34 -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
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