The current format is very useful information to get from bug reports
so add it as default output to swupd update.
Signed-off-by: William Douglas <william.douglas@intel.com>
When a bundle is removed, ensure the new orphans created are detected
by bundle-list and bundle-remove.
Signed-off-by: William Douglas <william.douglas@intel.com>
Includes needed dev packages and an ignore for error messages seen on
Ubuntu's version of curl but not in Clear Linux.
Signed-off-by: William Douglas <william.douglas@intel.com>
Allow users to update by stepping through each release between their
current version and the latest. This option is primarily for cases
where update is failing due to memory or disk space running out when
updating normally.
Signed-off-by: William Douglas <william.douglas@intel.com>
Enable an alternative swupd certificate location (the location of the
default or given cert with an ".alt" appended to it). The purpose of
this change is to allow more reliable and flexible key rotations.
If either the main cert or alt cert fails when doing content
verification then the other will be tried (and be used for the next
operation). In this way, as long as both certs don't fail for the same
content verification, progress can be made with either cert.
Signed-off-by: William Douglas <william.douglas@intel.com>
This test creates an alternate swupd root certificate. If one already
exists, back it up, and restore it when the test is done. Previously,
this test just blindly deleted the certificate if it existed.
Previously, these messages were printed to STDOUT:
Overriding version and content URLs with...
Overriding content URL with...
Overriding version URL with...
But especially with --quiet, the output to STDOUT should be strictly the
requested data. So print these as warnings instead.
systemctl reports that the timer file is missing now as a return code
4 so update the unknown start number.
Also with this change SWUPD_NO is no longer always returned so add a
new helper to check if a status is one of multiple options.
Signed-off-by: William Douglas <william.douglas@intel.com>
Currently sys_rm_recursive was used in any instance of deleting swupd
content from the system (update, repair and bundle-remove). This can
cause user data loss when unkown files are in directories that swupd
is deleting.
To prevent this, this patch changes how deleting content in swupd
operates. Swupd content removal is now done with sys_rm and the return
value is checked in case the removal failed due to a directory that
still had files in it. When this specific failure occurs, the
directory is added to a new list for reprocessing removals as it is
expected once the rest of the deletes on the system occur the failures
will go away as the directories will be empty (these deletes are
processed in alphabetical reverse order so leaf directories are
processed first). If the removal fails again it is presumed the
contents of the directory are not files swupd knows about and as such
should be kept somewhere else.
For handling the retention of user data, directories (with only the
content unknown to swupd) are renamed (currently using a
.deleted.$timestamp. prefix of the old name) and stored at the same
directory level they were previously found with one exception. The
exception is for nested deleted content best illustrated with an
example:
/swupd-dir1/user-file1
/swupd-dir1/swupd-dir2/user-file2
When swupd tries to remove the /swupd-dir1 content, it will store the
user files as follows:
/.deleted.$timestamp1.swupd-dir1/user-file1
/.deleted.$timestamp1.swupd-dir1/.deleted.$timestamp1.swupd-dir2/user-file2
To demarcate what was part of swupd content vs user content.
Signed-off-by: William Douglas <william.douglas@intel.com>
The disk space check was trying to match exact number of download
attempt messages which was not working consistently.
Move to simply detecting the failure messages once.
Signed-off-by: William Douglas <william.douglas@intel.com>
Also skips a few tests that do not run well with docker (changing date
and disk filling have a hard time). Adding comment for how to run
docker (needs the --cap-add LINUX_IMMUTABLE option passed).
Signed-off-by: William Douglas <william.douglas@intel.com>
There are some problems with how we are using multiplexed curl causing
huge slowdowns (2-5 times slower).
For now rather than rework the multiplexed curl code, switch to using
the synchronous code path.
Signed-off-by: William Douglas <william.douglas@intel.com>
The order of files in this test aren't very completely stable so make
do with looking at output chunks that seem to be reasonably consistent
across different environments.
Signed-off-by: William Douglas <william.douglas@intel.com>
Detect docker container usage when running test to handle cases where
systemd is unlikely to be running.
Signed-off-by: William Douglas <william.douglas@intel.com>
Instead of relying on a custom global_setup and global_teardown
functions, migrate to the use of bats' setup_file and teardown_file
functions.
Signed-off-by: William Douglas <william.douglas@intel.com>
Correctly quote arrays.
Also improve some commands getting the array content (fixes space
issues with quoting).
Signed-off-by: William Douglas <william.douglas@intel.com>
Shellcheck changed its detection for a few file sourcing errors from
1090 to 1091. Update the disables accordingly.
Signed-off-by: William Douglas <william.douglas@intel.com>
Mirror tests specifically invoke the URL override options that trigger
the new text output I've added, so the tests' expected output needs to
be updated to match.
There is something going wrong with installing the generated pemfile.
The file is created but not yet valid, this is not a problem for
local testing for some reason. To work around this issue, use a static
pemfile that is already valid and force install it.
Signed-off-by: William Douglas <william.r.douglas@gmail.com>
As these are CI only tests, the container image currently appears to
have the service masked so stop trying to modify it.
Signed-off-by: William Douglas <william.douglas@intel.com>
The exact size difference changed for some reason but shouldn't cause
the tests to fail as it isn't the point of this test.
Signed-off-by: William Douglas <william.douglas@intel.com>
The test requires an exact size reporting, fix the size but consider
using a regex match instead.
Signed-off-by: William Douglas <william.douglas@intel.com>
The setup() function is run at the beginning of each test by the BATS
system, we leverage this function to implement a global_setup() and a
test_setup().
This commit refactors the function to make it easier to understand, also
makes sure it loads the environment variables correctly for tests.
Variables are available just after being exported, however variables are
not kept between tests since the process that orchestrate the tests of a
test file is a parent process and child processes cannot set variables
of a parent process. This is problematic because we were loosing some
variables (like all third party variables) when running multiple tests
using a global_setup().
This commit fixes the issue by making all the environment variables
available to all tests in a test file regardless of if they use
test_setup() o global_setup().
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Unfortunatelly not all environment variables can be set in the same
place, since some values may depend on a specific function being run
before. However it is important to have easy to lacte places where env
variables are being set.
This commit adds a few more setter functions for envrionment variables
so they are easily identified.
Closes#1489
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Some env variables in testlib can be exported when the file is sourced,
but some other have to be exported only after the test environment has
been created because they depend on it and in values gotten from it.
However testlib should try to set env variables in as little places as
possible.
This commit moves the definition of variables that can be defined in
set_env_variables() to consolidate them there if possible.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Environment variables are used everywhere in testilb. This environment
variables are global variables that define the way testlib behaves.
However is was confusing to use the variables because they were
inconsistent between each other, for example some variables that define
paths would have absolute paths while other would have relative paths,
making it error prone while using them.
This commit makes the environment variables more consistent by following
a name convention for each type of variable, as an example, variables
that define absolute paths follow this convention ABS_<path_name>_DIR,
while variables that define relative paths are defined like this
<path_name>_DIR.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Global constants in testlib are just exported variables, so they should
be in all upper case so we know they were defined globally.
Closes#1484
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When the path provided by a user for the --statedir (or --cachedir)
contains a symlink swupd will fail to extrar tar files since
libarchive does not support extracting files through symlinks.
This commit fixes the issue allowing users to use symlinks in the
--statediri/--cachedir path.
Closes#1581
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
After sourcing testlib, if the user runs testlib from the terminal,
the help of the library is displayed which includes the list of
commands provided by the library.
Testlib uses some environment variables to modify the way tests are
run. This commit adds information about those env variables to the
testlib help.
Closes#1479
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
When checking the output of the "clean --dry-run" command in the test,
we expect the output to be shown in a specific order, but the order can
change depending on the system since readdir doesn't warranty a specific
order when reading the content of a directory.
This commit fixes the test by only checking for the files we are
intereseted in, and it checks them with separate assertions to make sure
we don't have false positives due to the order.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
"Swupd clean" removes cache from certain pre-defined directories. This
commit udpdates the locations where clean looks for cache so it includes
the new locations where the cache is stored.
Swupd will continue looking at old cache locations until the bump to
format 31.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Currently there is only one location, known as "statedir", where swupd
stores data and cache. Normally it make sense to keep the data in a
path that is relative to the path prefix of the target system, since the
data is specific to that system, but cache can be independent of the
system, and that way it can be reused for other target systems if
desired.
This commit splits the cache and data into two different locations.
It also stores the cache in a path that is dependent of the mirror url
being used by swupd. The commit also makes all references to files in
the cache or data directories through getter functions thus removing the
hardcoded reference to the file's location, making it easier to move the
location in the future if needed. Lastly, this commit changes the read
permissions for the data directory and the manifest directories in the
cache to be user readable.
Bash autocomplete scripts should be POSIX compliant, so fixing that and
adding a test to validate this.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
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>
Print a more useful error when we fail to locate a file to apply a
delta. Add a suggestion for the user to run `swupd repair` and make
it clear that the problem is in their system and not in the update
content.
Fixes#1425
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
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>