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>
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>
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>
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>
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.
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
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
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
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.
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.
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>
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.
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)
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.
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>
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.
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"
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
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.
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.
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
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.
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.
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.
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.
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.