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 check_in_proc);
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);
60 return scalar(`$cmd`);
64 my ($cmd, $args) = @_;
65 print "$libexecdir/ksplice-$cmd $args\n" if($verbose);
66 my $output = `$libexecdir/ksplice-$cmd $args`;
67 if($output =~ /ksplice: success/) {
71 print "Output: $output\n";
72 die "Failed during: $libexecdir/ksplice-$cmd $args";
79 runval("tar zxf $file");
80 my $ksplice = `find
*/ -maxdepth
0`;
82 chop($ksplice); # remove the trailing slash
90 print "/proc not mounted?\n";
93 if(! -e "/proc/ksplice_$kid") {
94 print "Ksplice id $kid is not present in the kernel\n";