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

2
debian/changelog vendored
View File

@@ -1,6 +1,8 @@
alien (8.87) UNRELEASED; urgency=low
* 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