public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [patch] a new setup.exe parameter to specify packages
@ 2008-08-02 20:24 Kohsuke Kawaguchi
  2008-08-04 15:35 ` Thrall, Bryan
  0 siblings, 1 reply; 8+ messages in thread
From: Kohsuke Kawaguchi @ 2008-08-02 20:24 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 637 bytes --]

Hi,

I wrote a patch for setup.exe so that it can take a list of packages
to be installed via the -P option, like this:

  setup.exe -P openssh,cvs,subversion

This would bring in the 3 modules and all their dependencies (of the
curr version.) The main use case for this is to perform unattended
installation from CLI.

I tried to make the coding style match with that of choose.cc, even
though the coding style of setup.exe as a whole seems to be different
from choose.cc. This is the first time I write a patch for Cygwin, so
my apologies if I'm missing some requirements.

-- 
Kohsuke Kawaguchi 
http://weblogs.java.net/blog/kohsuke/

[-- Attachment #2: P-option.diff --]
[-- Type: text/x-diff, Size: 1846 bytes --]

Index: choose.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/choose.cc,v
retrieving revision 2.144
diff -u -r2.144 choose.cc
--- choose.cc	8 Apr 2008 23:50:54 -0000	2.144
+++ choose.cc	2 Aug 2008 07:21:56 -0000
@@ -58,11 +58,15 @@
 #include "Generic.h"
 #include "ControlAdjuster.h"
 #include "prereq.h"
+#include "getopt++/StringOption.h"
 
 using namespace std;
 
 extern ThreeBarProgressPage Progress;
 
+StringOption PackageOption("", 'P', "package", "Packages to install", false);
+
+
 /*
   Sizing information.
  */
@@ -84,6 +88,22 @@
   sizeProcessor.AddControlInfo (ChooserControlsInfo);
 }
 
+vector<string>
+tokenize(const string& str)
+{
+  vector<string> result;
+
+  size_t s=0, e=string::npos;
+  do {
+    e=str.find_first_of(", ",s);
+    if(s!=e)
+      result.push_back(str.substr(s,e-s));
+    s=str.find_first_not_of(", ",e);
+  } while(s != string::npos);
+
+  return result;
+}
+
 void
 ChooserPage::createListview ()
 {
@@ -97,6 +117,22 @@
   chooser->Show(SW_SHOW);
 
   chooser->defaultTrust (TRUST_CURR);
+
+  // select ones that the user explicitly specified
+  vector<string> pkgs = tokenize(PackageOption);
+  for (vector <packagemeta *>::iterator i = db.packages.begin ();
+       i != db.packages.end (); ++i)
+    {
+      packagemeta* pkg = *i;
+      if (find(pkgs.begin(),pkgs.end(),pkg->name)!=pkgs.end())
+	    {
+          pkg->desired = pkg->trustp (TRUST_CURR);
+          if (pkg->desired)
+              pkg->desired.pick (pkg->desired.accessible() && 
+                                  pkg->desired != pkg->installed);
+	    }
+    }
+
   chooser->setViewMode (PickView::views::Category);
   if (!SetDlgItemText (GetHWND (), IDC_CHOOSE_VIEWCAPTION, chooser->mode_caption ()))
     log (LOG_BABBLE) << "Failed to set View button caption %ld" << 

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-08-06 17:18 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-02 20:24 [patch] a new setup.exe parameter to specify packages Kohsuke Kawaguchi
2008-08-04 15:35 ` Thrall, Bryan
2008-08-04 16:13   ` Christopher Faylor
2008-08-05 20:47     ` Brian Dessent
2008-08-05 20:50       ` Christopher Faylor
2008-08-06 16:42         ` Dave Korn
2008-08-06 17:18           ` Ralph Hempel
2008-08-04 20:35   ` Kohsuke Kawaguchi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).