From dafcd16174f824eb3e0a4e84da371c6e5570c1b8 Mon Sep 17 00:00:00 2001 From: joey Date: Wed, 1 Dec 1999 21:57:02 +0000 Subject: [PATCH] * Fixed problem with relocatable packages, and probably several other unrelated problems that were introduced last version. --- debian/changelog | 7 ++++ debian/control | 2 +- lib/Fromrpm.pm | 21 +++++------- lib/Fromslp.pm | 87 +++++++++++++++++++----------------------------- lib/Fromtgz.pm | 10 +++--- 5 files changed, 56 insertions(+), 71 deletions(-) diff --git a/debian/changelog b/debian/changelog index 854894a..b3d51bb 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +alien (6.50) unstable; urgency=low + + * Fixed problem with relocatable packages, and probably several other + unrelated problems that were introduced last version. + + -- Joey Hess Wed, 1 Dec 1999 13:52:55 -0800 + alien (6.49) unstable; urgency=low * Removed an obsolete note from the man page. diff --git a/debian/control b/debian/control index c39b711..43023ac 100644 --- a/debian/control +++ b/debian/control @@ -2,7 +2,7 @@ Source: alien Section: admin Priority: extra Maintainer: Joey Hess -Standards-Version: 3.1.0.0 +Standards-Version: 3.1.1.0 Package: alien Architecture: all diff --git a/lib/Fromrpm.pm b/lib/Fromrpm.pm index 30aa38c..f181581 100644 --- a/lib/Fromrpm.pm +++ b/lib/Fromrpm.pm @@ -38,10 +38,6 @@ sub GetFields { my ($self,$file)=@_; $fields{$fieldtrans{$field}}=$_ if $_ ne '(none)'; } - # DEFAULTPREFIX is special because it only exists in old versions of rpm. - $_=`rpm -qp $file --queryformat \%{PREFIXES} 2>/dev/null`; - $fields{PREFIXES}=$_ if $_ ne '' && $_ ne '(none)'; - if ($main::scripts) { # Fix up the scripts - they are always shell scripts, so make them so. foreach $field ('PREINST','POSTINST','PRERM','POSTRM') { @@ -116,20 +112,21 @@ sub GetFields { my ($self,$file)=@_; } # Unpack a rpm file. -sub Unpack { my ($self,$file,%fields)=@_; +sub Unpack { my ($self,$file,$nopatch,%fields)=@_; Alien::SafeSystem("(cd ..;rpm2cpio $file) | cpio --extract --make-directories --no-absolute-filenames --preserve-modification-time", "Error unpacking $file\n"); - # If the package is relocatable. We'd like to move it to be under the - # PREFIXES directory. However, it's possible that that directory is in the - # package - it seems some rpm's are marked as relocatable and unpack already - # in the directory they can relocate to, while some are marked relocatable - # and the directory they can relocate to is removed from all filenames in the - # package. I suppose this is due to some change between versions of rpm, but - # none of this is adequatly documented, so we'll just muddle through. + # PREFIXES directory. However, it's possible that that directory is in + # the package - it seems some rpm's are marked as relocatable and + # unpack already in the directory they can relocate to, while some are + # marked relocatable and the directory they can relocate to is removed + # from all filenames in the package. I suppose this is due to some + # vchange between versions of rpm, but none of this is adequatly + # documented, so we'll just muddle through. # # Test to see if the package contains the PREFIXES directory already. + print "----$fields{PREFIXES}\n"; if ($fields{PREFIXES} ne undef && ! -e "./$fields{PREFIXES}") { print "Moving unpacked files into $fields{PREFIXES}\n"; diff --git a/lib/Fromslp.pm b/lib/Fromslp.pm index 81e2edd..56d4e38 100644 --- a/lib/Fromslp.pm +++ b/lib/Fromslp.pm @@ -2,23 +2,13 @@ # # Package for converting from a .slp (Stampede) file. +# Pull in details on the binary footer. +use Slp; + package From::slp; use strict; -# Becuase .slp files are a binary format we parse by hand, I need to code in -# the details of the structure here. - - # Complete sizeof(slpformat) from slp.h in the stampede package manager source. - $From::slp::footer_size=3784; - - # This is the pack format string for the footer. - $From::slp::footer_packstring="A756IIIIA128A128A80A1536A512A512A30A30IA20A20III"; - - # What package format are we up to now? (Lowest one this is still compatable - # with.) - $From::slp::footer_version=5; - # 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; @@ -43,11 +33,11 @@ sub DecodeFooter { my $footer=shift; $fields{ARCH}, $fields{GROUP}, $fields{SLPKGVERSION}, - )=unpack($From::slp::footer_packstring,$footer); + )=unpack($slp::footer_packstring,$footer); # A simple sanity check. - if (! $fields{SLPKGVERSION} || $fields{SLPKGVERSION} < $From::slp::footer_version) { - Alien::Error("This is not a V$From::slp::footer_version or greater Stampede package"); + if (! $fields{SLPKGVERSION} || $fields{SLPKGVERSION} < $slp::footer_version) { + Alien::Error("This is not a V$slp::footer_version or greater Stampede package"); } return %fields; @@ -57,8 +47,8 @@ sub DecodeFooter { my $footer=shift; # in a scalar. sub GetFooter { my ($filename)=@_; open (SLP,"<$filename") || Alien::Error("unable to read $filename: $!"); - seek SLP,(-1 * $From::slp::footer_size),2; # position at beginning of footer (2 = seek from EOF) - read SLP,$_,$From::slp::footer_size; + seek SLP,(-1 * $slp::footer_size),2; # position at beginning of footer (2 = seek from EOF) + read SLP,$_,$slp::footer_size; close SLP; return $_; } @@ -74,54 +64,34 @@ sub GetFields { my ($self,$file)=@_; $fields{CONFFILES}.="\n"; } - if ($fields{COPYRIGHT} == 0) { - $fields{COPYRIGHT}="GPL"; - } - elsif ($fields{COPYRIGHT} == 1) { - $fields{COPYRIGHT}="BSD"; - } - elsif ($fields{COPYRIGHT} == 2) { - $fields{COPYRIGHT}="LGPL"; - } - elsif ($fields{COPYRIGHT} == 3) { - $fields{COPYRIGHT}="unknown"; + 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 ($fields{ARCH} == 0) { - $fields{ARCH}='all'; - } - elsif ($fields{ARCH} == 1) { - $fields{ARCH}='i386'; - } - elsif ($fields{ARCH} == 2) { - $fields{ARCH}='sparc'; - } - elsif ($fields{ARCH} == 3) { - $fields{ARCH}='alpha'; - } - elsif ($fields{ARCH} == 4) { - $fields{ARCH}='powerpc'; - } - elsif ($fields{ARCH} == 5) { - $fields{ARCH}='m68k'; + if ($$slp::archtrans{$fields{ARCH}}) { + $fields{ARCH}=$$slp::archtrans{$fields{ARCH}}; } else { - Alien::Error("An unknown architecture of \"$fields{ARCH}\" was specified."); + 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. - # Note that they will have a leading "." we don't want. $fields{FILELIST}=undef; my $fn; - foreach $fn (`tar -Itf $file`) { - $fn=~s/^\.//; + 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"; } @@ -131,9 +101,20 @@ sub GetFields { my ($self,$file)=@_; } # Unpack a slp file. -sub Unpack { my ($self,$file,%fields)=@_; - # Note it's a .tar.bz2, this the -I - Alien::SafeSystem ("(cd ..;cat $file) | tar Ixpf -","Error unpacking $file\n"); +# 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}."); + } } 1 diff --git a/lib/Fromtgz.pm b/lib/Fromtgz.pm index 113edca..7ba3fc8 100644 --- a/lib/Fromtgz.pm +++ b/lib/Fromtgz.pm @@ -15,7 +15,7 @@ sub GetFields { my ($self,$file)=@_; my ($basename)=('/'.$file)=~m#^/?.*/(.*?)$#; # Strip out any tar extentions. - $basename=~s/\.(tgz|tar\.gz)$//; + $basename=~s/\.(tgz|tar\.(gz|Z))$//; if ($basename=~m/(.*)-(.*)/ ne undef) { $fields{NAME}=$1; @@ -26,7 +26,7 @@ sub GetFields { my ($self,$file)=@_; $fields{VERSION}=1; } - $fields{ARCH}='i386'; + $fields{ARCH}='all'; if ($main::tgzdescription eq undef) { $fields{SUMMARY}='Converted Slackware tgz package'; } @@ -56,8 +56,8 @@ sub GetFields { my ($self,$file)=@_; } close FILELIST; - # Now get the whole filelist. We have to add leading /'s to the filenames. - # We have to ignore all files under /install/ + # Now get the whole filelist. We have to add leading /'s to the + # filenames. We have to ignore all files under /install/ $fields{FILELIST}=''; open (FILELIST, "tar ztf $file |"); while () { @@ -86,7 +86,7 @@ sub GetFields { my ($self,$file)=@_; } # Handles unpacking of tgz's. -sub Unpack { my ($self,$file)=@_; +sub Unpack { my ($self,$nopatch,$file)=@_; Alien::SafeSystem ("(cd ..;cat $file) | tar zxpf -","Error unpacking $file\n"); # Delete this install directory that has slackware info in it.