* LSB package support. It can generate LSB packages (not guarenteed

fully conformant with the LSB), and it can take LSB packages and convert
     them into other formats. Unlike all the other conversions, lsb packages's
     dependancy (on lsb) and their package scripts are preserved in the
     generated packages (when allowed by the target package format). This means
     your distribution will need to have a package named 'lsb' for the result
     to be installable. (Debian will have one soon..)
   * Suggest rpm-lsb, which is the preferred rpm to build lsb packages with.
     Use it if it's present, plain old rpm otherwise.
This commit is contained in:
joey
2002-02-11 19:19:44 +00:00
parent cf29615520
commit ea30cb70c6
10 changed files with 265 additions and 69 deletions

View File

@@ -61,7 +61,8 @@ The package's maintainer.
=item depends
The package's dependancies.
The package's dependancies. Only dependencies that should exist on all
target distributions can be put in here though (ie: lsb).
=item group
@@ -120,6 +121,11 @@ The preinst script of the package.
The prerm script of the package.
=item usescripts
Only use the above scripts fields when generating the package if this is set
to a true value.
=item unpacked_tree
Points to a directory where the package has been unpacked.
@@ -266,6 +272,15 @@ build methods might have on it.
sub cleantree {}
=item revert
This method should ensure that the object is in the same state it was in
before the prep method was called.
=cut
sub revert {}
=item build
This method takes a prepped build tree, and simply builds a package from

View File

@@ -138,7 +138,6 @@ sub scan {
Version => 'version',
Architecture => 'arch',
Maintainer => 'maintainer',
Depends => 'depends',
Section => 'group',
Description => 'summary',
);
@@ -300,11 +299,16 @@ sub prep {
print OUT "\n";
print OUT "Package: ".$this->name."\n";
print OUT "Architecture: ".$this->arch."\n";
print OUT "Depends: \${shlibs:Depends}\n";
if (defined $this->depends) {
print OUT "Depends: ".join(", ", "\${shlibs:Depends}", $this->depends)."\n";
}
else {
print OUT "Depends: \${shlibs:Depends}\n";
}
print OUT "Description: ".$this->summary."\n";
print OUT $this->description."\n";
print OUT " .\n";
print OUT " (Converted from a .".$this->origformat." package by alien.)\n";
print OUT " (Converted from a ".$this->origformat." package by alien.)\n";
close OUT;
# Copyright file.
@@ -381,16 +385,18 @@ EOF
chmod 0755,"$dir/debian/rules";
# Save any scripts.
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;
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;
}
}
my %dirtrans=( # Note: no trailing slahshes on these directory names!
# Move files to FHS-compliant locations, if possible.
'/usr/man' => '/usr/share/man',

128
Alien/Package/Lsb.pm Normal file
View File

@@ -0,0 +1,128 @@
#!/usr/bin/perl -w
=head1 NAME
Alien::Package::Lsb - an object that represents a lsb package
=cut
package Alien::Package::Lsb;
use strict;
use base qw(Alien::Package::Rpm);
=head1 DESCRIPTION
This is an object class that represents a lsb package. It is derived from
Alien::Package::Rpm.
=head1 FIELDS
=over 4
=head1 METHODS
=over 4
=item checkfile
Lsb files are rpm's with a lsb- prefix, that depend on a package called 'lsb'
and nothing else.
=cut
sub checkfile {
my $this=shift;
my $file=shift;
return unless $file =~ m/^lsb-.*\.rpm$/;
my @deps=`LANG=C rpm -qp -R $file`;
return 1 if grep { s/\s+//g; $_ eq 'lsb' } @deps;
return;
}
=item scan
Uses the parent scan method to read the file. lsb is added to the depends.
=cut
sub scan {
my $this=shift;
$this->SUPER::scan(@_);
$this->distribution("Linux Standard Base");
$this->origformat("lsb");
$this->depends("lsb");
# Converting from lsb, so the scripts should be portable and safe.
# Haha.
$this->usescripts(1);
return 1;
}
=item prep
The parent's prep method is used to generate the spec file. First though,
the package's name is munged to make it lsb compliant (sorta) and lsb is added
to its dependencies.
=cut
sub prep {
my $this=shift;
$this->_orig_name($this->name);
if ($this->name !~ /^lsb-/) {
$this->name("lsb-".$this->name);
}
$this->_orig_depends($this->depends);
$this->depends("lsb");
# Always include scripts when generating lsb package.
$this->_orig_usescripts($this->usescripts);
$this->usescripts(1);
$this->SUPER::prep(@_);
}
=item revert
Undo the changes made by prep.
=cut
sub revert {
my $this=shift;
$this->name($this->_orig_name);
$this->depends($this->_orig_depends);
$this->usescripts($this->_orig_usescripts);
$this->SUPER::revert(@_);
}
=item build
Uses the parent's build command. If a lsb-rpm is available, uses it to build
the package.
=cut
sub build {
my $this=shift;
my $buildcmd=shift || 'rpm';
foreach (split(/:/,$ENV{PATH})) {
if (-x "$_/lsb-rpm") {
$buildcmd='lsb-rpm';
last;
}
}
$this->SUPER::build($buildcmd);
}
=back
=head1 AUTHOR
Joey Hess <joey@kitenet.net>
=cut
1

View File

@@ -246,6 +246,7 @@ sub prep {
print OUT "Name: ".$this->name."\n";
print OUT "Version: ".$this->version."\n";
print OUT "Release: ".$this->release."\n";
print OUT "Requires: ".$this->depends."\n" if length $this->depends;
print OUT "Summary: ".$this->summary."\n";
print OUT "Copyright: ".$this->copyright."\n";
print OUT "Distribution: ".$this->distribution."\n";
@@ -254,30 +255,32 @@ sub prep {
print OUT "\%define _rpmdir ../\n"; # write rpm to current directory
print OUT "\%define _rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm\n";
print OUT "\n";
if ($this->preinst) {
print OUT "\%pre\n";
print OUT $this->preinst."\n";
print OUT "\n";
}
if ($this->postinst) {
print OUT "\%post\n";
print OUT $this->postinst."\n";
print OUT "\n";
}
if ($this->prerm) {
print OUT "\%preun\n";
print OUT $this->prerm."\n";
print OUT "\n";
}
if ($this->postun) {
print OUT "\%postun\n";
print OUT $this->postrm."\n";
print OUT "\n";
if ($this->usescripts) {
if ($this->preinst) {
print OUT "\%pre\n";
print OUT $this->preinst."\n";
print OUT "\n";
}
if ($this->postinst) {
print OUT "\%post\n";
print OUT $this->postinst."\n";
print OUT "\n";
}
if ($this->prerm) {
print OUT "\%preun\n";
print OUT $this->prerm."\n";
print OUT "\n";
}
if ($this->postun) {
print OUT "\%postun\n";
print OUT $this->postrm."\n";
print OUT "\n";
}
}
print OUT "\%description\n";
print OUT $this->description."\n";
print OUT "\n";
print OUT "(Converted from a .".$this->origformat." package by alien.)\n";
print OUT "(Converted from a ".$this->origformat." package by alien.)\n";
print OUT "\n";
print OUT "%files\n";
print OUT $filelist;
@@ -302,10 +305,14 @@ sub cleantree {
Build a rpm. If RPMBUILDOPT is set in the environement, the options in
it are passed to rpm on its command line.
An optional parameter, if passed, can be used to specify the program to use
to build the rpm. It defaults to rpm.
=cut
sub build {
my $this=shift;
my $buildcmd=shift || 'rpm';
my $dir=$this->unpacked_tree || die "The package must be unpacked first!";
# Ask rpm how it's set up. We want to know what architecture it
@@ -352,7 +359,7 @@ sub build {
}
$opts.=" $ENV{RPMBUILDOPTS}" if exists $ENV{RPMBUILDOPTS};
my $command="cd $dir; rpm -bb $opts ".$this->name."-".$this->version."-".$this->release.".spec";
my $command="cd $dir; $buildcmd -bb $opts ".$this->name."-".$this->version."-".$this->release.".spec";
my $log=`$command 2>&1`;
if ($?) {
die "Package build failed. Here's the log of the command ($command):\n", $log;

View File

@@ -234,7 +234,7 @@ sub build {
'', # Set up script. TODO
$this->summary,
$this->description,
'', # Depends.
$this->depends,
'', # Provides.
$this->maintainer,
scalar localtime, # Use current date.

View File

@@ -181,18 +181,20 @@ sub prep {
my $dir=$this->unpacked_tree || die "The package must be unpacked first!";
my $install_made=0;
foreach my $script (keys %{scripttrans()}) {
my $data=$this->$script();
my $out=$this->unpacked_tree."/install/".${scripttrans()}{$script};
next if ! defined $data || $data =~ m/^\s*$/;
if (!$install_made) {
mkdir $this->unpacked_tree."/install", 0755;
$install_made=1;
if ($this->usescripts) {
foreach my $script (keys %{scripttrans()}) {
my $data=$this->$script();
my $out=$this->unpacked_tree."/install/".${scripttrans()}{$script};
next if ! defined $data || $data =~ m/^\s*$/;
if (!$install_made) {
mkdir $this->unpacked_tree."/install", 0755;
$install_made=1;
}
open (OUT, ">$out") || die "$out: $!";
print OUT $data;
close OUT;
chmod 0755, $out;
}
open (OUT, ">$out") || die "$out: $!";
print OUT $data;
close OUT;
chmod 0755, $out;
}
}

View File

@@ -2,12 +2,13 @@ Begin3
Title: alien
Version: @version@
Entered-date: 31MAR97
Description: Alien converts Slackware .tgz packages, Red Hat .rpm packages
and Debian .deb packages. It can convert these formats to
either .deb or .rpm. It works only on binary packages.
Keywords: dpkg rpm tgz convert
Author: joey@kite.ml.org
Primary-site: sunsite.unc.edu /pub/Linux/utils/scripts
Description: Alien converts Slackware .tgz packages, Red Hat .rpm packages,
Debian .deb packages, and Stampede .slp packages. It can
convert from any of the formats to any other format. It works
only on binary packages. It also support LSB packages.
Keywords: debian dpkg deb red hat redhat rpm slackware tgz stampede slp convert package LSB
Author: joey@kitenet.net
Primary-site: sunsite.unc.edu /pub/Linux/utils/package
32 alien-@version@.tar.gz
Copying-policy: GPL
End

View File

@@ -11,10 +11,10 @@ alien - Convert or install an alien binary package
=head1 DESCRIPTION
B<alien> is a program that converts between Redhat rpm, Debian deb,
Stampede slp and Slackware tgz file formats. If you want to use a package
from another linux distribution than the one you have installed on your
system, you can use alien to convert it to your preferred package format
and install it.
Stampede slp, Slackware tgz, and Solaris pkg file formats. If you want to
use a package from another linux distribution than the one you have
installed on your system, you can use alien to convert it to your preferred
package format and install it. It also supports LSB packages.
=head1 WARNING
@@ -39,6 +39,22 @@ alien version.
For converting to and from rpm format the Red Hat Package Manager must be
installed.
=item lsb
To convert from lsb packages, the Red Hat Package Manager must be installed.
Unlike the other package formats, alien can handle the depenendencies of
lsb packages if the destination package format supports dependencies. Note
that this means that the package generated from a lsb package will depend on
a package named "lsb" -- your distribution should provide a package by that
name, if it is lsb compliant. The scripts in the lsb package will be converted
by default as well.
To generate lsb packages, the Red Hat Package Manager must be installed,
and alien will use by preference a program named lsb-rpm, if it exists.
No guarantees are made that the generated lsb packages will be fully LSB
compliant, and it's rather unlikely they will unless you build them in the
lsbdev environment.
=item deb
For converting to (but not from) deb format, the gcc, make, debmake,
@@ -136,6 +152,8 @@ scripts might be designed to work on a system unlike your own, and could
cause problems. It is recommended that you examine the scripts by hand
and check to see what they do before using this option.
This is enabled by default when converting from lsb packages.
=item B<-k>, B<--keep-version>
By default, alien adds one to the minor version number of each package it
@@ -230,6 +248,7 @@ use Alien::Package::Rpm;
use Alien::Package::Tgz;
use Alien::Package::Slp;
use Alien::Package::Pkg;
use Alien::Package::Lsb;
# Returns a list of directories to search for patches.
sub patchdirs {
@@ -257,6 +276,7 @@ Usage: alien [options] file [...]
directory.
-r, --to-rpm Generate a RedHat rpm package.
--to-slp Generate a Stampede slp package.
-l, --to-lsb Generate a LSB package.
-t, --to-tgz Generate a Slackware tgz package.
Enables the following option:
--description=<desc> Specify package description.
@@ -279,6 +299,7 @@ my (%destformats, $generate, $install, $single, $scripts, $patchfile,
GetOptions(
"to-deb|d", sub { $destformats{deb}=1 },
"to-rpm|r", sub { $destformats{rpm}=1 },
"to-lsb|l", sub { $destformats{lsb}=1 },
"to-tgz|t", sub { $destformats{tgz}=1 },
"to-slp", sub { $destformats{slp}=1 },
"to-pkg|p", sub { $destformats{pkg}=1 },
@@ -336,7 +357,13 @@ foreach my $file (@ARGV) {
# Figure out what kind of file this is.
my $package;
if (Alien::Package::Rpm->checkfile($file)) {
# Check lsb before rpm, since lsb packages are really just
# glorified rpms.
if (Alien::Package::Lsb->checkfile($file)) {
$package=Alien::Package::Lsb->new(filename => $file);
}
elsif (Alien::Package::Rpm->checkfile($file)) {
$package=Alien::Package::Rpm->new(filename => $file);
}
elsif (Alien::Package::Deb->checkfile($file)) {
@@ -356,13 +383,7 @@ foreach my $file (@ARGV) {
die "Unknown type of package, $file.\n";
}
# Kill scripts from the package, unless they were enabled.
unless (defined $scripts) {
$package->postinst('');
$package->postrm('');
$package->preinst('');
$package->prerm('');
}
$package->usescripts($scripts) unless $package->usescripts;
# Increment release.
unless (defined $keepversion) {
@@ -434,5 +455,7 @@ foreach my $file (@ARGV) {
# Note I don't unlink it. I figure that might annoy
# people, since it was an input file.
}
$package->revert;
}
}

14
debian/changelog vendored
View File

@@ -1,3 +1,17 @@
alien (8.00) unstable; urgency=low
* LSB package support. It can generate LSB packages (not guarenteed
fully conformant with the LSB), and it can take LSB packages and convert
them into other formats. Unlike all the other conversions, lsb packages's
dependancy (on lsb) and their package scripts are preserved in the
generated packages (when allowed by the target package format). This means
your distribution will need to have a package named 'lsb' for the result
to be installable. (Debian will have one soon..)
* Suggest rpm-lsb, which is the preferred rpm to build lsb packages with.
Use it if it's present, plain old rpm otherwise.
-- Joey Hess <joeyh@debian.org> Mon, 11 Feb 2002 12:55:42 -0500
alien (7.32) unstable; urgency=low
* Support ancient (bo-era) debs with upper-case field names. Closes: #130736

10
debian/control vendored
View File

@@ -9,11 +9,11 @@ Package: alien
Architecture: all
Section: admin
Depends: debhelper (>= 3), ${perl:Depends}, rpm (>= 2.4.4-2), dpkg-dev, make, cpio
Suggests: patch, bzip2
Description: Install Red Hat, Stampede, and Slackware Packages with dpkg.
Alien allows you to convert Red Hat, Stampede and Slackware Packages into
Debian packages, which can be installed with dpkg.
Suggests: patch, bzip2, lsb-rpm
Description: Install LSB, Red Hat, Stampede, and Slackware Packages with dpkg.
Alien allows you to convert LSB, Red Hat, Stampede and Slackware Packages
into Debian packages, which can be installed with dpkg.
.
It can also convert into Slackware, Red Hat, and Stampede packages.
It can also generate packages of any of the other formats.
.
This is a tool only suitable for binary packages.