This is the mail archive of the
cygwin-apps
mailing list for the Cygwin project.
[patch] a new setup.exe parameter to specify packages
- From: Kohsuke Kawaguchi <kk at kohsuke dot org>
- To: cygwin-apps at cygwin dot com
- Date: Sat, 02 Aug 2008 13:23:40 -0700
- Subject: [patch] a new setup.exe parameter to specify packages
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/
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" <<