1146 Commits
Author SHA1 Message Date
Otavio Pontes 260f710da9 Release v3.19.0
This release adds enhancements, bug fixes and test improvements.

Enhancements:
 - Download manifest deltas when provided by the server to have smaller updates
 - Swupd can verify a list of bundles instead of verifying the full system
 - Improve error messages on swupd network connection errors
 - Return meaningful and consistent exit codes on swupd errors
 - Add configurable download retries (--max-retries and --retry-delay)
 - Add bytes transferred in telemetry reports and inform this to the user on updates
 - Start tracking manually installed bundles so we can use that info in the future

Bug Fixes:
 - Don't remove files under /usr/src on verify --fix --picky
 - Don't force bootloader execution if the bootloader binary isn't present
 - Don't follow relative symlinks when installing new files
 - Use timestamp from installed system when adjusting the system time

Tests
 - Add unit tests to functions hard to test using functional tests

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
v3.19.0
2019-02-14 10:05:45 -08:00
Otavio Pontes 17e8708bb4 Curl: Don't set curl fail on error when checking the connection
When we are checking if the SSL is working and the server is up we don't care
about the server return code. We just care if the server is responding. So
we shouldn't set the curl option CURLOPT_FAILONERROR.

The major problem of this change is that some servers don't respond to GET
in '/'. So checking the connection using the version url will fail in that
cases if CURLOPT_FAILONERROR is set.

As we don't really need the other options, reverting that change back to
how it was before.

Fixes #792

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-13 23:01:10 -08:00
Otavio Pontes 3a689186dc Update issue templates 2019-02-13 14:26:12 -08:00
Otavio Pontes 7c26d67699 staging: Another memory leak
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-13 13:45:58 -08:00
Otavio Pontes 9d3fdbfea7 curl: Rewrite that message again
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-13 13:38:58 -08:00
Otavio Pontes 7861ea501e curl: Getting even better on message if swupd fails to connect to server
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-13 12:58:24 -08:00
Otavio Pontes e54fb1e9ed Fix some code styles
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-13 12:56:34 -08:00
Otavio Pontes 00c3400c9c globals: Free string left behind 2019-02-13 12:25:19 -08:00
William Douglas ad8177bee6 staging: Ensure staging doesn't escape path_prefix
Prevent content from being installed under the path_prefix by
validating the realpath of target files when staging file content.
2019-02-13 12:24:18 -08:00
William Douglas 6da50ee5d7 Fix manually installed bundle tracking and add tests
Update bundle tracking to correctly initialize tracked bundle state
and add testing to validate tracking works as expected.
2019-02-13 12:23:28 -08:00
William Douglas 44adf33ca3 Clarify function purpose with rename
The is_tracked_bundle function doesn't not accurately portray its
purpose, rename to is_installed_bundle as it is actually looking at
the installed content directory.
2019-02-13 12:23:28 -08:00
Castulo Martinez 00d7c1b366 Adding path_prefix for versionstamp
When a user is using the -p/--path option with swupd he can point to a
chroot installation of clear or a custom mount. However when swupd
checks the system time to see if it is sane it compares it with a
versionstamp hardcoded in  /usr/share/clear/versionstamp, which causes
swupd to fail in systems using -p.

This commit prepends the path_prefix to the versionstamp path so it
points to the correct file if using the --path option.

Closes #812

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-13 12:21:19 -08:00
Otavio Pontes 284162665e fullfile: Reduce the number of parallel downloads
27 was a number to big for max transfers and it was slowing download down in
multiple scenarios. Reducing that number.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 16:02:05 -08:00
Otavio Pontes 3276d23c00 curl: Stop download in parallel as soon as we have download errors
If we are having problems to download in parallel the best alternative
is to stop downloading in parallel instead of trying to reduce the
number of parallel downloads, because retries are expensive.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 16:02:05 -08:00
Otavio Pontes 4f6064beff curl: Make messages consistent
Replace all usages of "Curl: " to "Curl - "

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 16:01:03 -08:00
Otavio Pontes b6422f89d1 curl: Improve error messages when using fallback SSL certificates
Instead of printing errors and warnings, just print debug information
when we are looking for the right ca path to use. If we couldn't
connect to the server, abort and print a clear error message.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 16:01:03 -08:00
Otavio Pontes c03b1bd521 test: Fix wrong test
Test verify-latest-missing.bats was not checking what it says it should test.
Fixing that removeing the latest file instead of removing the full webdir.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 16:01:03 -08:00
Otavio Pontes f8eef790f9 update: Print total bytes downloaded in MB
Fixes #271

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 15:32:34 -08:00
Otavio Pontes 53a0984da9 update: Use manifest-deltas in swupd on update
Before downloading full manifests try to use manifest deltas if available.
If deltas are missing, use full manifest.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 15:11:00 -08:00
Otavio Pontes 2f612ef711 sys: Add a helper function to check if a file exists
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 15:11:00 -08:00
Otavio Pontes e7d19dd888 curl: Check for errors before using value from curl_easy_getinfo call
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 15:07:25 -08:00
Otavio Pontes 71b334159a update: Be consistent in exit codes when trying to update to the same version
Use similar output and same exit code used when you are already in the
last version in the case where you are updating to the same version you
already are.

i.e. if you are in version 100, both commands are going to have the same
exit code:

 - swupd update
 - swupd update -m 100

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 14:38:58 -08:00
Otavio Pontes 0a51655abe Moving update specific function from version to update
This function is specific for update and it couldn't be used in any
other situation (mostly because of the output messages). So moving it
to update.c

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-12 14:38:58 -08:00
Castulo Martinez 2c885f28f3 Providing option to disable compiler optimizations
This commit adds an option to disable compiler optimizations which is
very useful when debugging a problem in swupd.

Note: the user would still need to make sure the optimization option is
not enabled in his/her CFLAGS variable.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-11 14:28:48 -08:00
Otavio Pontes c17c232f85 docs: Fix documentation on --force option
--force/-x is specific for verify command, but documentation was stating
that it was global. Removing all references from a global --force and
adding that information to the help page of verify command.

Also moves the force variable from global to verify.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-11 14:24:31 -08:00
Otavio Pontes 70200b3251 test: Fix tests broken by curl changes
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-11 12:32:40 -08:00
Otavio Pontes 093ac7630a travis: Use a newer curl to build swupd tests
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-02-11 12:32:40 -08:00
Auke Kok 29d8e122e2 Telemetry: include bytes transferred wherever applicable.
Display the bytes transferred after each update in the message
that shows "took N seconds" by appending the info.

This includes total transfer bytes for verify, update, check,
bundle-add and bundle-remove.

The curl error handling function is the perfect location to
capture the bytes for each transfer, and add them to a global
counter. The global counter is then included in each telemetry
event.
2019-02-11 12:32:40 -08:00
Castulo Martinez 880191fd1b Return non-0 code if search does not find entries
swupd search returns 0 both when something is found and when nothing
is found.

This commit makes a change so it returns 0 (SWUPD_OK) if search found
somthing and 1 (SWUPD_NO) if it didn't.

Closes #731

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-05 13:03:25 -08:00
Castulo Martinez 0f63bfe858 Replacing switch for ifs in retry_download_loop
To reduce code duplication, this commit replaces the switch within the
retry_download_loop function with if statements.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-01 12:30:45 -08:00
Castulo Martinez cf8f81ccb4 Test for configurable download retries
This commit adds the tests to validate the configurable retries
for sync downloads.

It also moves the tests for autocompletion from their own "completion"
directory to a more general "usability" directory so we can add more
tests in that directory in the future.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-01 12:30:45 -08:00
Castulo Martinez b135d49deb Testlib: option to force a response in web server
Sometimes is useful for some tests to be able to force an http code that
corresponds to a filure when using the test web server, that way we can
simulate network problems very easily.

This commit adds an option for forcing the web server to return a
specified http code.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-01 12:30:45 -08:00
Castulo Martinez 0721ddfdba Adding configurable download retries
This commit adds two new options:

-r, --max-retries: maximum number of retries for download failures
-d, --retry-delay: initial delay between download retries

With these two is possible to increase the number of retries in case the
user is in a non reliable network, or to turn off retries intirely (by
setting --max-retries to 0). The --retry-delay will also allow more
flexibility for unreliable connections, and will make testing easier
since the --retry-delat can also be set to 0.

Closes #322

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-01 12:30:45 -08:00
Castulo Martinez 49907d4a60 Consistent timeouts for sync and async downloads
Curl is using a different max retry value for async and sync downloads,
also is using a different variable for the delay between retries.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-01 12:30:45 -08:00
Castulo Martinez e28c24a50a Refactoring retry code for fullfiles
The retry code in swupd is not an ideal implementation, making it
difficult to use throughout the code base. Some parts retry
differently based on needing to support retries for network errors,
or retry based on IO errors.

This commit refactors this code into a consistent implementation so
the retry code is not spread across the code base.

Closes #211

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-02-01 12:30:45 -08:00
Otavio Pontes 8648e83c33 test: Add first swupd unit test
Adding a unit test for string functions on string.h module.
Unit tests will help us to test functions that are hard to test
with function tests. String conversions, for example would be extremely
hard to test using functional tests.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-01-31 10:55:17 -08:00
Otavio Pontes 3eebc10b73 strings: Move str to int conversion functions to strings module
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-01-31 10:55:17 -08:00
Castulo Martinez 6b49ca562b Checking if the boot script exist before running
When swupd needs to run a boot script it does so without checking if the
file exists in the system or not. This will cause an error to be raised
by the shell if the script does not exist.

This commit adds a check for the existance of the script before
attempting to run it.

Closes #795

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-31 10:03:41 -08:00
Otavio Pontes 90834ae18f docs: Remove generated manpages from repository
Those files are generate that in build time, so there's no reason to keep
them here.
We went out of sync before and it's easier to make sure the last man page is
used if we generate that on build time.

Also removes man page tests because they don't make sense anymore. And add
option --disable-manpage, so we can build swupd without manpages if rst2man.py
isn't available.

Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
2019-01-28 17:27:24 -08:00
Castulo Martinez 03ee2623b4 Reorganizing codes to match old values
This commit reorganize the codes in the swupd_code enum so the codes
that were already defined before are still the same. This commit also
renames some of those codes so they are more consistent with the rest of
the codes in the enum.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez 97187ac439 Adding guidelines for exit codes to the guide
The guide in how_to_contribute.md specify a set og rules to follow to be
a contributor of the swupd client project.

This commit adds the guidelines for using return/exit codes in functions
within the swupd source code.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez 8f7f0b15ee Using swupd_code as return code of main functions
All exit codes that get propagated to the end user should be defined in
the swupd_exit_codes.h file. This commit changes the type of data
returned by those functions which the user interacts with so instead of
returning an int we return a swupd_code. This way it'll be easier to
identify what functions only return a documented code. If a function
returns an integer value not in swupd_exit_code.h then it should use int
instead.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez a723c0bc4a verify should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for verify.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez 1aed824085 update should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for update.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez 84046e107f mirror should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for mirror.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez ff18daa680 clean should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for clean.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez bfdebbaf3e search should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for search.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez 49a1928849 chek-update should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for check-update.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez b653c6308d hashdump should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for hashdump.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00
Castulo Martinez acdc0e0d74 bundle-list should return consistent exit codes
Regardless of what codes are used internally, swupd should always
exit with a code defined in swupd_exit_codes.h.

This commit makes those changes for bundle-list.

Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
2019-01-24 15:23:15 -08:00