474 Commits
Author SHA1 Message Date
Brian J Lovin a77cbee6da Add free space check before adding bundles
Prevoiusly, when running bundle-add there was no check in
place to verify free storage before attempting to add the
new bundle.

Added this check, a warning message, and a flag to ignore
the message if desired.

related to issue #266

V2: Fixed many issues issues from review.
V3: Removed recursive size function, removed extra files,
    reverted search.c.
V4: Forgot to run 'git compliant', did so and added the
    changes.

Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com>
2018-06-29 08:23:52 -07:00
Matthew Johnson eef2a4f5f8 clean: separate into callable function and use in update
Separate the main statedir clean functionality into a callable function
and call it after performing an update. This helps clean up unused
files that bloat the state directory on a regular basis and helps
prevent the state directory from getting into a weird state over
updates.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-18 16:09:42 -07:00
Matthew Johnson 5f39d1e86e manpages: add return-code documentation
Additionally remove the unused EPREP_MOUNT error code.
Fixes #296

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-18 10:50:40 -07:00
Matthew Johnson ec4f9e40cc delta: improve delta failure message
When delta application failed due to swupd being unable to calculate the
hash of the from file or a hash-mismatch against what was expected print
an error message that indicates there is a corrupted file.

Fixes #469

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-18 09:15:00 -07:00
Matthew Johnson e4c636a200 verify: Ignore mix state when fixing to version
When the version the user is fixing to is different from the version
they are on disable checks for mixer state on the system. This allows
users on local mixes to easily migrate back to the upstream update
stream. It also means users are not able to fix to another version
within their own mix.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-15 16:32:10 -07:00
Matthew Johnson eec6e4a9a0 Fix up code style
Style issue identified via 'make compliant'

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-14 15:11:55 -07:00
Otavio Pontes 38b9272caa manifest: Fix memory leak - Manifest data was not freed on errors 2018-06-14 15:01:23 -07:00
Otavio Pontes 23697b6bb8 search: Fix memory leak - lists and data were not freed 2018-06-14 15:01:23 -07:00
Otavio Pontes 18835bb09d bundle: Fix memory leak - data from list was not freed 2018-06-14 15:01:23 -07:00
Otavio Pontes 6d0523d9e5 Fix string memory leaks
Fixing some string memory leaks on:
 - bundle
 - helpers
 - manifest
 - packs
 - verify
2018-06-14 15:01:23 -07:00
Otavio Pontes 8b63972c89 globals: Fix integer overflow error and memory leak
In systems where sizeof(long long int) > sizeof(int) we could have an
integer overflow in the function get_version_from_path().

Also fixing a memory leak of variable ret_str.
2018-06-14 15:01:23 -07:00
Otavio Pontes c0229ef92d manifest: Removing unecessary check
alloc_manifest() aborts when manifest allocation fails, so the result
will never be NULL
2018-06-14 15:01:23 -07:00
Otavio Pontes 93f24604de bundle-add: Use download resume on bundle-add too
There's no reason to support pack resume on bundle-add
2018-06-14 13:04:31 -07:00
Otavio Pontes 9dce69bd09 curl: Check if resume is supported only when needed
Instead of checking if server supports resume for every execution
that uses the network, do it only when resume is going to be used

Fixes one of the problems cited on #432
2018-06-14 13:04:31 -07:00
Otavio Pontes 15d86581bb download: Resume was corrupting the downloaded file
When resuming a download, we need to open the file to append data.
Previous code was opening it using write mode and all data already
dowloaded was lost and the final file was corrupted
2018-06-14 13:04:31 -07:00
Castulo Martinez 81d616b605 Be consistent in bundle-add/remove error messages
The operations have different command result output styles. Also,
in particular bundle-remove error is a bit redundant.

This commit changes the messages displayed by the bundle-add and
bundle-remove functions so they have consistent messages for their
corresponding operations.

Fixes #475
2018-06-13 14:47:36 -07:00
Castulo Martinez f98a578fb2 Fixes an issue attempting to add multiple bundles
There is a bug that causes the install operation to abort when
trying to install multiple bundles and at least one is invalid.

This commit fixes the issue so if other bundles are valid they
get installed.
2018-06-13 14:47:36 -07:00
Otavio Pontes d5e8f1300c bundle-list: Let any user to run swupd bundle-list
As /usr/share/clear/bundles has read permissions for everyone, we can
let regular users to run "swupd bundle-list". If a path_prefix is
informed and the user don't have access to it, it will fail printing
an error message.
2018-06-13 09:23:46 -07:00
Matthew Johnson 8bdb4e6c0a Add brackets around single-line if
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-12 13:28:02 -07:00
Matthew Johnson f0a50295b7 bundle-add: bump fullfile minimum to 10
Local testing with some small bundles shows that bumping the fullfile
download minimum to 10 still yields much faster results than downloading
the zero pack. 10 is a more realistic heuristic.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-12 13:28:02 -07:00
Matthew Johnson 556813ee7a Fix code style
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-12 13:28:02 -07:00
Arjan van de Ven 07ab12302f fix relative path 2018-06-12 13:28:02 -07:00
Arjan van de Ven 6b8397dee3 Optimize bundle-add by not reading all manifests for the common case
for error recovery, bundle-add needs to read all currently installed manifests
and consolidate them into the normal tree.

currently, bundle-add does this always, even for the common case of no errors.

this patch turns this around and does this work lazily once the first
error is encountered.
2018-06-12 13:28:02 -07:00
Arjan van de Ven 1bab2b2748 Allow do_staging() to be called with a NULL MoM
There are some cases where do_staging() is ok to be called without
having a full MoM for performance reasons (e.g. in bundle_add
where alternative recovery is in place)
2018-06-12 13:28:02 -07:00
Arjan van de Ven c93aea46e0 Optimize bundle-add to only install files that don't yet exist
With overlapping bundle-content, it's not entirely uncommon for files
that are in a newly added bundle to already exist on the system.

This patch optimizes this case by removing these from the files that need
to be installed.

In addition, if after this filter step, there's less than 5
(number to be tuned) files to install left, skip downloading the pack
for the bundle and just grab the full files directly.
2018-06-12 13:28:02 -07:00
Otavio Pontes 2f444dc7f6 fullfile: Fix double free
String that is reused later shoudn't be freed.

Fix double free reported on issue #480
2018-06-12 11:29:57 -07:00
Matthew Johnson 9790937402 Add os-core index to mixin state
Mixin re-creates the os-core bundle when creating a local mix. This
causes the corresponding os-core-update-index bundle-info file to have
changes to the metadata listed inside. Treate this as mixin state and do
not check hashes for this file.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-12 11:29:35 -07:00
Castulo Martinez e388674a94 Renaming variable for consistency
Renaming a variable from camel case to snake case to keep
consistency with the project.
2018-06-08 10:49:21 -07:00
Castulo Martinez 1dc830fa57 Store the bundle to be removed in a variable
In order to avoid the need to dereference *bundles all the time
another variable was added.
The check about making sure the bundle to be removed is not os-core
was moved before the message "Removing bundle: <bundle>" to avoid
confusions.
2018-06-08 10:49:21 -07:00
Castulo Martinez 006e29b565 Removing unnecessary curopts struct
The curopts struct is no longer being used to save parsed options
when using the bundle-remove command so it can be removed from the
code.
2018-06-08 10:49:21 -07:00
Castulo Martinez f49fb714fe Fixing typo in remove bundle message
When 1 or more bundles fail to be removed from the system a message
was being displayed, a message that looked like this:
"1 bundle(s) of 2 failed to remove"

This commit changes that message so it uses pasive voice, like this:
"1 bundle(s) of 2 failed to be removed"
2018-06-08 10:49:21 -07:00
Castulo Martinez 71a2a4cb0e Refactor bundle-remove to handle multiple bundles
The current remove_bundle() function was designed to only be called
once, but for multiple bundle removals, it is currently called
multiple times.

This commit refactors this function so the bundle removal code can
handle multiple bundles at once.

Fixes #449
2018-06-08 10:49:21 -07:00
Otavio Pontes b0911b3f0a Verify --install: Download full files if pack download fails
Use fullfile_download to download full files from server if a pack
download has failed or if the file is missing/corrupted in a pack.

Verify --install wasn't checking if the content of the downloaded
files match the hash in the manifest. As the fullfile download
function check that, the hashes in some tests needed to be fixed.
2018-06-08 10:43:09 -07:00
Otavio Pontes c7c224de47 Bundle-add: Download full files if pack download fails or has problems
Use fullfile_download to download full files from server if a pack
download has failed or if the file is missing/corrupted in a pack.
2018-06-08 10:43:09 -07:00
Otavio Pontes 9648035803 Update: Use consolidated version of fullfiles download
Use download_fullfiles() instead of reimplementing it on
full_download_loop().

Tests:
 - Test skip-verified-fullfiles was alterered because in the current
implementation start_full_download() won't be called when there's no
extra file to download.
2018-06-08 10:43:09 -07:00
Otavio Pontes 660537d36f Verify: Consolidate download fullfile fallback to be reused
Moving the fullfile fallback to a single file and exporting it in
swupd.h in order to be reused on update and bundle add.

Tests:
 - Changing verify tests becase download function won't be called when
 there's no file to be downloaded
2018-06-08 10:43:09 -07:00
Otavio Pontes 6a51b2e451 Verify: Remove file hash comparison from download function
Checking for hashes inside the download function was out of scope
and made the function harder to be reused. Instead, check if hashes
matches the files in the system before calling the download function,
so only necessary files will be downloaded.
2018-06-08 10:43:09 -07:00
Caio Marcelo de Oliveira Filho c773afc6e6 clean: do not keep content around
Instead of keeping recent content around, just delete all the files,
with exception of the latest relevant Manifests.
2018-06-08 10:37:15 -07:00
Otavio Pontes 2284ebb6f4 Fix missing brackets on single line ifs 2018-06-08 10:21:52 -07:00
Otavio Pontes 4096b123d8 curl: Make the swupd_curl_get_file easier to use
In most cases the parameters in_memory_file, bool resume_ok are ignored
in swupd_curl_get_file. So creating a swupd_curl_get_file_full with all
parameters and leaving the swupd_curl_get_file clearer.
2018-06-06 11:47:01 -07:00
Otavio Pontes 2f0a9810e0 curl: Don't use the heap for a local struct 2018-06-06 11:47:01 -07:00
Otavio Pontes c491c6d058 curl: Removing unused parameter 2018-06-06 11:47:01 -07:00
Otavio Pontes 887716ad56 curl: Reduce coupling of curl module by removing information about version
Curl module doesn't need to have any information on what is the content of
the file it's going to download. And there's no reason to force users to
use memory to store a file only for version numbers. If there's another
small file needed in the future, we can use the memory to hold it.

Also fixes:
 - Memory allocated for version string was too big. Using maximum number of
   chars to store an integer for it.
 - As the size to store a version string is small, uses the stack instead of
   the heap for it.
 - On swupd_curl_test_resume, don't alocate memory and copy data to it
   to be discarded later.
2018-06-06 11:47:01 -07:00
Otavio Pontes 5d30df9daf curl: Remove unused code
req_version and curr_version in curl.c weren't used anywhere. Probably
this is a left over. Removing them.
2018-06-06 11:47:01 -07:00
Otavio Pontes 372fc39781 curl: Rename function to match the same pattern as swupd_deinit 2018-06-06 11:47:01 -07:00
Otavio Pontes dada319498 Remove #warnings from code. Use TODO instead
All #warnings messages on swupd code were related to tasks to be performed
in the future and not real code warnings. Using the TODO comment, that is
already used for other tasks.

It's too annoying to see warning messages on compile time and having them
makes a bit harder to noticed when we are introducing real compiler warnings.
2018-06-05 16:38:37 -07:00
Otavio Pontes 10064b823f Update: Change log order to have a clearer output
Message informing that the system was successfully updated should be
the last message. Having a message that looks like an error as the
last message in an update can be confusing for users.
2018-06-05 11:29:45 -07:00
Caio Marcelo de Oliveira Filho 07c9eb7c74 Report when a pack is missing using telemetry
Fixes #450.
2018-06-05 11:23:09 -07:00
Matthew Johnson 83208d4906 Code style fix
Result of 'make complaint'

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-06-05 09:42:52 -07:00
Otavio Pontes 3001e66d49 Downloads: Fixing typo 2018-06-05 09:37:46 -07:00