From 7d098feedd5d772d7276971c4a1f337b96586abf Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 10 Dec 1999 18:30:26 +0000 Subject: [PATCH] * Fixed the problem I thought I fixed in 6.50. Hmm. Closes: #52402 --- alien | 2 +- debian/changelog | 6 ++++++ lib/Fromrpm.pm | 2 +- lib/Fromslp.pm | 2 +- lib/Fromtgz.pm | 2 +- lib/Torpm.pm | 55 ++++++++++++++++++++++++++++++++++++------------ lib/Toslp.pm | 13 ++++++++---- lib/Totgz.pm | 14 +++++++----- 8 files changed, 70 insertions(+), 26 deletions(-) diff --git a/alien b/alien index b654e2f..6568986 100755 --- a/alien +++ b/alien @@ -195,7 +195,7 @@ foreach $file (@ARGV) { $workdir="$fields{NAME}-$fields{VERSION}"; Alien::SafeMkdir($workdir); chdir $workdir; - $src->Unpack($file,$nopatch,%fields); + $src->Unpack($file,%fields); chdir ".."; # Conversion stage. diff --git a/debian/changelog b/debian/changelog index 0dd49eb..1ac3c7c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +alien (6.53) unstable; urgency=low + + * Fixed the problem I thought I fixed in 6.50. Hmm. Closes: #52402 + + -- Joey Hess Fri, 10 Dec 1999 10:21:43 -0800 + alien (6.52) unstable; urgency=low * Added (very simple) build dep. diff --git a/lib/Fromrpm.pm b/lib/Fromrpm.pm index f181581..4bec426 100644 --- a/lib/Fromrpm.pm +++ b/lib/Fromrpm.pm @@ -112,7 +112,7 @@ sub GetFields { my ($self,$file)=@_; } # Unpack a rpm file. -sub Unpack { my ($self,$file,$nopatch,%fields)=@_; +sub Unpack { my ($self,$file,%fields)=@_; Alien::SafeSystem("(cd ..;rpm2cpio $file) | cpio --extract --make-directories --no-absolute-filenames --preserve-modification-time", "Error unpacking $file\n"); diff --git a/lib/Fromslp.pm b/lib/Fromslp.pm index 56d4e38..e987ecf 100644 --- a/lib/Fromslp.pm +++ b/lib/Fromslp.pm @@ -103,7 +103,7 @@ sub GetFields { my ($self,$file)=@_; # Unpack a slp file. # They can be compressed in various ways, depending on what is in # $fields{COMPRESSTYPE}. -sub Unpack { my ($self,$file,$nopatch,%fields)=@_; +sub Unpack { my ($self,$file,%fields)=@_; if ($fields{COMPRESSTYPE} eq 0) { Alien::SafeSystem ("(cd ..;cat $file) | bzip2 -d | tar xpf -","Error unpacking $file\n"); } diff --git a/lib/Fromtgz.pm b/lib/Fromtgz.pm index 7ba3fc8..16b7b73 100644 --- a/lib/Fromtgz.pm +++ b/lib/Fromtgz.pm @@ -86,7 +86,7 @@ sub GetFields { my ($self,$file)=@_; } # Handles unpacking of tgz's. -sub Unpack { my ($self,$nopatch,$file)=@_; +sub Unpack { my ($self,$file)=@_; Alien::SafeSystem ("(cd ..;cat $file) | tar zxpf -","Error unpacking $file\n"); # Delete this install directory that has slackware info in it. diff --git a/lib/Torpm.pm b/lib/Torpm.pm index 2abbed2..ed95fb0 100644 --- a/lib/Torpm.pm +++ b/lib/Torpm.pm @@ -19,12 +19,15 @@ sub FixFields { my ($self,%fields)=@_; foreach $field ('POSTINST', 'POSTRM', 'PREINST', 'PRERM') { if ($fields{$field}) { $fields{$field}= - "rm -f /tmp/alien.$field\n". - qq{perl -pe '\$_=unpack("u",\$_)' << '__EOF__' > /tmp/alien.$field\n}. + "set -e\n". + "mkdir /tmp/alien.\$\$\n". + qq{perl -pe '\$_=unpack("u",\$_)' << '__EOF__' > /tmp/alien.\$\$/script\n}. pack("u",$fields{$field}). "__EOF__\n". - "sh /tmp/alien.$field \"\$@\"\n". - "rm -f /tmp/alien.$field\n"; + "chmod 755 /tmp/alien.\$\$/script\n". + "/tmp/alien.\$\$/script \"\$@\"\n". + "rm -f /tmp/alien.\$\$/script\n". + "rmdir /tmp/alien.\$\$"; } } @@ -32,7 +35,7 @@ sub FixFields { my ($self,%fields)=@_; } # Generate the spec file. -sub Convert { my ($self,$workdir,%fields)=@_; +sub Convert { my ($self,$workdir,$nopatch,%fields)=@_; Alien::Status("Automatic spec file generation"); # Create some more fields we will need. @@ -47,8 +50,7 @@ sub Convert { my ($self,$workdir,%fields)=@_; my $fn; foreach $fn (split(/\n/,$fields{FILELIST})) { if ($fn=~m:/$: eq undef) { # not a directory - my $efn=quotemeta($fn); - if (grep(m:^$efn$:,@conffiles)) { # it's a conffile + if (grep(m:^\Q$fn\E$:,@conffiles)) { # it's a conffile $filelist.="%config $fn\n"; } else { # normal file @@ -82,27 +84,54 @@ sub GetPackageName { my ($self,%fields)=@_; $rpmdir=$1; } } - if (!$rpmarch || !$rpmdir) { + if (!$rpmarch) { Alien::Error("rpm --showrc failed."); } - # Debian's "all" architecture is a special case, and the output rpm will - # be a noarch rpm. + # Debian's "all" architecture is a special case, and the output rpm + # will be a noarch rpm. if ($fields{ARCH} eq 'all') { $rpmarch='noarch' } - return "$rpmdir/$rpmarch/$fields{NAME}-$fields{VERSION}-$fields{RELEASE}.$rpmarch.rpm"; + + if (! $rpmdir) { + # Presumably we're delaing with rpm 3.0 or above, which + # doesn't output rpmdir in any format I'd care to try to parse. + # Instead, rpm is now of a late enough version to notice the + # %define's in the spec file, that will make the file end up in + # the directory we started in. + return "$fields{NAME}-$fields{VERSION}-$fields{RELEASE}.$rpmarch.rpm"; + } + else { + # Old rpm. + return "$rpmdir/$rpmarch/$fields{NAME}-$fields{VERSION}-$fields{RELEASE}.$rpmarch.rpm"; + } } # Build a rpm file. sub Build { my ($self,%fields)=@_; # Debian's "all" architecture is a special case where we make noarch rpms. my $buildarch; - if ($fields{ARCH} eq 'all') { $buildarch="--buildarch noarch" } + if ($fields{ARCH} eq 'all') { + # Nasty version check in here because rpm gratuitously + # changed this option at version 3.0. + my $lc_all=$ENV{LC_ALL}; + $ENV{LC_ALL}='C'; + my $version=`rpm --version`; + $ENV{LC_ALL}=$lc_all; # important to reset it. + my $minor; + ($version,$minor)=$version=~m/version (\d+).(\d+)/; + if ($version >= 3 || ($version eq 2 && $minor >= 92)) { + $buildarch="--target noarch"; + } + else { + $buildarch="--buildarch noarch" + } + } Alien::SafeSystem("rpm $buildarch -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 ($self,$package)=shift; +sub Install { my ($self,$package)=@_; Alien::SafeSystem("rpm -ivh $ENV{RPMINSTALLOPT} $package"); } diff --git a/lib/Toslp.pm b/lib/Toslp.pm index a551bf5..953344b 100644 --- a/lib/Toslp.pm +++ b/lib/Toslp.pm @@ -70,7 +70,10 @@ sub FixFields { my ($self,%fields)=@_; } # Do any necessary conversions on the file tree. -sub Convert { my ($self,$workdir,%fields)=@_; +sub Convert { my ($self,$workdir,$nopatch,%fields)=@_; + if ($main::generate) { + print "Directory $workdir prepared.\n"; + } } # Passed the available info about the package in a hash, return the name of @@ -104,7 +107,7 @@ sub MakeFooter { my %fields=@_; $fields{COMPILER}, $fields{VERSION}, $fields{NAME}, - $fields{ARCH}, + $fields{BINFORMAT}, $fields{GROUP}, $fields{SLPKGVERSION}, )); @@ -114,8 +117,10 @@ sub MakeFooter { my %fields=@_; # This consists of first generating a .tar.bz2 file, and then appending the # footer to it. sub Build { my ($self,%fields)=@_; - # Note the -I is for making a .bzip2 file. - Alien::SafeSystem("tar cIf ../".$self->GetPackageName(%fields)." ."); + # Note that it's important I use "./*" instead of just "." or something like + # that, becuase it results in a tar file where all the files in it start + # with "./", which is consitent with how normal stampede files look. + Alien::SafeSystem("tar cf - ./* | bzip2 - > ../".$self->GetPackageName(%fields)); # Now append the footer to that. open (OUT,">>../".$self->GetPackageName(%fields)) || diff --git a/lib/Totgz.pm b/lib/Totgz.pm index 892aab3..dd6680f 100644 --- a/lib/Totgz.pm +++ b/lib/Totgz.pm @@ -12,7 +12,7 @@ sub FixFields { my ($self,%fields)=@_; return %fields; } -sub Convert { my ($self,$workdir,%fields)=@_; +sub Convert { my ($self,$workdir,$nopatch,%fields)=@_; if ($main::scripts) { my $install_made=undef; my %scripttrans=( @@ -38,6 +38,10 @@ sub Convert { my ($self,$workdir,%fields)=@_; } } } + + if ($main::generate) { + print "Directory $workdir prepared.\n"; + } } # Passed the available info about the package in a hash, return the name of @@ -52,14 +56,14 @@ sub Build { my ($self,%fields)=@_; } # Install the passed tgz file. -sub Install { my ($self,$package)=shift; +sub Install { my ($self,$package)=@_; if (-x "/sbin/installpkg") { Alien::SafeSystem("/sbin/installpkg $package"); } else { - print STDERR "Sorry, I cannot install the generated .tgz file,\n"; - print STDERR "\"$package\" because /sbin/installpkg is not\n"; - print STDERR "present. You can use tar to install it yourself.\n"; + Alien::Warning("Sorry, I cannot install the generated .tgz file,"); + Alien::Warning("\"$package\" because /sbin/installpkg is not"); + Alien::Warning("present. You can use tar to install it yourself."); exit 1; # otherwise alien will delete the package file on us. } }