aboutsummaryrefslogtreecommitdiffstats
path: root/rpmbuildupdate
diff options
context:
space:
mode:
Diffstat (limited to 'rpmbuildupdate')
-rwxr-xr-xrpmbuildupdate86
1 files changed, 58 insertions, 28 deletions
diff --git a/rpmbuildupdate b/rpmbuildupdate
index 09475c7..b969ddf 100755
--- a/rpmbuildupdate
+++ b/rpmbuildupdate
@@ -1,6 +1,6 @@
#!/usr/bin/perl -w
#
-# rpmbuildupdate by Julien Danjou <jdanjou at mandrakesoft dot com>
+# rpmbuildupdate by Julien Danjou
#
# Copyright (c) 2003-2004 by MandrakeSoft
#
@@ -27,6 +27,44 @@ sub build_from_src
{ &build($1, $nv, $_); }
}
+sub fetch
+{
+ my ($url) = @_;
+ my $basename = `basename $url`; chomp($basename);
+ my ($temp, $turl);
+ my $wget = "wget -N -q";
+
+ system("rm -f $basename");
+
+ print "Trying to fetch $url...\n";
+ system("$wget $url");
+
+ if (! -f $basename)
+ {
+ ($turl = $url) =~ s/bz2/gz/;
+ $temp = `basename $turl`; chomp($temp);
+ print "Trying to fetch $turl...\n";
+ system("$wget $turl; [ -f $temp ] && bzme $temp");
+ }
+
+ if (! -f $basename)
+ {
+ ($turl = $url) =~ s/\.tar\.bz2/.tgz/;
+ $temp = `basename $turl`; chomp($temp);
+ print "Trying to fetch $turl...\n";
+ system("$wget $turl; [ -f $temp ] && bzme $temp");
+ }
+
+ if (! -f $basename)
+ {
+ ($turl = $url) =~ s/\.tar\.bz2/.zip/;
+ $temp = `basename $turl`; chomp($temp);
+ print "Trying to fetch $turl...\n";
+ system("$wget $turl; [ -f $temp ] && bzme $temp");
+ }
+ return (-f $basename);
+}
+
sub build
{
my $pkg = shift;
@@ -143,7 +181,7 @@ sub build
my $basename = `basename $_`; chomp($basename);
-
+ # download from Fedora
if(/ftp\.redhat\.com/)
{
opendir(MP, $config{fedora}) or die "$config{fedora} is not a directory";
@@ -170,36 +208,28 @@ sub build
wait;
}
}
+ # download from sourceforge mirrors
+ if (m@http://prdownloads.sourceforge.net@)
+ {
+ foreach my $site ("http://heanet.dl.sourceforge.net/sourceforge/",
+ "http://aleron.dl.sourceforge.net/sourceforge/",
+ "http://keihanna.dl.sourceforge.net/sourceforge/",
+ "http://belnet.dl.sourceforge.net/sourceforge/",
+ "http://unc.dl.sourceforge.net/sourceforge/",
+ "http://twtelecom.dl.sourceforge.net/sourceforge/",
+ )
+ {
+ (my $dest = $_) =~ s@http://prdownloads.sourceforge.net/@$site@;
+ last if (fetch($dest));
+ }
+ }
+ # download specified url
if (! -f "${top}/SOURCES/$basename")
{
- print "Trying $_...\n";
-
- system("wget -N ".$_);
- if($basename =~ /gz/)
- {
- s/gz/bz2/;
- $basename = `basename $_`; chomp($basename);
- print "Trying to fetch .bz2...\n";
- system("wget -N ".$_);
- }
- elsif($basename =~ /bz2/)
- {
- s/bz2/gz/;
- print "Trying to fetch .gz...\n";
- system("wget -N ".$_);
- $basename = `basename $_`; chomp($basename);
- # If gz was downloaded, recompressing it in bz2
- if(-f $basename)
- {
- system("bzme ".$basename);
- $basename =~ s/bz2/gz/;
- }
- }
+ fetch($_);
}
- $found = 1 if(-e $basename);
- $basename =~ s/bz2/gz/;
- $found = 1 if(-e $basename);
+ $found++ if(-e $basename);
}
open(SPECFILE, ">../SPECS/".$pkg.".spec") or die "Unable to open $pkg.spec";