456 Commits
Author SHA1 Message Date
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
Otavio Pontes bd24a844c1 Hash: Don't use the heap for a local struct 2018-06-05 09:37:46 -07:00
root 8984007cc4 search: Add --nosigcheck
Fixes #454

Added the -n/--nosigcheck paramater to search, based on the other subcommands that
already have nosigcheck.

I tested this by invalidating Swupd_Root.pem and testing the failing
and passing cases - without nosigcheck and with nosigcheck
respectively.

Signed-off-by: Brian J Lovin <brian.j.lovin@intel.com>
2018-06-05 09:36:15 -07:00
Murilo Belluzzo 1448ca456c Remove all commented code from the code base
We use a full feature version control system (git) for a reason.

'non-production' code can be kept on each one favorite personal branch
and debug code, if key for development, should be implemented as
working/tested part of the project (via a well designed logging system)
and not as commented code.

Not to mention that this is be a best pratice which we should all watch
over.

Signed-off-by: Murilo Belluzzo <murilo.belluzzo@intel.com>
2018-06-01 12:17:45 -07:00
Otavio Pontes 74756a13c1 Update: Fix memory leak on subscription list
If current_subs was cloned free the list structure. Free the list
and subscription data otherwise.

Fixes issue #363
2018-05-31 11:40:40 -07:00
Matthew Johnson 5b06fac117 mixer integration: check for file collisions after new build
Fixes #446
When a new upstream version is detected the new local mixer build must
be done before manifest uniqueness is checked. This is due to the fact
that os-core can change in the upstream version, so it has to be
re-built locally against the upstream content in order to avoid false
positives for file colisions.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-05-23 14:35:50 -07:00
Matthew Johnson 28224c2103 mixer integration: add more state files to ingore list
These additional files are files that change on the system due to the
local mix. Add these to the ignore list for file colision checks.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-05-23 14:35:50 -07:00
Icarus Sparry 6d452a824d Fix findstatic warnings
Fixes #448

Make a number of functions static, and bodge around the extra symbol
that gcc adds (__gnu_lto_v1) when compiling with -flto=4

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2018-05-22 15:08:38 -07:00
Matthew Johnson 85fee9aa51 Update mixer integration to use latest features
Update mixer integration to key off the .valid-mix flag file to check if
a mix exists. Also update the .clearversion filename to upstreamurl (it
has changed in upstream).

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-05-15 11:35:18 -07:00
Matthew Johnson 7b2e76239e Move copyright_header to main.c
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-05-14 12:52:34 -07:00
Matthew Johnson 01f771d362 Remove copyright header messages
swupd-client is properly open-sourced and licensed. The copyright header
is unnecessary, confusing, and causes issues for scripts parsing output.
The copyright header is now only printed when swupd is passed the
--version flag.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-05-14 11:05:33 -07:00
Brett T. Warden 541acddecd Tidy up /etc/swupd creation
Set /etc/swupd permissions to 0777 to let the default umask policy
handle stripping bits appropriately.
If we can write files to /etc/swupd, do it, making the directory first,
if necessary. If not, bail out cleanly. Only delete the
mirror_contenturl and mirror_versionurl files from the directory, not
the directory itself.
Add tests to verify normal behavior and corner cases.
2018-05-09 16:51:23 -07:00
Brett T. Warden c264c23f61 Set mirror override path perm to 0755
When /etc/swupd is created to hold mirror URL override files, set the
permissions to 0755.
2018-05-08 16:45:14 -07:00
Matthew Johnson b513c07c20 Move path_prefix NULL check to mk_full_filename
Deduplicate all the path_prefix == NULL checks into the mk_full_filename
function.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-04-30 14:54:23 -07:00
Matthew Johnson 9a1ee05855 Remove useless status fprintf
The user does not need to know that swupd is trying to determine the
server version. This is printed twice when doing mirror checks.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-04-30 14:54:23 -07:00
Matthew Johnson b32a4c2f61 Handle stale mirrors
Handle updates against configured mirrors by warning or unsetting
out-of-date mirrors. If a mirror is only slightly out of date warn the
user that the mirror is stale but continue normal operations. If a
mirror is out of date by a large range (arbitrary difference of 500, or
about a month and a half) simply unset the mirror and continue using the
upstream url.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-04-30 14:54:23 -07:00
Matthew Johnson 978ff026ea Provide CLI to set and unset mirror URL
The mirror subcommand provides users with an interface to use to set or
unset their configured mirror URL.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-04-30 14:25:57 -07:00
Matthew Johnson efca683d10 Add mirror configuration for contenturl/versionurl
To allow swupd users located in geos far from the default Clear Linux
CDN to get efficient download speeds, allow them to set a mirror content
and version url under

/etc/swupd/mirror_contenturl
/etc/swupd/mirror_versionurl

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-04-30 14:25:57 -07:00
Matthew Johnson 15e66263bf Return meaningful errors for SSL Cert failures
Add a specific printf and separate failure code to indicate SSL cert
failures. This return code (24) will be returned to telemetry as well to
indicate this specific failure.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2018-04-30 11:10:21 -07:00