setup.exe: feature request with patch

Dr. F. Lee rl201@cam.ac.uk
Mon Mar 6 15:10:00 GMT 2006


Hi All,

I deploy cygwin using unattended (http://unattended.sf.net/) and wpkg 
(http://www.wpkg.org/). It's useful for me to be able to specify 
additional packages to be installed on the command line. The attached 
file is a patch to provide this: call "setup -p 
package1,package2,package3,...,packageN" to have packages1-N 
artificially included in the 'Base' part of the distribution and hence 
automatically included.

No doubt there are many better ways of doing this (I'm not a C++ 
programmer and had to go with 'what I could do' rather than 'the best 
way') but perhaps this will be useful.

Yours,

Frank




-- 
Frank Lee
Semiconductor Physics, Cavendish Laboratory http://www.sp.phy.cam.ac.uk/
-------------- next part --------------
diff -u --strip-trailing-cr setup/package_db.cc setup-new/package_db.cc

--- setup/package_db.cc	2005-10-14 05:10:26.000000000 +0100

+++ setup-new/package_db.cc	2006-03-06 13:35:31.279477400 +0000

@@ -399,9 +399,16 @@

 #endif

 }

 

+void 

+packagedb::addFromCmdLine ()

+{

+  for_each(packages.begin(), packages.end(), mem_fun(&packagemeta::addToCategoryBase));

+}

+

 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));

 }

diff -u --strip-trailing-cr setup/package_db.h setup-new/package_db.h

--- setup/package_db.h	2003-07-29 11:07:22.000000000 +0100

+++ setup-new/package_db.h	2006-03-06 13:38:21.148123000 +0000

@@ -47,6 +47,7 @@

   PackageDBConnectedIterator connectedEnd();

   void fillMissingCategory();

   void markUnVisited();

+  void addFromCmdLine();

   void setExistence();

   /* all seen binary packages */

   static std::vector < packagemeta *> packages;

diff -u --strip-trailing-cr setup/package_meta.cc setup-new/package_meta.cc

--- setup/package_meta.cc	2005-09-11 15:45:54.000000000 +0100

+++ setup-new/package_meta.cc	2006-03-06 15:02:16.480086200 +0000

@@ -43,6 +43,7 @@

 #include "script.h"

 

 #include "package_version.h"

+#include "getopt++/StringOption.h"

 #include "cygpackage.h"

 #include "package_db.h"

 

@@ -53,6 +54,8 @@

 

 /*****************/

 

+static StringOption PackageOption ("", 'p', "package", "Packages to include");

+

 const

   packagemeta::_actions

 packagemeta::Default_action (0);

@@ -654,6 +657,25 @@

   return categories.size() == 0;

 }

 

+bool

+packagemeta::isManuallyWanted() const

+{  

+  string packages_option = PackageOption;

+  string tname;

+  /* Split the packages listed in the option up */

+  string::size_type loc = packages_option.find( ",", 0 );

+  bool breturn=false;

+  while ( loc != string::npos ) {

+    tname=packages_option.substr(0,loc);

+    packages_option=packages_option.substr(loc+1);

+    breturn = breturn || (name.compare(tname)==0);

+    loc = packages_option.find( ",", 0 );

+  }

+  /* At this point, no "," exists */

+  breturn=breturn || (name.compare(packages_option)==0);

+  return breturn;

+}

+

 void

 packagemeta::setDefaultCategories()

 {

@@ -665,3 +687,9 @@

 {

   add_category ("All");

 }

+

+void

+packagemeta::addToCategoryBase()

+{

+  add_category ("Base");

+}

diff -u --strip-trailing-cr setup/package_meta.h setup-new/package_meta.h

--- setup/package_meta.h	2005-05-03 22:55:08.000000000 +0100

+++ setup-new/package_meta.h	2006-03-06 13:37:39.642747800 +0000

@@ -54,8 +54,10 @@

   void visited(bool const &);

   bool visited() const;

   bool hasNoCategories() const;

+  bool isManuallyWanted() const;

   void setDefaultCategories();

   void addToCategoryAll();

+  void addToCategoryBase();

 

   class _actions

   {

diff -u --strip-trailing-cr setup/setup_version.c setup-new/setup_version.c

--- setup/setup_version.c	2006-03-06 12:24:59.154337800 +0000

+++ setup-new/setup_version.c	2006-03-06 13:05:52.788225000 +0000

@@ -1,3 +1,3 @@

 #define VERSION_PREFIX "%%% setup-version"

-static const char version_store[] = VERSION_PREFIX " 2.524";

+static const char version_store[] = VERSION_PREFIX " 2.524RFL";

 const char *setup_version = version_store + sizeof (VERSION_PREFIX);

diff -u --strip-trailing-cr setup/state.cc setup-new/state.cc

--- setup/state.cc	2005-05-04 15:52:34.000000000 +0100

+++ setup-new/state.cc	2006-03-06 14:27:05.103281400 +0000

@@ -23,6 +23,7 @@

 #include "state.h"

 

 bool unattended_mode;

+String packages_option;

 

 int source;

 

diff -u --strip-trailing-cr setup/state.h setup-new/state.h

--- setup/state.h	2005-05-04 15:52:34.000000000 +0100

+++ setup-new/state.h	2006-03-06 14:26:55.125727000 +0000

@@ -33,6 +33,8 @@

 

 extern bool unattended_mode;

 

+extern String packages_option;

+

 extern int source;

 

 extern String local_dir;

-------------- next part --------------
--
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/


More information about the Cygwin mailing list