mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-06 13:41:29 +00:00
bundle-add installs optional bundles by default
An optional bundle is not required to be installed in the system while included bundles are. Swupd will install optional bundles on bundle-add by default. Signed-off-by: Castulo Martinez <castulo.martinez@intel.com>
This commit is contained in:
committed by
Otavio Pontes
parent
afc27768bd
commit
9924bf7ee2
@@ -175,6 +175,7 @@ BATS = \
|
||||
test/functional/bundleadd/add-experimental.bats \
|
||||
test/functional/bundleadd/add-fall-back-to-fullfile.bats \
|
||||
test/functional/bundleadd/add-include.bats \
|
||||
test/functional/bundleadd/add-include-optional.bats \
|
||||
test/functional/bundleadd/add-install-time.bats \
|
||||
test/functional/bundleadd/add-json.bats \
|
||||
test/functional/bundleadd/add-multiple.bats \
|
||||
|
||||
@@ -728,6 +728,16 @@ int add_subscriptions(struct list *bundles, struct list **subs, struct manifest
|
||||
}
|
||||
ret |= r; /* merge in recursive call results */
|
||||
}
|
||||
|
||||
if (manifest->optional) {
|
||||
int r = add_subscriptions(manifest->optional, subs, mom, find_all, recursion + 1);
|
||||
if (r & add_sub_ERR) {
|
||||
free_manifest(manifest);
|
||||
goto out;
|
||||
}
|
||||
ret |= r; /* merge in recursive call results */
|
||||
}
|
||||
|
||||
free_manifest(manifest);
|
||||
|
||||
if (!find_all && is_installed_bundle(bundle)) {
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# Author: Castulo Martinez
|
||||
# Email: castulo.martinez@intel.com
|
||||
|
||||
load "../testlib"
|
||||
|
||||
test_setup() {
|
||||
|
||||
create_test_environment "$TEST_NAME"
|
||||
create_bundle -n test-bundle1 -f /foo/test-file1 "$TEST_NAME"
|
||||
create_bundle -n test-bundle2 -f /bar/test-file2 "$TEST_NAME"
|
||||
create_bundle -n test-bundle3 -f /baz/test-file3 "$TEST_NAME"
|
||||
# add test-bundle2 as a dependency of test-bundle1 and test-bundle3 as optional
|
||||
add_dependency_to_manifest "$WEBDIR"/10/Manifest.test-bundle1 test-bundle2
|
||||
add_dependency_to_manifest -o "$WEBDIR"/10/Manifest.test-bundle1 test-bundle3
|
||||
|
||||
}
|
||||
|
||||
@test "ADD051: Adding a bundle that includes an optional bundle" {
|
||||
|
||||
# An optional bundle is not required to be installed in the system while includes
|
||||
# are. Swupd will install optional bundles on bundle-add unless specified otherwise
|
||||
# by using the --skip--optional flag.
|
||||
|
||||
run sudo sh -c "$SWUPD bundle-add $SWUPD_OPTS test-bundle1"
|
||||
|
||||
assert_status_is 0
|
||||
expected_output=$(cat <<-EOM
|
||||
Starting download of remaining update content. This may take a while...
|
||||
Finishing download of update content...
|
||||
Installing bundle(s) files...
|
||||
Calling post-update helper scripts.
|
||||
Successfully installed 1 bundle
|
||||
EOM
|
||||
)
|
||||
assert_is_output "$expected_output"
|
||||
assert_file_exists "$TARGETDIR"/foo/test-file1
|
||||
assert_file_exists "$TARGETDIR"/bar/test-file2
|
||||
assert_file_exists "$TARGETDIR"/baz/test-file3
|
||||
|
||||
}
|
||||
@@ -868,7 +868,9 @@ add_to_manifest() { # swupd_function
|
||||
add_dependency_to_manifest() { # swupd_function
|
||||
|
||||
local partial=false
|
||||
local flag=includes
|
||||
[ "$1" = "-p" ] && { partial=true ; shift ; }
|
||||
[ "$1" = "-o" ] && { flag=optional ; shift ; }
|
||||
local manifest=$1
|
||||
local dependency=$2
|
||||
local path
|
||||
@@ -879,13 +881,18 @@ add_dependency_to_manifest() { # swupd_function
|
||||
if [ $# -eq 0 ]; then
|
||||
cat <<-EOM
|
||||
Usage:
|
||||
add_dependency_to_manifest <manifest> <dependency>
|
||||
add_dependency_to_manifest [-p] [-o] <manifest> <dependency>
|
||||
|
||||
Options:
|
||||
-p If set (partial), the dependency will be added to the manifest,
|
||||
but the manifest's tar won't be re-created, nor the hash in the
|
||||
MoM will be updated either. This is useful if more updates are
|
||||
to be done in the manifest to avoid extra processing
|
||||
-o If set (optional), the dependency will be added to the manifest
|
||||
as an optional dependency.
|
||||
|
||||
Note: if both options -p and -o are to be used, they must be specified in that order or
|
||||
one option will be ignored.
|
||||
EOM
|
||||
return
|
||||
fi
|
||||
@@ -910,7 +917,7 @@ add_dependency_to_manifest() { # swupd_function
|
||||
update_manifest -p "$manifest" previous "$pre_version"
|
||||
fi
|
||||
update_manifest -p "$manifest" timestamp "$(date +"%s")"
|
||||
sudo sed -i "/^contentsize:.*/a includes:\\t$dependency" "$manifest"
|
||||
sudo sed -i "/^contentsize:.*/a $flag:\\t$dependency" "$manifest"
|
||||
# If a manifest tar already exists for that manifest, renew the manifest tar
|
||||
# unless specified otherwise
|
||||
if [ "$partial" = false ]; then
|
||||
|
||||
Reference in New Issue
Block a user