Commit Graph
1366 Commits
Author SHA1 Message Date
William Douglas bf5e1f1297 Fix missing header
Header file ordering hid a missing list structure definition.

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas dbeb3662a4 Apply changes from clang-format
Running:
clang-format -i -style=file src/*.[ch] src/lib/*.[ch] \
src/3rd_party/*.[ch] src/cmds/*.[ch] src/swupd_lib/*.[ch] \
src/verifytime/*.[ch]

with clang v15

Signed-off-by: William Douglas <william.douglas@intel.com>
2023-02-17 12:58:05 -08:00
William Douglas 7e00e0a20b Switch off of string n functions
These functions lead to spurious errors and warnings for our use
cases.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-07 12:51:05 -07:00
William Douglas b6a4aff5b7 Remove deprecated function use
Since OpenSSL 1.1.0 this function is no longer needed.

Signed-off-by: William Douglas <william.douglas@intel.com>
2022-10-07 12:51:05 -07:00
Arjan van de Ven 4774daf00d allow for non-versioned delta files 2022-10-07 12:51:05 -07:00
Brett T. Warden 39515d2fc0 Announce overrides of content and version URLs
When using -v, -c, or -u to set alternate version or content URLs, print
out a message so it's more obvious.
2022-10-05 11:08:47 -07:00
Castulo Martinez 04dfaa1db7 Allow paths that contain symlinks for cachedir
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>
2020-06-15 15:24:34 -07:00
Castulo Martinez 68b4eee984 Adding flags to set data and cache in swupd
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>
2020-06-08 12:10:39 -07:00
Castulo Martinez 40472f5a21 Updating "clean" to remove new and old cache dirs
"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>
2020-06-08 12:10:39 -07:00
Castulo Martinez 8d54e6c995 Separating the cache from the data used by swupd
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.
2020-06-08 12:10:39 -07:00
Otavio Pontes 91173f50b2 heuristics: Use a sorted list algorithm to apply heuristic rules
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>
2020-05-29 14:42:54 -07:00
Otavio Pontes 99823e0d66 sys: Use a list for get_mounted_directories()
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>
2020-05-29 14:42:54 -07:00
Otavio Pontes a9301c660a heuristics: Create heuristics rules
Instead of using multiple ifs, create heuristics rules to be applied
to each file.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-29 14:42:54 -07:00
Otavio Pontes 8d40ad38bd heuristics: Remove function with unused result
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>
2020-05-29 14:42:54 -07:00
Castulo Martinez e3326a4e34 Removing dead code in clean.c
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-21 14:31:20 -07:00
Otavio Pontes 721aae6358 clean: Clean manifests in deprecated location
Manifest directory has moved and we need to clean manifests in previous location.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-19 13:47:37 -07:00
Castulo Martinez 9d995c1ad5 Move manifest deltas to the manifest dir in state
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-15 11:47:33 -07:00
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 c83391321c Revert "Move manifest deltas to the manifest dir in state"
This reverts commit 845b74f95b.
2020-05-15 08:18:45 -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
Otavio Pontes 24ecf6c913 delta: Improve message on delta errors
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>
2020-05-14 13:41:59 -07:00
Castulo Martinez 845b74f95b Move manifest deltas to the manifest dir in state
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 11:03:51 -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 e473385084 Bug_Fix: Only update templates if repos exist
Closes #1566

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-14 10:49:45 -07:00
Otavio Pontes 062cab09cf curl: Remove '*' character in error output
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-14 09:26:12 -07:00
Castulo Martinez 9958f9c4ce Moving some remaining functions to statedir.c
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>
2020-05-14 08:27:24 -07:00
Otavio Pontes 7263b2d774 verify: Don't apply heuristic to os-install
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>
2020-05-13 08:24:37 -07:00
Castulo Martinez 66d002d0ce Repairig amemory leak in delta.c
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-13 08:24:24 -07:00
Otavio Pontes 260fed75d5 thread_pool: Number of threads can be zero
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>
2020-05-13 08:24:06 -07:00
Castulo Martinez e552a95645 Add function to remove the content of a directory
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>
2020-05-12 14:21:11 -07:00
Castulo Martinez cf263bbd07 Move function to set the path to the statedir
Moving the function to the appropriate statedir module.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 62bb6bd8a0 Function to get the version from statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 8ba1812c6f Function to get the delta pack from statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 251c2cb68f Functions to get the manifests directory and delta
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez 74ec454110 Function to get the path to the swupd_lock file
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Castulo Martinez a3a1ad1d3d Function to get telemetry record from statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 14:21:11 -07:00
Otavio Pontes 043351ab09 Fix integer to float conversion errors
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes e1fd274599 Fixing multiple unsigned to signed int conversion errors
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 235ea872a8 strings: Use correct variable type for str_len return
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 2a7f181e00 int: Fix some integer conversion errors when using malloc
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 9fd1632ef0 int: Add functions to safely convert signed ints to unsigned
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes 5f67a46354 string: Add function to convert from string to unsigned ints
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:27:06 -07:00
Otavio Pontes fb43852440 motd: Remove motd code that was not being used
check-update was trying to create a motd in a deprecated directory and
it was always failing.

Removing code for now.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:26:16 -07:00
Otavio Pontes 7f5c1b6ab3 log: Adding missing '\n' at the end of log messages
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2020-05-12 12:26:09 -07:00
Castulo Martinez 14bbc2c44d Add functions to get manifest from the statedir
Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 10:15:51 -07:00
Castulo Martinez eee1585f64 Add functions to get fullfile tars from statedir
This commit adds these function:
- statedir_get_delta_dir: to get the "download" directory
- tatedir_get_fullfile_tar: to get thet downloaded fullfile tar
- statedir_get_fullfile_renamed_tar: to get the renamed fullfile during
  untarring

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 10:15:51 -07:00
Castulo Martinez 9844f2a1d0 Add function to get delta dir from statedir
This commit adds the following function:
- statedir_get_delta_dir()

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 10:15:51 -07:00
Castulo Martinez 858965f52e Move function to create state dirs to statedir mod
This commit moves the function to create the state directories to the
statedir module.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 09:05:26 -07:00
Castulo Martinez 39bfd77831 Add function to get staging files from statedir
This commit adds the following functions:
- statedir_get_staged_dir()
- statedir_get_staged_file()

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 09:05:26 -07:00
Castulo Martinez ca2601efc7 Consolidate functions to track bundles
Currently we have two functions to track bundles, bundles should always
be tracked in the same location, if there is an exception to this rule
then it should be handled separately.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2020-05-12 09:05:26 -07:00