From a94c7537c31813cd98ec5fd7558b2597a17f1ee9 Mon Sep 17 00:00:00 2001 From: freesource Date: Wed, 22 Aug 2001 23:35:49 +0000 Subject: [PATCH] This fixes a major bug which effected copying because of the logic employed. Now enoent (unstripped binary) copies properly. Uid/Gid for /home/user will need to be handled either through a script which runs on first login, or directly by the administrator, for now the adm will handle this, but Replacement user/group are now preserved. Unless user is in the hosts group file this is how things need to be done. --- BootRoot/Yard.pm | 64 +++++++++++++++++++----------------------------- 1 file changed, 25 insertions(+), 39 deletions(-) diff --git a/BootRoot/Yard.pm b/BootRoot/Yard.pm index 7c229b5..5c7f505 100644 --- a/BootRoot/Yard.pm +++ b/BootRoot/Yard.pm @@ -1039,8 +1039,8 @@ sub copy_strip_file { my $error; if ($strippable{$from}) { - # Copy it stripped + # Copy it stripped if ($strip_lib) { if (defined($lib_needed_by{$from})) { # It's a library @@ -1053,6 +1053,26 @@ sub copy_strip_file { sys("$objcopy --strip-debug $from $to"); } } + } + if ($strip_module) { + if (defined($is_module{$from})) { + info(1, "Copy/stripping module $from to $to\n"); + sys("$objcopy --strip-debug $from $to"); + } + } + if ($strip_bin) { + if (!defined($is_module{$from}) && + !defined($lib_needed_by{$from})) { + # It's a binary executable + info(1, "Copy/stripping binary executable $from to $to\n"); + sys("$objcopy --strip-all $from $to"); + } + } + else { # fallback just in case + # Normal copy, no strip + info(1, "Copying $from to $to\n"); + sys("cp -a $from $to"); + } # Copy file perms and owner my($mode, $uid, $gid); @@ -1060,49 +1080,15 @@ sub copy_strip_file { my $from_base = basename($from); chown($uid, $gid, $to) or ($error = error("chown: $! \($from_base\)\n")); - ##return "ERROR"if $error && $error eq "ERROR"; + return "ERROR"if $error && $error eq "ERROR"; chmod($mode, $to) or ($error = error("chmod: $! \($from_base\)\n")); - ##return "ERROR"if $error && $error eq "ERROR"; - } - elsif ($strip_module) { - info(1, "Copy/stripping module $from to $to\n"); - sys("$objcopy --strip-debug $from $to"); - - # Copy file perms and owner - my($mode, $uid, $gid); - (undef, undef, $mode, undef, $uid, $gid) = stat $from; - my $from_base = basename($from); - chown($uid, $gid, $to) or ($error = - error("chown: $! \($from_base\)\n")); - ##return "ERROR"if $error && $error eq "ERROR"; - chmod($mode, $to) or ($error = - error("chmod: $! \($from_base\)\n")); - return "ERROR"if $error && $error eq "ERROR"; - } elsif ($strip_bin) { - # It's a binary executable - info(1, "Copy/stripping binary executable $from to $to\n"); - sys("$objcopy --strip-all $from $to"); - - # Copy file perms and owner - my($mode, $uid, $gid); - (undef, undef, $mode, undef, $uid, $gid) = stat $from; - my $from_base = basename($from); - chown($uid, $gid, $to) or ($error = - error("chown: $! \($from_base\)\n")); - ##return "ERROR"if $error && $error eq "ERROR"; - chmod($mode, $to) or ($error = - error("chmod: $! \($from_base\)\n")); - return "ERROR"if $error && $error eq "ERROR"; - } - else { - # Normal copy, no strip - sys("cp $from $to"); - } + return "ERROR"if $error && $error eq "ERROR"; } else { # Normal copy, no strip - sys("cp $from $to"); + info(1, "Copying $from to $to\n"); + sys("cp -a $from $to"); } }