Initial revision

This commit is contained in:
joey
1999-09-05 05:50:40 +00:00
commit ad046046f0
44 changed files with 4582 additions and 0 deletions

67
lib/fromdeb.pl Normal file
View File

@@ -0,0 +1,67 @@
#!/usr/bin/perl
#
# Package for converting from a .deb file.
# Query a deb file for fields, and return a hash of the fields found.
# Pass the filename of the deb file to query.
sub GetFields { my $file=shift;
my %fields;
# Extract the control file from the deb file.
my @control = `ar p $file control.tar.gz | tar Oxzf - control`;
# Parse control file and extract fields.
my $i=0;
while ($i<=$#control) {
$_ = $control[$i];
chomp;
$fields{NAME} = $1 if (/^Package: (.+)/i);
$fields{VERSION} = $1 if (/^Version: (.+)/i);
$fields{ARCH} = $1 if (/^Architecture: (.+)/i);
$fields{MAINTAINER} = $1 if (/^Maintainer: (.+)/i);
$fields{DEPENDS} = $1 if (/^Depends: (.+)/i);
$fields{REQUIRES} = $1 if (/^Requires: (.+)/i);
$fields{GROUP} = $1 if (/^Section: (.+)/i);
if (/^Description: (.+)/i) {
$fields{SUMMARY} = "$1";
$i++;
while (($i<=$#control) && ($control[$i])) {
$control[$i] =~ s/^ //g; #remove leading space
$control[$i] = "\n" if ($control[$i] eq ".\n");
$fields{DESCRIPTION}.=$control[$i];
$i++;
}
$i--;
}
$i++;
}
$fields{COPYRIGHT}="see /usr/doc/$fields{NAME}/copyright";
$fields{GROUP}="unknown" if (!$fields{GROUP});
$fields{DISTRIBUTION}="Debian";
if ($fields{VERSION} =~ /(.+)-(.+)/) {
$fields{VERSION} = $1;
$fields{RELEASE} = $2 + 1;
} else {
$fields{RELEASE} = '1';
}
# Read in the list of conffiles, if any.
$fields{CONFFILES}=`ar p $file control.tar.gz | tar Oxzf - conffiles 2>/dev/null`;
# Read in the list of all files.
# Note that tar doesn't supply a leading `/', so we have to add that.
$fields{FILELIST}=undef;
foreach $fn (`ar p $file data.tar.gz | tar tzf -`) {
$fields{FILELIST}.="/$fn";
}
return %fields;
}
# Handles unpacking of debs.
sub Unpack { my ($file)=@_;
SafeSystem ("(cd ..;ar p $file data.tar.gz) | tar zxpf -","Error unpacking $file\n");
}
1

72
lib/fromrpm.pl Normal file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/perl
#
# Package for converting from a .rpm file.
# Query a rpm file for fields, and return a hash of the fields found.
# Pass the filename of the rpm file to query.
sub GetFields { my $file=shift;
my %fields;
# Use --queryformat to pull out all the fields we need.
foreach $field ('NAME','VERSION','RELEASE','ARCH','CHANGELOGTEXT',
'SUMMARY','DESCRIPTION','COPYRIGHT') {
$_=`rpm -qp $file --queryformat \%{$field}`;
$fields{$field}=$_ if $_ ne '(none)';
}
# Get the conffiles list.
$fields{CONFFILES}=`rpm -qcp $file`;
# Include the output of rpm -qi in the copyright file.
$fields{COPYRIGHT_EXTRA}=`rpm -qpi $file`;
# Sanity check fields.
if (!$fields{SUMMARY}) {
# Older rpms will have no summary, but will have a
# description. We'll take the 1st line out of the
# description, and use it for the summary.
($fields{SUMMARY})=($fields{DESCRIPTION}."\n")=~m/(.*?)\n/m;
# Fallback.
if (!$fields{SUMMARY}) {
$fields{SUMMARY}="Converted RPM package";
}
}
if (!$fields{COPYRIGHT}) {
$fields{COPYRIGHT}="unknown";
}
if (!$fields{DESCRIPTION}) {
$fields{DESCRIPTION}=$fields{SUMMARY};
}
# Convert ARCH into string, if it isn't already a string.
if ($fields{ARCH} eq 1) {
$fields{ARCH}='i386';
}
elsif ($fields{ARCH} eq 2) {
$fields{ARCH}='alpha';
}
elsif ($fields{ARCH} eq 3) {
$fields{ARCH}='sparc';
}
elsif ($fields{ARCH} eq 6) {
$fields{ARCH}='m68k';
}
if (!$fields{RELEASE} || !$fields{VERSION} || !$fields{NAME}) {
Error("Error querying rpm file.");
}
$fields{RELEASE}=$fields{RELEASE}+1;
$fields{DISTRIBUTION}="Red Hat";
return %fields;
}
# Unpack a rpm file.
sub Unpack { my ($file)=@_;
SafeSystem("(cd ..;rpm2cpio $file) | cpio --extract --make-directories --no-absolute-filenames",
"Error unpacking $file\n");
}
1

65
lib/fromtgz.pl Normal file
View File

@@ -0,0 +1,65 @@
#!/usr/bin/perl
#
# Package for converting from a tgz file.
# Query a tgz file for fields, and return a hash of the fields found.
# Pass the filename of the tgz file to query.
sub GetFields { my $file=shift;
my %fields;
# Get basename of the filename.
my ($basename)=('/'.$file)=~m#^/?.*/(.*?)$#;
# Strip out any tar extentions.
$basename=~s/\.(tgz|tar\.gz)$//;
if ($basename=~m/(.*)-(.*)/ ne undef) {
$fields{NAME}=$1;
$fields{VERSION}=$2;
}
else {
$fields{NAME}=$basename;
$fields{VERSION}=1;
}
$fields{ARCH}='i386';
$fields{SUMMARY}='Converted Slackware tgz package';
$fields{DESCRIPTION}=$fields{SUMMARY};
$fields{COPYRIGHT}="unknown";
$fields{RELEASE}=1;
$fields{DISTRIBUTION}="Slackware";
# Now figure out the conffiles. Assume anything in etc/ is a conffile.
# It's a little nasty to do it here, but it's much cleaner than waiting
# until the tar file is unpacked and then doing it.
$fields{CONFFILES}='';
open (FILELIST,"tar zvtf $file | grep etc/ |") || Error("Getting filelist: $!");
while (<FILELIST>) {
# Make sure it's a normal file. This is looking at the
# permissions, and making sure the first character is '-'.
# Ie: -rw-r--r--
if (m:^-:) {
# Strip it down to the filename.
m/^(.*) (.*)$/;
$fields{CONFFILES}.="/$2\n";
}
}
close FILELIST;
# Now get the whole filelist. We have to add leading /'s to the filenames.
$fields{FILELIST}='';
open (FILELIST, "tar ztf $file |");
while (<FILELIST>) {
$fields{FILELIST}.="/$_";
}
close FILELIST;
return %fields;
}
# Handles unpacking of tgz's.
sub Unpack { my ($file)=@_;
SafeSystem ("(cd ..;cat $file) | tar zxpf -","Error unpacking $file\n");
}
1

9
lib/rpm/changelog Normal file
View File

@@ -0,0 +1,9 @@
#PACKAGE# (#VERSION#-#DELTA#) unstable; urgency=low
* Converted from RPM binary format to debian
-- #USERNAME# <#EMAIL#> #DATE#
Local variables:
mode: debian-changelog
End:

11
lib/rpm/control Normal file
View File

@@ -0,0 +1,11 @@
Source: #PACKAGE#
Section: unknown
Priority: extra
Maintainer: #USERNAME# <#EMAIL#>
Standards-Version: 2.1.1.0
Package: #PACKAGE#
Architecture: #ARCHIT#
Depends: ${shlibs:Depends}
Description: Converted RPM package
Not available

6
lib/rpm/copyright Normal file
View File

@@ -0,0 +1,6 @@
This package was debianized by the alien program by converting
a binary RPM Package on #DATE#.
Copyright: Unknown
Information from the binary Package:

9
lib/tgz/changelog Normal file
View File

@@ -0,0 +1,9 @@
#PACKAGE# (#VERSION#-#DELTA#) unstable; urgency=low
* Converted from Slackware .tgz binary format to debian
-- #USERNAME# <#EMAIL#> #DATE#
Local variables:
mode: debian-changelog
End:

11
lib/tgz/control Normal file
View File

@@ -0,0 +1,11 @@
Source: #PACKAGE#
Section: unknown
Priority: extra
Maintainer: #USERNAME# <#EMAIL#>
Standards-Version: 2.1.1.0
Package: #PACKAGE#
Architecture: #ARCHIT#
Depends: ${shlibs:Depends}
Description: Converted Slackware tgz package
Not available

4
lib/tgz/copyright Normal file
View File

@@ -0,0 +1,4 @@
This package was debianized by the alien program by converting
a binary Slackware tgz Package on #DATE#.
Copyright: Unknown

54
lib/tgz/rules Normal file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/make -f
#
# This is a special rules files for handling alien or binary packages
# Christoph Lameter, October 30, 1996
package=#PACKAGE#
debian/build:
$(checkdir)
touch debian/build
clean:
$(checkdir)
-rm -f debian/build
-rm -rf *~ debian/tmp debian/*~ debian/files*
binary-indep: checkroot debian/build
$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package. If there were any they would be
# made here.
binary-arch: checkroot debian/build
$(checkdir)
-rm -rf debian/tmp
# Install binary package
install -d debian/tmp
cp -a `ls | grep -v debian` debian/tmp
#
# If you need to move files around in debian/tmp or do some
# binary patching ... Insert it here
#
debstd $(package)
dpkg-gencontrol
dpkg --build debian/tmp ..
define checkdir
test -f debian/rules
endef
# Below here is fairly generic really
binary: binary-indep binary-arch
build: debian/build
source diff:
@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
checkroot:
$(checkdir)
test root = "`whoami`"
.PHONY: binary binary-arch binary-indep clean checkroot

11
lib/to-deb/rpm/changelog Normal file
View File

@@ -0,0 +1,11 @@
#NAME# (#VERSION#-#RELEASE#) unstable; urgency=low
* Converted from RPM binary format to debian
-- #USERNAME# <#EMAIL#> #DATE#
#CHANGELOGTEXT#
Local variables:
mode: debian-changelog
End:

11
lib/to-deb/rpm/control Normal file
View File

@@ -0,0 +1,11 @@
Source: #NAME#
Section: unknown
Priority: extra
Maintainer: #USERNAME# <#EMAIL#>
Standards-Version: 2.1.1.0
Package: #NAME#
Architecture: #ARCH#
Depends: ${shlibs:Depends}
Description: #SUMMARY#
#DESCRIPTION#

7
lib/to-deb/rpm/copyright Normal file
View File

@@ -0,0 +1,7 @@
This package was debianized by the alien program by converting
a binary RPM Package on #DATE#.
Copyright: #COPYRIGHT#
Information from the binary Package:
#COPYRIGHT_EXTRA#

9
lib/to-deb/tgz/changelog Normal file
View File

@@ -0,0 +1,9 @@
#NAME# (#VERSION#-#RELEASE#) unstable; urgency=low
* Converted from Slackware .tgz binary format to debian
-- #USERNAME# <#EMAIL#> #DATE#
Local variables:
mode: debian-changelog
End:

1
lib/to-deb/tgz/conffiles Normal file
View File

@@ -0,0 +1 @@
#CONFFILES#

11
lib/to-deb/tgz/control Normal file
View File

@@ -0,0 +1,11 @@
Source: #NAME#
Section: unknown
Priority: extra
Maintainer: #USERNAME# <#EMAIL#>
Standards-Version: 2.1.1.0
Package: #NAME#
Architecture: #ARCH#
Depends: ${shlibs:Depends}
Description: Converted Slackware tgz package
Converted Slackware tgz package

4
lib/to-deb/tgz/copyright Normal file
View File

@@ -0,0 +1,4 @@
This package was debianized by the alien program by converting
a binary Slackware tgz Package on #DATE#.
Copyright: Unknown

54
lib/to-deb/tgz/rules Normal file
View File

@@ -0,0 +1,54 @@
#!/usr/bin/make -f
#
# This is a special rules files for handling alien or binary packages
# Christoph Lameter, October 30, 1996
package=#NAME#
debian/build:
$(checkdir)
touch debian/build
clean:
$(checkdir)
-rm -f debian/build
-rm -rf *~ debian/tmp debian/*~ debian/files*
binary-indep: checkroot debian/build
$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package. If there were any they would be
# made here.
binary-arch: checkroot debian/build
$(checkdir)
-rm -rf debian/tmp
# Install binary package
install -d debian/tmp
cp -a `ls | grep -v debian` debian/tmp
#
# If you need to move files around in debian/tmp or do some
# binary patching ... Insert it here
#
debstd
dpkg-gencontrol
dpkg --build debian/tmp ..
define checkdir
test -f debian/rules
endef
# Below here is fairly generic really
binary: binary-indep binary-arch
build: debian/build
source diff:
@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
checkroot:
$(checkdir)
test root = "`whoami`"
.PHONY: binary binary-arch binary-indep clean checkroot

14
lib/to-rpm/deb/spec Normal file
View File

@@ -0,0 +1,14 @@
Buildroot: #BUILDROOT#
Name: #NAME#
Version: #VERSION#
Release: #RELEASE#
Summary: #SUMMARY#
Copyright: #COPYRIGHT#
Distribution: #DISTRIBUTION#
Group: Converted/#DISTRIBUTION#
%description
#DESCRIPTION#
%files
#FILELIST#

86
lib/todeb.pl Normal file
View File

@@ -0,0 +1,86 @@
#!/usr/bin/perl
#
# Package for converting to .deb file.
# Create debian/* files, either from a patch, or automatically.
sub Convert { my ($workdir,%fields)=@_;
if ($generate && !$single) {
SafeSystem("cp -fa $workdir $workdir.orig", "Error creating $workdir.orig");
}
# Make sure package name is all lower case.
$fields{NAME}=lc($fields{NAME});
# Fix up the description field to Debian standards (indented at
# least one space, no empty lines.)
my $description=undef;
foreach $line (split(/\n/,$fields{DESCRIPTION})) {
$line=~s/\t/ /g; # change tabs to spaces.
$line=~s/\s+$//g; # remove trailing whitespace.
if (!$line) { # empty lines
$line=" .";
}
else { # normal lines
$line=" $line";
}
$description.=$line."\n";
}
chomp $description;
$fields{DESCRIPTION}=$description."\n";
# Do the actual conversion here.
mkdir "$fields{NAME}-$fields{VERSION}/debian",0755
|| Error("Unable to make debian directory");
$patchfile=GetPatch($fields{NAME}) if !$patchfile;
if ($patchfile) {
Patch($patchfile,$workdir);
}
else {
AutoDebianize($workdir,%fields);
}
chmod 0755,"$workdir/debian/rules";
# Make the .orig directory if we were instructed to do so.
if ($single) {
print "Directory $workdir prepared.\n";
}
elsif ($generate) {
print "Directories $workdir and $workdir.orig prepared.\n";
}
}
# Fill out templates to create debian/* files.
# Pass it the work directory, and the type of package we are debianizing.
sub AutoDebianize { my ($workdir,%fields)=@_;
Status("Automatic package debianization");
# Generate some more fields we need.
$fields{DATE}=GetDate();
$fields{EMAIL}=GetEmail();
$fields{USERNAME}=GetUserName();
# Fill out all the templates.
foreach $fn (glob("$libdir/to-$desttype/$filetype/*")) {
my $destfn=$fn;
$destfn=~s#^$libdir/to-$desttype/$filetype/##;
FillOutTemplate($fn,"$workdir/debian/$destfn",%fields);
}
}
# Passed the available info about the package in a hash, return the name of
# the debian package that will be made.
sub GetPackageName { my %fields=@_;
return "$fields{NAME}_$fields{VERSION}-$fields{RELEASE}_$fields{ARCH}.deb";
}
# Build the debian package.
sub Build {
SafeSystem("debian/rules binary","Package build failed.\n");
}
# Install the debian package that is passed.
sub Install { my $package=shift;
SafeSystem("dpkg -i $package");
}
1

72
lib/torpm.pl Normal file
View File

@@ -0,0 +1,72 @@
#!/usr/bin/perl
#
# Package for converting to .rpm file.
# Generate the spec file.
sub Convert { my ($workdir,%fields)=@_;
Status("Automatic spec file generation");
# Create some more fields we will need.
my $pwd=`pwd`;
chomp $pwd;
$fields{BUILDROOT}="$pwd/$workdir"; # must be absolute filename.
# Remove directories from the filelist. Place %config in front of files
# that are conffiles.
my @conffiles=split(/\n/,$fields{CONFFILES});
my $filelist;
foreach $fn (split(/\n/,$fields{FILELIST})) {
if ($fn=~m:/$: eq undef) { # not a directory
if (grep(m:^$fn$:,@conffiles)) { # it's a conffile
$filelist.="%config $fn\n";
}
else { # normal file
$filelist.="$fn\n";
}
}
}
$fields{FILELIST}=$filelist;
FillOutTemplate("$libdir/to-$desttype/$filetype/spec",
"$workdir/$fields{NAME}-$fields{VERSION}-$fields{RELEASE}.spec",%fields);
if ($generate) {
print "Directory $workdir prepared.\n";
}
}
# Passed the available info about the package in a hash, return the name of
# the rpm package that will be made.
sub GetPackageName { my %fields=@_;
# Ask rpm how it's set up. We want to know what architecture it will output,
# and where it will place rpms.
my $rpmarch, $rpmdir;
foreach (`rpm --showrc`) {
chomp;
if (/^build arch\s+:\s(.*)$/) {
$rpmarch=$1;
}
elsif (/^rpmdir\s+:\s(.*)$/) {
$rpmdir=$1;
}
}
if (!$rpmarch || !$rpmdir) {
Error("rpm --showrc failed.");
}
return "$rpmdir/$rpmarch/$fields{NAME}-$fields{VERSION}-$fields{RELEASE}.$rpmarch.rpm";
}
# Build a rpm file.
sub Build { my (%fields)=@_;
SafeSystem("rpm -bb $ENV{RPMBUILDOPT} $fields{NAME}-$fields{VERSION}-$fields{RELEASE}.spec",
"Error putting together the RPM package.\n");
}
# Install the passed rpm file.
sub Install { my $package=shift;
SafeSystem("rpm -ivh $ENV{RPMINSTALLOPT} $package");
}
1

27
lib/totgz.pl Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/perl
#
# Package for converting to .tgz file.
sub Convert { my ($workdir,%fields)=@_;
# Nothing to do.
}
# Passed the available info about the package in a hash, return the name of
# the tgz package that will be made.
sub GetPackageName { my %fields=@_;
return "$fields{NAME}.tgz";
}
# Build a tgz file.
sub Build { my (%fields)=@_;
SafeSystem("tar czf ../".GetPackageName(%fields)." .");
}
# Install the passed tgz file.
sub Install { my $package=shift;
# Not yet supported. (I really don't like unpacking tgz files into the
# root directory. :-)
print STDERR "Sorry, installing generated .tgz files in not yet supported.\n";
}
1