From f85230dc81b2c13a8590d61ea5cf474bdd6664c3 Mon Sep 17 00:00:00 2001 From: joey Date: Sat, 22 Apr 2000 02:09:13 +0000 Subject: [PATCH] more bugfixes --- Alien/Package.pm | 9 +++++++++ Alien/Package/Deb.pm | 13 +++++++++++++ Alien/Package/Rpm.pm | 16 +++++++++++++++- alien | 15 ++++++++++----- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/Alien/Package.pm b/Alien/Package.pm index 3dc6e12..9319501 100644 --- a/Alien/Package.pm +++ b/Alien/Package.pm @@ -253,6 +253,15 @@ to produce a suitable build tree. sub prep {} +=item cleantree + +This method should clean the unpacked_tree of any effects the prep and +build methods might have on it. + +=cut + +sub cleantree {} + =item build This method takes a prepped build tree, and simply builds a package from diff --git a/Alien/Package/Deb.pm b/Alien/Package/Deb.pm index ec75383..8af71d1 100644 --- a/Alien/Package/Deb.pm +++ b/Alien/Package/Deb.pm @@ -384,6 +384,19 @@ sub build { return $this->name."_".$this->version."-".$this->release."_".$this->arch.".deb"; } +=item cleantree + +Delete the entire debian/ directory. + +=cut + +sub cleantree { + my $this=shift; + my $dir=$this->unpacked_tree || die "The package must be unpacked first!"; + + system("rm -rf $dir/debian"); +} + =item package Set/get package name. diff --git a/Alien/Package/Rpm.pm b/Alien/Package/Rpm.pm index 7042886..80219b4 100644 --- a/Alien/Package/Rpm.pm +++ b/Alien/Package/Rpm.pm @@ -265,6 +265,19 @@ sub prep { close OUT; } +=item cleantree + +Delete the spec file. + +=cut + +sub cleantree { + my $this=shift; + my $dir=$this->unpacked_tree || die "The package must be unpacked first!"; + + unlink "$dir/".$this->name."-".$this->version."-".$this->release.".spec"; +} + =item build Build a rpm. If RPMBUILDOPT is set in the environement, the options in @@ -376,7 +389,8 @@ sub _script_helper { # get return unless defined wantarray; # optimization $_=$this->{$script}; - return $_ if ! defined $_ || m/^\s*$/; + return '' unless defined $_; + return $_ if m/^\s*$/; my $f = pack("u",$_); $f =~ s/%/%%/g; # Rpm expands %S, so escape such things. return "set -e\n". diff --git a/alien b/alien index 09ef41b..a14ca82 100755 --- a/alien +++ b/alien @@ -283,7 +283,7 @@ if (($generate || $single) && $install) { die "You can not use --generate or --single with --install.\n"; } if (($generate || $single) && keys %destformats > 1) { - die "--generate and --single may noly be used when converting to a single format.\n"; + die "--generate and --single may only be used when converting to a single format.\n"; } if ($patchfile && ! -f $patchfile) { die "Specified patch file, \"$patchfile\" cannot be found.\n"; @@ -298,11 +298,11 @@ unless (@ARGV) { # Check alien's working anvironment. if (! -w '.') { - die("Cannot write to current directory. Try changing to /tmp and re-running alien.\n"); + die("Cannot write to current directory. Try moving to /tmp and re-running alien.\n"); } if ($> ne 0) { if ($destformats{deb} && ! $generate && ! $single) { - die "Must run as root to convert to .deb format (or you may use fakeroot).\n"; + die "Must run as root to convert to deb format (or you may use fakeroot).\n"; } print STDERR "Warning: alien is not running as root!\n"; print STDERR "Ownerships of files in the generated packages will probably be messed up.\n"; @@ -349,7 +349,12 @@ foreach my $file (@ARGV) { # Skip conversion if package is already the correct format. if ($package->origformat ne $format) { # Only unpack once. - $package->unpack unless $package->unpacked_tree; + if ($package->unpacked_tree) { + $package->cleantree; + } + else { + $package->unpack; + } # Mutate package into desired format. bless($package, "Alien::Package::".ucfirst($format)); @@ -370,7 +375,7 @@ foreach my $file (@ARGV) { else { print "Directory ".$package->unpacked_tree." prepared.\n"; } - # Make sure $package does not whipe out the + # Make sure $package does not wipe out the # directory when it is destroyed. $package->unpacked_tree(''); exit;