hey all,

below is a relatively small patch to setup.exe that adds the following 
command line options:

-E:     use IE connection settings for downloading
-H:     give a proxy name to use ...
-P:     give a proxy port to use ...
-a:             install everything
-u:             uninstall everything
-e:     re-install everything


Hence:

setup.exe -R C:\cygwin -a -E -n -s ftp://planetmirror.com -q

installs all of cygwin (ie: every cygwin package) into C:\cygwin, using 
IE5 settings from site planetmirror.com, and doesn't put any shortcuts on the 
desktop, and does it in unattended mode (-q).

Anyways, like I said its somewhat small but might be large enough to warrant
going to cygwin-patches instead, but I don't relish the idea of subscribing
to cygwin-patches just for the sake of sending patches. I'm also hoping that 
its small and obvious enough that I don't have to go through the rigamarole 
of the standard assignment form and copyright handover.

Ed
2004-02-05  Edward Peschko  <[EMAIL PROTECTED]>

        * ConnectionSetting.cc (ConnectionSetting::UseIE5, 
        ConnectionSetting::ProxyHost, ConnectionSetting::ProxyPort): 
        Added headers "getopt++/BoolOption.h", "getopt++/StringOption.h" - 
        static variables for command line options
        UseIE5 (short -E) to by default use IE settings rather than default,
        ProxyHost (short -H) to by default use a given host, and
        ProxyPort (short -P) to by default use a given port.
        (ConnectionSetting::load): added support for command line options
        ProxyHost, ProxyPort in setting options for downloading cygwin packages.
        (ConnectionSetting::typeFromString): added support for UseIE5, ProxyHost
        command line variables to override defaults. 
        * PickCategoryLine.h (PickCategoryLine::PickCategoryLine):
        changed constructor to take an optional Default Action parameter
        in support of AllInstall, UnInstall, and ReInstall command line
        arguments (see below). Set current_default to this parameter.
        * PickView.cc (PickView::setViewMode):
        added support for AllInstall, UnInstall, and ReInstall by 
        setting the default install type for each set of contents
        - PickCategoryLines - based on arguments from commandline.
        (PickView::insert_pkg): added parameter that passes command
        line argument AllInstall, UnInstall, or ReInstall to PickCategoryLine
        constructor.
        (PickView::PickView): changed default install param from 0 
        (second argument) to packagemeta::action_from_argv() (which
        supports AllInstall, UnInstall or ReInstall)
        * main.cc (main): moved argument processing to earlier in the file
        so that added parameters would exist before their windows were 
        created.
        * net.cc (NetPage::OnInit): changed the default order for package
        download preferences to be NET_IE5 first (as per docs, ie: bug fix).
        * package_meta.cc: added header "getopt++/BoolOption.h",
        static boolean variables (AllInstall, UnInstall, ReInstall) -
        AllInstall (short -a) controls whether or not a user wants
        to by command line install all of cygwin.
        UnInstall (short -u) allows users to uninstall all of cygwin
        by command line, and
        ReInstall (short -e, allows users to reinstall all of cygwin.
        (packagemeta::action_from_argv): new function. returns back which
        of the options users selected.
        * package_meta_h: added headers for action_from_argv, copy constructor
diff -upr setup/ConnectionSetting.cc setup.new/ConnectionSetting.cc
--- setup/ConnectionSetting.cc  2003-10-26 04:02:52.000000000 -0800
+++ setup.new/ConnectionSetting.cc      2004-02-05 20:46:27.652250000 -0800
@@ -25,26 +25,49 @@ static const char *cvsid =
 #include "resource.h"
 #include "String++.h"
 
+#include "getopt++/BoolOption.h"
+#include "getopt++/StringOption.h"
+
+static BoolOption UseIE5(false, 'E', "use-ie5", "Use IE5 connection settings");
+static StringOption ProxyHost( "" , 'H', "proxy-name", "Name of proxy to use in 
download", false );
+static StringOption ProxyPort( "" , 'P', "proxy-port", "Proxy port to use in 
download", false );
+
 void
 ConnectionSetting::load()
 {
   static int inited = 0;
   if (inited)
     return;
-  io_stream *f = UserSettings::Instance().settingFileForLoad("last-connection");
-  if (f)
+
+  if (UseIE5 || (((std::string) ProxyHost).size()))
     {
-      char localdir[1000];
-      char *fg_ret = f->gets (localdir, 1000);
-      if (fg_ret)
-        net_method = typeFromString(fg_ret);
-      fg_ret = f->gets (localdir, 1000);
-      if (fg_ret)
-        net_proxy_host = strdup(fg_ret);
-      fg_ret = f->gets (localdir, 1000);
-      if (fg_ret)
-        net_proxy_port = atoi(fg_ret);
-      delete f;
+      net_method = typeFromString("");
+
+      if (((std::string)ProxyHost).size())
+        {
+          net_proxy_host = strdup(((std::string)ProxyHost).c_str());
+          net_proxy_port = (((std::string)ProxyPort).size())? 
+                            atoi(((std::string)ProxyPort).c_str()) :
+                            80;
+        }
+     }    
+  else
+    {
+      io_stream *f = UserSettings::Instance().settingFileForLoad("last-connection");
+      if (f)
+        {
+          char localdir[1000];
+          char *fg_ret = f->gets (localdir, 1000);
+          if (fg_ret)
+            net_method = typeFromString(fg_ret);
+          fg_ret = f->gets (localdir, 1000);
+          if (fg_ret)
+            net_proxy_host = strdup(fg_ret);
+          fg_ret = f->gets (localdir, 1000);
+          if (fg_ret)
+            net_proxy_port = atoi(fg_ret);
+          delete f;
+        }
     }
   inited = 1;
 }
@@ -80,6 +103,12 @@ ConnectionSetting::save()
 int
 ConnectionSetting::typeFromString(String const & aType)
 {
+  if (UseIE5)
+    return IDC_NET_IE5;
+
+  if (((std::string)ProxyHost).size())
+    return IDC_NET_PROXY;
+
   if (!aType.casecompare("Direct"))
     return IDC_NET_DIRECT;
   if (!aType.casecompare("IE"))
diff -upr setup/PickCategoryLine.h setup.new/PickCategoryLine.h
--- setup/PickCategoryLine.h    2003-06-23 13:48:59.000000000 -0700
+++ setup.new/PickCategoryLine.h        2004-02-05 21:27:28.121000000 -0800
@@ -25,12 +25,18 @@ class PickView;
 class PickCategoryLine:public PickLine
 {
 public:
-  PickCategoryLine (PickView & aView, Category & _cat, size_t thedepth = 0, bool 
aBool =
-                     true, bool aBool2 =
-                     true):PickLine (_cat.first),
-    current_default (packagemeta::Default_action), cat (_cat), labellength (0),
+  PickCategoryLine (
+    PickView & aView, 
+    Category & _cat, 
+    packagemeta::_actions _current_default = packagemeta::Default_action, 
+    size_t thedepth = 0, 
+    bool aBool = true, 
+    bool aBool2 = true) :
+
+    PickLine (_cat.first), cat (_cat), labellength (0),
     depth (thedepth), theView (aView)
   {
+    current_default = _current_default;
     if (aBool)
       {
        collapsed = true;
@@ -41,6 +47,7 @@ public:
        collapsed = false;
        show_label = aBool2;
       }
+      set_action(current_default);
   };
   ~PickCategoryLine ()
   {
diff -upr setup/PickPackageLine.cc setup.new/PickPackageLine.cc
--- setup/PickPackageLine.cc    2003-04-11 17:39:37.000000000 -0700
+++ setup.new/PickPackageLine.cc        2004-02-05 20:46:27.683500000 -0800
@@ -174,7 +174,7 @@ PickPackageLine::click (int const myrow,
 
   if (x >= theView.headers[theView.new_col].x - HMARGIN / 2
       && x <= theView.headers[theView.new_col + 1].x - HMARGIN / 2)
-    pkg.set_action (pkg.trustp(theView.deftrust));
+    pkg.set_action (pkg.trustp(theView.deftrust)); 
   
   packagemeta::PrepareForVisit();
   /* Add any packages that are needed by this package */
diff -upr setup/PickView.cc setup.new/PickView.cc
--- setup/PickView.cc   2003-10-26 11:38:30.000000000 -0800
+++ setup.new/PickView.cc       2004-02-05 20:46:27.714750000 -0800
@@ -220,6 +220,12 @@ PickView::setViewMode (PickView::views m
   scroll_ulc_x = scroll_ulc_y = 0;
 
   InvalidateRect (GetHWND(), &r, TRUE);
+
+  if (packagemeta::action_from_argv() != packagemeta::Default_action)
+  {
+      packagemeta::PrepareForVisit();
+      contents.set_action(packagemeta::action_from_argv()); 
+  }
 }
 
 const char *
@@ -251,6 +257,7 @@ PickView::views::caption ()
 void
 PickView::insert_pkg (packagemeta & pkg)
 {
+
   if (view_mode != views::Category)
     {
       PickLine & line = *new PickPackageLine (*this, pkg);
@@ -267,7 +274,9 @@ PickView::insert_pkg (packagemeta & pkg)
            continue;
 
          PickCategoryLine & catline = 
-           *new PickCategoryLine (*this,* db.categories.find (*x), 1);
+           *new PickCategoryLine (*this,* db.categories.find (*x), 
+                packagemeta::action_from_argv(), 1);
+
          PickLine & line = *new PickPackageLine(*this, pkg);
          catline.insert (line);
          contents.insert (catline);
@@ -281,7 +290,9 @@ PickView::insert_category (Category * ca
   // Urk, special case
   if (cat->first.casecompare ("All") == 0)
     return;
-  PickCategoryLine & catline = *new PickCategoryLine (*this, *cat, 1, collapsed);
+  PickCategoryLine & catline = *new PickCategoryLine(*this, *cat, 
+      packagemeta::action_from_argv(), 1, collapsed);
+
   for (vector <packagemeta *>::iterator i = cat->second.begin ();
        i != cat->second.end () ; ++i)
     {
@@ -440,7 +451,7 @@ PickView::init_headers (HDC dc)
 
 
 PickView::PickView (Category &cat) : deftrust (TRUST_UNKNOWN),
-contents (*this, cat, 0, false, true), hasClientRect (false)
+contents (*this, cat, packagemeta::action_from_argv(), false, true), hasClientRect 
(false)
 {
 }
 
diff -upr setup/main.cc setup.new/main.cc
--- setup/main.cc       2003-12-20 14:29:58.000000000 -0800
+++ setup.new/main.cc   2004-02-05 20:46:27.730375000 -0800
@@ -426,6 +426,25 @@ main (int argc, char **argv)
   local_dir = String (cwd);
   delete cwd;
 
+// TODO: make an equivalent for __argv under cygwin.
+  char **_argv;
+#ifndef __CYGWIN__
+  int argc;
+//  char **_argv;
+#ifndef __CYGWIN__
+  for (argc = 0, _argv = __argv; *_argv; _argv++)++argc;
+  _argv = __argv;
+#else
+//  for (argc = 0, _argv = argv; *_argv; _argv++)++argc;
+  _argv = argv;
+#endif
+#else
+  _argv = argv;
+#endif
+
+  if (!GetOption::GetInstance().Process (argc,_argv, NULL))
+    theLog->exit(1);
+
   LogSingleton::SetInstance (*(theLog = LogFile::createLogFile()));
   theLog->setFile (LOG_BABBLE, local_dir + "/setup.log.full", false);
   theLog->setFile (0, local_dir + "/setup.log", true);
@@ -447,24 +466,6 @@ main (int argc, char **argv)
 
   log (LOG_TIMESTAMP) << "Current Directory: " << local_dir << endLog;
 
-  // TODO: make an equivalent for __argv under cygwin.
-  char **_argv;
-#ifndef __CYGWIN__
-  int argc;
-//  char **_argv;
-#ifndef __CYGWIN__
-  for (argc = 0, _argv = __argv; *_argv; _argv++)++argc;
-  _argv = __argv;
-#else
-//  for (argc = 0, _argv = argv; *_argv; _argv++)++argc;
-  _argv = argv;
-#endif
-#else
-  _argv = argv;
-#endif
-
-  if (!GetOption::GetInstance().Process (argc,_argv, NULL))
-    theLog->exit(1);
 // #endif
 
   if (HelpOption)
diff -upr setup/net.cc setup.new/net.cc
--- setup/net.cc        2003-07-30 03:41:43.000000000 -0700
+++ setup.new/net.cc    2004-02-05 20:46:27.746000000 -0800
@@ -102,12 +102,12 @@ NetPage::OnInit ()
   CheckIfEnableNext();
 
   // Check to see if any radio buttons are selected. If not, select a default.
-  if ((!SendMessage (GetDlgItem (IDC_NET_IE5), BM_GETCHECK, 0, 0) ==
+  if ((!SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_GETCHECK, 0, 0) ==
        BST_CHECKED)
       && (!SendMessage (GetDlgItem (IDC_NET_PROXY), BM_GETCHECK, 0, 0)
          == BST_CHECKED))
     {
-      SendMessage (GetDlgItem (IDC_NET_DIRECT), BM_CLICK, 0, 0);
+      SendMessage (GetDlgItem (IDC_NET_IE5), BM_CLICK, 0, 0);
     }
 }
 
diff -upr setup/package_meta.cc setup.new/package_meta.cc
--- setup/package_meta.cc       2003-07-28 01:32:07.000000000 -0700
+++ setup.new/package_meta.cc   2004-02-05 20:46:27.761625000 -0800
@@ -44,9 +44,14 @@ static const char *cvsid = "\n%%% $Id: p
 
 #include <algorithm>
 #include "Generic.h"
+#include "getopt++/BoolOption.h"
 
 using namespace std;
 
+static BoolOption AllInstall ( false, 'a', "all-install", "install it all");
+static BoolOption UnInstall ( false, 'u', "un-install", "un-install it all");
+static BoolOption ReInstall ( false, 'e', "re-install", "re-Install it all");
+
 static const char *standard_dirs[] = {
   "bin",
   "etc",
@@ -111,6 +116,18 @@ const
   packagemeta::_actions
 packagemeta::Uninstall_action (3);
 
+packagemeta::_actions packagemeta::action_from_argv()
+{
+
+  return
+    (
+      (AllInstall)? packagemeta::Install_action   : 
+      (UnInstall)?  packagemeta::Uninstall_action : 
+      (ReInstall)?  packagemeta::Reinstall_action : 
+      packagemeta::Default_action
+   );
+}
+
 char const *
 packagemeta::_actions::caption ()
 {
diff -upr setup/package_meta.h setup.new/package_meta.h
--- setup/package_meta.h        2003-07-28 01:32:07.000000000 -0700
+++ setup.new/package_meta.h    2004-02-05 20:46:27.777250000 -0800
@@ -26,6 +26,7 @@ class category;
 #include "category.h"
 #include "PackageTrust.h"
 #include "package_version.h"
+#include <iostream>
 
 /* NOTE: A packagemeta without 1 packageversion is invalid! */
 class packagemeta
@@ -40,6 +41,7 @@ public:
   {
   }
 
+  void _printcanon();
   packagemeta (String const &pkgname,
               String const &installedfrom):name (pkgname), key(pkgname),
               installed_from (installedfrom),
@@ -61,23 +63,28 @@ public:
   class _actions
   {
   public:
-    _actions ():_value (0) {};
+    _actions ():_value (0) {}; 
     _actions (int aInt) {
     _value = aInt;
     if (_value < 0 ||  _value > 3)
       _value = 0;
     }
+
+//    _actions & operator= (int val);
     _actions & operator ++ ();
     bool operator == (_actions const &rhs) { return _value == rhs._value; }
     bool operator != (_actions const &rhs) { return _value != rhs._value; }
+    
     const char *caption ();
   private:
     int _value;
   };
+
   static const _actions Default_action;
   static const _actions Install_action;
   static const _actions Reinstall_action;
   static const _actions Uninstall_action;
+  static _actions action_from_argv();
   void set_action (packageversion const &default_version);
   void set_action (_actions, packageversion const & default_version);
   void uninstall ();
@@ -143,6 +150,7 @@ public:
   void logSelectionStatus() const;
   void logAllVersions() const;
 
+
 protected:
   packagemeta &operator= (packagemeta const &);
 private:

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

Reply via email to