Finished conversion.

This commit is contained in:
joey
2000-04-21 22:09:14 +00:00
parent e06549623e
commit b78f13c060
3 changed files with 40 additions and 179 deletions

View File

@@ -16,6 +16,27 @@ use base qw(Alien::Package);
This is an object class that represents a tgz package, as used in Slackware. This is an object class that represents a tgz package, as used in Slackware.
It is derived from Alien::Package. It is derived from Alien::Package.
=head1 CLASS DATA
=over 4
=item scripttrans
Translation table between canoical script names and the names used in
tgz's.
=cut
use constant
scriptrans => {
postinst => 'doinst.sh',
postrm => 'delete.sh',
prerm => 'predelete.sh',
preinst => 'predoinst.sh',
};
=back
=head1 FIELDS =head1 FIELDS
=over 4 =over 4
@@ -48,8 +69,8 @@ sub install {
=item scan =item scan
Scan a tgz file for fields. Has to scan the actual filename, since Scan a tgz file for fields. Has to scan the filename for most of the
there is little useful data in the file itself. information, since there is little useful metadata in the file itself.
=cut =cut
@@ -112,14 +133,8 @@ sub scan {
$this->filelist(\@filelist); $this->filelist(\@filelist);
# Now get the scripts. # Now get the scripts.
my %scripttrans=( foreach my $script (keys %{scripttrans()}) {
'postinst' => 'doinst.sh', $this->$script(`tar Oxzf $file install/${scripttrans()}{$script} 2>/dev/null`);
'postrm' => 'delete.sh',
'prerm' => 'predelete.sh',
'preinst' => 'predoinst.sh',
);
foreach my $script (keys(%scripttrans)) {
$this->$script(`tar Oxzf $file install/$scripttrans{$script} 2>/dev/null`);
} }
return 1; return 1;
@@ -146,7 +161,7 @@ sub unpack {
=item prep =item prep
Adds a populated install/ directory to the build tree. Adds a populated install directory to the build tree.
=cut =cut
@@ -154,7 +169,20 @@ sub prep {
my $this=shift; my $this=shift;
my $dir=$this->unpacked_tree || die "The package must be unpacked first!"; my $dir=$this->unpacked_tree || die "The package must be unpacked first!";
my $install_made=0;
foreach my $script (keys %{scriptrans()}) {
my $data=$this->$script;
next if ! defined $data || $data =~ m/^\s*$/;
if (!$install_made) {
mkdir $this->unpacked_tree."/install", 0755;
$install_made=1;
}
open OUT (">".$this->unpacked_tree."/install/$script") ||
die $this->unpacked_tree."/install/$script: $!"
print OUT $data;
close OUT;
chmod 0755, $this->unpacked_tree."/install/$script";
}
} }
=item build =item build

View File

@@ -1,96 +0,0 @@
#!/usr/bin/perl
#
# Package for converting from a tgz file.
package From::tgz;
use strict;
# 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 ($self,$file)=@_;
my %fields;
# Get basename of the filename.
my ($basename)=('/'.$file)=~m#^/?.*/(.*?)$#;
# Strip out any tar extentions.
$basename=~s/\.(tgz|tar\.(gz|Z))$//;
if ($basename=~m/(.*)-(.*)/ ne undef) {
$fields{NAME}=$1;
$fields{VERSION}=$2;
}
else {
$fields{NAME}=$basename;
$fields{VERSION}=1;
}
$fields{ARCH}='all';
if ($main::tgzdescription eq undef) {
$fields{SUMMARY}='Converted Slackware tgz package';
}
else {
$fields{SUMMARY}=$main::tgzdescription;
}
$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/ |")
|| Alien::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. We have to ignore all files under /install/
$fields{FILELIST}='';
open (FILELIST, "tar ztf $file |");
while (<FILELIST>) {
if ($_=~m:^install/: eq undef) {
$fields{FILELIST}.="/$_";
}
}
close FILELIST;
# Now get the scripts.
if ($main::scripts) {
my %scripttrans=(
'doinst.sh' => 'POSTINST',
'delete.sh' => 'POSTRM',
'predelete.sh' => 'PRERM',
'predoinst.sh' => 'PREINST',
);
my $script;
foreach $script (keys(%scripttrans)) {
$fields{$scripttrans{$script}}=
`tar Oxzf $file install/$script 2>/dev/null`;
}
}
return %fields;
}
# Handles unpacking of tgz's.
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.
Alien::SafeSystem ("rm -rf install");
}
1

View File

@@ -1,71 +0,0 @@
#!/usr/bin/perl
#
# Package for converting to .tgz file.
package To::tgz;
use strict;
sub FixFields { my ($self,%fields)=@_;
# Nothing to do.
return %fields;
}
sub Convert { my ($self,$workdir,$nopatch,%fields)=@_;
if ($main::scripts) {
my $install_made=undef;
my %scripttrans=(
'doinst.sh' => 'POSTINST',
'delete.sh' => 'POSTRM',
'predelete.sh' => 'PRERM',
'predoinst.sh' => 'PREINST',
);
my $script;
foreach $script (keys(%scripttrans)) {
if ($fields{$scripttrans{$script}}) {
if (!$install_made) {
Alien::Status("Setting up scripts.");
mkdir "$fields{NAME}-$fields{VERSION}/install",0755
|| Alien::Error("Unable to make install directory");
$install_made=1;
}
open (OUT,">$workdir/install/$script") ||
Alien::Error("$workdir/install/$script: $!");;
print OUT $fields{$scripttrans{$script}};
close OUT;
chmod 0755,"$workdir/install/$script";
}
}
}
if ($main::generate) {
print "Directory $workdir prepared.\n";
}
}
# Passed the available info about the package in a hash, return the name of
# the tgz package that will be made.
sub GetPackageName { my ($self,%fields)=@_;
return "$fields{NAME}-$fields{VERSION}-$fields{RELEASE}.tgz";
}
# Build a tgz file.
sub Build { my ($self,%fields)=@_;
Alien::SafeSystem("tar czf ../".$self->GetPackageName(%fields)." .");
}
# Install the passed tgz file.
sub Install { my ($self,$package)=@_;
if (-x "/sbin/installpkg") {
Alien::SafeSystem("/sbin/installpkg $package");
}
else {
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.
}
}
1