Skip to content

Commit

Permalink
Refactor unpack_update to create a temporary directory itself.
Browse files Browse the repository at this point in the history
Signed-off-by: Anders Kaseorg <[email protected]>
  • Loading branch information
andersk committed Aug 20, 2009
1 parent d21c162 commit 068fa53
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
5 changes: 3 additions & 2 deletions Ksplice.pm.in
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,9 @@ sub runval_outfile {

sub unpack_update {
my ($file) = @_;
runval("tar", "--force-local", "-zxf", $file);
my ($ksplice) = glob('*/');
my $tmpdir = tempdir('ksplice-tmp-XXXXXX', TMPDIR => 1, CLEANUP => 1);
runval("tar", "-C", $tmpdir, "--force-local", "-zxf", $file);
my ($ksplice) = glob("$tmpdir/*/");
chop($ksplice); # remove the trailing slash
return $ksplice;
}
Expand Down
7 changes: 2 additions & 5 deletions ksplice-apply.in
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,11 @@ GetOptions(@common_options,

pod2usage(1) if($help || scalar(@ARGV) != 1);

my $file = abs_path($ARGV[0]);
my $file = $ARGV[0];
$debugon = 1 if(defined $debug);
$debug = abs_path($debug) if (defined $debug);

my $tmpdir = tempdir('ksplice-tmp-XXXXXX', TMPDIR => 1, CLEANUP => 1);
chdir($tmpdir);
my $ksplice = unpack_update($file);
chdir($ksplice);
chdir(unpack_update($file));

die "No contents file in $file\n" if (!-e "contents");
open(CONTENTS, '<', "contents");
Expand Down
7 changes: 2 additions & 5 deletions ksplice-view.in
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ sub view_kid {
}

sub view_file {
my $tmpdir = tempdir('ksplice-tmp-XXXXXX', TMPDIR => 1, CLEANUP => 1);
copy($file, "$tmpdir/" . basename($file));
chdir($tmpdir);
my $ksplice = unpack_update($file);
open(PATCH, '<', "$ksplice/patch") or die $!;
chdir(unpack_update($file));
open(PATCH, '<', "patch") or die $!;
local $/;
print <PATCH>;
close(PATCH);
Expand Down

0 comments on commit 068fa53

Please sign in to comment.