3 Tails::Persistence::Configuration - manage live-persistence.conf and presets
7 package Tails
::Persistence
::Configuration
;
16 use Tails
::Persistence
::Configuration
::Atom
;
17 use Tails
::Persistence
::Configuration
::ConfigFile
;
18 use Tails
::Persistence
::Configuration
::Presets
;
19 use Types
::Path
::Tiny
qw{AbsPath
};
23 setlocale
(LC_MESSAGES
, "");
24 textdomain
("tails-persistence-setup");
33 has
'config_file_path' => (
36 coerce
=> AbsPath
->coercion,
42 isa
=> 'Tails::Persistence::Configuration::ConfigFile',
47 isa
=> 'Tails::Persistence::Configuration::Presets',
49 has
'force_enable_presets' => (
51 isa
=> 'ArrayRef[Str]',
52 default => sub { [] },
57 isa
=> 'ArrayRef[Tails::Persistence::Configuration::Atom]',
58 handles_via
=> 'Array',
60 all_atoms
=> 'elements',
72 my $file = Tails
::Persistence
::Configuration
::ConfigFile
->new(
73 config_file_path
=> $self->config_file_path
80 Tails
::Persistence
::Configuration
::Presets
->new();
85 return $self->merge_file_with_presets($self->file, $self->presets);
92 sub lines_not_in_presets
{
96 ! grep { $_->equals_line($line) } $self->presets->all
97 } $self->file->all_lines;
100 sub merge_file_with_presets
{
102 # Modifying and returning clones of the presets atoms would be a bit cleaner.
103 $self->presets->set_state_from_lines($self->file->all_lines);
104 $self->presets->set_state_from_overrides($self->force_enable_presets);
109 Tails
::Persistence
::Configuration
::Atom
->new_from_line(
113 } $self->lines_not_in_presets,
117 sub all_enabled_atoms
{
119 grep { $_->enabled } $self->all_atoms;
122 sub all_enabled_lines
{
125 Tails
::Persistence
::Configuration
::Line
->new(
126 destination
=> $_->destination,
127 options
=> $_->options,
129 } $self->all_enabled_atoms;
134 $self->file->lines([ $self->all_enabled_lines ]);