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.
Set response explicitly in case of curl_easy_getinfo error (though in
practice the response isn't modified and so program behavior is the
same as before this change).
Signed-off-by: William Douglas <william.douglas@intel.com>
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>
Previous use of CURLINFO_CONTENT_LENGTH_DOWNLOAD is deprecated so
switch to the updated CURLINFO_CONTENT_LENGTH_DOWNLOAD_T API.
This change does not propagate the curl type used to the rest of
swupd-client but instead tries to use reasonable type casts for their
given purpose.
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 remove_files_in_manifest_from_fs function isn't used and was a
user of a rather dangerous recursive remove function. Get rid of it to
avoid potential confusion.
Signed-off-by: William Douglas <william.douglas@intel.com>
In cases where curl perform returns an error but is actually a 400
level response, swupd needs to check curl info to see this. If the
info reveals a 400 level response, return the corresponding download
status error to prevent useless download retries.
Signed-off-by: William Douglas <william.douglas@intel.com>
The error message about skipping unsupported file optimization levels
only needs to be printed once so do that instead of potentially
spamming it.
Signed-off-by: William Douglas <william.douglas@intel.com>
Add support for new APX optimization level. Change increases the
maximim potential optimization level but does not yet allow the files
to be used (installed). get_opt_level_mask still needs to be updated
to account for system supporting the new optimization level (and
adding APX_SKIP_FILE support) before the APX files can be installed.
This change is being done at this time to allow mixer to create these
files without swupd error messages during updates.
Signed-off-by: William Douglas <william.douglas@intel.com>
Allow the usage of non-SSE files from manifests. This involves testing
what the currently running system supports for optimized content and
installing the best matching available binary the manifest provides.
There is an exception for operations where the prefix is set to
something other than the rootfs where SSE binaries will be used in all
cases.
Signed-off-by: William Douglas <william.douglas@intel.com>
mixer-tools populates the optimized mask based on a matrix of values
where the mask includes both the optimization of the file on the line
but also the combined masks of all matching files.
This means a file mask needs to be translaed from the mask to what its
actual optimization level is and what other optimizations levels are
available to be useful. This change adds 2 new elements to the file
struct. The opt_level stores a files optimization level and
available_levels stores a bitwise or of the different optimization
levels that can be found in the file list for the same file.
For instance an AVX2_3 mask indicates the file is AVX2 with both SSE
and AVX512 files also available (SSE | AVX2 | AVX512 == 3).
Signed-off-by: William Douglas <william.douglas@intel.com>
In the case of the system default paths being set, potential errors
from state_set_*_path functions were being ignored. Handle errors and
exit accordingly.
Previously the directories were not attempted to be created in this
code path so there was no error handling needed but with the mkdir
addition, no longer handling this erro will cause segfaults later on
as the mkdir failure prevents the path setting further causing
uninitalized variables to be used.
Signed-off-by: William Douglas <william.douglas@intel.com>
Remove duplicate '9' in string for generating OPTIMIZED_BITMASKS array
and regenerate. This also requires an additional element is added to
the array to get to the 64 characters usable in the map.
Signed-off-by: William Douglas <william.douglas@intel.com>
The modifier field will be a character that translates roughly into a
base64 encoded bitmask. The first 3 bytes are the optimization level
and the last three are the max optimization level any files with that
same filename can have.
For now though skip all lines that don't match SSE_OPT (the previous
values the modifier field would have: 'b', 's' and 'C' all map to
the SSE_OPT bitmask).
Also rework the manifest unit tests a bit more. Noticed the exported
flag was wrong in the data and the X flag for the 3rd field was
completely unchecked for in swupd code. Added testing for the ignored
'b', 's' and 'C' values of the modifier field and checked the non-sse
is in fact skipped as a file for now.
Signed-off-by: William Douglas <william.douglas@intel.com>
The logic is testing a flag that mixer does not set and would like
to change the purpose of in a new version. Remove the test (needs a
format bump before mixer can use the flag) for the flag.
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>
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>
This commit provides the --datadir and --cachedir flags that can be used
to specify different locations for the data and cache. If the same
location is desired for both (default) then users can still use the
existing --statedir flag.
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.
Instead of comparing all rules to all files we can use the fact that the
file list is already sorted to compare only the elements that we need.
So if n is the number of files and m is the number of rules we moved from a
O(n*m) code to O(n+m).
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Instead of saving it in a global string, just use a list of strings to
return the current mounted directories. Also moving function to sys.c
Also fixes hashdump command to correctly print the warning if file is a
mounted directory.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Function is_under_mounted_directory() has a bug in the file comparsion function,
so it's returning always false. As this is broken and this doesn't look to be
needed, removing it.
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>
Some of these references to statedir where left in the code, this commit
moves them to the statedir.c module so references to content of the
statedir are not hardcoded. Files in the statedir can move to different
locations freely this way.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
Don't run heuristics for os-install or repair --quick.
On os-install we want all files to be always installed. On repair --quick
we don't process any do_not_update files
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Actually thread_pool supports zero threads, that means exactly running in
serial. So rolling back to what it was before the integer conversion fix of
commit 2a7f181e00.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
Instead of having a function to remove the contents of a specific
directory in the statedir this commit creates a generic function to
remove the contents of a directory without removing the directory
itself.
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>