mirror of
https://github.com/clearlinux/swupd-server.git
synced 2026-10-04 07:58:32 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a46cb6a9d | ||
|
|
15c045de8d | ||
|
|
22823ec8c8 | ||
|
|
c69a5d87bf | ||
|
|
b103c214a0 |
@@ -114,9 +114,11 @@ dist_check_SCRIPTS = \
|
||||
test/functional/full-run/test.bats \
|
||||
test/functional/fullfiles/test.bats \
|
||||
test/functional/include-version-bump/test.bats \
|
||||
test/functional/includes-deduplicate/test.bats \
|
||||
test/functional/no-delta/test.bats \
|
||||
test/functional/pack/test.bats \
|
||||
test/functional/state-file/test.bats \
|
||||
test/functional/subtract-delete/test.bats \
|
||||
test/functional/update/test.bats
|
||||
endif
|
||||
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
# Process this file with autoconf to produce a configure script.
|
||||
|
||||
AC_PREREQ([2.66])
|
||||
AC_INIT(swupd-server, 3.3.3, tudor.marcu@intel.com)
|
||||
AC_INIT(swupd-server, 3.3.5, tudor.marcu@intel.com)
|
||||
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
|
||||
AM_SILENT_RULES([yes])
|
||||
AC_PROG_CC
|
||||
|
||||
+17
-2
@@ -406,25 +406,40 @@ int main(int argc, char **argv)
|
||||
GList *name_includes;
|
||||
char *group = next_group();
|
||||
struct manifest *manifest;
|
||||
struct manifest *current = NULL;
|
||||
|
||||
if (!group) {
|
||||
break;
|
||||
}
|
||||
manifest = g_hash_table_lookup(new_manifests, group);
|
||||
name_includes = manifest->includes;
|
||||
|
||||
while (name_includes) {
|
||||
char *name = name_includes->data;
|
||||
name_includes = g_list_next(name_includes);
|
||||
manifest_includes = g_list_prepend(manifest_includes, g_hash_table_lookup(new_manifests, name));
|
||||
|
||||
current = g_hash_table_lookup(new_manifests, name);
|
||||
|
||||
// Avoid adding duplicate includes to the list
|
||||
if (g_list_find(manifest_includes, current) == NULL) {
|
||||
manifest_includes = g_list_prepend(manifest_includes, current);
|
||||
}
|
||||
}
|
||||
manifest->includes = manifest_includes;
|
||||
manifest_includes = NULL;
|
||||
manifest = g_hash_table_lookup(old_manifests, group);
|
||||
name_includes = manifest->includes;
|
||||
|
||||
while (name_includes) {
|
||||
char *name = name_includes->data;
|
||||
name_includes = g_list_next(name_includes);
|
||||
manifest_includes = g_list_prepend(manifest_includes, g_hash_table_lookup(old_manifests, name));
|
||||
|
||||
current = g_hash_table_lookup(old_manifests, name);
|
||||
|
||||
// Avoid adding duplicate includes to the list
|
||||
if (g_list_find(manifest_includes, current) == NULL) {
|
||||
manifest_includes = g_list_prepend(manifest_includes, current);
|
||||
}
|
||||
}
|
||||
manifest->includes = manifest_includes;
|
||||
}
|
||||
|
||||
@@ -582,6 +582,16 @@ void subtract_manifests(struct manifest *m1, struct manifest *m2)
|
||||
list1 = g_list_next(list1);
|
||||
list2 = g_list_next(list2);
|
||||
|
||||
/* When both files are marked deleted, skip
|
||||
* subtraction. Preserving the deleted entries in both
|
||||
* manifests is required for 'swupd update' to know
|
||||
* when to delete the file, because the m2 bundle may
|
||||
* be installed with or without the m1 bundle.
|
||||
*/
|
||||
if (file1->is_deleted && file2->is_deleted) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (file1->is_deleted == file2->is_deleted && file1->is_file == file2->is_file) {
|
||||
m1->files = g_list_delete_link(m1->files, todel);
|
||||
m1->count--;
|
||||
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# common functions
|
||||
load "../swupdlib"
|
||||
|
||||
setup() {
|
||||
clean_test_dir
|
||||
init_test_dir
|
||||
|
||||
init_server_ini
|
||||
set_latest_ver 0
|
||||
init_groups_ini os-core test-bundle1 test-bundle2
|
||||
|
||||
set_os_release 10 os-core
|
||||
track_bundle 10 os-core
|
||||
track_bundle 10 test-bundle1
|
||||
track_bundle 10 test-bundle2
|
||||
|
||||
set_os_release 20 os-core
|
||||
track_bundle 20 os-core
|
||||
track_bundle 20 test-bundle1
|
||||
track_bundle 20 test-bundle2
|
||||
|
||||
gen_file_plain 10 os-core test0
|
||||
gen_file_plain 10 test-bundle1 test1
|
||||
gen_file_plain 10 test-bundle2 test2
|
||||
|
||||
gen_includes_file test-bundle2 10 test-bundle1 test-bundle1
|
||||
gen_includes_file test-bundle2 20 test-bundle1 test-bundle1
|
||||
}
|
||||
|
||||
@test "deduplicate bundle includes" {
|
||||
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||
set_latest_ver 10
|
||||
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
|
||||
|
||||
# includes list should be deduplicated in both the old and new manifests
|
||||
[[ 1 -eq $(grep '^includes: test-bundle1$' $DIR/www/10/Manifest.test-bundle2 | wc -l) ]]
|
||||
[[ 1 -eq $(grep '^includes: test-bundle1$' $DIR/www/20/Manifest.test-bundle2 | wc -l) ]]
|
||||
}
|
||||
|
||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||
Executable
+56
@@ -0,0 +1,56 @@
|
||||
#!/usr/bin/env bats
|
||||
|
||||
# common functions
|
||||
load "../swupdlib"
|
||||
|
||||
setup() {
|
||||
clean_test_dir
|
||||
init_test_dir
|
||||
|
||||
init_server_ini
|
||||
set_latest_ver 0
|
||||
init_groups_ini os-core test-bundle
|
||||
|
||||
# start with both bundles containing a file "foo"
|
||||
set_os_release 10 os-core
|
||||
track_bundle 10 os-core
|
||||
track_bundle 10 test-bundle
|
||||
gen_file_plain 10 os-core foo
|
||||
gen_file_plain 10 test-bundle foo
|
||||
|
||||
# delete "foo" from os-core (the included bundle)
|
||||
set_os_release 20 os-core
|
||||
track_bundle 20 os-core
|
||||
track_bundle 20 test-bundle
|
||||
gen_file_plain 20 test-bundle foo
|
||||
|
||||
# delete "foo" from test-bundle
|
||||
set_os_release 30 os-core
|
||||
track_bundle 30 os-core
|
||||
track_bundle 30 test-bundle
|
||||
|
||||
# make modification (add new file) to test-bundle
|
||||
set_os_release 40 os-core
|
||||
track_bundle 40 os-core
|
||||
track_bundle 40 test-bundle
|
||||
gen_file_plain 40 test-bundle foobar
|
||||
}
|
||||
|
||||
@test "no subtraction for two deleted files" {
|
||||
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
|
||||
set_latest_ver 10
|
||||
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
|
||||
set_latest_ver 20
|
||||
sudo $CREATE_UPDATE --osversion 30 --statedir $DIR --format 3
|
||||
set_latest_ver 30
|
||||
sudo $CREATE_UPDATE --osversion 40 --statedir $DIR --format 3
|
||||
set_latest_ver 40
|
||||
|
||||
# If the file is absent in test-bundle, this means it was subtracted. If
|
||||
# present, subtraction was not performed.
|
||||
hash1=$(hash_for 40 test-bundle "/foo")
|
||||
[ -n "$hash1" ]
|
||||
}
|
||||
|
||||
|
||||
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
|
||||
Reference in New Issue
Block a user