* When converting from rpm, do parent directory 755 chmods first, then

known permissions setting from rpm --queryformat, so that it can override
     any directories that do indeed have a permission set.
   * Fixed MakeFile.PL to work with perl 5.8.
This commit is contained in:
joey
2002-08-19 16:53:30 +00:00
parent c6b855ed5c
commit 21393f2767
4 changed files with 41 additions and 34 deletions

View File

@@ -176,31 +176,6 @@ sub unpack {
or die "error moving unpacked files into the default prefix directory: $!";
}
if ($> == 0) {
# rpm files have two sets of permissions; the set in the cpio
# archive, and the set in the control data; which override them.
# The set in the control data are more correct, so let's use those.
open (GETPERMS, 'rpm --queryformat \'[%{FILEMODES} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]\' -qp '.$this->filename.' |');
while (<GETPERMS>) {
chomp;
my ($mode, $owner, $group, $file) = split(/ /, $_, 4);
$mode = $mode & 07777; # remove filetype
my $uid = getpwnam($owner);
if (! defined $uid) {
print STDERR "WARNING: $file is owned by a user ($owner) not on this system; using root instead";
$uid=0;
}
my $gid = getgrnam($group);
if (! defined $gid) {
print STDERR "WARNING: $file is owned by a group ($group) not on this system; using group root instead";
$gid=0;
}
next unless -e "$workdir/$file"; # skip broken links
chown($uid, $gid, "$workdir/$file") || die "failed chowning $file to $uid\:$gid\: $!";
chmod($mode, "$workdir/$file") || die "failed changing mode of $file to $mode\: $!";
}
}
# When cpio extracts the file, any child directories that are
# present, but whose parent directories are not, end up mode 700.
# This next block corrects that to 755, which is more reasonable.
@@ -234,6 +209,31 @@ sub unpack {
}
chmod 0755, keys %tochmod if %tochmod;
if ($> == 0) {
# rpm files have two sets of permissions; the set in the cpio
# archive, and the set in the control data; which override them.
# The set in the control data are more correct, so let's use those.
open (GETPERMS, 'rpm --queryformat \'[%{FILEMODES} %{FILEUSERNAME} %{FILEGROUPNAME} %{FILENAMES}\n]\' -qp '.$this->filename.' |');
while (<GETPERMS>) {
chomp;
my ($mode, $owner, $group, $file) = split(/ /, $_, 4);
$mode = $mode & 07777; # remove filetype
my $uid = getpwnam($owner);
if (! defined $uid) {
print STDERR "WARNING: $file is owned by a user ($owner) not on this system; using root instead\n";
$uid=0;
}
my $gid = getgrnam($group);
if (! defined $gid) {
print STDERR "WARNING: $file is owned by a group ($group) not on this system; using group root instead\n";
$gid=0;
}
next unless -e "$workdir/$file"; # skip broken links
chown($uid, $gid, "$workdir/$file") || die "failed chowning $file to $uid\:$gid\: $!";
chmod($mode, "$workdir/$file") || die "failed changing mode of $file to $mode\: $!";
}
}
return 1;
}