Commit d2436999 authored by intrigeri's avatar intrigeri
Browse files

Upgrader: drop temporary directory management (refs: #15283)

It was only needed for extracting nested archives.
Now that we can simply mount the IUK, we don't use this anymore.
parent 4644ebf0
......@@ -19,7 +19,7 @@ use Carp::Assert::More;
use Cwd;
use Data::Dumper;
use File::Copy;
use File::Temp qw{tempdir tempfile};
use File::Temp qw{tempfile};
use Function::Parameters;
use Path::Tiny;
use Try::Tiny;
......@@ -66,11 +66,6 @@ option 'override_boot_device_file' =>
format => 's',
predicate => 1;
has 'tempdir' =>
is => 'lazy',
isa => AbsDir,
predicate => 1;
has 'modules_file' =>
is => 'lazy',
isa => AbsFile;
......@@ -100,25 +95,6 @@ has 'running_system' =>
=cut
method _build_tempdir () {
$self->remount_liveos_rw;
my $base_live_tmp_dir = $self->liveos_mountpoint->child('tmp')->stringify;
# --parents is used to avoid error if existing, not to create parents.
run_as_root('mkdir', '--parents', $base_live_tmp_dir);
-d $base_live_tmp_dir or $self->fatal("Could not make '$base_live_tmp_dir' directory: $!");
my $tempdir = `sudo -n mktemp --directory --tmpdir=$base_live_tmp_dir`;
chomp $tempdir;
-d $tempdir or $self->fatal("Could not make '$tempdir' temporary directory: $!");
# This is useless in Tails, but useful for testing.
run_as_root(qw{chmod -R go+rX}, $base_live_tmp_dir);
path($tempdir);
}
method _build_installed_squashfs () { [] }
method _build_modules_file () {
......@@ -126,15 +102,7 @@ method _build_modules_file () {
}
method _build_reader () {
Tails::IUK::Read->new_from_file(
$self->from_file,
tempdir => $self->tempdir,
);
}
method clean () {
run_as_root(qw{rm --recursive --force --preserve-root}, $self->tempdir)
if $self->has_tempdir;
Tails::IUK::Read->new_from_file($self->from_file);
}
method _build_running_system () {
......@@ -149,10 +117,6 @@ method _build_running_system () {
Tails::RunningSystem->new(@args);
}
method DEMOLISH (@args) {
$self->clean;
}
=head1 METHODS
......@@ -160,9 +124,7 @@ method DEMOLISH (@args) {
method fatal (@msg) {
Tails::IUK::Utils::fatal(
msg => \@msg,
rmtree => $self->has_tempdir ? [ $self->tempdir ] : [],
rmtree_as_root => 1,
msg => \@msg,
);
}
......@@ -260,8 +222,6 @@ method run () {
) if -e $mbr;
system('sync');
$self->clean;
}
no Moo;
......
......@@ -61,11 +61,6 @@ has 'files' =>
is => 'lazy',
isa => ArrayRef;
has 'tempdir' =>
is => 'lazy',
isa => AbsDir,
predicate => 1;
has 'mountpoint' =>
is => 'lazy',
isa => AbsDir,
......@@ -105,8 +100,6 @@ method _build_control () {
method _build_files () { [ $self->archive->files ] }
method _build_tempdir () { path(File::Temp::tempdir(CLEANUP => 0)) };
method BUILD (@args) {
my $format_version;
try {
......@@ -126,8 +119,6 @@ fun new_from_file (ClassName $class, AbsFile $filename, @rest) {
}
method clean () {
run_as_root(qw{rm --recursive --force --preserve-root}, $self->tempdir)
if $self->has_tempdir;
run_as_root('umount', $self->mountpoint) if $self->has_mountpoint;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment