1999-09-05 06:03:10 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
#
|
|
|
|
|
# Package for converting from a .slp (Stampede) file.
|
|
|
|
|
|
1999-12-01 21:57:02 +00:00
|
|
|
# Pull in details on the binary footer.
|
|
|
|
|
use Slp;
|
|
|
|
|
|
1999-09-05 06:03:10 +00:00
|
|
|
package From::slp;
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
|
|
# Pass it a chunk of footer, it will attempt a decode and spit back the result
|
|
|
|
|
# in a hash, %fields.
|
|
|
|
|
sub DecodeFooter { my $footer=shift;
|
|
|
|
|
my %fields;
|
|
|
|
|
|
|
|
|
|
($fields{CONFFILES},
|
|
|
|
|
$fields{PRIORITY},
|
|
|
|
|
$fields{COMPRESSTYPE},
|
|
|
|
|
$fields{RELEASE},
|
|
|
|
|
$fields{COPYRIGHT},
|
|
|
|
|
$fields{CONFLICTS},
|
|
|
|
|
$fields{SETUPSCRIPT},
|
|
|
|
|
$fields{SUMMARY},
|
|
|
|
|
$fields{DESCRIPTION},
|
|
|
|
|
$fields{DEPENDS},
|
|
|
|
|
$fields{PROVIDES},
|
|
|
|
|
$fields{AUTHOR},
|
|
|
|
|
$fields{DATE},
|
|
|
|
|
$fields{COMPILER},
|
|
|
|
|
$fields{VERSION},
|
|
|
|
|
$fields{NAME},
|
|
|
|
|
$fields{ARCH},
|
|
|
|
|
$fields{GROUP},
|
|
|
|
|
$fields{SLPKGVERSION},
|
1999-12-01 21:57:02 +00:00
|
|
|
)=unpack($slp::footer_packstring,$footer);
|
1999-09-05 06:03:10 +00:00
|
|
|
|
|
|
|
|
# A simple sanity check.
|
1999-12-01 21:57:02 +00:00
|
|
|
if (! $fields{SLPKGVERSION} || $fields{SLPKGVERSION} < $slp::footer_version) {
|
|
|
|
|
Alien::Error("This is not a V$slp::footer_version or greater Stampede package");
|
1999-09-05 06:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return %fields;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Pass it a filename of a .slp file, it will pull out a footer and return it
|
|
|
|
|
# in a scalar.
|
|
|
|
|
sub GetFooter { my ($filename)=@_;
|
|
|
|
|
open (SLP,"<$filename") || Alien::Error("unable to read $filename: $!");
|
1999-12-01 21:57:02 +00:00
|
|
|
seek SLP,(-1 * $slp::footer_size),2; # position at beginning of footer (2 = seek from EOF)
|
|
|
|
|
read SLP,$_,$slp::footer_size;
|
1999-09-05 06:03:10 +00:00
|
|
|
close SLP;
|
|
|
|
|
return $_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Query a slp file for fields, and return a hash of the fields found.
|
|
|
|
|
# Pass the filename of the slp file to query.
|
|
|
|
|
sub GetFields { my ($self,$file)=@_;
|
|
|
|
|
my %fields=DecodeFooter(GetFooter($file));
|
|
|
|
|
|
|
|
|
|
# Massage the fields into appropriate formats.
|
|
|
|
|
if ($fields{CONFFILES}) {
|
|
|
|
|
$fields{CONFFILES}=~s/:/\n/g;
|
|
|
|
|
$fields{CONFFILES}.="\n";
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 21:57:02 +00:00
|
|
|
if ($$slp::copyrighttrans{$fields{COPYRIGHT}}) {
|
|
|
|
|
$fields{COPYRIGHT}=$$slp::copyrighttrans{$fields{COPYRIGHT}};
|
1999-09-05 06:03:10 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
Alien::Warning("I don't know what copyright type \"$fields{COPYRIGHT}\" is.");
|
|
|
|
|
$fields{COPYRIGHT}="unknown";
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-01 21:57:02 +00:00
|
|
|
if ($$slp::archtrans{$fields{ARCH}}) {
|
|
|
|
|
$fields{ARCH}=$$slp::archtrans{$fields{ARCH}};
|
1999-09-05 06:03:10 +00:00
|
|
|
}
|
|
|
|
|
else {
|
1999-12-01 21:57:02 +00:00
|
|
|
Alien::Error("An unknown architecture, \"$fields{ARCH}\" was specified.");
|
1999-09-05 06:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$fields{RELEASE}++ unless $main::keep_version;
|
|
|
|
|
$fields{DISTRIBUTION}="Stampede";
|
|
|
|
|
|
|
|
|
|
# Read in the list of all files.
|
|
|
|
|
$fields{FILELIST}=undef;
|
|
|
|
|
my $fn;
|
1999-12-01 21:57:02 +00:00
|
|
|
foreach $fn (`bzip2 -d < $file | tar -tf -`) {
|
|
|
|
|
# They may have a leading "." we don't want.
|
|
|
|
|
$fn=~s:^\./:/:;
|
|
|
|
|
# Ensure there is always a leading '/'.
|
|
|
|
|
if ($fn=~m:^/: eq undef) {
|
|
|
|
|
$fn="/$fn";
|
|
|
|
|
}
|
1999-09-05 06:03:10 +00:00
|
|
|
$fields{FILELIST}.="$fn\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# TODO: read in postinst script.
|
|
|
|
|
|
|
|
|
|
return %fields;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# Unpack a slp file.
|
1999-12-01 21:57:02 +00:00
|
|
|
# They can be compressed in various ways, depending on what is in
|
|
|
|
|
# $fields{COMPRESSTYPE}.
|
|
|
|
|
sub Unpack { my ($self,$file,$nopatch,%fields)=@_;
|
|
|
|
|
if ($fields{COMPRESSTYPE} eq 0) {
|
|
|
|
|
Alien::SafeSystem ("(cd ..;cat $file) | bzip2 -d | tar xpf -","Error unpacking $file\n");
|
|
|
|
|
}
|
|
|
|
|
elsif ($fields{COMPRESSTYPE} eq 1) {
|
|
|
|
|
# .gz
|
|
|
|
|
Alien::SafeSystem ("(cd ..;cat $file) | tar zxpf -","Error unpacking $file\n");
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
# Seems .zip might be a possibility, but I have no way of testing it.
|
|
|
|
|
Alien::Error("This packages uses an unknown compression type, $fields{COMPRESSTYPE}.");
|
|
|
|
|
}
|
1999-09-05 06:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
1
|