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: allow -p option to specify categories as well as packages


    Last but not least,

  I found myself wanting to run setup in unattended mode to install absolutely
everything, so I figured the nicest solution was to allow the -p option to
accept category names as well as package names, so that I could use "-p All".
 The attached patch does just that.

	* package_meta.cc (packagemeta::isManuallyWanted): Allow category
	names as well as individual package names in packages_option.
	* package_db.cc (packagedb::fillMissingCategory): Don't check for
	manually-wanted packages until after initialising all the categories.

  Tested by running it a few times with no -p options and then with -p options
for things like "Net" and/or a couple of individual packages mixed in.  OK?

    cheers,
      DaveK
Index: package_meta.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/package_meta.cc,v
retrieving revision 2.54
diff -p -u -r2.54 package_meta.cc
--- package_meta.cc	13 Aug 2008 08:54:14 -0000	2.54
+++ package_meta.cc	4 Nov 2009 16:47:04 -0000
@@ -286,6 +286,7 @@ bool packagemeta::isManuallyWanted() con
 {
   static bool parsed_yet = false;
   static std::set<string> parsed_names;
+  static std::set<string> parsed_categories;
   bool bReturn = false;
   /* First time through, we parse all the names out from the 
     option string and store them away in an STL set.  */
@@ -299,12 +300,14 @@ bool packagemeta::isManuallyWanted() con
       {
 	tname = packages_option.substr(0,loc);
 	packages_option = packages_option.substr(loc+1);
-	parsed_names.insert (tname);
+	(packagedb::categories.find (tname) != packagedb::categories.end ()
+	  ? parsed_categories : parsed_names).insert (tname);
 	bReturn = bReturn || (name.compare(tname) == 0);
 	loc = packages_option.find(",",0);
       }
     /* At this point, no "," exists in packages_option.  */
-    parsed_names.insert (packages_option);
+    (packagedb::categories.find (packages_option) != packagedb::categories.end ()
+      ? parsed_categories : parsed_names).insert (packages_option);
     bReturn = bReturn || (name.compare(packages_option) == 0);
     parsed_yet = true;
     if (bReturn)
@@ -314,6 +317,19 @@ bool packagemeta::isManuallyWanted() con
   /* If we've already parsed the option string, just do
     a lookup in the cache of already-parsed names.  */
   bReturn = parsed_names.find(name) != parsed_names.end();
+  /* If we didn't select the package manually, did we select any 
+     of the categories it is in? */
+  if (!bReturn && parsed_categories.size ())
+    {
+      std::set<std::string, casecompare_lt_op>::iterator curcat;
+      for (curcat = categories.begin (); curcat != categories.end (); curcat++)
+	if (parsed_categories.find (*curcat) != parsed_categories.end ())
+	  {
+	    log (LOG_PLAIN) << "Found category " << *curcat << " in package " << name << endLog;
+	    bReturn = true;
+	  }
+    }
+  
   if (bReturn)
     log (LOG_PLAIN) << "Added manual package " << name << endLog;
   return bReturn;
Index: package_db.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/package_db.cc,v
retrieving revision 2.41
diff -p -u -r2.41 package_db.cc
--- package_db.cc	7 May 2009 14:14:58 -0000	2.41
+++ package_db.cc	4 Nov 2009 16:47:04 -0000
@@ -430,8 +430,8 @@ packagedb::setExistence ()
 void
 packagedb::fillMissingCategory ()
 {
-  for_each(packages.begin(), packages.end(), visit_if(mem_fun(&packagemeta::addToCategoryBase), mem_fun(&packagemeta::isManuallyWanted)));
   for_each(packages.begin(), packages.end(), visit_if(mem_fun(&packagemeta::setDefaultCategories), mem_fun(&packagemeta::hasNoCategories)));
   for_each(packages.begin(), packages.end(), mem_fun(&packagemeta::addToCategoryAll));
+  for_each(packages.begin(), packages.end(), visit_if(mem_fun(&packagemeta::addToCategoryBase), mem_fun(&packagemeta::isManuallyWanted)));
 }
 

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