Moved in patch finding code.

This commit is contained in:
joey
2000-04-21 22:23:53 +00:00
parent 25d4bcbe7a
commit fe84a0dbfc
2 changed files with 32 additions and 35 deletions

View File

@@ -200,6 +200,38 @@ sub unpack {
return 1; return 1;
} }
=item getpatch
This method tries to find a patch file to use in the prep stage. If it
finds one, it returns it. Pass in a list of directories to search for
patches in.
=cut
sub getpatch {
my $this=shift;
my @patches;
foreach my $dir (@_) {
push @patches,glob("$dir/".$this->name."_".$this->version."-".$this->revision."*.diff.gz");
}
unless (@patches) {
# Try not matching the revision, see if that helps.
foreach my $dir (@_) {
push @patches,glob("$dir/".$this->name."_".$this->version."*.diff.gz");
}
unless (@patches) {
# Fallback to anything that matches the name.
foreach my $dir (@_) {
push @patches,glob("$dir/".$this->name."_*.diff.gz");
}
}
}
# If we ended up with multiple matches, return the first.
return $patches[0];
}
=item prep =item prep
Adds a populated debian directory the unpacked package tree, making it Adds a populated debian directory the unpacked package tree, making it

View File

@@ -1,35 +0,0 @@
#!/usr/bin/perl
#
# Misc. functions used by alien.
package Alien;
use strict;
# Pass this the name and version and revision of a package, it will return the
# filename of a patch file for the package or undef if there is none.
sub GetPatch { my ($name,$version,$revision)=@_;
my @patches=();
my $dir;
foreach $dir (@main::patchdirs) {
push @patches,glob("$dir/$name\_$version-$revision*.diff.gz");
}
if ($#patches < 0) {
# try not matching the revision, see if that helps.
foreach $dir (@main::patchdirs) {
push @patches,glob("$dir/$name\_$version*.diff.gz");
}
if ($#patches < 0) {
# fallback to anything that matches the name.
foreach $dir (@main::patchdirs) {
push @patches,glob("$dir/$name\_*.diff.gz");
}
}
}
# If we ended up with multiple matches, return the first.
return $patches[0];
}
1