summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorintrigeri <intrigeri@boum.org>2020-01-11 19:49:07 +0000
committerintrigeri <intrigeri@boum.org>2020-01-11 23:20:24 +0000
commitf2a786f12ed9f49233a63dcce20a1364f95f0259 (patch)
tree310b20eaff6dcb7c591549fb0609f34c705200f1 /config
parentf122cc078ef4421f1f4d94ecf716620993e5a2ea (diff)
Upgrader: don't assume that all offered upgrades are relevant (refs: #17425)
Before this commit, the Upgrader blindly assumed that _any_ upgrade path that's proposed for the initially installed version actually contains an upgrade to a version that's strictly newer than the currently running one. This assumption used to hold in the v1 scheme, but in the v2 scheme: - When running version == initially installed version, i.e. when one runs a Tails that was never upgraded, this assumption is true. - Else, this assumption is wrong. As a consequence, any Tails >= 4.2 that hasn't this fix, and that ever got an incremental upgrade applied, will keep proposing an upgrade even if it's up-to-date already. To fix this, let's filter the proposed upgrade paths to ignore those that would "upgrade" to a lower-or-equal version than the currently running one.
Diffstat (limited to 'config')
-rw-r--r--config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/Frontend.pm3
-rw-r--r--config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/UpgradeDescriptionFile.pm38
2 files changed, 28 insertions, 13 deletions
diff --git a/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/Frontend.pm b/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/Frontend.pm
index 6d4eff3..e1fef1d 100644
--- a/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/Frontend.pm
+++ b/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/Frontend.pm
@@ -335,7 +335,8 @@ method run () {
$self->refresh_signing_key;
my ($upgrade_description_text) = $self->get_upgrade_description;
my $upgrade_description = Tails::IUK::UpgradeDescriptionFile->new_from_text(
- $upgrade_description_text
+ text => $upgrade_description_text,
+ product_version => $self->running_system->product_version,
);
assert_isa($upgrade_description, 'Tails::IUK::UpgradeDescriptionFile');
diff --git a/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/UpgradeDescriptionFile.pm b/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/UpgradeDescriptionFile.pm
index 11aa604..078d67a 100644
--- a/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/UpgradeDescriptionFile.pm
+++ b/config/chroot_local-includes/usr/src/iuk/lib/Tails/IUK/UpgradeDescriptionFile.pm
@@ -24,7 +24,7 @@ use Function::Parameters;
use List::MoreUtils qw{any};
use List::Util qw{sum};
use Path::Tiny;
-use Types::Standard qw{ArrayRef Str};
+use Types::Standard qw{ArrayRef ClassName Maybe Str};
use YAML::Any;
use namespace::clean;
@@ -41,6 +41,13 @@ has "$_" => (
predicate => 1,
) for (qw{product_name initial_install_version build_target channel});
+has product_version => (
+ is => 'ro',
+ isa => Maybe[Str],
+ default => sub { undef },
+ predicate => 1,
+);
+
has upgrades =>
is => 'lazy',
isa => ArrayRef,
@@ -70,10 +77,18 @@ has upgrade_paths =>
method _build_upgrades () { return [] }
method _build_upgrade_paths () {
+ assert($self->has_product_version);
+ assert_defined($self->product_version);
my @upgrade_paths;
foreach my $upgrade ($self->all_upgrades) {
- exists $upgrade->{'upgrade-paths'} or $upgrade->{'upgrade-paths'} = [];
- foreach my $path (@{$upgrade->{'upgrade-paths'}}) {
+ next unless exists $upgrade->{'upgrade-paths'};
+ my @upgrade_paths_to_newer_version = grep {
+ version_compare(
+ $upgrade->{version},
+ $self->product_version
+ ) == 1;
+ } @{$upgrade->{'upgrade-paths'}};
+ foreach my $path (@upgrade_paths_to_newer_version) {
foreach my $key (qw{type target-files}) {
assert(exists $path->{$key});
assert(defined $path->{$key});
@@ -88,9 +103,9 @@ method _build_upgrade_paths () {
return \@upgrade_paths;
}
-sub new_from_text {
- my $class = shift;
- my $text = shift;
+fun new_from_text (ClassName $class,
+ Str :$text,
+ Maybe[Str] :$product_version = undef) {
my $data = YAML::Any::Load($text);
@@ -101,17 +116,16 @@ sub new_from_text {
$args{$attribute} = $data->{$key};
}
- $class->new(%args);
+ $class->new(%args, product_version => $product_version);
}
-sub new_from_file {
- my $class = shift;
- my $filename = shift;
-
+fun new_from_file (ClassName $class,
+ Str :$filename,
+ Maybe[Str] :$product_version = undef) {
my $content = path($filename)->slurp;
assert_nonblank($content);
- $class->new_from_text($content);
+ $class->new_from_text($content, product_version => $product_version);
}