mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-10-03 23:38:25 +00:00
Allow adding bundle dependency in newer versions
With the current test library a user can create a test bundle and then add a dependency to that bundle by adding it to the bundle's manifest. However this only worked if there was only one version available in the web-server. A second issue was that after modifying the manifest the hash in the MoM would need to be updated. This commit allow users to create a version N, create a bundle for version N, then create a version N+M and add a dependency to that bundle in that new version N+M. It also recalculate all hashes in the MoM so users writing tests don't need to remember to update them themselves. Finally this commit includes some updates for some tests that use the add_dependency_to_manifest function since they don't need to update hashes in the MoM as a separate step any more.
This commit is contained in:
committed by
Matthew Johnson
parent
fe196094ec
commit
dfe878d159
@@ -9,8 +9,6 @@ test_setup() {
|
||||
create_bundle -n test-bundle2 -f /bar/test-file2 "$TEST_NAME"
|
||||
# add test-bundle2 as a dependency of test-bundle1
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle2
|
||||
# since we modified one manifest we need to update that in MoM too, so re add the bundle manifest
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ test_setup() {
|
||||
# add bundle2 and 3 as dependencies of bundle1
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle2
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle3
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ test_setup() {
|
||||
# add bundle2 as dependencies of bundle1 and bundle 3 as dependency of bundle2
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle1 test-bundle2
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle3
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ test_setup() {
|
||||
# add bundle1 as dependencies of bundle2 and bundle 2 as dependency of bundle3
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ test_setup() {
|
||||
# add bundle1 as dependencies of bundle2 and bundle 2 as dependency of bundle3
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ test_setup() {
|
||||
# add bundle1 as dependencies of bundle2 and bundle 2 as dependency of bundle3
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ test_setup() {
|
||||
# add dependencies
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle3 test-bundle2
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,6 @@ test_setup() {
|
||||
create_bundle -L -n test-bundle2 -f /bar/test-file2 "$TEST_NAME"
|
||||
# add test-bundle1 as dependency of test-bundle2
|
||||
add_dependency_to_manifest "$TEST_NAME"/web-dir/10/Manifest.test-bundle2 test-bundle1
|
||||
update_hashes_in_mom "$TEST_NAME"/web-dir/10/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -450,7 +450,8 @@ add_dependency_to_manifest() {
|
||||
local dependency=$2
|
||||
local path
|
||||
local manifest_name
|
||||
local bundle_name
|
||||
local version
|
||||
local pre_version
|
||||
# If no parameters are received show usage
|
||||
if [ $# -eq 0 ]; then
|
||||
cat <<-EOM
|
||||
@@ -460,14 +461,31 @@ add_dependency_to_manifest() {
|
||||
return
|
||||
fi
|
||||
validate_item "$manifest"
|
||||
path=$(dirname "$manifest")
|
||||
manifest_name=$(basename "$manifest")
|
||||
bundle_name=${manifest_name#Manifest.}
|
||||
validate_param "$dependency"
|
||||
|
||||
path=$(dirname "$(dirname "$manifest")")
|
||||
version=$(basename "$(dirname "$manifest")")
|
||||
manifest_name=$(basename "$manifest")
|
||||
|
||||
# if the provided manifest does not exist in the current version, it means
|
||||
# we need to copy it from a previous version.
|
||||
# this could happen for example if a manifest is created in one version (e.g. 10),
|
||||
# but the dependency should be added in a different, future version (e.g. 20)
|
||||
if [ ! -e "$path"/"$version"/"$manifest_name" ]; then
|
||||
pre_version="$version"
|
||||
while [ "$pre_version" -gt 0 ] && [ ! -e "$path"/"$pre_version"/"$manifest_name" ]; do
|
||||
pre_version=$(awk '/previous/ { print $2 }' "$path"/"$pre_version"/Manifest.MoM)
|
||||
done
|
||||
sudo cp "$path"/"$pre_version"/"$manifest_name" "$path"/"$version"/"$manifest_name"
|
||||
sudo sed -i "s/version:.*/version:\\t$version/" "$manifest"
|
||||
sudo sed -i "s/previous:.*/previous:\\t$pre_version/" "$manifest"
|
||||
fi
|
||||
sudo sed -i "s/timestamp:.*/timestamp:\\t$(date +"%s")/" "$manifest"
|
||||
sudo sed -i "/contentsize:.*/a includes:\\t$dependency" "$manifest"
|
||||
# If a manifest tar already exists for that manifest, renew the manifest tar
|
||||
sudo rm -f "$manifest".tar
|
||||
create_tar "$manifest"
|
||||
update_hashes_in_mom "$path"/"$version"/Manifest.MoM
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user