1999-09-05 06:03:10 +00:00
|
|
|
#!/usr/bin/perl
|
|
|
|
|
#
|
|
|
|
|
# Package for converting to .tgz file.
|
|
|
|
|
|
|
|
|
|
package To::tgz;
|
|
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
|
|
sub FixFields { my ($self,%fields)=@_;
|
|
|
|
|
# Nothing to do.
|
|
|
|
|
|
|
|
|
|
return %fields;
|
|
|
|
|
}
|
|
|
|
|
|
1999-12-10 18:30:26 +00:00
|
|
|
sub Convert { my ($self,$workdir,$nopatch,%fields)=@_;
|
1999-09-05 06:03:10 +00:00
|
|
|
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";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
1999-12-10 18:30:26 +00:00
|
|
|
|
|
|
|
|
if ($main::generate) {
|
|
|
|
|
print "Directory $workdir prepared.\n";
|
|
|
|
|
}
|
1999-09-05 06:03:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# 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.
|
1999-12-10 18:30:26 +00:00
|
|
|
sub Install { my ($self,$package)=@_;
|
1999-09-05 06:03:10 +00:00
|
|
|
if (-x "/sbin/installpkg") {
|
|
|
|
|
Alien::SafeSystem("/sbin/installpkg $package");
|
|
|
|
|
}
|
|
|
|
|
else {
|
1999-12-10 18:30:26 +00:00
|
|
|
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.");
|
1999-09-05 06:03:10 +00:00
|
|
|
exit 1; # otherwise alien will delete the package file on us.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
1
|