This is the mail archive of the cygwin-apps mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Setup.exe: New commandline option --only-site


    Hello perverts and non-perverts alike!

  Having recently become a pervert, oops I mean provider, I wanted to provide
a full turnkey installation on a DVD for offline use, and to avoid confusing
any cygn00bs among them, I wanted it to have a setup.exe that would just
install from the provided disk and not scare them with any of that stuff about
external mirrors.  I also wanted it to work regardless of whether there was an
existing installation on the local drive or not, and when there was one,
setup.exe would of course pick up the user settings from it, most of which is
desirable, but I didn't want them to be shown a whole long list of mirrors and
have to do something potentially offputting like multi-selecting stuff, nor
want them to be confused by all these external sites showing up (perhaps not
realising that the local mirror will have been added right at the very bottom
of the list and won't be visible without scrolling down).

  So, the --only-site option lets you invoke setup.exe in locked-down mode
where the only site it shows is the one you've specified on the command-line
using the -s option.  It doesn't bother to download the mirrors list, but it
doesn't update the local mirrors list either, so it won't wipe out any
existing one.  I didn't make it disable the "Add" button or skip the mirror
page altogether, because I didn't want to take away the user's "get out of
jail free card" for when something goes wrong, or if they want to change from
installing from a local DVD to installing from a network-drive copy of the
install disk, and besides if you want that then what you're really looking for
is probably to use full-blown unattended mode, but maybe we might add another
option in the future that specifies "Unattended mode for everything except the
package chooser page"?  Anyway, here it is for your consideration.

	* site.cc: Add #include of BoolOption header from libgetopt.
	(OnlySiteOption): New BoolOption for command-line -O option.
	(get_site_list): Respect BoolOption by not downloading mirror
	list, nor using nor updating cached mirrors.

  OK?

    cheers,
      DaveK
Index: site.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/site.cc,v
retrieving revision 2.47
diff -p -u -r2.47 site.cc
--- site.cc	18 Sep 2009 15:40:49 -0000	2.47
+++ site.cc	4 Nov 2009 16:35:14 -0000
@@ -78,6 +78,7 @@ SitePage::SitePage ()
 }
 
 #include "getopt++/StringOption.h"
+#include "getopt++/BoolOption.h"
 #include "UserSettings.h"
 
 using namespace std;
@@ -100,6 +101,8 @@ SiteList dropped_site_list;
 
 StringOption SiteOption("", 's', "site", "Download site", false);
 
+BoolOption OnlySiteOption(false, 'O', "only-site", "Ignore all sites except for -s");
+
 SiteSetting::SiteSetting (): saved (false)
 {
   string SiteOptionString = SiteOption;
@@ -289,7 +292,7 @@ get_site_list (HINSTANCE h, HWND owner)
   char mirror_url[1000];
 
   char *theMirrorString, *theCachedString;
-  const char *cached_mirrors = UserSettings::instance().get ("mirrors-lst");
+  const char *cached_mirrors = OnlySiteOption ? NULL : UserSettings::instance().get ("mirrors-lst");
   if (cached_mirrors)
     {
       log (LOG_BABBLE) << "Loaded cached mirror list" << endLog;
@@ -305,7 +308,7 @@ get_site_list (HINSTANCE h, HWND owner)
   if (LoadString (h, IDS_MIRROR_LST, mirror_url, sizeof (mirror_url)) <= 0)
     return 1;
 
-  string mirrors = get_url_to_string (mirror_url, owner);
+  string mirrors = OnlySiteOption ? string ("") : get_url_to_string (mirror_url, owner);
   if (mirrors.size())
     cache_needs_writing = true;
   else

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]