3 use File
::Temp qw
/:mktemp/;
7 our @ISA = qw(Exporter);
8 our @EXPORT = qw($datadir $libexecdir $verbose $version_str init_tmpdir runcd runstr runval runval_raw runsuc unpack_update);
10 our ($datadir, $libexecdir) = qw(KSPLICE_DATA_DIR KSPLICE_LIBEXEC_DIR);
11 our $version_str = "Ksplice version PACKAGE_VERSION\n";
15 my $argdir = $ENV{TMPDIR
};
16 $argdir = "/tmp" if(!defined $argdir || ! -d
$argdir);
19 my $tmpdir = mkdtemp
("$argdir/ksplice-tmp-XXXXXX");
20 die if(!defined $tmpdir || ! -d
$tmpdir);
26 print "chdir($dir)\n" if($verbose);
28 die "Failed during: chdir($dir)\n";
34 if(runval_raw
(@cmd) != 0) {
35 die "Failed during: @cmd\n";
42 print "@cmd\n" if($verbose);
44 open $out, ">&STDOUT" or die "Can't dup STDOUT: $!";
45 open $err, ">&STDERR" or die "Can't dup STDERR: $!";
46 open STDOUT
, '>', "/dev/null" or die "Can't hide STDOUT: $!";
47 open STDERR
, '>', "/dev/null" or die "Can't hide STDERR: $!";
49 my $val = system(@cmd);
51 open STDOUT
, ">&", $out or die "Can't restore STDOUT: $!";
52 open STDERR
, ">&", $err or die "Can't restore STDERR: $!";
59 print "@cmd\n" if($verbose);
61 open PIPE
, '-|', @cmd or die "Can't run @cmd: $!";
63 close PIPE
or $! == 0 or die "Can't run @cmd: $!";
68 my ($cmd, @args) = @_;
69 my $output = runstr
("$libexecdir/ksplice-$cmd", @args);
71 print "Output: $output\n";
72 die "Failed during: $libexecdir/ksplice-$cmd @args";
79 runval
("tar", "zxf", $file);
80 my ($ksplice) = glob('*/');
81 chop($ksplice); # remove the trailing slash