diff options
Diffstat (limited to 'perl-install')
-rw-r--r-- | perl-install/common.pm | 40 | ||||
-rw-r--r-- | perl-install/install2.pm | 2 |
2 files changed, 41 insertions, 1 deletions
diff --git a/perl-install/common.pm b/perl-install/common.pm index 170ad831d..93004c37f 100644 --- a/perl-install/common.pm +++ b/perl-install/common.pm @@ -308,4 +308,44 @@ sub unpack_with_refs { @r; } + +sub my_cp_with_option { + my $option = shift @_; + my $keep_special = $option =~ /a/; + + my $dest = pop @_; + + @_ or return; + @_ == 1 || -d $dest or die "cp: copying multiple files, but last argument ($dest) is not a directory\n"; + + foreach my $src (@_) { + my $dest = $dest; + -d $dest and $dest .= '/' . basename($src); + + unlink $dest; + + if (-l $src && $keep_special) { + unless (symlink(readlink($src) || die("readlink failed: $!"), $dest)) { + warn "symlink: can't create symlink $dest: $!\n"; + } + } elsif (-d $src) { + -d $dest or mkdir $dest, (stat($src))[2] or die "mkdir: can't create directory $dest: $!\n"; + my_cp_af(glob_($src), $dest); + } elsif ((-b $src || -c $src) && $keep_special) { + my @stat = stat($src); + require MDK::Common::System; + MDK::Common::System::syscall_('mknod', $dest, $stat[2], $stat[6]) or die "mknod failed (dev $dest): $!"; + } else { + open(my $F, $src) or die "can't open $src for reading: $!\n"; + open(my $G, "> $dest") or die "can't cp to file $dest: $!\n"; + local $_; while (<$F>) { print $G $_ } + chmod((stat($src))[2], $dest); + } + } + 1; +} + +sub my_cp_f { my_cp_with_option('f', @_) } +sub my_cp_af { my_cp_with_option('af', @_) } + 1; diff --git a/perl-install/install2.pm b/perl-install/install2.pm index de315aad7..6fea37b19 100644 --- a/perl-install/install2.pm +++ b/perl-install/install2.pm @@ -206,7 +206,7 @@ sub formatPartitions { #- needed by lilo if (my @vgs = map { $_->{VG_name} } @{$o->{all_hds}{lvms}}) { - cp_af("/dev/$_", "$::prefix/dev") foreach 'mapper', @vgs; + common::my_cp_af("/dev/$_", "$::prefix/dev") foreach 'mapper', @vgs; } } |