Compare commits

...
5 Commits
Author SHA1 Message Date
Tudor Marcu f9ec967aa2 Release v3.5.0
This release removes a stale, unused script, adds a check to ensure format
number validity to ensure format numbers do not decrease, and enables adding
an actions: field in the Manifest.MoM to tell swupd-client to perform certain
actions post update.

Signed-off-by: Tudor Marcu <tudor.marcu@intel.com>
2017-07-28 23:54:30 -07:00
Matthew Johnson 925a5203f4 Add functional test for format bump actions field
Adds a functional test to check for the

actions:	update

line in the Manifest.MoM for the new format.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-07-28 23:13:21 -07:00
Matthew Johnson 31bb949b9b Add actions field to Manifest.MoM for format bumps
When a format bump occurs and the new format is greater than the old
format, an actions field is written to the Manifest.MoM containing the
string "update". This "update" action tells the client that it is
necessary to re-execute swupd update to bring the client to the latest
version within the new format.

Signed-off-by: Matthew Johnson <matthew.johnson@intel.com>
2017-07-28 23:13:21 -07:00
Patrick McCarty a0c7025a9b Add basic check for format number validity
Because the intention is for swupd format numbers to either remain the
same between LAST_VER and current, or to increase as part of a format
bump, this leaves the remaining undesirable case.

Add a basic check to make sure the format never decreases, and add a
functional test.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-07-24 15:00:39 -07:00
Patrick McCarty 06320f2862 Remove unused script
The packfsck.pl is unused, so we can safely remove it from the repo.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
2017-07-05 11:23:07 -07:00
9 changed files with 136 additions and 91 deletions
+3 -1
View File
@@ -110,6 +110,7 @@ dist_check_SCRIPTS = \
test/functional/basic/test.bats \ test/functional/basic/test.bats \
test/functional/delete-no-version-bump/test.bats \ test/functional/delete-no-version-bump/test.bats \
test/functional/file-name-blacklisted/test.bats \ test/functional/file-name-blacklisted/test.bats \
test/functional/format-no-decrement/test.bats \
test/functional/full-run-delta/test.bats \ test/functional/full-run-delta/test.bats \
test/functional/full-run/test.bats \ test/functional/full-run/test.bats \
test/functional/fullfiles/test.bats \ test/functional/fullfiles/test.bats \
@@ -119,7 +120,8 @@ dist_check_SCRIPTS = \
test/functional/pack/test.bats \ test/functional/pack/test.bats \
test/functional/state-file/test.bats \ test/functional/state-file/test.bats \
test/functional/subtract-delete/test.bats \ test/functional/subtract-delete/test.bats \
test/functional/update/test.bats test/functional/update/test.bats \
test/functional/format-bump/test.bats
if RENAMES if RENAMES
dist_check_SCRIPTS += \ dist_check_SCRIPTS += \
+1 -1
View File
@@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script. # Process this file with autoconf to produce a configure script.
AC_PREREQ([2.66]) AC_PREREQ([2.66])
AC_INIT(swupd-server, 3.4.0, tudor.marcu@intel.com) AC_INIT(swupd-server, 3.5.0, tudor.marcu@intel.com)
AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects]) AM_INIT_AUTOMAKE([foreign -Wall -W subdir-objects])
AM_SILENT_RULES([yes]) AM_SILENT_RULES([yes])
AC_PROG_CC AC_PROG_CC
+3 -1
View File
@@ -85,6 +85,8 @@ struct manifest {
GList *submanifests; /* as struct manifest */ GList *submanifests; /* as struct manifest */
GList *includes; /* struct manifests for all bundles included into this one */ GList *includes; /* struct manifests for all bundles included into this one */
GList *actions; /* post-update actions */
}; };
struct file; struct file;
@@ -184,7 +186,7 @@ extern GList *get_last_versions_list(int next_version, int max_versions);
extern char *file_type_to_string(struct file *file); extern char *file_type_to_string(struct file *file);
extern struct manifest *manifest_from_file(int version, char *module); extern struct manifest *manifest_from_file(int version, char *module);
extern void free_manifest(struct manifest *manifest); extern void free_manifest(struct manifest *manifest);
extern struct manifest *alloc_manifest(int version, char *module); extern struct manifest *alloc_manifest(int version, char *module, GList *actions);
extern int match_manifests(struct manifest *m1, struct manifest *m2); extern int match_manifests(struct manifest *m1, struct manifest *m2);
extern void sort_manifest_by_version(struct manifest *manifest); extern void sort_manifest_by_version(struct manifest *manifest);
extern bool manifest_includes(struct manifest *manifest, char *component); extern bool manifest_includes(struct manifest *manifest, char *component);
-82
View File
@@ -1,82 +0,0 @@
#!/usr/bin/perl -w
#
#
# arguments:
# perl packfsck.pl <target version>
my $target = $ARGV[0];
system("rm /tmp/Manifest");
system("wget --quiet --output-document=/tmp/Manifest https://download.clearlinux.org/update/$target/Manifest.os-core");
my $from = $target;
while ($from > $target - 100) {
$from = $from - 10;
print "Testing the $from-$target pack\n";
system("rm /tmp/pack.tar");
system("wget --quiet ---output-document=/tmp/pack.tar https://download.clearlinux.org/update/$target/pack-os-core-from-$from.tar");
open FILE, "</tmp/Manifest";
my %expected_hashes;
my %files;
while (<FILE>) {
my $line = $_;
if ($line =~ /(^[FDLr\.]+)\s*([0-9a-f]+)\s*([0-9]+)\s*+(.*)\n/) {
my $type = $1;
my $hash = $2;
my $version = $3;
my $filename = $4;
if ($version > $from) {
$expected_hashes{"$hash"} = 1;
$files{"$hash"} = $filename;
# print "$1 - $2 - $3 - $4\n";
}
}
}
close FILE;
open FILE2, "-|", "tar -tf /tmp/pack.tar 2> /dev/null";
while (<FILE2>) {
my $line = $_;
if ($line =~ /^\.\/delta\/[0-9]+.[0-9]+.([0-9a-f]+)/) {
my $hash = $1;
if (!defined($expected_hashes{"$hash"})) {
print "\tUnexpected delta hash found $hash\n";
}
$expected_hashes{"$hash"} = 2;
}
if ($line =~ /\.\/staged\/([0-9a-f]+)/) {
my $hash = $1;
if (!defined($expected_hashes{"$hash"})) {
print "\tUnexpected staged hash found $hash\n";
}
$expected_hashes{"$hash"} = 2;
}
}
close FILE2;
my $count = 0;
foreach my $key ( keys %expected_hashes )
{
my $value = $expected_hashes{$key};
if ($value eq 1) {
my $fn = $files{$key};
print "\tFile $fn ($key) is not in the pack\n";
$count = $count = 1;
}
}
if ($count < 1) {
print "\tThe $from-$target pack has no files missing\n";
}
}
+2 -2
View File
@@ -481,7 +481,7 @@ struct manifest *full_manifest_from_directory(int version)
LOG(NULL, "Computing hashes", "for %i/full", version); LOG(NULL, "Computing hashes", "for %i/full", version);
manifest = alloc_manifest(version, "full"); manifest = alloc_manifest(version, "full", NULL);
string_or_die(&dir, "%s/%i/full", image_dir, version); string_or_die(&dir, "%s/%i/full", image_dir, version);
@@ -557,7 +557,7 @@ struct manifest *sub_manifest_from_directory(char *component, int version)
LOG(NULL, "Creating component manifest", "for %i/%s", version, component); LOG(NULL, "Creating component manifest", "for %i/%s", version, component);
manifest = alloc_manifest(version, component); manifest = alloc_manifest(version, component, NULL);
string_or_die(&dir, "%s/%i/%s", image_dir, version, component); string_or_die(&dir, "%s/%i/%s", image_dir, version, component);
+19 -1
View File
@@ -340,7 +340,25 @@ int main(int argc, char **argv)
/* Step 2: Make a manifest for the os-core set */ /* Step 2: Make a manifest for the os-core set */
old_MoM = manifest_from_file(current_version, "MoM"); old_MoM = manifest_from_file(current_version, "MoM");
new_MoM = alloc_manifest(newversion, "MoM");
/* Verify that the new format is not older than the previous format. It
* never makes sense to decrease the format number for the next build. */
if (format < old_MoM->format) {
LOG(NULL, "", "Current format (%llu) must be greater than or equal to previous format (%llu). Exiting",
format, old_MoM->format);
printf("Current format (%llu) must be greater than or equal to previous format (%llu). Exiting\n",
format, old_MoM->format);
goto exit;
}
/* Detect a format bump and add the "update" action to the manifest
* "actions:" field */
GList *actions = NULL;
if (format > old_MoM->format) {
actions = g_list_prepend(actions, "update");
}
new_MoM = alloc_manifest(newversion, "MoM", actions);
old_core = manifest_from_file(manifest_subversion(old_MoM, "os-core"), "os-core"); old_core = manifest_from_file(manifest_subversion(old_MoM, "os-core"), "os-core");
new_core = sub_manifest_from_directory("os-core", newversion); new_core = sub_manifest_from_directory("os-core", newversion);
add_component_hashes_to_manifest(new_core, new_full); add_component_hashes_to_manifest(new_core, new_full);
+13 -3
View File
@@ -92,7 +92,7 @@ int file_sort_filename(gconstpointer a, gconstpointer b)
return 0; return 0;
} }
struct manifest *alloc_manifest(int version, char *component) struct manifest *alloc_manifest(int version, char *component, GList *actions)
{ {
struct manifest *manifest; struct manifest *manifest;
@@ -104,6 +104,7 @@ struct manifest *alloc_manifest(int version, char *component)
manifest->version = version; manifest->version = version;
manifest->component = strdup(component); manifest->component = strdup(component);
manifest->format = format; manifest->format = format;
manifest->actions = actions;
return manifest; return manifest;
} }
@@ -133,7 +134,7 @@ struct manifest *manifest_from_file(int version, char *component)
if (infile == NULL) { if (infile == NULL) {
LOG(NULL, "Cannot read manifest", "%s (%s)\n", filename, strerror(errno)); LOG(NULL, "Cannot read manifest", "%s (%s)\n", filename, strerror(errno));
free(filename); free(filename);
return alloc_manifest(version, component); return alloc_manifest(version, component, NULL);
} }
/* line 1: MANIFEST\t<version> */ /* line 1: MANIFEST\t<version> */
@@ -193,7 +194,7 @@ struct manifest *manifest_from_file(int version, char *component)
} }
} }
manifest = alloc_manifest(version, component); manifest = alloc_manifest(version, component, NULL);
manifest->format = format_number; manifest->format = format_number;
manifest->prevversion = previous; manifest->prevversion = previous;
manifest->includes = includes; manifest->includes = includes;
@@ -714,6 +715,7 @@ static int write_manifest_plain(struct manifest *manifest)
{ {
GList *includes; GList *includes;
GList *list; GList *list;
GList *actions;
struct file *file; struct file *file;
FILE *out = NULL; FILE *out = NULL;
char *base = NULL, *dir; char *base = NULL, *dir;
@@ -763,6 +765,14 @@ static int write_manifest_plain(struct manifest *manifest)
includes = g_list_next(includes); includes = g_list_next(includes);
fprintf(out, "includes:\t%s\n", sub->component); fprintf(out, "includes:\t%s\n", sub->component);
} }
actions = manifest->actions;
while (actions) {
char *action = actions->data;
fprintf(out, "actions:\t%s\n", action);
actions = g_list_next(actions);
}
fprintf(out, "\n"); fprintf(out, "\n");
list = g_list_first(manifest->files); list = g_list_first(manifest->files);
+60
View File
@@ -0,0 +1,60 @@
#!/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
set_os_release 10 os-core
track_bundle 10 os-core
set_os_release 20 os-core
track_bundle 20 os-core
set_os_release 30 os-core
track_bundle 30 os-core
}
@test "full run update creation with delta packs over format bump" {
# build the first version
echo $CREATE_UPDATE
echo $DIR
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 10
sudo $MAKE_PACK --statedir $DIR 0 10 os-core
set_latest_ver 10
# then the second version...
echo $CREATE_UPDATE
echo $DIR
sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 3
sudo $MAKE_FULLFILES --statedir $DIR 20
sudo $MAKE_PACK --statedir $DIR 0 20 os-core
set_latest_ver 20
# then the third version...
echo $CREATE_UPDATE
echo $DIR
sudo $CREATE_UPDATE --osversion 30 --statedir $DIR --format 4
sudo $MAKE_FULLFILES --statedir $DIR 30
sudo $MAKE_PACK --statedir $DIR 0 30 os-core
# zero packs should exist (non-zero size) for all versions
[ -s $DIR/www/10/pack-os-core-from-0.tar ]
[ -s $DIR/www/20/pack-os-core-from-0.tar ]
[ -s $DIR/www/30/pack-os-core-from-0.tar ]
[[ 0 -eq $(grep '^actions: update$' $DIR/www/10/Manifest.MoM | wc -l) ]]
[[ 0 -eq $(grep '^actions: update$' $DIR/www/20/Manifest.MoM | wc -l) ]]
[[ 1 -eq $(grep '^actions: update$' $DIR/www/30/Manifest.MoM | wc -l) ]]
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80
+35
View File
@@ -0,0 +1,35 @@
#!/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
set_os_release 10 os-core
track_bundle 10 os-core
set_os_release 20 os-core
track_bundle 20 os-core
gen_file_plain 10 os-core foo
gen_file_plain 10 os-core bar
gen_file_plain 20 os-core foo
gen_file_plain 20 os-core baz
}
@test "ensure format numbers cannot be decremented" {
sudo $CREATE_UPDATE --osversion 10 --statedir $DIR --format 3
set_latest_ver 10
# Now, decrement the format number. Should result in an EXIT_FAILURE.
run sudo $CREATE_UPDATE --osversion 20 --statedir $DIR --format 2
echo "$output"
[ $status -eq 1 ]
}
# vi: ft=sh ts=8 sw=2 sts=2 et tw=80