Fix adding of postinst script to deb, containing rpm permissions fixups code. Closes: #667651

This commit is contained in:
Joey Hess
2012-04-05 13:51:24 -04:00
parent f717997da1
commit b69f536367
2 changed files with 40 additions and 20 deletions

View File

@@ -443,17 +443,15 @@ EOF
close OUT; close OUT;
$this->do("chmod", 755, "$dir/debian/rules"); $this->do("chmod", 755, "$dir/debian/rules");
# Save any scripts.
if ($this->usescripts) { if ($this->usescripts) {
foreach my $script (qw{postinst postrm preinst prerm}) { foreach my $script (qw{postinst postrm preinst prerm}) {
my $data=$this->$script(); $this->savescript($script, $this->$script());
next unless defined $data; }
next if $data =~ m/^\s*$/; }
open (OUT,">$dir/debian/$script") || else {
die "$dir/debian/$script: $!"; # There may be a postinst with permissions fixups even when
print OUT $data; # scripts are disabled.
close OUT; $this->savescript("postinst", undef);
}
} }
my %dirtrans=( # Note: no trailing slashes on these directory names! my %dirtrans=( # Note: no trailing slashes on these directory names!
@@ -729,30 +727,50 @@ sub username {
return $username; return $username;
} }
=item postinst =item savescript
Returns the postinst. This may include generated shell code to set owners Saves script to debian directory.
and groups from the owninfo field, and update modes from the modeinfo field.
=cut =cut
sub postinst { sub savescript {
my $this=shift; my $this=shift;
my $script=shift;
my $data=shift;
if (@_) { if ($script eq 'postinst') {
$this->{postinst}=shift; $data=$this->gen_postinst($data);
} }
my $dir=$this->unpacked_tree;
return unless defined $data;
next if $data =~ m/^\s*$/;
open (OUT,">$dir/debian/$script") ||
die "$dir/debian/$script: $!";
print OUT $data;
close OUT;
}
=item gen_postinst
Modifies or creates a postinst. This may include generated shell code to set
owners and groups from the owninfo field, and update modes from the modeinfo
field.
=cut
sub gen_postinst {
my $this=shift;
my $postinst=shift;
my $owninfo = $this->owninfo; my $owninfo = $this->owninfo;
my $modeinfo = $this->modeinfo; my $modeinfo = $this->modeinfo;
my $postinst = $this->{postinst}; return $postinst unless ref $owninfo && %$owninfo;
return $postinst unless ref $owninfo;
# If there is no postinst, let's make one up.. # If there is no postinst, let's make one up..
$postinst="#!/bin/sh\n" unless defined $postinst && length $postinst; $postinst="#!/bin/sh\n" unless defined $postinst && length $postinst;
return $postinst unless %$owninfo;
my ($firstline, $rest)=split(/\n/, $postinst, 2); my ($firstline, $rest)=split(/\n/, $postinst, 2);
if ($firstline !~ m/^#!\s*\/bin\/(ba)?sh/) { if ($firstline !~ m/^#!\s*\/bin\/(ba)?sh/) {
print STDERR "warning: unable to add ownership fixup code to postinst as the postinst is not a shell script!\n"; print STDERR "warning: unable to add ownership fixup code to postinst as the postinst is not a shell script!\n";

2
debian/changelog vendored
View File

@@ -1,6 +1,8 @@
alien (8.87) UNRELEASED; urgency=low alien (8.87) UNRELEASED; urgency=low
* Use lsb-rpmbuild, not lsb-rpm. Closes: #667044 * Use lsb-rpmbuild, not lsb-rpm. Closes: #667044
* Fix adding of postinst script to deb, containing rpm permissions
fixups code. Closes: #667651
-- Joey Hess <joeyh@debian.org> Wed, 04 Apr 2012 13:34:26 -0400 -- Joey Hess <joeyh@debian.org> Wed, 04 Apr 2012 13:34:26 -0400