From 0785a47617b287386d97cb5e0546607de3292bf4 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 21 Apr 2000 10:50:35 +0000 Subject: [PATCH] converted --- lib/Fromslp.pm | 120 ------------------------------------------------- 1 file changed, 120 deletions(-) delete mode 100644 lib/Fromslp.pm diff --git a/lib/Fromslp.pm b/lib/Fromslp.pm deleted file mode 100644 index e987ecf..0000000 --- a/lib/Fromslp.pm +++ /dev/null @@ -1,120 +0,0 @@ -#!/usr/bin/perl -# -# Package for converting from a .slp (Stampede) file. - -# Pull in details on the binary footer. -use Slp; - -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}, - )=unpack($slp::footer_packstring,$footer); - - # A simple sanity check. - if (! $fields{SLPKGVERSION} || $fields{SLPKGVERSION} < $slp::footer_version) { - Alien::Error("This is not a V$slp::footer_version or greater Stampede package"); - } - - 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: $!"); - seek SLP,(-1 * $slp::footer_size),2; # position at beginning of footer (2 = seek from EOF) - read SLP,$_,$slp::footer_size; - 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"; - } - - if ($$slp::copyrighttrans{$fields{COPYRIGHT}}) { - $fields{COPYRIGHT}=$$slp::copyrighttrans{$fields{COPYRIGHT}}; - } - else { - Alien::Warning("I don't know what copyright type \"$fields{COPYRIGHT}\" is."); - $fields{COPYRIGHT}="unknown"; - } - - if ($$slp::archtrans{$fields{ARCH}}) { - $fields{ARCH}=$$slp::archtrans{$fields{ARCH}}; - } - else { - Alien::Error("An unknown architecture, \"$fields{ARCH}\" was specified."); - } - - $fields{RELEASE}++ unless $main::keep_version; - $fields{DISTRIBUTION}="Stampede"; - - # Read in the list of all files. - $fields{FILELIST}=undef; - my $fn; - 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"; - } - $fields{FILELIST}.="$fn\n"; - } - - # TODO: read in postinst script. - - return %fields; -} - -# Unpack a slp file. -# They can be compressed in various ways, depending on what is in -# $fields{COMPRESSTYPE}. -sub Unpack { my ($self,$file,%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}."); - } -} - -1