From fe84a0dbfc5ba3955cd2629881cb398fed29a9a5 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 21 Apr 2000 22:23:53 +0000 Subject: [PATCH] Moved in patch finding code. --- Alien/Package/Deb.pm | 32 ++++++++++++++++++++++++++++++++ lib/Alien.pm | 35 ----------------------------------- 2 files changed, 32 insertions(+), 35 deletions(-) delete mode 100644 lib/Alien.pm diff --git a/Alien/Package/Deb.pm b/Alien/Package/Deb.pm index ebea496..253510c 100644 --- a/Alien/Package/Deb.pm +++ b/Alien/Package/Deb.pm @@ -200,6 +200,38 @@ sub unpack { 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 Adds a populated debian directory the unpacked package tree, making it diff --git a/lib/Alien.pm b/lib/Alien.pm deleted file mode 100644 index 615f7ab..0000000 --- a/lib/Alien.pm +++ /dev/null @@ -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