2000-04-21 02:23:53 +00:00
|
|
|
#!/usr/bin/perl -w
|
|
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
|
|
Alien::Package::Deb - an object that represents a deb package
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
package Alien::Package::Deb;
|
|
|
|
|
use strict;
|
|
|
|
|
use base qw(Alien::Package);
|
2014-05-09 07:41:26 +02:00
|
|
|
use List::Util qw(first);
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
|
|
|
|
This is an object class that represents a deb package. It is derived from
|
|
|
|
|
Alien::Package.
|
|
|
|
|
|
|
|
|
|
=head1 FIELDS
|
|
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
|
|
=item have_dpkg_deb
|
|
|
|
|
|
2000-04-21 05:08:50 +00:00
|
|
|
Set to a true value if dpkg-deb is available.
|
2000-04-21 02:23:53 +00:00
|
|
|
|
2014-05-09 07:41:26 +02:00
|
|
|
=item deb_member_list
|
|
|
|
|
|
|
|
|
|
Set to the list of member names in the deb package.
|
|
|
|
|
|
2001-10-26 18:28:28 +00:00
|
|
|
=item dirtrans
|
|
|
|
|
|
|
|
|
|
After the build stage, set to a hash reference of the directories we moved
|
|
|
|
|
files from and to, so these moves can be reverted in the cleantree stage.
|
|
|
|
|
|
2002-04-22 02:24:42 +00:00
|
|
|
=item fixperms
|
|
|
|
|
|
|
|
|
|
If this is set to true, the generated debian/rules will run dh_fixperms.
|
|
|
|
|
|
2000-04-21 02:23:53 +00:00
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=head1 METHODS
|
|
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
|
|
=item init
|
|
|
|
|
|
2000-04-21 05:08:50 +00:00
|
|
|
Sets have_dpkg_deb if dpkg-deb is in the path. I prefer to use dpkg-deb,
|
|
|
|
|
if it is available since it is a lot more future-proof.
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
2002-05-03 00:12:13 +00:00
|
|
|
sub _inpath {
|
2000-04-21 02:23:53 +00:00
|
|
|
my $this=shift;
|
2002-05-03 00:12:13 +00:00
|
|
|
my $program=shift;
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
foreach (split(/:/,$ENV{PATH})) {
|
2002-05-03 00:12:13 +00:00
|
|
|
if (-x "$_/$program") {
|
|
|
|
|
return 1;
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-05-03 00:12:13 +00:00
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sub init {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
$this->SUPER::init(@_);
|
|
|
|
|
|
|
|
|
|
$this->have_dpkg_deb($this->_inpath('dpkg-deb'));
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 22:18:49 +00:00
|
|
|
=item checkfile
|
|
|
|
|
|
|
|
|
|
Detect deb files by their extention.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub checkfile {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
my $file=shift;
|
|
|
|
|
|
2004-12-08 21:20:13 +00:00
|
|
|
return $file =~ m/.*\.u?deb$/;
|
2000-04-21 22:18:49 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 05:08:50 +00:00
|
|
|
=item install
|
|
|
|
|
|
2000-04-21 06:40:08 +00:00
|
|
|
Install a deb with dpkg. Pass in the filename of the deb to install.
|
2000-04-21 05:08:50 +00:00
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub install {
|
|
|
|
|
my $this=shift;
|
2000-04-21 06:40:08 +00:00
|
|
|
my $deb=shift;
|
2000-04-21 05:08:50 +00:00
|
|
|
|
2007-05-23 18:03:47 +00:00
|
|
|
my $v=$Alien::Package::verbose;
|
|
|
|
|
$Alien::Package::verbose=2;
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("dpkg", "--no-force-overwrite", "-i", $deb)
|
2000-09-11 23:27:32 +00:00
|
|
|
or die "Unable to install";
|
2007-05-23 18:03:47 +00:00
|
|
|
$Alien::Package::verbose=$v;
|
2000-04-21 05:08:50 +00:00
|
|
|
}
|
|
|
|
|
|
2002-05-03 00:12:13 +00:00
|
|
|
=item test
|
|
|
|
|
|
|
|
|
|
Test a deb with lintian. Pass in the filename of the deb to test.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub test {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
my $deb=shift;
|
|
|
|
|
|
|
|
|
|
if ($this->_inpath("lintian")) {
|
|
|
|
|
# Ignore some lintian warnings that don't matter for
|
|
|
|
|
# aliened packages.
|
|
|
|
|
return map { s/\n//; $_ }
|
|
|
|
|
grep {
|
|
|
|
|
! /unknown-section alien/
|
2011-06-11 13:00:34 -04:00
|
|
|
} $this->runpipe(1, "lintian '$deb'");
|
2002-05-03 00:12:13 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
return "lintian not available, so not testing";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 07:41:26 +02:00
|
|
|
=item get_deb_member_list
|
|
|
|
|
|
|
|
|
|
Helper method. Pass it the name of the deb and it will return the list of
|
|
|
|
|
ar members.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub get_deb_member_list {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
my $file=$this->filename;
|
|
|
|
|
my $members=$this->deb_member_list;
|
|
|
|
|
|
|
|
|
|
unless (defined $members) {
|
|
|
|
|
$members = [ map { chomp; $_ } $this->runpipe(1, "ar -t '$file'") ];
|
|
|
|
|
$this->deb_member_list($members);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return @{$members};
|
|
|
|
|
}
|
|
|
|
|
|
2000-07-20 22:52:50 +00:00
|
|
|
=item getcontrolfile
|
|
|
|
|
|
|
|
|
|
Helper method. Pass it the name of a control file, and it will pull it out
|
|
|
|
|
of the deb and return it.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub getcontrolfile {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
my $controlfile=shift;
|
|
|
|
|
my $file=$this->filename;
|
|
|
|
|
|
|
|
|
|
if ($this->have_dpkg_deb) {
|
2011-06-11 13:00:34 -04:00
|
|
|
return $this->runpipe(1, "dpkg-deb --info '$file' $controlfile 2>/dev/null");
|
2000-07-20 22:52:50 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2001-11-07 17:14:27 +00:00
|
|
|
# Solaris tar doesn't support O
|
|
|
|
|
sub tar_out {
|
|
|
|
|
my $file = shift;
|
|
|
|
|
|
|
|
|
|
return "(mkdir /tmp/tar_out.$$ &&".
|
|
|
|
|
" cd /tmp/tar_out.$$ &&".
|
2011-06-11 13:00:34 -04:00
|
|
|
" tar xf - './$file' &&".
|
|
|
|
|
" cat '$file'; cd /; rm -rf /tmp/tar_out.$$)";
|
2001-11-07 17:14:27 +00:00
|
|
|
}
|
2014-05-09 07:41:26 +02:00
|
|
|
my $controlcomp;
|
|
|
|
|
my $controlmember = first { /^control\.tar/ }
|
|
|
|
|
$this->get_deb_member_list;
|
|
|
|
|
if (! defined $controlmember) {
|
|
|
|
|
die 'Cannot find control member!';
|
|
|
|
|
} elsif ($controlmember eq 'control.tar.gz') {
|
|
|
|
|
$controlcomp = 'gzip -dc';
|
|
|
|
|
} elsif ($controlmember eq 'control.tar.xz') {
|
|
|
|
|
$controlcomp = 'xz -dc';
|
|
|
|
|
} elsif ($controlmember eq 'control.tar') {
|
|
|
|
|
$controlcomp = 'cat';
|
|
|
|
|
} else {
|
|
|
|
|
die 'Unknown control member!';
|
|
|
|
|
}
|
|
|
|
|
my $getcontrol = "ar -p '$file' $controlmember | $controlcomp | ".tar_out($controlfile)." 2>/dev/null";
|
2005-04-21 15:44:50 +00:00
|
|
|
return $this->runpipe(1, $getcontrol);
|
2000-07-20 22:52:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-09 07:41:26 +02:00
|
|
|
=item get_datamember_cmd
|
|
|
|
|
|
|
|
|
|
Helper method. Pass it the name of the deb and it will return the raw
|
|
|
|
|
command needed to extract the data.tar member.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub get_datamember_cmd {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
my $file=$this->filename;
|
|
|
|
|
|
|
|
|
|
my $datacomp;
|
|
|
|
|
my $datamember = first { /^data\.tar/ }
|
|
|
|
|
$this->get_deb_member_list;
|
|
|
|
|
if (! defined $datamember) {
|
|
|
|
|
die 'Cannot find data member!';
|
|
|
|
|
} elsif ($datamember eq 'data.tar.gz') {
|
|
|
|
|
$datacomp = 'gzip -dc';
|
|
|
|
|
} elsif ($datamember eq 'data.tar.bz2') {
|
|
|
|
|
$datacomp = 'bzip2 -dc';
|
|
|
|
|
} elsif ($datamember eq 'data.tar.xz') {
|
|
|
|
|
$datacomp = 'xz -dc';
|
|
|
|
|
} elsif ($datamember eq 'data.tar.lzma') {
|
|
|
|
|
$datacomp = 'xz -dc';
|
|
|
|
|
} elsif ($datamember eq 'data.tar') {
|
|
|
|
|
$datacomp = 'cat';
|
|
|
|
|
} else {
|
|
|
|
|
die 'Unknown data member!';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return "ar -p '$file' $datamember | $datacomp";
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-21 06:40:08 +00:00
|
|
|
=item scan
|
2000-04-21 02:23:53 +00:00
|
|
|
|
2000-04-21 06:40:08 +00:00
|
|
|
Implement the scan method to read a deb file.
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
2000-04-21 06:40:08 +00:00
|
|
|
sub scan {
|
2000-04-21 02:23:53 +00:00
|
|
|
my $this=shift;
|
2000-04-21 09:56:06 +00:00
|
|
|
$this->SUPER::scan(@_);
|
2000-04-21 02:28:52 +00:00
|
|
|
my $file=$this->filename;
|
2000-04-21 02:23:53 +00:00
|
|
|
|
2000-07-20 22:52:50 +00:00
|
|
|
my @control=$this->getcontrolfile('control');
|
2001-11-07 17:14:27 +00:00
|
|
|
die "Control file couldn't be read!"
|
|
|
|
|
if @control == 0;
|
2000-04-21 05:08:50 +00:00
|
|
|
# Parse control file and extract fields. Use a translation table
|
|
|
|
|
# to map between the debian names and the internal field names,
|
|
|
|
|
# which more closely resemble those used by rpm (for historical
|
|
|
|
|
# reasons; TODO: change to deb style names).
|
|
|
|
|
my $description='';
|
2000-04-21 02:23:53 +00:00
|
|
|
my $field;
|
|
|
|
|
my %fieldtrans=(
|
|
|
|
|
Package => 'name',
|
|
|
|
|
Version => 'version',
|
|
|
|
|
Architecture => 'arch',
|
|
|
|
|
Maintainer => 'maintainer',
|
|
|
|
|
Section => 'group',
|
|
|
|
|
Description => 'summary',
|
|
|
|
|
);
|
|
|
|
|
for (my $i=0; $i <= $#control; $i++) {
|
|
|
|
|
$_ = $control[$i];
|
|
|
|
|
chomp;
|
|
|
|
|
if (/^(\w.*?):\s+(.*)/) {
|
2002-01-25 04:42:41 +00:00
|
|
|
# Really old debs might have oddly capitalized
|
|
|
|
|
# field names.
|
|
|
|
|
$field=ucfirst(lc($1));
|
2000-04-21 02:23:53 +00:00
|
|
|
if (exists $fieldtrans{$field}) {
|
|
|
|
|
$field=$fieldtrans{$field};
|
|
|
|
|
$this->$field($2);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elsif (/^ / && $field eq 'summary') {
|
2000-04-21 05:08:50 +00:00
|
|
|
# Handle extended description.
|
2000-04-21 02:23:53 +00:00
|
|
|
s/^ //g;
|
|
|
|
|
$_="" if $_ eq ".";
|
2000-04-21 05:08:50 +00:00
|
|
|
$description.="$_\n";
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
|
|
|
|
}
|
2000-04-21 05:08:50 +00:00
|
|
|
$this->description($description);
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
$this->copyright("see /usr/share/doc/".$this->name."/copyright");
|
|
|
|
|
$this->group("unknown") if ! $this->group;
|
|
|
|
|
$this->distribution("Debian");
|
2000-04-21 06:16:26 +00:00
|
|
|
$this->origformat("deb");
|
2000-07-20 22:52:50 +00:00
|
|
|
$this->binary_info(scalar $this->getcontrolfile('control'));
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
# Read in the list of conffiles, if any.
|
|
|
|
|
my @conffiles;
|
2000-07-20 22:52:50 +00:00
|
|
|
@conffiles=map { chomp; $_ } $this->getcontrolfile('conffiles');
|
2000-04-21 02:23:53 +00:00
|
|
|
$this->conffiles(\@conffiles);
|
|
|
|
|
|
|
|
|
|
# Read in the list of all files.
|
2003-05-14 22:14:29 +00:00
|
|
|
# Note that tar doesn't supply a leading '/', so we have to add that.
|
2014-05-09 07:41:26 +02:00
|
|
|
my $datamember_cmd;
|
2000-04-21 02:23:53 +00:00
|
|
|
if ($this->have_dpkg_deb) {
|
2014-05-09 07:41:26 +02:00
|
|
|
$datamember_cmd = "dpkg-deb --fsys-tarfile '$file'";
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2014-05-09 07:41:26 +02:00
|
|
|
$datamember_cmd = $this->get_datamember_cmd($file);
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
2014-05-09 07:41:26 +02:00
|
|
|
my @filelist=map { chomp; s:\./::; "/$_" }
|
|
|
|
|
$this->runpipe(0, "$datamember_cmd | tar tf -");
|
2000-04-21 02:23:53 +00:00
|
|
|
$this->filelist(\@filelist);
|
|
|
|
|
|
|
|
|
|
# Read in the scripts, if any.
|
|
|
|
|
foreach my $field (qw{postinst postrm preinst prerm}) {
|
2000-07-20 22:52:50 +00:00
|
|
|
$this->$field(scalar $this->getcontrolfile($field));
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=item unpack
|
|
|
|
|
|
2006-12-14 22:35:37 +00:00
|
|
|
Implement the unpack method to unpack a deb file.
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub unpack {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
$this->SUPER::unpack(@_);
|
2000-04-21 02:28:52 +00:00
|
|
|
my $file=$this->filename;
|
2000-04-21 02:23:53 +00:00
|
|
|
|
|
|
|
|
if ($this->have_dpkg_deb) {
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("dpkg-deb", "-x", $file, $this->unpacked_tree)
|
|
|
|
|
or die "Unpacking of '$file' failed: $!";
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
|
|
|
|
else {
|
2014-05-09 07:41:26 +02:00
|
|
|
my $datamember_cmd = $this->get_datamember_cmd($file);
|
|
|
|
|
|
|
|
|
|
$this->do("$datamember_cmd | (cd ".$this->unpacked_tree."; tar xpf -)")
|
2003-05-14 22:14:29 +00:00
|
|
|
or die "Unpacking of '$file' failed: $!";
|
2000-04-21 02:23:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-21 22:23:53 +00:00
|
|
|
=item getpatch
|
|
|
|
|
|
|
|
|
|
This method tries to find a patch file to use in the prep stage. If it
|
2002-08-23 23:58:36 +00:00
|
|
|
finds one, it returns it. Pass in a list of directories to search for
|
2000-04-21 22:23:53 +00:00
|
|
|
patches in.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub getpatch {
|
|
|
|
|
my $this=shift;
|
2002-08-22 16:04:41 +00:00
|
|
|
my $anypatch=shift;
|
|
|
|
|
|
2000-04-21 22:23:53 +00:00
|
|
|
my @patches;
|
|
|
|
|
foreach my $dir (@_) {
|
2000-05-09 21:42:41 +00:00
|
|
|
push @patches, glob("$dir/".$this->name."_".$this->version."-".$this->release."*.diff.gz");
|
2000-04-21 22:23:53 +00:00
|
|
|
}
|
2002-08-23 23:58:36 +00:00
|
|
|
if (! @patches) {
|
|
|
|
|
# Try not matching the release, see if that helps.
|
2000-04-21 22:23:53 +00:00
|
|
|
foreach my $dir (@_) {
|
|
|
|
|
push @patches,glob("$dir/".$this->name."_".$this->version."*.diff.gz");
|
|
|
|
|
}
|
2002-08-23 23:58:36 +00:00
|
|
|
if (@patches && $anypatch) {
|
2000-04-21 22:23:53 +00:00
|
|
|
# Fallback to anything that matches the name.
|
|
|
|
|
foreach my $dir (@_) {
|
|
|
|
|
push @patches,glob("$dir/".$this->name."_*.diff.gz");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If we ended up with multiple matches, return the first.
|
|
|
|
|
return $patches[0];
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-21 06:16:26 +00:00
|
|
|
=item prep
|
|
|
|
|
|
|
|
|
|
Adds a populated debian directory the unpacked package tree, making it
|
|
|
|
|
ready for building. This can either be done automatically, or via a patch
|
|
|
|
|
file.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub prep {
|
|
|
|
|
my $this=shift;
|
2000-04-21 06:40:08 +00:00
|
|
|
my $dir=$this->unpacked_tree || die "The package must be unpacked first!";
|
2000-04-21 06:16:26 +00:00
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("mkdir $dir/debian") ||
|
2000-04-21 06:16:26 +00:00
|
|
|
die "mkdir $dir/debian failed: $!";
|
|
|
|
|
|
|
|
|
|
# Use a patch file to debianize?
|
|
|
|
|
if (defined $this->patchfile) {
|
|
|
|
|
# The -f passed to zcat makes it pass uncompressed files
|
|
|
|
|
# through without error.
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("zcat -f ".$this->patchfile." | (cd $dir; patch -p1)")
|
2000-09-11 23:27:32 +00:00
|
|
|
or die "patch error: $!";
|
2000-04-21 06:16:26 +00:00
|
|
|
# Look for .rej files.
|
|
|
|
|
die "patch failed with .rej files; giving up"
|
2011-06-11 13:00:34 -04:00
|
|
|
if $this->runpipe(1, "find '$dir' -name \"*.rej\"");
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do('find', '.', '-name', '*.orig', '-exec', 'rm', '{}', ';');
|
|
|
|
|
$this->do("chmod", 755, "$dir/debian/rules");
|
2002-08-23 23:58:36 +00:00
|
|
|
|
|
|
|
|
# It's possible that the patch file changes the debian
|
|
|
|
|
# release or version. Parse changelog to detect that.
|
|
|
|
|
open (my $changelog, "<$dir/debian/changelog") || return;
|
|
|
|
|
my $line=<$changelog>;
|
2003-07-11 19:24:18 +00:00
|
|
|
if ($line=~/^[^ ]+\s+\(([^)]+)\)\s/) {
|
2002-08-23 23:58:36 +00:00
|
|
|
my $version=$1;
|
2009-06-17 13:07:18 -04:00
|
|
|
$version=~s/\s+//; # ensure no whitespace
|
2002-08-23 23:58:36 +00:00
|
|
|
if ($version=~/(.*)-(.*)/) {
|
|
|
|
|
$version=$1;
|
|
|
|
|
$this->release($2);
|
|
|
|
|
}
|
|
|
|
|
$this->version($1);
|
|
|
|
|
}
|
|
|
|
|
close $changelog;
|
|
|
|
|
|
2000-04-21 06:16:26 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Automatic debianization.
|
|
|
|
|
# Changelog file.
|
|
|
|
|
open (OUT, ">$dir/debian/changelog") || die "$dir/debian/changelog: $!";
|
|
|
|
|
print OUT $this->name." (".$this->version."-".$this->release.") experimental; urgency=low\n";
|
|
|
|
|
print OUT "\n";
|
2005-07-20 00:57:38 +00:00
|
|
|
print OUT " * Converted from .".$this->origformat." format to .deb by alien version $Alien::Version\n";
|
2008-05-01 15:40:57 -04:00
|
|
|
print OUT " \n";
|
|
|
|
|
if (defined $this->changelogtext) {
|
|
|
|
|
my $ct=$this->changelogtext;
|
|
|
|
|
$ct=~s/^/ /gm;
|
|
|
|
|
print OUT $ct."\n";
|
|
|
|
|
}
|
2000-04-21 06:16:26 +00:00
|
|
|
print OUT "\n";
|
|
|
|
|
print OUT " -- ".$this->username." <".$this->email."> ".$this->date."\n";
|
|
|
|
|
close OUT;
|
|
|
|
|
|
|
|
|
|
# Control file.
|
|
|
|
|
open (OUT, ">$dir/debian/control") || die "$dir/debian/control: $!";
|
|
|
|
|
print OUT "Source: ".$this->name."\n";
|
|
|
|
|
print OUT "Section: alien\n";
|
|
|
|
|
print OUT "Priority: extra\n";
|
|
|
|
|
print OUT "Maintainer: ".$this->username." <".$this->email.">\n";
|
|
|
|
|
print OUT "\n";
|
|
|
|
|
print OUT "Package: ".$this->name."\n";
|
|
|
|
|
print OUT "Architecture: ".$this->arch."\n";
|
2002-02-11 19:19:44 +00:00
|
|
|
if (defined $this->depends) {
|
|
|
|
|
print OUT "Depends: ".join(", ", "\${shlibs:Depends}", $this->depends)."\n";
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
print OUT "Depends: \${shlibs:Depends}\n";
|
|
|
|
|
}
|
2000-04-21 06:16:26 +00:00
|
|
|
print OUT "Description: ".$this->summary."\n";
|
|
|
|
|
print OUT $this->description."\n";
|
|
|
|
|
close OUT;
|
|
|
|
|
|
|
|
|
|
# Copyright file.
|
|
|
|
|
open (OUT, ">$dir/debian/copyright") || die "$dir/debian/copyright: $!";
|
|
|
|
|
print OUT "This package was debianized by the alien program by converting\n";
|
|
|
|
|
print OUT "a binary .".$this->origformat." package on ".$this->date."\n";
|
|
|
|
|
print OUT "\n";
|
|
|
|
|
print OUT "Copyright: ".$this->copyright."\n";
|
|
|
|
|
print OUT "\n";
|
|
|
|
|
print OUT "Information from the binary package:\n";
|
|
|
|
|
print OUT $this->binary_info."\n";
|
|
|
|
|
close OUT;
|
|
|
|
|
|
2004-01-16 03:21:43 +00:00
|
|
|
# Conffiles, if any. Note that debhelper takes care of files in /etc.
|
|
|
|
|
my @conffiles=grep { $_ !~ /^\/etc/ } @{$this->conffiles};
|
2000-04-21 06:16:26 +00:00
|
|
|
if (@conffiles) {
|
|
|
|
|
open (OUT, ">$dir/debian/conffiles") || die "$dir/debian/conffiles: $!";
|
|
|
|
|
print OUT join("\n", @conffiles)."\n";
|
|
|
|
|
close OUT;
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-23 18:56:57 -04:00
|
|
|
# Use debhelper v7
|
|
|
|
|
open (OUT, ">$dir/debian/compat") || die "$dir/debian/compat: $!";
|
|
|
|
|
print OUT "7\n";
|
|
|
|
|
close OUT;
|
|
|
|
|
|
2000-04-21 06:16:26 +00:00
|
|
|
# A minimal rules file.
|
|
|
|
|
open (OUT, ">$dir/debian/rules") || die "$dir/debian/rules: $!";
|
2002-04-22 02:24:42 +00:00
|
|
|
my $fixpermscomment = $this->fixperms ? "" : "#";
|
|
|
|
|
print OUT << "EOF";
|
2000-04-21 06:16:26 +00:00
|
|
|
#!/usr/bin/make -f
|
|
|
|
|
# debian/rules for alien
|
|
|
|
|
|
2002-04-22 02:24:42 +00:00
|
|
|
PACKAGE=\$(shell dh_listpackages)
|
2001-02-15 23:38:25 +00:00
|
|
|
|
2000-04-21 06:16:26 +00:00
|
|
|
build:
|
|
|
|
|
dh_testdir
|
|
|
|
|
|
|
|
|
|
clean:
|
|
|
|
|
dh_testdir
|
|
|
|
|
dh_testroot
|
2004-07-29 17:17:18 +00:00
|
|
|
dh_clean -d
|
2000-04-21 06:16:26 +00:00
|
|
|
|
|
|
|
|
binary-indep: build
|
|
|
|
|
|
|
|
|
|
binary-arch: build
|
|
|
|
|
dh_testdir
|
|
|
|
|
dh_testroot
|
2010-05-23 18:56:57 -04:00
|
|
|
dh_prep
|
2000-04-21 06:16:26 +00:00
|
|
|
dh_installdirs
|
2002-03-24 02:35:58 +00:00
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
dh_installdocs
|
|
|
|
|
dh_installchangelogs
|
|
|
|
|
|
2002-05-24 02:41:24 +00:00
|
|
|
# Copy the packages's files.
|
|
|
|
|
find . -maxdepth 1 -mindepth 1 -not -name debian -print0 | \\
|
|
|
|
|
xargs -0 -r -i cp -a {} debian/\$(PACKAGE)
|
2002-03-24 02:35:58 +00:00
|
|
|
|
2000-04-21 06:16:26 +00:00
|
|
|
#
|
2002-04-22 02:24:42 +00:00
|
|
|
# If you need to move files around in debian/\$(PACKAGE) or do some
|
2001-02-15 23:38:25 +00:00
|
|
|
# binary patching, do it here
|
2000-04-21 06:16:26 +00:00
|
|
|
#
|
2003-05-14 22:14:29 +00:00
|
|
|
|
|
|
|
|
|
2001-02-15 23:38:25 +00:00
|
|
|
# This has been known to break on some wacky binaries.
|
2000-04-21 06:16:26 +00:00
|
|
|
# dh_strip
|
|
|
|
|
dh_compress
|
2002-04-22 02:24:42 +00:00
|
|
|
$fixpermscomment dh_fixperms
|
2001-02-15 23:58:48 +00:00
|
|
|
dh_makeshlibs
|
2000-04-21 06:16:26 +00:00
|
|
|
dh_installdeb
|
|
|
|
|
-dh_shlibdeps
|
|
|
|
|
dh_gencontrol
|
|
|
|
|
dh_md5sums
|
|
|
|
|
dh_builddeb
|
|
|
|
|
|
|
|
|
|
binary: binary-indep binary-arch
|
|
|
|
|
.PHONY: build clean binary-indep binary-arch binary
|
|
|
|
|
EOF
|
|
|
|
|
close OUT;
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("chmod", 755, "$dir/debian/rules");
|
2000-04-21 06:16:26 +00:00
|
|
|
|
2002-02-11 19:19:44 +00:00
|
|
|
if ($this->usescripts) {
|
|
|
|
|
foreach my $script (qw{postinst postrm preinst prerm}) {
|
2012-04-05 13:51:24 -04:00
|
|
|
$this->savescript($script, $this->$script());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
# There may be a postinst with permissions fixups even when
|
|
|
|
|
# scripts are disabled.
|
|
|
|
|
$this->savescript("postinst", undef);
|
2000-04-21 06:16:26 +00:00
|
|
|
}
|
2002-02-11 19:19:44 +00:00
|
|
|
|
2002-03-24 02:35:58 +00:00
|
|
|
my %dirtrans=( # Note: no trailing slashes on these directory names!
|
2001-10-26 18:28:28 +00:00
|
|
|
# Move files to FHS-compliant locations, if possible.
|
|
|
|
|
'/usr/man' => '/usr/share/man',
|
|
|
|
|
'/usr/info' => '/usr/share/info',
|
|
|
|
|
'/usr/doc' => '/usr/share/doc',
|
|
|
|
|
);
|
|
|
|
|
foreach my $olddir (keys %dirtrans) {
|
|
|
|
|
if (-d "$dir/$olddir" && ! -e "$dir/$dirtrans{$olddir}") {
|
|
|
|
|
# Ignore failure..
|
|
|
|
|
my ($dirbase)=$dirtrans{$olddir}=~/(.*)\//;
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("install", "-d", "$dir/$dirbase");
|
|
|
|
|
$this->do("mv", "$dir/$olddir", "$dir/$dirtrans{$olddir}");
|
2001-10-26 18:28:28 +00:00
|
|
|
if (-d "$dir/$olddir") {
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("rmdir", "-p", "$dir/$olddir");
|
2001-10-26 18:28:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
delete $dirtrans{$olddir};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
$this->dirtrans(\%dirtrans); # store for cleantree
|
2000-04-21 06:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 06:40:08 +00:00
|
|
|
=item build
|
|
|
|
|
|
2000-04-21 08:48:04 +00:00
|
|
|
Build a deb.
|
2000-04-21 06:40:08 +00:00
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub build {
|
|
|
|
|
my $this=shift;
|
2010-08-30 17:02:03 -04:00
|
|
|
|
|
|
|
|
# Detect architecture mismatch and abort with a comprehensible
|
|
|
|
|
# error message.
|
|
|
|
|
my $arch=$this->arch;
|
2010-09-09 08:24:54 -04:00
|
|
|
if ($arch ne 'all') {
|
|
|
|
|
my $ret=system("dpkg-architecture", "-i".$arch);
|
|
|
|
|
if ($ret != 0) {
|
|
|
|
|
die $this->filename." is for architecture ".$this->arch." ; the package cannot be built on this system"."\n";
|
|
|
|
|
}
|
2010-08-30 17:02:03 -04:00
|
|
|
}
|
2000-04-21 06:40:08 +00:00
|
|
|
|
|
|
|
|
chdir $this->unpacked_tree;
|
2005-04-21 15:44:50 +00:00
|
|
|
my $log=$this->runpipe(1, "debian/rules binary 2>&1");
|
2010-04-28 11:30:44 -04:00
|
|
|
chdir "..";
|
|
|
|
|
my $err=$?;
|
|
|
|
|
if ($err) {
|
|
|
|
|
if (! defined $log) {
|
|
|
|
|
die "Package build failed; could not run generated debian/rules file.\n";
|
|
|
|
|
}
|
2001-07-15 14:23:13 +00:00
|
|
|
die "Package build failed. Here's the log:\n", $log;
|
|
|
|
|
}
|
2000-04-21 06:40:08 +00:00
|
|
|
|
|
|
|
|
return $this->name."_".$this->version."-".$this->release."_".$this->arch.".deb";
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-22 02:09:13 +00:00
|
|
|
=item cleantree
|
|
|
|
|
|
|
|
|
|
Delete the entire debian/ directory.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub cleantree {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
my $dir=$this->unpacked_tree || die "The package must be unpacked first!";
|
|
|
|
|
|
2001-10-26 18:28:28 +00:00
|
|
|
my %dirtrans=%{$this->dirtrans};
|
|
|
|
|
foreach my $olddir (keys %dirtrans) {
|
|
|
|
|
if (! -e "$dir/$olddir" && -d "$dir/$dirtrans{$olddir}") {
|
|
|
|
|
# Ignore failure.. (should I?)
|
|
|
|
|
my ($dirbase)=$dir=~/(.*)\//;
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("install", "-d", "$dir/$dirbase");
|
|
|
|
|
$this->do("mv", "$dir/$dirtrans{$olddir}", "$dir/$olddir");
|
2001-10-26 18:28:28 +00:00
|
|
|
if (-d "$dir/$dirtrans{$olddir}") {
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("rmdir", "-p", "$dir/$dirtrans{$olddir}");
|
2001-10-26 18:28:28 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
$this->do("rm", "-rf", "$dir/debian");
|
2000-04-22 02:09:13 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 05:08:50 +00:00
|
|
|
=item package
|
|
|
|
|
|
|
|
|
|
Set/get package name.
|
|
|
|
|
|
|
|
|
|
Always returns the packge name in lowercase with all invalid characters
|
2006-12-14 22:35:37 +00:00
|
|
|
rmoved. The name is however, stored unchanged.
|
2000-04-21 05:08:50 +00:00
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub name {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
|
|
|
|
|
# set
|
|
|
|
|
$this->{name} = shift if @_;
|
|
|
|
|
return unless defined wantarray; # optimization
|
|
|
|
|
|
|
|
|
|
# get
|
|
|
|
|
$_=lc($this->{name});
|
|
|
|
|
tr/_/-/;
|
|
|
|
|
s/[^a-z0-9-\.\+]//g;
|
|
|
|
|
return $_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=item version
|
|
|
|
|
|
|
|
|
|
Set/get package version.
|
|
|
|
|
|
|
|
|
|
When the version is set, it will be stripped of any epoch. If there is a
|
|
|
|
|
release, the release will be stripped away and used to set the release
|
|
|
|
|
field as a side effect. Otherwise, the release will be set to 1.
|
|
|
|
|
|
|
|
|
|
More sanitization of the version is done when the field is retrieved, to
|
|
|
|
|
make sure it is a valid debian version field.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub version {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
|
|
|
|
|
# set
|
|
|
|
|
if (@_) {
|
|
|
|
|
my $version=shift;
|
|
|
|
|
if ($version =~ /(.+)-(.+)/) {
|
|
|
|
|
$version=$1;
|
|
|
|
|
$this->release($2);
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$this->release(1);
|
|
|
|
|
}
|
|
|
|
|
# Kill epochs.
|
|
|
|
|
$version=~s/^\d+://;
|
|
|
|
|
|
|
|
|
|
$this->{version}=$version;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# get
|
|
|
|
|
return unless defined wantarray; # optimization
|
|
|
|
|
$_=$this->{version};
|
2012-08-09 14:14:59 -04:00
|
|
|
# Make sure the version contains a digit at the start, as required
|
|
|
|
|
# by dpkg-deb.
|
|
|
|
|
unless (/^[0-9]/) {
|
|
|
|
|
$_="0".$_;
|
|
|
|
|
}
|
2011-11-12 13:12:25 -04:00
|
|
|
# filter out some characters not allowed in debian versions
|
|
|
|
|
s/[^-.+~:A-Za-z0-9]//g; # see lib/dpkg/parsehelp.c parseversion
|
2000-04-21 05:08:50 +00:00
|
|
|
return $_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=item release
|
|
|
|
|
|
|
|
|
|
Set/get package release.
|
|
|
|
|
|
|
|
|
|
Always returns a sanitized release version. The release is however, stored
|
|
|
|
|
unchanged.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub release {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
|
|
|
|
|
# set
|
|
|
|
|
$this->{release} = shift if @_;
|
|
|
|
|
|
|
|
|
|
# get
|
|
|
|
|
return unless defined wantarray; # optimization
|
|
|
|
|
$_=$this->{release};
|
|
|
|
|
# Make sure the release contains digets.
|
|
|
|
|
return $_."-1" unless /[0-9]/;
|
|
|
|
|
return $_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=item description
|
|
|
|
|
|
|
|
|
|
Set/get description
|
|
|
|
|
|
|
|
|
|
Although the description is stored internally unchanged, this will always
|
|
|
|
|
return a sanitized form of it that is compliant with Debian standards.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub description {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
|
|
|
|
|
# set
|
|
|
|
|
$this->{description} = shift if @_;
|
|
|
|
|
|
|
|
|
|
# get
|
|
|
|
|
return unless defined wantarray; # optimization
|
|
|
|
|
my $ret='';
|
|
|
|
|
foreach (split /\n/,$this->{description}) {
|
|
|
|
|
s/\t/ /g; # change tabs to spaces
|
|
|
|
|
s/\s+$//g; # remove trailing whitespace
|
|
|
|
|
$_="." if $_ eq ''; # empty lines become dots
|
|
|
|
|
$ret.=" $_\n";
|
|
|
|
|
}
|
2002-04-01 18:35:19 +00:00
|
|
|
$ret=~s/^\n+//g; # kill leading blank lines
|
|
|
|
|
$ret.=" .\n" if length $ret;
|
2003-11-18 04:21:20 +00:00
|
|
|
$ret.=" (Converted from a ".$this->origformat." package by alien version $Alien::Version.)";
|
2000-04-21 05:08:50 +00:00
|
|
|
return $ret;
|
|
|
|
|
}
|
2000-04-21 02:23:53 +00:00
|
|
|
|
2000-04-21 06:16:26 +00:00
|
|
|
=item date
|
|
|
|
|
|
|
|
|
|
Returns the date, in rfc822 format.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub date {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
|
2007-03-22 21:46:04 +00:00
|
|
|
my $date=$this->runpipe(1, "date -R");
|
2000-04-21 06:16:26 +00:00
|
|
|
chomp $date;
|
|
|
|
|
if (!$date) {
|
2007-03-22 21:46:04 +00:00
|
|
|
die "date -R did not return a valid result.";
|
2000-04-21 06:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $date;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=item email
|
|
|
|
|
|
|
|
|
|
Returns an email address for the current user.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub email {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
|
|
|
|
|
return $ENV{EMAIL} if exists $ENV{EMAIL};
|
|
|
|
|
|
|
|
|
|
my $login = getlogin || (getpwuid($<))[0] || $ENV{USER};
|
2000-05-24 02:30:46 +00:00
|
|
|
my $mailname='';
|
2000-05-22 23:23:32 +00:00
|
|
|
if (open (MAILNAME,"</etc/mailname")) {
|
|
|
|
|
$mailname=<MAILNAME>;
|
2001-03-24 22:20:09 +00:00
|
|
|
if (defined $mailname) {
|
|
|
|
|
chomp $mailname;
|
|
|
|
|
}
|
2000-05-22 23:23:32 +00:00
|
|
|
close MAILNAME;
|
|
|
|
|
}
|
2000-04-21 06:16:26 +00:00
|
|
|
if (!$mailname) {
|
2009-05-29 13:03:17 -04:00
|
|
|
$mailname=$this->runpipe(1, "hostname");
|
2000-04-21 06:16:26 +00:00
|
|
|
chomp $mailname;
|
|
|
|
|
}
|
|
|
|
|
return "$login\@$mailname";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
=item username
|
|
|
|
|
|
|
|
|
|
Returns the user name of the real uid.
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
sub username {
|
|
|
|
|
my $this=shift;
|
|
|
|
|
|
|
|
|
|
my $username;
|
|
|
|
|
my $login = getlogin || (getpwuid($<))[0] || $ENV{USER};
|
|
|
|
|
(undef, undef, undef, undef, undef, undef, $username) = getpwnam($login);
|
|
|
|
|
|
|
|
|
|
# Remove GECOS fields from username.
|
|
|
|
|
$username=~s/,.*//g;
|
|
|
|
|
|
|
|
|
|
# The ultimate fallback.
|
2000-04-21 06:40:08 +00:00
|
|
|
if ($username eq '') {
|
2000-04-21 06:16:26 +00:00
|
|
|
$username=$login;
|
|
|
|
|
}
|
2000-04-21 06:40:08 +00:00
|
|
|
|
|
|
|
|
return $username;
|
2000-04-21 06:16:26 +00:00
|
|
|
}
|
|
|
|
|
|
2012-04-05 13:51:24 -04:00
|
|
|
=item savescript
|
2002-08-25 19:10:56 +00:00
|
|
|
|
2012-04-05 13:51:24 -04:00
|
|
|
Saves script to debian directory.
|
2002-08-25 19:10:56 +00:00
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
2012-04-05 13:51:24 -04:00
|
|
|
sub savescript {
|
2002-08-25 19:10:56 +00:00
|
|
|
my $this=shift;
|
2012-04-05 13:51:24 -04:00
|
|
|
my $script=shift;
|
|
|
|
|
my $data=shift;
|
2002-08-25 19:10:56 +00:00
|
|
|
|
2012-04-05 13:51:24 -04:00
|
|
|
if ($script eq 'postinst') {
|
|
|
|
|
$data=$this->gen_postinst($data);
|
2005-07-19 20:17:34 +00:00
|
|
|
}
|
2012-04-05 13:51:24 -04:00
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
2002-08-25 19:10:56 +00:00
|
|
|
my $owninfo = $this->owninfo;
|
2003-10-15 20:02:38 +00:00
|
|
|
my $modeinfo = $this->modeinfo;
|
2012-04-05 13:51:24 -04:00
|
|
|
return $postinst unless ref $owninfo && %$owninfo;
|
2002-08-25 19:10:56 +00:00
|
|
|
|
|
|
|
|
# If there is no postinst, let's make one up..
|
2011-01-06 13:49:40 -04:00
|
|
|
$postinst="#!/bin/sh\n" unless defined $postinst && length $postinst;
|
2002-08-25 19:10:56 +00:00
|
|
|
|
|
|
|
|
my ($firstline, $rest)=split(/\n/, $postinst, 2);
|
2009-06-08 13:22:30 -04:00
|
|
|
if ($firstline !~ m/^#!\s*\/bin\/(ba)?sh/) {
|
2002-08-25 19:10:56 +00:00
|
|
|
print STDERR "warning: unable to add ownership fixup code to postinst as the postinst is not a shell script!\n";
|
|
|
|
|
return $postinst;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
my $permscript="# alien added permissions fixup code\n";
|
2003-10-15 20:02:38 +00:00
|
|
|
foreach my $file (sort keys %$owninfo) {
|
2002-08-25 19:10:56 +00:00
|
|
|
my $quotedfile=$file;
|
|
|
|
|
$quotedfile=~s/'/'"'"'/g; # no single quotes in single quotes..
|
2003-11-03 21:13:24 +00:00
|
|
|
$permscript.="chown '".$owninfo->{$file}."' '$quotedfile'\n";
|
2003-11-03 21:16:22 +00:00
|
|
|
$permscript.="chmod '".$modeinfo->{$file}."' '$quotedfile'\n"
|
2003-10-15 20:02:38 +00:00
|
|
|
if (defined $modeinfo->{$file});
|
2002-08-25 19:10:56 +00:00
|
|
|
}
|
|
|
|
|
return "$firstline\n$permscript\n$rest";
|
|
|
|
|
}
|
|
|
|
|
|
2009-02-15 19:56:50 -05:00
|
|
|
=back
|
2002-08-25 19:10:56 +00:00
|
|
|
|
2000-04-21 02:23:53 +00:00
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
|
|
|
|
Joey Hess <joey@kitenet.net>
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
|
|
1
|