3 use File
::Temp qw
/:mktemp/;
8 our @ISA = qw(Exporter);
9 our @EXPORT = qw($datadir $libexecdir $version_str init_tmpdir runcd runstr runval runval_raw runsuc unpack_update get_debugfs);
11 our ($datadir, $libexecdir) = qw(KSPLICE_DATA_DIR KSPLICE_LIBEXEC_DIR);
12 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::level
);
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::level
);
43 if(!$verbose::level
) {
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);
50 if(!$verbose::level
) {
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::level
);
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
86 my ($modname, $debugfs_out) = @_;
88 my $debugfsdir = init_tmpdir
();
89 runval_raw
(qw(mount -t debugfs debugfs), $debugfsdir);
90 if (-e
"$debugfsdir/$modname") {
91 system(qw(cp -a), "$debugfsdir/$modname", "$debugfs_out");
92 $debug = runstr
("cat", "$debugfsdir/$modname");
93 runval_raw
(qw(rmdir), $debugfsdir);
95 runval_raw
(qw(umount), $debugfsdir);