2000-04-21 23:24:47 +00:00
|
|
|
#!/usr/bin/perl -w
|
2000-04-21 22:48:23 +00:00
|
|
|
|
|
|
|
|
=head1 NAME
|
|
|
|
|
|
|
|
|
|
alien - Convert or install an alien binary package
|
|
|
|
|
|
|
|
|
|
=head1 SYNOPSIS
|
|
|
|
|
|
|
|
|
|
alien [--to-deb] [--to-rpm] [--to-tgz] [--to-slp] [options] file [...]
|
|
|
|
|
|
|
|
|
|
=head1 DESCRIPTION
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
B<alien> is a program that converts between Red Hat rpm, Debian deb,
|
2002-02-11 19:19:44 +00:00
|
|
|
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
|
2003-05-14 22:14:29 +00:00
|
|
|
installed on your system, you can use B<alien> to convert it to your preferred
|
2002-02-11 19:19:44 +00:00
|
|
|
package format and install it. It also supports LSB packages.
|
2000-04-21 22:48:23 +00:00
|
|
|
|
|
|
|
|
=head1 WARNING
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
Despite the high version number, B<alien> is still (and will probably always
|
2000-04-21 22:48:23 +00:00
|
|
|
be) rather experimental software. It's been under development for many
|
|
|
|
|
years now, but there are still many bugs and limitations.
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
B<alien> should not be used to replace important system packages, like
|
2000-04-21 22:48:23 +00:00
|
|
|
init, libc, or other things that are essential for the functioning of
|
|
|
|
|
your system. Many of these packages are set up differently by the
|
|
|
|
|
different distributions, and packages from the different distributions
|
|
|
|
|
cannot be used interchangeably. In general, if you can't remove a
|
|
|
|
|
package without breaking your system, don't try to replace it with an
|
|
|
|
|
alien version.
|
|
|
|
|
|
|
|
|
|
=head1 PACKAGE FORMAT NOTES
|
|
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
|
|
=item rpm
|
|
|
|
|
|
|
|
|
|
For converting to and from rpm format the Red Hat Package Manager must be
|
|
|
|
|
installed.
|
|
|
|
|
|
2002-02-11 19:19:44 +00:00
|
|
|
=item lsb
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
Unlike the other package formats, B<alien> can handle the depenendencies of
|
2002-02-11 19:19:44 +00:00
|
|
|
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,
|
2003-05-14 22:14:29 +00:00
|
|
|
and B<alien> will use by preference a program named lsb-rpm, if it exists.
|
2002-02-11 19:19:44 +00:00
|
|
|
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.
|
|
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=item deb
|
|
|
|
|
|
|
|
|
|
For converting to (but not from) deb format, the gcc, make, debmake,
|
|
|
|
|
dpkg-dev, and dpkg packages must be installed.
|
|
|
|
|
|
|
|
|
|
=item tgz
|
|
|
|
|
|
|
|
|
|
Note that when converting from the tgz format, B<alien> will simply generate an
|
2000-04-21 23:24:47 +00:00
|
|
|
output package that has the same files in it as are in the tgz file. This
|
|
|
|
|
only works well if the tgz file has precompiled binaries in it in a
|
2003-05-14 22:14:29 +00:00
|
|
|
standard linux directory tree. Do NOT run B<alien> on tar files with source
|
2000-04-21 22:48:23 +00:00
|
|
|
code in them, unless you want this source code to be installed in your root
|
|
|
|
|
directory when you install the package!
|
|
|
|
|
|
2001-10-26 18:28:28 +00:00
|
|
|
=item pkg
|
|
|
|
|
|
|
|
|
|
To manipulate packages in the Solaris pkg format (which is really the SV
|
|
|
|
|
datastream package format), you will need the Solaris pkginfo and pkgtrans
|
|
|
|
|
tools.
|
|
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=head1 OPTIONS
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
B<alien> will convert all the files you pass into it into all the output types
|
2000-04-21 22:48:23 +00:00
|
|
|
you specify. If no output type is specified, it defaults to converting to
|
|
|
|
|
deb format.
|
|
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
|
|
=item file [...]
|
|
|
|
|
|
|
|
|
|
The list of package files to convert.
|
|
|
|
|
|
|
|
|
|
=item B<-d>, B<--to-deb>
|
|
|
|
|
|
|
|
|
|
Make debian packages. This is the default.
|
|
|
|
|
|
|
|
|
|
=item B<-r>, B<--to-rpm>
|
|
|
|
|
|
|
|
|
|
Make rpm packages.
|
|
|
|
|
|
|
|
|
|
=item B<-t>, B<--to-tgz>
|
|
|
|
|
|
|
|
|
|
Make tgz packages.
|
|
|
|
|
|
|
|
|
|
=item B<--to-slp>
|
|
|
|
|
|
|
|
|
|
Make slp packages.
|
|
|
|
|
|
2001-10-26 18:28:28 +00:00
|
|
|
=item B<-p>, B<--to-pkg>
|
|
|
|
|
|
|
|
|
|
Make Solaris pkg packages.
|
|
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=item B<-i>, B<--install>
|
|
|
|
|
|
|
|
|
|
Automatically install each generated package, and remove the package file
|
|
|
|
|
after it has been installed.
|
|
|
|
|
|
|
|
|
|
=item B<-g>, B<--generate>
|
|
|
|
|
|
|
|
|
|
Generate a temporary directory suitable for building a package from, but do
|
|
|
|
|
not actually create the package. This is useful if you want to move files
|
|
|
|
|
around in the package before building it. The package can be built from
|
|
|
|
|
this temporary directory by running "debian/rules binary", if you were creating
|
|
|
|
|
a Debian package, or by running "rpm -bb <packagename>.spec" if you were
|
|
|
|
|
creating a Red Hat package.
|
|
|
|
|
|
|
|
|
|
=item B<-s>, B<--single>
|
|
|
|
|
|
2000-04-22 06:02:51 +00:00
|
|
|
Like B<-g>, but do not generate the packagename.orig directory. This is only
|
2000-04-21 22:48:23 +00:00
|
|
|
useful when you are very low on disk space and are generating a debian
|
|
|
|
|
package.
|
|
|
|
|
|
|
|
|
|
=item B<--patch=>I<patch>
|
|
|
|
|
|
|
|
|
|
Specify the patch to be used instead of automatically looking the patch up
|
|
|
|
|
in B</var/lib/alien>. This has no effect unless a debian package is being
|
|
|
|
|
built.
|
|
|
|
|
|
2002-08-22 16:04:41 +00:00
|
|
|
=item B<--anypatch>
|
|
|
|
|
|
|
|
|
|
Be less strict about which patch file is used, perhaps attempting to use a patch
|
|
|
|
|
file for an older verson of the package. This is not guaranteed to always work;
|
|
|
|
|
older patches may necessarily not work with newer packages.
|
|
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=item B<--nopatch>
|
|
|
|
|
|
|
|
|
|
Do not use any patch files.
|
|
|
|
|
|
|
|
|
|
=item B<--description=>I<desc>
|
|
|
|
|
|
|
|
|
|
Specifiy a description for the package. This only has an effect when
|
|
|
|
|
converting from the tgz package format, which lacks descriptions.
|
|
|
|
|
|
2002-10-21 03:13:12 +00:00
|
|
|
=item B<--version=>I<version>
|
|
|
|
|
|
|
|
|
|
Specifiy a version for the package. This only has an effect when
|
|
|
|
|
converting from the tgz package format, which may lack version
|
|
|
|
|
information.
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
Note that without an argument, this displays the version of B<alien> instead.
|
2002-10-21 03:13:12 +00:00
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=item B<-c>, B<--scripts>
|
|
|
|
|
|
|
|
|
|
Try to convert the scripts that are meant to be run when the
|
|
|
|
|
package is installed and removed. Use this with caution, becuase these
|
|
|
|
|
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.
|
|
|
|
|
|
2002-02-11 19:19:44 +00:00
|
|
|
This is enabled by default when converting from lsb packages.
|
|
|
|
|
|
2002-05-03 00:12:13 +00:00
|
|
|
=item B<-T>, B<--test>
|
|
|
|
|
|
|
|
|
|
Test the generated packages. Currently this is only supported for debian
|
|
|
|
|
packages, which, if lintian is installed, will be tested with lintian and
|
|
|
|
|
lintian's output displayed.
|
|
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=item B<-k>, B<--keep-version>
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
By default, B<alien> adds one to the minor version number of each package it
|
|
|
|
|
converts. If this option is given, B<alien> will not do this.
|
2000-04-21 22:48:23 +00:00
|
|
|
|
2002-04-22 02:24:42 +00:00
|
|
|
=item B<--fixperms>
|
|
|
|
|
|
|
|
|
|
Sanitize all file owners and permissions when building a deb. This may be
|
|
|
|
|
useful if the original package is a mess. On the other hand, it may break
|
|
|
|
|
some things to mess with their permissions and owners to the degree this does,
|
|
|
|
|
so it defaults to off. This can only be used when converting to debian
|
|
|
|
|
packages.
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
=item B<-v>, B<--verbose>
|
|
|
|
|
|
|
|
|
|
Be verbose: Display each command B<alien> runs in the process of converting a
|
|
|
|
|
package.
|
|
|
|
|
|
|
|
|
|
=item B<--veryverbose>
|
|
|
|
|
|
|
|
|
|
Be verbose as with --verbose, but also display the output of each command
|
|
|
|
|
run. Some commands may generate a lot of output.
|
|
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=item B<-h>, B<--help>
|
|
|
|
|
|
|
|
|
|
Display a short usage summary.
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
=item B<-V>, B<--version>
|
|
|
|
|
|
|
|
|
|
Display the version of B<alien>.
|
|
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=head1 EXAMPLES
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
Here are some examples of the use of B<alien>:
|
2000-04-21 22:48:23 +00:00
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
|
|
=item alien --to-deb package.rpm
|
|
|
|
|
|
|
|
|
|
Convert the package.rpm into a package.deb
|
|
|
|
|
|
|
|
|
|
=item alien --to-rpm package.deb
|
|
|
|
|
|
|
|
|
|
Convert the package.deb into a package.rpm
|
|
|
|
|
|
|
|
|
|
=item alien -i package.rpm
|
|
|
|
|
|
|
|
|
|
Convert the package.rpm into a package.deb (converting to a .deb package is
|
|
|
|
|
default, so you need not specify --to-deb), and install the generated
|
|
|
|
|
package.
|
|
|
|
|
|
|
|
|
|
=item alien --to-deb --to-rpm --to-tgz --to-slp foo.deb bar.rpm baz.tgz
|
|
|
|
|
|
|
|
|
|
Creates 9 new packages. When it is done, foo bar and baz are available in
|
|
|
|
|
all 4 package formats.
|
|
|
|
|
|
|
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=head1 ENVIRONMENT
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
B<alien> recognizes the following environemnt variables:
|
2000-04-21 22:48:23 +00:00
|
|
|
|
|
|
|
|
=over 4
|
|
|
|
|
|
|
|
|
|
=item RPMBUILDOPT
|
|
|
|
|
|
|
|
|
|
Options to pass to rpm when it is building a package.
|
|
|
|
|
|
|
|
|
|
=item RPMINSTALLOPT
|
|
|
|
|
|
|
|
|
|
Options to pass to rpm when it is installing a package.
|
|
|
|
|
|
2001-10-26 18:28:28 +00:00
|
|
|
=item EMAIL
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
If set, B<alien> assumes this is your email address. Email addresses are
|
|
|
|
|
included in generated debian packages.
|
2001-10-26 18:28:28 +00:00
|
|
|
|
2000-04-21 22:48:23 +00:00
|
|
|
=back
|
|
|
|
|
|
|
|
|
|
=head1 NOTES
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
When using B<alien> to convert a tgz package, all files in /etc in are assumed
|
2001-10-26 18:28:28 +00:00
|
|
|
to be configuration files.
|
2000-04-21 22:48:23 +00:00
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
If B<alien> is not run as root, the files in the generated package will have
|
2000-04-21 22:48:23 +00:00
|
|
|
incorrect owners and permissions.
|
|
|
|
|
|
|
|
|
|
=head1 AUTHOR
|
|
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
B<alien> was written by Christoph Lameter, B<<clameter@debian.org>>.
|
2000-04-21 22:48:23 +00:00
|
|
|
|
2003-05-14 22:14:29 +00:00
|
|
|
deb to rpm conversion code was taken from the martian program by
|
2000-04-21 23:24:47 +00:00
|
|
|
Randolph Chung, B<<tausq@debian.org>>.
|
2000-04-21 22:48:23 +00:00
|
|
|
|
2001-10-26 18:28:28 +00:00
|
|
|
The Solaris pkg code was written by Mark A. Hershberger B<<mah@everybody.org>>.
|
|
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
Alien has been extensively rewritten (3 times) and is now maintained by
|
|
|
|
|
Joey Hess, B<<joeyh@debian.org>>.
|
2000-04-21 22:48:23 +00:00
|
|
|
|
|
|
|
|
=head1 COPYRIGHT
|
|
|
|
|
|
2002-09-20 19:01:39 +00:00
|
|
|
Alien may be copied and modified under the terms of the GNU General Public
|
2000-04-21 22:48:23 +00:00
|
|
|
License.
|
|
|
|
|
|
|
|
|
|
=cut
|
1999-11-18 21:43:35 +00:00
|
|
|
|
|
|
|
|
use strict;
|
2000-04-22 23:32:45 +00:00
|
|
|
use lib '.'; # For debugging, removed by Makefile.
|
1999-11-18 21:43:35 +00:00
|
|
|
use Getopt::Long;
|
2000-04-21 23:24:47 +00:00
|
|
|
use Alien::Package::Deb;
|
|
|
|
|
use Alien::Package::Rpm;
|
|
|
|
|
use Alien::Package::Tgz;
|
|
|
|
|
use Alien::Package::Slp;
|
2001-10-26 18:28:28 +00:00
|
|
|
use Alien::Package::Pkg;
|
2002-02-11 19:19:44 +00:00
|
|
|
use Alien::Package::Lsb;
|
2000-04-21 23:24:47 +00:00
|
|
|
|
|
|
|
|
# Returns a list of directories to search for patches.
|
|
|
|
|
sub patchdirs {
|
2000-11-16 20:03:36 +00:00
|
|
|
return '/var/lib/alien',"/usr/share/alien/patches";
|
2000-04-21 23:24:47 +00:00
|
|
|
}
|
1999-11-18 21:43:35 +00:00
|
|
|
|
|
|
|
|
# Display alien's version number.
|
2000-04-21 23:24:47 +00:00
|
|
|
sub version {
|
2000-11-16 20:03:36 +00:00
|
|
|
my $version_string='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE
|
1999-11-18 21:43:35 +00:00
|
|
|
print "Alien version $version_string\n";
|
2000-04-21 23:24:47 +00:00
|
|
|
exit;
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Display usage help.
|
2000-04-21 23:24:47 +00:00
|
|
|
sub usage {
|
|
|
|
|
print STDERR <<EOF;
|
|
|
|
|
Usage: alien [options] file [...]
|
1999-11-18 21:43:35 +00:00
|
|
|
file [...] Package file or files to convert.
|
2000-04-21 23:24:47 +00:00
|
|
|
-d, --to-deb Generate a Debian deb package (default).
|
2003-05-14 22:14:29 +00:00
|
|
|
Enables these options:
|
1999-11-18 21:43:35 +00:00
|
|
|
--patch=<patch> Specify patch file to use instead of automatically
|
|
|
|
|
looking for patch in /var/lib/alien.
|
|
|
|
|
--nopatch Do not use patches.
|
2002-08-22 16:04:41 +00:00
|
|
|
--anypatch Use even old version os patches.
|
2000-04-21 23:24:47 +00:00
|
|
|
--single Like --generate, but do not create .orig
|
|
|
|
|
directory.
|
2002-04-22 02:24:42 +00:00
|
|
|
--fixperms Munge/fix permissions and owners.
|
2002-05-03 00:12:13 +00:00
|
|
|
--test Test generated packages with lintian.
|
2003-05-14 22:14:29 +00:00
|
|
|
-r, --to-rpm Generate a Red Hat rpm package.
|
2000-04-21 23:24:47 +00:00
|
|
|
--to-slp Generate a Stampede slp package.
|
2002-02-11 19:19:44 +00:00
|
|
|
-l, --to-lsb Generate a LSB package.
|
1999-11-18 21:43:35 +00:00
|
|
|
-t, --to-tgz Generate a Slackware tgz package.
|
2003-05-14 22:14:29 +00:00
|
|
|
Enables these options:
|
2000-04-21 23:24:47 +00:00
|
|
|
--description=<desc> Specify package description.
|
2002-10-21 03:13:12 +00:00
|
|
|
--version=<version> Specify package version.
|
2001-10-26 18:28:28 +00:00
|
|
|
-p, --to-pkg Generate a Solaris pkg package.
|
1999-11-18 21:43:35 +00:00
|
|
|
-i, --install Install generated package.
|
|
|
|
|
-g, --generate Unpack, but do not generate a new package.
|
|
|
|
|
-c, --scripts Include scripts in package.
|
2003-05-14 22:14:29 +00:00
|
|
|
-v, --verbose Display each command alien runs.
|
|
|
|
|
--veryverbose Be verbose, and also display output of run commands.
|
1999-11-18 21:43:35 +00:00
|
|
|
-k, --keep-version Do not change version of generated package.
|
|
|
|
|
-h, --help Display this help message.
|
2003-05-14 22:14:29 +00:00
|
|
|
-V, --version Display alien's version number.
|
1999-11-18 21:43:35 +00:00
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
EOF
|
|
|
|
|
exit 1;
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
# Start by processing the parameters.
|
|
|
|
|
my (%destformats, $generate, $install, $single, $scripts, $patchfile,
|
2002-10-21 03:13:12 +00:00
|
|
|
$nopatch, $tgzdescription, $tgzversion, $keepversion, $fixperms, $test,
|
|
|
|
|
$anypatch);
|
2000-04-21 23:24:47 +00:00
|
|
|
|
2002-07-07 20:43:48 +00:00
|
|
|
# Bundling is nice anyway, and it is required or Getopt::Long will confuse
|
|
|
|
|
# -T and -t.
|
|
|
|
|
Getopt::Long::Configure("bundling");
|
|
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
GetOptions(
|
2003-05-14 22:14:29 +00:00
|
|
|
"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 },
|
|
|
|
|
"test|T" => \$test,
|
|
|
|
|
"generate|g" => \$generate,
|
|
|
|
|
"install|i" => \$install,
|
|
|
|
|
"single|s" => sub { $single=1; $generate=1 },
|
|
|
|
|
"scripts|c" => \$scripts,
|
|
|
|
|
"patch=s" => \$patchfile,
|
|
|
|
|
"nopatch" => \$nopatch,
|
|
|
|
|
"anypatch" => \$anypatch,
|
|
|
|
|
"description=s" => \$tgzdescription,
|
|
|
|
|
"V" => \&version,
|
|
|
|
|
"version:s" => sub { length $_[1] ? $tgzversion=$_[1] : version() },
|
|
|
|
|
"verbose|v" => \$Alien::Package::verbose,
|
|
|
|
|
"veryverbose" => sub { $Alien::Package::verbose=2 },
|
|
|
|
|
"keep-version|k" => \$keepversion,
|
|
|
|
|
"fixperms" => \$fixperms,
|
|
|
|
|
"help|h" => \&usage,
|
2000-04-21 23:24:47 +00:00
|
|
|
) || usage();
|
|
|
|
|
|
|
|
|
|
# Default to deb conversion.
|
|
|
|
|
if (! %destformats) {
|
|
|
|
|
$destformats{deb}=1;
|
|
|
|
|
}
|
1999-11-18 21:43:35 +00:00
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
# A few sanity checks.
|
2000-04-22 01:58:31 +00:00
|
|
|
if (($generate || $single) && $install) {
|
|
|
|
|
die "You can not use --generate or --single with --install.\n";
|
|
|
|
|
}
|
|
|
|
|
if (($generate || $single) && keys %destformats > 1) {
|
2000-04-22 02:09:13 +00:00
|
|
|
die "--generate and --single may only be used when converting to a single format.\n";
|
2000-04-22 01:58:31 +00:00
|
|
|
}
|
2000-04-21 23:24:47 +00:00
|
|
|
if ($patchfile && ! -f $patchfile) {
|
|
|
|
|
die "Specified patch file, \"$patchfile\" cannot be found.\n";
|
|
|
|
|
}
|
|
|
|
|
if ($patchfile && $nopatch) {
|
|
|
|
|
die "The options --nopatch and --patchfile cannot be used together.\n";
|
|
|
|
|
}
|
|
|
|
|
unless (@ARGV) {
|
|
|
|
|
print STDERR "You must specify a file to convert.\n\n";
|
|
|
|
|
usage();
|
|
|
|
|
}
|
1999-11-18 21:43:35 +00:00
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
# Check alien's working anvironment.
|
|
|
|
|
if (! -w '.') {
|
2000-04-22 02:09:13 +00:00
|
|
|
die("Cannot write to current directory. Try moving to /tmp and re-running alien.\n");
|
2000-04-21 23:24:47 +00:00
|
|
|
}
|
2002-07-09 00:54:38 +00:00
|
|
|
if ($> != 0) {
|
2000-04-21 23:24:47 +00:00
|
|
|
if ($destformats{deb} && ! $generate && ! $single) {
|
2000-04-22 02:09:13 +00:00
|
|
|
die "Must run as root to convert to deb format (or you may use fakeroot).\n";
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
2000-04-21 23:24:47 +00:00
|
|
|
print STDERR "Warning: alien is not running as root!\n";
|
2000-04-22 00:56:50 +00:00
|
|
|
print STDERR "Ownerships of files in the generated packages will probably be messed up.\n";
|
2000-04-21 23:24:47 +00:00
|
|
|
}
|
1999-11-18 21:43:35 +00:00
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
foreach my $file (@ARGV) {
|
|
|
|
|
if (! -f $file) {
|
|
|
|
|
die "File \"$file\" not found.\n";
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
# Figure out what kind of file this is.
|
|
|
|
|
my $package;
|
2002-02-11 19:19:44 +00:00
|
|
|
|
|
|
|
|
# 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)) {
|
2000-04-21 23:24:47 +00:00
|
|
|
$package=Alien::Package::Rpm->new(filename => $file);
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
2000-04-21 23:24:47 +00:00
|
|
|
elsif (Alien::Package::Deb->checkfile($file)) {
|
|
|
|
|
$package=Alien::Package::Deb->new(filename => $file);
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
2000-04-21 23:24:47 +00:00
|
|
|
elsif (Alien::Package::Tgz->checkfile($file)) {
|
|
|
|
|
$package=Alien::Package::Tgz->new(filename => $file);
|
2000-04-22 00:56:50 +00:00
|
|
|
$package->description($tgzdescription) if defined $tgzdescription;
|
2002-10-21 03:13:12 +00:00
|
|
|
$package->version($tgzversion) if defined $tgzversion;
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
2000-04-21 23:24:47 +00:00
|
|
|
elsif (Alien::Package::Slp->checkfile($file)) {
|
|
|
|
|
$package=Alien::Package::Slp->new(filename => $file);
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
2001-10-26 18:28:28 +00:00
|
|
|
elsif (Alien::Package::Pkg->checkfile($file)) {
|
|
|
|
|
$package=Alien::Package::Pkg->new(filename => $file);
|
|
|
|
|
}
|
1999-11-18 21:43:35 +00:00
|
|
|
else {
|
2000-04-21 23:24:47 +00:00
|
|
|
die "Unknown type of package, $file.\n";
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
|
|
|
|
|
2002-02-11 19:19:44 +00:00
|
|
|
$package->usescripts($scripts) unless $package->usescripts;
|
2000-04-21 23:30:38 +00:00
|
|
|
|
2000-04-22 00:56:50 +00:00
|
|
|
# Increment release.
|
|
|
|
|
unless (defined $keepversion) {
|
2000-05-11 22:48:33 +00:00
|
|
|
$^W=0; # Shut of possible "is not numeric" warning.
|
2000-04-22 00:56:50 +00:00
|
|
|
$package->release($package->release + 1);
|
2000-05-11 22:48:33 +00:00
|
|
|
$^W=1; # Re-enable warnings.
|
2000-04-21 23:30:38 +00:00
|
|
|
}
|
|
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
foreach my $format (keys %destformats) {
|
|
|
|
|
# Skip conversion if package is already the correct format.
|
|
|
|
|
if ($package->origformat ne $format) {
|
|
|
|
|
# Only unpack once.
|
2000-04-22 02:09:13 +00:00
|
|
|
if ($package->unpacked_tree) {
|
|
|
|
|
$package->cleantree;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
$package->unpack;
|
|
|
|
|
}
|
2000-04-21 23:24:47 +00:00
|
|
|
|
|
|
|
|
# Mutate package into desired format.
|
|
|
|
|
bless($package, "Alien::Package::".ucfirst($format));
|
2000-04-21 23:30:38 +00:00
|
|
|
|
2000-04-22 04:52:41 +00:00
|
|
|
# Make .orig.tar.gz directory?
|
2000-04-22 01:47:39 +00:00
|
|
|
if ($format eq 'deb' && ! $single && $generate) {
|
|
|
|
|
# Make .orig.tar.gz directory.
|
2003-05-14 22:14:29 +00:00
|
|
|
Alien::Package->do("cp", "-fa", "--", $package->unpacked_tree, $package->unpacked_tree.".orig")
|
2000-09-11 23:27:32 +00:00
|
|
|
or die "cp -fa failed";
|
2000-04-22 01:47:39 +00:00
|
|
|
}
|
2000-04-22 04:52:41 +00:00
|
|
|
|
|
|
|
|
# See if a patch file should be used.
|
|
|
|
|
if ($format eq 'deb' && ! $nopatch) {
|
|
|
|
|
if (defined $patchfile) {
|
|
|
|
|
$package->patchfile($patchfile)
|
|
|
|
|
}
|
|
|
|
|
else {
|
2002-08-22 16:04:41 +00:00
|
|
|
$package->patchfile($package->getpatch($anypatch, patchdirs()));
|
2000-04-22 04:52:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
2002-04-22 02:24:42 +00:00
|
|
|
|
|
|
|
|
$package->fixperms($fixperms);
|
|
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
$package->prep;
|
2000-04-22 01:47:39 +00:00
|
|
|
|
|
|
|
|
# If generating build tree only, stop here with message.
|
|
|
|
|
if ($generate) {
|
|
|
|
|
if ($format eq 'deb' && ! $single) {
|
|
|
|
|
print "Directories ".$package->unpacked_tree." and ".$package->unpacked_tree.".orig prepared.\n"
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
print "Directory ".$package->unpacked_tree." prepared.\n";
|
|
|
|
|
}
|
2000-04-22 02:09:13 +00:00
|
|
|
# Make sure $package does not wipe out the
|
2000-04-22 01:47:39 +00:00
|
|
|
# directory when it is destroyed.
|
|
|
|
|
$package->unpacked_tree('');
|
|
|
|
|
exit;
|
|
|
|
|
}
|
|
|
|
|
|
2000-04-21 23:24:47 +00:00
|
|
|
my $newfile=$package->build;
|
2002-05-03 00:12:13 +00:00
|
|
|
if ($test) {
|
|
|
|
|
my @results = $package->test($newfile);
|
|
|
|
|
if (@results) {
|
|
|
|
|
print "Test results:\n";
|
|
|
|
|
print "\t$_\n" foreach @results;
|
|
|
|
|
}
|
|
|
|
|
}
|
2000-04-21 23:24:47 +00:00
|
|
|
if ($install) {
|
|
|
|
|
$package->install($newfile);
|
|
|
|
|
unlink $newfile;
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
# Tell them where the package ended up.
|
|
|
|
|
print "$newfile generated\n";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
elsif ($install) {
|
|
|
|
|
# Don't convert the package, but do install it.
|
|
|
|
|
$package->install($file);
|
|
|
|
|
# Note I don't unlink it. I figure that might annoy
|
|
|
|
|
# people, since it was an input file.
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
2002-02-11 19:19:44 +00:00
|
|
|
|
|
|
|
|
$package->revert;
|
1999-11-18 21:43:35 +00:00
|
|
|
}
|
|
|
|
|
}
|