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.
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.
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.
If content_url is local, do not attempt certain certain download
retries. I've focused on changing only the spots that caused 'make
check' to sleep as a first step. But I agree the retry logic needs
some extra care as posted in #221.
This patch reduces the time of running 'make check' in my system from
2m44s to 24s.
Consider all deltas from a pack instead of only those who are involved
in a rename. This will allow the server to make better packs
regardless of the from/to version, with the possibility of a delta to
a file that was not necessarily marked with the rename flag.
This makes deltapeer member of file unused, so it was removed. The
peer member continues to be used for its original role: mapping the
same files (same filename) between two manifests, usually the state of
the local system and some new version to be installed.
The test case added is like test/functional/update/rename, but without
the rename flags present. Since in that test there are some fullfiles
missing, it will only pass if swupd-client applies the deltas in the
pack.
Make swupd save a copy of the current MoM in a readable location, so
the completion code for bundle-add has access to it.
Stop generating the completion code, just use the file directly.
Remove the short option from the completion code, whilst they are
useful for an expert there is little point typing minus tab and then a
letter rather than minus and the letter.
Add crude filename completion for hashdump.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Create a test-bundle manifest with a stupid number of files, see that
it is rejected. Unfortunately because of retries this takes a long
time (70 seconds) time to run.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
The previous value - 13,805,671,819 is bogus, and we want to be able
to test if the value is reasonable.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Fixes#252Fixes#370Fixes#371
When failing to add bundle with a file with the wrong hash remove the
file and fall back to the verify_fix_path. Improve warnings so they
don't look like errors until they are actually errors.
Add tests so we don't regress in this regard.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Most of the functional tests properly reverted the chown operations in
teardown(), but three of them were missing the reverts.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
When output was changed to stderr for user output, this broke
automatic generation of the bash completion function.
Add suitable redirection to the generation script to capture stderr.
Add test to check the generated file looks reasonable.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>
Instead of relying on swupd-server to put the post-update action in the
correct manifest and in the correct format, do the format change
detection on the client.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
The target-dir is wiped every run, so putting the .gitignore in the
target-dir directory doesn't work.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Fixes#306
Because 'ignore-list' contains patterns that cannot match lines from
'lines-checked', they should also be absent from the diff output that
compares 'lines-checked' to 'lines-output'. Implement this by post
processing 'lines-output' to omit ignored lines.
This change improves error reporting when check_lines() finds mismatches
between 'lines-checked' and 'lines-output' for a particular test.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Since I changed check_lines() to propogate the matcher.awk exit status,
this test failed due to a missing 'lines-checked' file. Add the file to
fix that issue.
Also, remove the -x and -v options to the shell invocation, because more
lines of output are produced and that should not be checked.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Fixes#307
Previously to this change, lines-checked may have contained lines
matching patterns from the ignore-list, but matcher.awk does not expect
this situation and may result in difficult-to-diagnose test failures.
Instead, pre-validate lines-checked and if this validation fails, exit
with status code 2.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
If the test passes, BATS will not print the output anyway, so always
echoing $output (regardless of exit status) is better.
Also, make sure check_lines() returns the correct status.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
Because the next commit will be adding validation to ensure
lines-checked lines do not match ignore-list patterns, ignore-list must
be processed first.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
I will be reusing this logic, so moving it into a user-defined AWK
function will help with maintenance.
Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
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>
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>
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
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>
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>
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>
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>
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>
Since this step can take a while print a header to give an indication of
what the progress percentage is tracking. Update functional tests to
include new output.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
Add a progress indication for redirected output such as for logging,
testing, or third-party software such as ister.
For every 10 files or steps completed a dot (".") is printed to the
screen.
Adds a few more progress indications for silent loops.
Also adds leading newlines to some existing print statements so they are
printed on their own line.
Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
As the state_dir (normally /var/lib/swupd) contains things like the
downloaded bundles, it is important that there is no access to
non-root users who could potentially explot races to replace files
between them being checked and them being installed.
Ensure that the state_dir is root owned, and mode 0700, as well as the
critical directories below it.
Note that a proper fix would involve using chdir to move into the
directory and only use relative paths. This would prevent faulty
permissions higher up the directory tree being exploited. It *might*
be possible to use openat(2) to prevent this exploitation.
Add a test to ensure that the enforcement is taking place.
Signed-off-by: Icarus Sparry <icarus.w.sparry@intel.com>