Brian,

Done. I moved to --mirror, and added --mirror-list. I'm not really happy with the way I did it, basically, try to download systeminstaller-1.04-1.noarch.rpm off of prdownloads.sourceforge.net, and page scrape the mirror lists off of there, but I couldn't find any other way of getting the lists out of sourceforge. I'm definitely open to suggestions if there is a better way

I also realized that the stuff I added before didn't really do what I thought it was supposed to, because of the placement of the $cmd before my changing $url.. it's after now, and it actually pulls from the right server.



Brian Elliott Finley wrote:
Paul,

Thanks for the changes.  It took me a while as I had to apply the
changes manually.  Patches in the body of an email tend to get mangled.

For future patches (and it'll be easier for me to apply them and they'll
get uploaded faster) can you do this (as an example):

   cp install install.orig
   edit install
   diff -urN install.orig install > install.choose_an_sfsite.patch

Then, send an email to the devel list with
"install.choose_an_sfsite.patch" as an attachment.

Now, with that in mind, I have a couple of additional improvements, that
I think would be really nifty if your up to it:

   * rename the -sfsite option to --mirror
   * add an option:  --mirror-list, which would show you a list of
     available mirrors in a format where you could cut and paste the one
     you wanted as an argument to --mirror PASTED.

     For example, the output might look like this:

     % ./install --list
     Mirror sites that you can use with the --mirror option:

       easynews
       puzzle
       optusnet
       [etc...]


Thanks again for the changes, and I've got the updated install file up
at: http://sisuite.org/install

Cheers,

-Brian



Thus spake Paul Greidanus ([EMAIL PROTECTED]):


-------- Original Message --------
Subject: Re: [Sisuite-devel] install changes to use sourceforge mirror
Date: Mon, 05 Dec 2005 15:04:27 -0700
From: Paul Greidanus <[EMAIL PROTECTED]>
To: SIS Devel <sisuite-devel@lists.sourceforge.net>
References: <[EMAIL PROTECTED]>

Ok, I just reread my diff, and realised how much cruft I left in there
from a few other ideas on how to implement..

This one should work better:

Index: install
===================================================================
RCS file: /cvsroot/sisuite/sisuite/install,v
retrieving revision 1.9
diff -r1.9 install
74a75
    "sfsite=s"                => \$opt{sfsite}
191c192,196
<
---
      if ($opt{sfsite} && $url =~ m/install.sisuite.org/) {
              $url =~ s^http://install.sisuite.org/sourceforge^^;
$url =
"http://$opt{sfsite}.dl.sourceforge.net/sourceforge"; . $url;
      }

412c417
<                [--list] [--package-list FILE] [--tag ($tags)]
---
[--list] [--package-list FILE] [--tag ($tags)]
[--sfsite (sfsite)]
428a434,436
--sfsite (mirror)
Select to download via a sourceforge mirror, rather then
sisuite.org
      mirror need to be a valid sourceforge mirror (i.e. us or eu)



Paul Greidanus wrote:
Hi All,

I hacked a few little changes into the install script, to allow for the use of sourceforge mirrors, rather then the install.sisuite.org site for downloads. Basically, if you put a --sfsite (site) on the command line, it comes into action, rewrites the URLS from the stable.list or devel.list into the corresponding (site).dl.sourceforge.net site. No checking is done on what the user selects as their sfsite.. does it need it?



--
Paul Greidanus
CAD Administrator / Systems Administrator
Center of Excellence in Integrated Nanotools    University of Alberta
[EMAIL PROTECTED]            780-492-7368
http://www.cein.ualberta.ca



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
Sisuite-devel mailing list
Sisuite-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sisuite-devel

--
Paul Greidanus
CAD Administrator / Systems Administrator
Center of Excellence in Integrated Nanotools    University of Alberta
[EMAIL PROTECTED]            780-492-7368
http://www.cein.ualberta.ca




--
Paul Greidanus
CAD Administrator / Systems Administrator
Center of Excellence in Integrated Nanotools    University of Alberta
[EMAIL PROTECTED]                       780-492-7368
http://www.cein.ualberta.ca

--- install.orig        2005-12-22 15:19:56.000000000 -0700
+++ install     2005-12-22 16:10:30.000000000 -0700
@@ -20,6 +20,8 @@
 #   - if --list and --download-only, just --list
 #  2005.12.21  Paul Greidanus
 #   - allow user to choose a specific sf mirror
+#  2005.12.22  Paul Greidanus
+#   - added --mirror-list, and move --sfsite to --mirror
 #
 #  Run "./install --help" for description.
 #
@@ -74,7 +76,8 @@
     "package-list=s"    => \$opt{package_list},
     "download-only"     => \$opt{download_only},
     "directory=s"       => \$opt{directory},
-    "sfsite=s"          => \$opt{sfsite},
+    "mirror=s"          => \$opt{mirror},
+    "mirror-list"      => \my $mirrorlist,
 ) or usage(1);
 
 
################################################################################
@@ -101,10 +104,15 @@
         $tag = "stable";
 }
 
-unless(($list) or ($opt{download_only}) or ($ARGV[0])) {
+unless(($list) or ($opt{download_only}) or ($ARGV[0]) or $mirrorlist) {
         usage(1);
 }
 
+if ($mirrorlist) {
+       &list_mirrors;
+       exit(0);
+}
+
 # create download dir if it doesn't exist
 if(!-d $opt{directory}) { mkdir $opt{directory}, 0775; }
 
@@ -140,6 +148,7 @@
         exit 0;
 }
 
+
 if($opt{download_only} && !$ARGV[0]) {
         print "ERROR: Must specify one or more packages with 
--download-only.\n";
         print "       Try --list to see available packages.\n\n";
@@ -192,11 +201,11 @@
                 $wget_opts .= " --quiet";
         }
         
-        my $cmd = "wget $wget_opts $url";
-        if ($opt{sfsite} && $url =~ m/install.sisuite.org/) {
+        if ($opt{mirror} && $url =~ m/install.sisuite.org/) {
                 $url =~ s^http://install.sisuite.org/sourceforge^^;
-                $url = "http://$opt{sfsite}.dl.sourceforge.net/sourceforge"; . 
$url;
+                $url = "http://$opt{mirror}.dl.sourceforge.net/sourceforge"; . 
$url;
         }
+        my $cmd = "wget $wget_opts $url";
 
         print "Downloading: $url..." if($opt{verbose});
         print "\n$cmd\n"              if($opt{vverbose});
@@ -402,6 +411,20 @@
         return 1;
 }
 
+# This is a horrible hack to get the sourceforge mirrors list, but I can't 
seem to find another way
+# Paul Greidanus ([EMAIL PROTECTED])
+sub list_mirrors {
+       my $line;
+       my $cmd = "wget -q -O - 
http://prdownloads.sourceforge.net/systeminstaller/systeminstaller-1.04-1.noarch.rpm
 2> /dev/null | grep form.submit | grep value | grep -v none";
+       my $mirror_sites = `$cmd`;
+       $mirror_sites =~ s#<[^>]*>##g;
+
+       print "The following are available mirrors to use for the --mirror 
command\n";
+       print "They are listed in \"mirror (LL)\" where LL is the country of 
the mirror server\n";
+       print "You need to use the \"mirror\" component in the --mirror 
command\n\n";
+       print "$mirror_sites\n";
+}
+
 sub usage {
 
         my $exit_status = shift;
@@ -418,7 +441,7 @@
 
 Usage: install [--help] [-v,--verbose] [-vv,--vverbose] [--download-only] 
                [--list] [--package-list FILE] [--tag ($tags)]
-               [--sfsite (sfsite)] [PKG1 PKG2 ...]
+               [--mirror (mirror)] [--mirror-list] [PKG1 PKG2 ...]
 
  --help
         Show this output.
@@ -448,10 +471,13 @@
         Download packages into DIR.
         (defaults to '/tmp/sis-packages')
 
- --sfsite (mirror)
+ --mirror (mirror)
        Select to download via a sourceforge mirror, rather then sisuite.org
        mirror need to be a valid sourceforge mirror (i.e. us or eu)
 
+ --mirror-list
+       Prints out a list of currently available mirrors from sourceforge
+
 Examples:
         ./install --list
         ./install --verbose systemconfigurator perl-AppConfig

Reply via email to