488 Commits
Author SHA1 Message Date
Matthew Johnson 4d4acf4af6 Release 3.12.3
This release makes several bug fixes and minor improvements.

Bug fixes
- File rename bug fixed, swupd-client can now handle the simplest case
  of renames where the file name changes but the content does not.
- Several compiler warning fixes.
- A fix for doc build failure for separate src and build dirs.
- Travis CI dependency update.
- Progress meter will always fully reach 100%.
- Progress meter flushes to stdout during redirected output.

Improvements
- Add progress updates for --verify.
- Support IPv6 in downloads.
- Support mixing of http and file URLs for content and version URLs.
- Add CApath fallback support.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
v3.12.3
2017-10-02 13:49:41 -07:00
Matthew Johnson e22c597023 Code style fixes
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-10-02 13:43:05 -07:00
Icarus Sparry c35e559651 Fix renames of files without changes
Fixes #272

The create_update_list function was not adding a file onto its return
list if it was part of a rename that didn't change the contents. This
was due to a short circuit which failed to check if the flags
associated with a file (is_file, is_deleted etc) were the same.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-10-02 13:13:27 -07:00
Icarus Sparry 58e2a5c527 Test for rename
This test renames foo to bar with no changes to contents, and baz to
bat with minimal changes.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-10-02 13:13:27 -07:00
Icarus Sparry 52c0ad20df Additional swupdlib.bash functionality
Allow chown_root and revert_chown_root to take multiple parameters, in
particular they can now take -R to do a recursive chown.

New functions clean_web_dir, clean_state_dir and clean_target_dir to
clean things up (clean_test_dir is now an alias for
clean_state_dir).

New function set_os_release to set the value in target_dir

New function unpack_target_from_manifest. This takes two parameters
release and name. It reads the manifest, locates the files from the
web-dir/$release/staged directory and copies them into target-dir, and
also creates the directories. Helpful in creating initial versions of
target-dir. Should be expanded to do deletion.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-10-02 13:13:27 -07:00
Arzhan Kinzhalin feadea96b6 Implement fallback CApath support.
A colon-separated list of alternative CApath options can be passed to
swupd-client at the configuration time using --with-fallback-capaths
option.

In runtime, fallback CApath support is implemented as part of the
connectivity check. The implementation will try the default (built into
curl) and then will iterate through the list in the order they were
specified. It is done only once on the first call.

The code is reorganized to keep the connectivity check inside curl
wrapper:

* Deleted check_network implementation from version.c
* Removed have_network global (globals.c)
* Scoped swupd_curl_test_resume to curl.c
* Change use of check_network to swupd_curl_check_network

Also:

* Fixed an issue where SSL was only enabled if a URL was matching the
  content URL
2017-10-02 11:30:48 -07:00
Icarus Sparry 653415b89e Portability for Makefile
Fixes #300

Do not use GNU Make 'dir' function, instead use shell dirname command.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-10-02 11:12:40 -07:00
Patrick Ohly e562379004 downloads: support mixing http and file URLs
swupd used to enforce that version and content URL had to use the same
protocol because then it only needed to check once whether it was
downloading locally.

However, it's not that much more difficult to check each individual
URL, so now that's what swupd does now and thus the restriction is
gone.

Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
2017-09-28 15:03:31 -07:00
Patrick McCarty 286435e9b0 Fix compiler warnings in search.c
The calls to strstr() and strcasestr() in file_search() from search.c
result in compiler warnings when -Wnonnull is specified, because GCC's
"nonnull" attribute applies to these functions.

The logic from the file_search() call sites prevent NULL pointers from
being passed to these functions, but to protect against future
refactoring introducing this bug, check that the appropriate pointers
are non-NULL before calling the string functions.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-09-28 13:18:11 -07:00
Patrick McCarty 7522e8d68b Support IPv6 in download code
Fixes #200

Because swupd-client uses libcurl, and my guess is that libcurl has
supported IPv6 for a long time, I don't see any reason to restrict
downloads to IPv4 only.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-09-28 12:34:49 -07:00
Matthew Johnson 7e18d507bd Update tests and error output for check_network usage
Fixing the compiler issue for check_network in check_update.c triggered
test failures. Fix the test failures and improve the error output for
when check_network() fails.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-28 11:27:01 -07:00
Matthew Johnson 1a2226340e Fix compiler warning in check_update.c
Fixes #263
The conditional checking for network connection always evaluated as true
since the check_network() function was not being called. Add the
parentheses to actually check for network.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-28 11:27:01 -07:00
Matthew Johnson 0efd3f1e3d Fix compiler warning in clr_bundle_rm.c
Fixes #264
The static keyword should be at the beginning of the line.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-28 11:27:01 -07:00
Icarus Sparry e8cfa5f0d4 compiler warnings in xattrs
Fixes #262

Define silly little function to get gcc to shut up about unused
parameters.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-09-28 11:26:39 -07:00
Icarus Sparry 60bf270626 Add progress updates for Verifying files
Fixes #276

Refactor fixing a single file into its own routine, then call it in a
loop with print_progress.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-09-28 11:21:58 -07:00
Krisztian Litkey d918dd7232 Fix (doc) build failure for separate src and build dirs.
Signed-off-by: Krisztian Litkey <krisztian.litkey@intel.com>
2017-09-28 11:18:45 -07:00
Icarus Sparry b303fbfeeb Flush dots in progress meter
The progress meter adds a dot for every 10 steps taken if the output
is not to a terminal, but the output is probably block buffered so
output only occurs every 40960 steps. Add a fflush to force it out
straight away.

Related to #256.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-09-28 08:59:49 -07:00
Icarus Sparry 0d29fb21da Fix progress meters
The denominator for the progress report is based on the length of the
linked list to be processed, and the numerator is the number of
elements processed. Most loops have short cut conditions, which invoke
continue, which don't therefore update the numerator, and so loops end
before the progress meter shows 100%. In particular the final file
might be skipped.

Update the numerator early in the loop, and add a final call to
print_progress to force showing 100% if it has not already been done.

Note this can force another dot to be output for the case where stdout
is not connected to a terminal.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-09-28 08:59:49 -07:00
Icarus Sparry 397d8758af Update fix-missing-file test to account for progress dots
Now we have dots (or percentages) when files are being downloaded
these can intermingle with the normal output if they are flushed.

Alter the fix-missing-file test to remove dots from the lines to be
compared, and alter the lines-checked to add in the lines which would
normally be ignored but no longer match due to the missing dots,
e.g. "Downloading packs."

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-09-28 08:59:49 -07:00
Matthew Johnson 591c08a2d5 Travis: Use github as upstream for check
Recent outages to sourceforge break Travis CI runs. Use the github
release instead and update to the latest version of libcheck (0.11.0).

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-27 11:11:54 -07:00
Icarus Sparry ff1628191d Fix for issue 260, make portability
Use = rather than := on the line. It is only an efficiency gain.

replace patsubst and filter with a new variable and standard
substitution.

Replace %-style pattern with suffix rule.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-09-25 14:11:02 -07:00
Icarus Sparry 682baab1f3 fix for issue 261, compiler warning
glibc marks system() as a function whose return value should not be
ignored, which is generally reasonable. In this case we do want to
ignore the return value. Just casting to void is not enough to stop
the gcc warning. So instead we use the value in an if statement with
an empty body, which we trust the optimizer to remove so there is no
run time penalty.

The alternative solution would be to use
    #pragma GCC diagnostic push
    #pragma GCC diagnostic ignored "-Wwarn_unused_result"
    system(log_cmd);
    #pragma GCC diagnostic pop
but that is rather gcc specific.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-09-25 14:05:32 -07:00
Matthew Johnson 0e49188c3f Release v3.12.2
This release improves error reporting for container use-cases.
* Adds systemctl check for autoupdate to correctly report that swupd is
  "Unable to determine autoupdate status" in a container.
* Adds a --no-boot-update flag to disable boot file updates particularly
  for use in a container when boot file management will fail.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
v3.12.2
2017-09-19 10:40:29 -07:00
Matthew Johnson ad556debec Clean up code style
New clang version...

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-15 10:55:02 -07:00
Matthew Johnson d0e18b8a69 Add functional tests for --no-boot-update flag
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-15 10:44:32 -07:00
Matthew Johnson c23dfb558c Add --no-boot-update flag for container usage
Since clr-boot-manager does not work in a container add the
--no-boot-update option to allow installation into a container to skip
the boot partition management. This also calls apply_heuristics when
running bundle-add, with the result of running CBM when necessary for
bundle-adds and skipping CBM when the --no-boot-update flag is
specified.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-15 10:44:32 -07:00
Matthew Johnson 2ba4127ad7 Add initial systemctl check for autoupdate
In a container systemctl does not work, and /usr/bin/systemctl fails as
expected with "Failed to connect to bus: No such file or directory."
Because of this, swupd autoupdate will not work either. However,
"systemctl is-enabled ..." will not fail, even though it should.

Add an additional check to make sure /usr/bin/systemctl is working
before checking if swupd-update.service is-enabled. Report that swupd
was "Unable to determine autoupdate status" if this check fails.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 18:13:01 -07:00
Matthew Johnson bbbabc72a0 Release v3.12.1
This release improves error messages for post update scripts when
systemd is not operable, such as in a container, adds a --force or
--picky requirement when verify --fixing to another version, and
performs hash checks on every file when adding a bundle.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
v3.12.1
2017-09-12 12:36:32 -07:00
Matthew Johnson 3fd547ec25 Clean up code style
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 11:50:17 -07:00
Matthew Johnson a2f9759e11 Add functional tests for verify version mismatch and override
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 11:48:44 -07:00
Matthew Johnson 5bc1a646bd Require -x or -Y when verifying to different version
When running verify --fix with -m specifying a different version than
the current OS version, require --picky to enforce management of files
under /usr or require --force as an override. Adding --picky can solve
issues such as issue #238 where fixing backward caused glibc library
confusion.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 11:48:44 -07:00
Matthew Johnson f9180d3f43 Fix several hash mismatches in bundleadd tests
Now that bundleadd verifies each file it downloads the incorrect hashes
cause test failures. Update these hashes to be correct.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 11:46:29 -07:00
Matthew Johnson 92fbc077be Improve error reporting for bundleadd hash check
Add a check for missing file so that bundleadd can fall back to the
verify_fix_path to attempt to re-download the file instead of failing
the hash check due to the hash being all 0s.

Improve error messages by reporting the filename instead of the hash in
the error.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-12 11:46:29 -07:00
Tudor Marcu 4f4820305f Do hash checks for bundle add
Hash check every file before adding it to the file system.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-09-12 11:46:29 -07:00
Matthew Johnson 3550331a2c Clean up code style
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-11 15:01:30 -07:00
Matthew Johnson 1a1e4c16f2 Print warning when systemd not operable
When running swupd in a container systemd is not operable and fails with
a "Failed to connect to bus" error. Instead of printing these errors
directly check if systemd is operable at all and print a warning if not,
then return early from the update_triggers.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-11 14:51:30 -07:00
Matthew Johnson c6295e7deb Add newline to informational print
Add newline so progress updates are printed correctly. Instead of this:

...10%File /file was not in a pack
...11%

Print a newline before the message:

...10%
File /file was not in a pack
...11%

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-08 08:57:15 -07:00
Matthew Johnson 89a47cde78 Release v3.12.0
This release adds the --deps and --has-dep subcommands to bundle-list to
print dependencies of a bundle and a tree of bundles that have the
specified bundle as a dependency, respectively. It also improves error
handling when checking that the state directory is owned by root.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
v3.12.0
2017-09-01 07:37:50 -07:00
Matthew Johnson 9635eabbe9 Update copyright header for 2017
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-09-01 07:30:26 -07:00
Icarus Sparry 5ea52968ea Test a statedir is removed directly
Don't use the return value from swupd_rm, which is poorly defined, but
test directly that the file no longer exists.

Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
2017-08-31 16:13:21 -07:00
Matthew Johnson ac7345318c Add functional tests for bundle-list --deps
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson da21ad7eef Add bundlelist --deps subcommand
Allow user to list all bundle dependencies of a bundle passed to

swupd bundle-list --deps BUNDLE

This lists all included bundles (included those recursively included)
for the BUNDLE. This is particularly useful when applications or users
need to determine just how large the bundle addition will be. For
example, a user may not be aware that by bundle-adding desktop-dev they
are recursively adding 12 other bundles. This command allows the user to
make this check before installation.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson c83c4ce78f Add functional tests for bundle-list --has-deps
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson ee06e85931 Add --has-dep argument to bundle list
The --has-dep=BUNDLE argument will display a tree representing all
installed bundles that recursively include BUNDLE.

One may pass the --all argument as well to list the dependency tree for
BUNDLE including all installable bundles available on the server.

**Example output without --all:**

Installed bundles that have os-installer as a dependency:
format:
 # * is-required-by
 #   |-- is-required-by
 # * is-also-required-by
 # ...

  * mixer
    |-- os-clr-on-clr

**Example output with --all:**

Attempting to download version string to memory
All installable and installed bundles that have os-installer as a dependency:
format:
 # * is-required-by
 #   |-- is-required-by
 # * is-also-required-by
 # ...

  * clr-devops
  * mixer
    |-- os-clr-on-clr
        |-- os-clr-on-clr-dev
    |-- clr-devops
    |-- os-clr-on-clr-dev

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson 6108f50bb9 Print bundle dependencies when failing to remove
A bundle will fail to be removed from the filesystem when other bundles
require that bundle as a dependency. Print a list of each of these
bundles along with the error message.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-08-31 09:50:50 -07:00
Matthew Johnson a201a0c417 Release v3.11.0
This release fixes several errant return codes, adds progress status for
long-running tasks, ensures the swupd state directory is created and is
owned by root at runtime, fixes --format arg validation, and enforces
format transitions for verify.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
v3.11.0
2017-08-30 16:52:59 -07:00
Patrick McCarty 485ab31f22 Add functional tests for verify format mismatch and override
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-08-30 11:12:50 -07:00
Patrick McCarty e6cdcf8aa1 verify: enforce format transitions
When using verify's -m option, it generally only makes sense to verify a
build within the same format, since the subsequent format (if any) might
not be compatible. Therefore, we should disallow verifying to a build
with a different format by default. This commit adds the proper
enforcement by making this condition a fatal error. The early exit can
be bypassed using the -x/--force option, which will print a warning
message instead.

For now, this compatibility check is targeting the use case of verifying
to a newer build, so I also report the latest supported build for the
current format. Verifying to an older build is not guaranteed to succeed
at present, and swupd-client does not yet understand the
version/formatN/first file. In other words, reporting to the user the
oldest build they can verify to will be a future improvement.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-08-30 11:12:50 -07:00
Patrick McCarty b682263c96 verify: remove misplaced tab in the help output
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-08-30 11:12:50 -07:00
Caio Marcelo de Oliveira Filho 4a6796c47f Don't accept trailing characters when validating numbers for --format
strtoull succeed when the leading characters of the input form a valid
number, so it is necessary to verify that there is no trailing
characters. Use the endptr parameter (that will point to the end of
the accepted input) to verify that.

Fixes #142.

Signed-off-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
2017-08-22 11:00:26 -07:00