diff options
author | Francois Pons <fpons@mandriva.com> | 1999-11-07 19:14:26 +0000 |
---|---|---|
committer | Francois Pons <fpons@mandriva.com> | 1999-11-07 19:14:26 +0000 |
commit | 5fe426f2d1024c2a73791ffdafc2404bfccb8736 (patch) | |
tree | 78086e10a885260845b33785663530503a13d104 /perl-install/commands.pm | |
parent | fe9d92c84e2888c470a72d903b78f74288c84a9b (diff) | |
download | drakx-5fe426f2d1024c2a73791ffdafc2404bfccb8736.tar drakx-5fe426f2d1024c2a73791ffdafc2404bfccb8736.tar.gz drakx-5fe426f2d1024c2a73791ffdafc2404bfccb8736.tar.bz2 drakx-5fe426f2d1024c2a73791ffdafc2404bfccb8736.tar.xz drakx-5fe426f2d1024c2a73791ffdafc2404bfccb8736.zip |
*** empty log message ***
Diffstat (limited to 'perl-install/commands.pm')
-rw-r--r-- | perl-install/commands.pm | 66 |
1 files changed, 64 insertions, 2 deletions
diff --git a/perl-install/commands.pm b/perl-install/commands.pm index f4ed2d870..34653ba74 100644 --- a/perl-install/commands.pm +++ b/perl-install/commands.pm @@ -14,7 +14,6 @@ use common qw(:common :file :system :constant); #-##################################################################################### my $BUFFER_SIZE = 1024; - #-###################################################################################### #- Functions #-###################################################################################### @@ -403,7 +402,13 @@ sub insmod { $_ = $1 if m@.*/([^/]*)\.o@; unless (-r ($f = "/lib/modules/$_.o")) { $f = "/tmp/$_.o"; - run_program::run("cd /tmp ; bzip2 -cd /lib/modules.cpio.bz2 | cpio -i $_.o"); + if (-e "/lib/modules.cz2") { + run_program::run("extract_archive /lib/modules /tmp $_.o"); + } elsif (-e "/lib/modules.cpio.bz2") { + run_program::run("cd /tmp ; bzip2 -cd /lib/modules.cpio.bz2 | cpio -i $_.o"); + } else { + die "unable to find an archive for modules"; + } } } -r $f or die "can't find module $_"; @@ -512,6 +517,63 @@ sub install_cpio($$) { $cached_failed_install_cpio{"$dir $name"} = 1; } +sub catsksz($$$$) { + my ($input, $seek, $siz, $output) = @_; + my ($buf, $sz); + + while (($sz = sysread($input, $buf, $seek > 4096 ? 4096 : $seek))) { + $seek -= $sz; + last unless $seek > 0; + } + while (($sz = sysread($input, $buf, $siz > 4096 ? 4096 : $siz))) { + $siz -= $sz; + syswrite($output, $buf); + last unless $siz > 0; + } +} + +sub extract_from_archive($$$) { + my ($archive, $dir, $file) = @_; + + require 'log.pm'; + + log::l("data=$archive->{data}"); + unless (-r $archive->{archive}) { + log::l($_) foreach keys %{$archive}; + log::l("unable to access archive $archive->{archive} from $archive"); + return; + } + unless ($archive->{data}) { + my %data; + + log::l("loading archive description file $archive->{data_file}"); + eval `cat $archive->{data_file}`; + $archive->{data} = { %data }; + } + my $data_of_file = $archive->{data}{$file}; + unless ($data_of_file) { + log::l("unable to find file $file in archive $archive->{archive}"); + return; + } + unless ($data_of_file->[0] >= 0 && $data_of_file->[1] > 0 && + $data_of_file->[2] >= 0 && $data_of_file->[3] > 0) { + log::l("bad entry of file $file in archive $archive->{archive}"); + return; + } + + local *OUTPUT; + if (open OUTPUT, "-|") { #- parent create file from child extraction from archive. + local *FILE; open FILE, ">$dir/$file"; + catsksz(\*OUTPUT, $data_of_file->[2], $data_of_file->[3], \*FILE); + } else { #- child execute bzip2 -d on its stdout which is OUTPUT. + local *BUNZIP2; open BUNZIP2, "| bzip2 -d >&STDOUT"; + local *ARCHIVE; open ARCHIVE, "<$archive->{archive}" or exec 'false'; + catsksz(\*ARCHIVE, $data_of_file->[0], $data_of_file->[1], \*BUNZIP2); + exec 'true'; + } + 1; +} + #-###################################################################################### #- Wonderful perl :( #-###################################################################################### |