public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* Patch for unattended setup (updated)
@ 2008-04-09 16:15 Dr. Frank Lee
  2008-04-09 22:02 ` Brian Dessent
  0 siblings, 1 reply; 12+ messages in thread
From: Dr. Frank Lee @ 2008-04-09 16:15 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: TEXT/PLAIN, Size: 666 bytes --]


I attach a re-working of my previous patch to setup.exe to support the '-p
package1[,package2[...]]' command line option. This patch also intercepts 
all
message boxes and returns some default values to the calling function for
unattended installations. A patched setup.exe will return 
IDS_REBOOT_REQUIRED
(=118) if a reboot seems desirable.

This patch applies to setup version 2.578 (the most recent I could 
compile).

(http://www.sp.phy.cam.ac.uk/~rl201/cygwin-setup-unattended-patch.diff 
contains
this patch and http://www.sp.phy.cam.ac.uk/~rl201/setup-patched.exe the
resulting executable - usual caveats about running such binaries apply!)

Yours,

Frank


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-diff; name=cygwin-setup-unattended-patch.diff, Size: 7061 bytes --]

Common subdirectories: setup-2.578/.deps and setup-2.578RFL/.deps
Common subdirectories: setup-2.578/cfgaux and setup-2.578RFL/cfgaux
Common subdirectories: setup-2.578/csu_util and setup-2.578RFL/csu_util
diff -u setup-2.578/install.cc setup-2.578RFL/install.cc
--- setup-2.578/install.cc	2008-04-09 16:46:25.718797700 +0100
+++ setup-2.578RFL/install.cc	2008-04-09 16:48:01.739933100 +0100
@@ -135,7 +135,7 @@
 
 static int num_installs, num_uninstalls;
 static void md5_one (const packagesource& source);
-static bool rebootneeded;
+// RFL static bool rebootneeded;
 
 void
 Installer::preremoveOne (packagemeta & pkg)
@@ -624,7 +624,11 @@
   if (myInstaller.errors)
     exit_msg = IDS_INSTALL_INCOMPLETE;
   else if (!unattended_mode)
-    exit_msg = IDS_INSTALL_COMPLETE;
+      exit_msg = IDS_INSTALL_COMPLETE;
+  
+  if (rebootneeded) 
+      exit_msg = IDS_REBOOT_REQUIRED;
+  
 }
 
 static DWORD WINAPI
Common subdirectories: setup-2.578/libgetopt++ and setup-2.578RFL/libgetopt++
Common subdirectories: setup-2.578/libmd5-rfc and setup-2.578RFL/libmd5-rfc
diff -u setup-2.578/main.cc setup-2.578RFL/main.cc
--- setup-2.578/main.cc	2008-04-09 16:48:32.321998100 +0100
+++ setup-2.578RFL/main.cc	2008-04-09 16:23:15.845822300 +0100
@@ -200,8 +200,11 @@
 
     // Clean exit.. save user options.
     UserSettings::Instance().saveAllSettings();
-
-    theLog->exit (0);
+    if (rebootneeded) {
+      theLog->exit (IDS_REBOOT_REQUIRED);
+    } else {
+      theLog->exit (0);
+    }
   }
   TOPLEVEL_CATCH("main");
 
diff -u setup-2.578/msg.cc setup-2.578RFL/msg.cc
--- setup-2.578/msg.cc	2008-04-09 16:48:50.170661100 +0100
+++ setup-2.578RFL/msg.cc	2008-04-09 15:54:06.363639500 +0100
@@ -30,6 +30,9 @@
 #include <stdarg.h>
 #include "dialog.h"
 
+// RFL
+#include "state.h"
+
 void
 msg (const char *fmt, ...)
 {
@@ -50,6 +53,35 @@
 
   vsnprintf (buf, 1000, fmt, args);
   log (LOG_PLAIN) << "mbox " << name << ": " << buf << endLog;
+  // RFL suspects this code should really be in the _custom_MessageBox routine but code
+  // placed there doesn't get executed (for the 'Files in-use have been replaced' message,
+  // at least.
+  if (unattended_mode) {
+    // Return some default values.
+    log (LOG_PLAIN) << "Unattended_mode is set at mbox" << endLog;
+    switch (type & MB_TYPEMASK) 
+      {
+      case MB_OK | MB_OKCANCEL:
+        return IDOK;
+        break;
+      case MB_YESNO | MB_YESNOCANCEL:
+        return IDYES;
+        break;
+      case MB_ABORTRETRYIGNORE: 
+        return IDIGNORE;
+        break;
+      case MB_RETRYCANCEL: // Retry -> infinite loop perchance
+        return IDCANCEL;
+        break;
+      //case MB_CANCELTRYCONTINUE:
+      //  return IDCONTINUE;
+      //  break;
+      default:
+        return 0;
+      }   
+  } 
+  // Back to previous code
+
   return MessageBox (owner, buf, "Cygwin Setup", type);
 }
 
diff -u setup-2.578/package_db.cc setup-2.578RFL/package_db.cc
--- setup-2.578/package_db.cc	2008-04-09 16:49:14.479883100 +0100
+++ setup-2.578RFL/package_db.cc	2008-04-09 15:40:01.339239500 +0100
@@ -398,8 +398,15 @@
 }
 
 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 setup-2.578/package_db.h setup-2.578RFL/package_db.h
--- setup-2.578/package_db.h	2008-04-09 16:49:27.526145100 +0100
+++ setup-2.578RFL/package_db.h	2008-04-09 15:37:58.356892100 +0100
@@ -46,6 +46,7 @@
   PackageDBConnectedIterator connectedEnd();
   void fillMissingCategory();
   void markUnVisited();
+  void addFromCmdLine();
   void setExistence();
   /* all seen binary packages */
   static std::vector < packagemeta *> packages;
diff -u setup-2.578/package_meta.cc setup-2.578RFL/package_meta.cc
--- setup-2.578/package_meta.cc	2008-04-09 16:50:17.677603100 +0100
+++ setup-2.578RFL/package_meta.cc	2008-04-09 15:42:15.103472300 +0100
@@ -42,6 +42,7 @@
 #include "script.h"
 
 #include "package_version.h"
+#include "getopt++/StringOption.h"
 #include "cygpackage.h"
 #include "package_db.h"
 
@@ -242,6 +243,26 @@
   return pkg.SDesc().size();
 }
 
+static StringOption PackageOption ("", 'p', "package", "Packages to include");
+
+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 in packages_option */
+  bReturn=bReturn || (name.compare(packages_option)==0);
+  return bReturn;
+}
+
 const std::string
 packagemeta::SDesc () const
 {
@@ -664,3 +685,9 @@
 {
   add_category ("All");
 }
+
+void 
+packagemeta::addToCategoryBase() 
+{
+  add_category ("Base");
+}
diff -u setup-2.578/package_meta.h setup-2.578RFL/package_meta.h
--- setup-2.578/package_meta.h	2008-04-09 16:49:48.519051100 +0100
+++ setup-2.578RFL/package_meta.h	2008-04-09 15:30:06.535953500 +0100
@@ -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
   {
Only in setup-2.578RFL: state.bak
diff -u setup-2.578/state.cc setup-2.578RFL/state.cc
--- setup-2.578/state.cc	2006-04-15 22:21:25.000000000 +0100
+++ setup-2.578RFL/state.cc	2008-04-09 16:32:11.076677500 +0100
@@ -23,6 +23,7 @@
 #include "state.h"
 
 bool unattended_mode;
+bool rebootneeded;
 
 int source;
 
diff -u setup-2.578/state.h setup-2.578RFL/state.h
--- setup-2.578/state.h	2008-04-09 16:50:45.694216100 +0100
+++ setup-2.578RFL/state.h	2008-04-09 16:22:36.223567100 +0100
@@ -32,10 +32,12 @@
 #include <string>
 
 extern bool unattended_mode;
+extern bool rebootneeded;
 
 extern int source;
 
 extern std::string local_dir;
+extern std::string packages_option;
 
 extern int root_text;
 extern int root_scope;
Common subdirectories: setup-2.578/tests and setup-2.578RFL/tests

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

* Re: Patch for unattended setup (updated)
  2008-04-09 16:15 Patch for unattended setup (updated) Dr. Frank Lee
@ 2008-04-09 22:02 ` Brian Dessent
       [not found]   ` <alpine.DEB.0.99.0804100029430.7705@gath>
  0 siblings, 1 reply; 12+ messages in thread
From: Brian Dessent @ 2008-04-09 22:02 UTC (permalink / raw)
  To: Dr. Frank Lee; +Cc: cygwin-apps

"Dr. Frank Lee" wrote:

> I attach a re-working of my previous patch to setup.exe to support the '-p
> package1[,package2[...]]' command line option. This patch also intercepts
> all
> message boxes and returns some default values to the calling function for
> unattended installations. A patched setup.exe will return
> IDS_REBOOT_REQUIRED
> (=118) if a reboot seems desirable.
> 
> This patch applies to setup version 2.578 (the most recent I could
> compile).
> 
> (http://www.sp.phy.cam.ac.uk/~rl201/cygwin-setup-unattended-patch.diff
> contains
> this patch and http://www.sp.phy.cam.ac.uk/~rl201/setup-patched.exe the
> resulting executable - usual caveats about running such binaries apply!)

Sorry but there are a number of problems with this.

1. Please don't send a patch with CRLF line endings when the file has LF
line endings.

2. Patches need to be against current CVS, not an 8 month old version. 
For example, CVS setup has already had a -p option (for specifying proxy
options) for several months, so you need to pick a different name.  Or
stated differently: if, when applied to HEAD, your patch won't compile
then it's a serious problem with the patch that needs fixing, since it
can only be applied to HEAD.  I just uploaded a 2.588 snapshot yesterday
so I know that HEAD builds fine.

3. You need to follow the the GNU coding style, e.g. opening brace on
its own line, 2 space indents, space before '(' and on both sides of
'='.  I know that not all of setup is consistent this way, but it
doesn't help to make the problem worse by introducing more.

4. There is no ChangeLog entry.

5. This looks like a messy work in progress; hunks like these are
unacceptable:

-static bool rebootneeded;
+// RFL static bool rebootneeded;

+// RFL
+#include "state.h"
+

+      //case MB_CANCELTRYCONTINUE:
+      //  return IDCONTINUE;
+      //  break;

+  // RFL suspects this code should really be in the _custom_MessageBox
routine but code
+  // placed there doesn't get executed (for the 'Files in-use have been
replaced' message,
+  // at least.
+  if (unattended_mode) {

In other words, if something needs to be removed, it should be removed
not commented out.  Also, patches should not have marker/vanity
comments.

Brian

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

* Re: Patch for unattended setup (updated)
       [not found]   ` <alpine.DEB.0.99.0804100029430.7705@gath>
@ 2008-04-09 23:58     ` Brian Dessent
  2008-04-10  0:12       ` Dr. Frank Lee
  0 siblings, 1 reply; 12+ messages in thread
From: Brian Dessent @ 2008-04-09 23:58 UTC (permalink / raw)
  To: Dr. Frank Lee; +Cc: cygwin-apps

"Dr. Frank Lee" wrote:

> I'm trying to compile from CVS and running into a few problems. Might I
> pick your brains, please?

Sure, but please use the mailing list rather than sending to me
directly.

> I see I should install some packages, which I do. I run bootstrap.sh which
> appears to run correctly, and ./configure with a number of options which
> appears to run fine. And then I run 'make', resulting in the command:
> test -f inilex.cc || /bin/sh ./cfgaux/ylwrap inilex.ll .c inilex.cc --
> flex  -8
> failing with exit code 1.
> 
> This is a clean install of cygwin and I'm rather at a loss to diagnose
> much further. inilex.cc certainly doesn't exist, so it seems the ylwrap
> script is failing but this is starting to get beyond my area of
> expertise...

inilex.cc is generated from inilex.ll by flex.  The ylwrap script is a
wrapper for invoking flex and handling the renaming of the output file
to the correct name.  I appears you don't have flex installed though, in
which case ylwrap can't do anything.

I see that README doesn't list flex as required, which I'll fix shortly.

BTW there is a similar thing with iniparse.cc being generated from
iniparse.yy with bison, which is also required when building from CVS
and not currently listed in README.

Brian

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

* Re: Patch for unattended setup (updated)
  2008-04-09 23:58     ` Brian Dessent
@ 2008-04-10  0:12       ` Dr. Frank Lee
  2008-04-10  0:39         ` Brian Dessent
  0 siblings, 1 reply; 12+ messages in thread
From: Dr. Frank Lee @ 2008-04-10  0:12 UTC (permalink / raw)
  To: cygwin-apps

(re: request for assistance building the CVS for setup.exe)
> Sure, but please use the mailing list rather than sending to me
> directly.

Many thanks. Replying through the list, as suggested.

> inilex.cc is generated from inilex.ll by flex.  The ylwrap script is a
> wrapper for invoking flex and handling the renaming of the output file
> to the correct name.  I appears you don't have flex installed though, in
> which case ylwrap can't do anything.

'which flex' suggests that flex is installed in /usr/bin/flex. 'which 
bison' suggests /usr/bin/bison is installed.

> I see that README doesn't list flex as required, which I'll fix shortly.

Thanks.

At the risk of poking around in things I don't pretend to understand, 
inserting "set -xv" into the second line of the ylwrap script produces the 
following output below (which I hope might help).

Yours,

Frank

(last N lines of output from 'make':)
+ test 0 -eq 0
+ set X .c inilex.cc
+ shift
+ first=yes
+ y_tab_nodot=no
+ test -f y_tab.c
+ test -f y_tab.h
echo "$input" | sed -e 's,\([\/]\)[^\/]*$,\1,'
++ echo /cygdrive/c/temp/setup/inilex.ll
++ sed -e 's,\([\/]\)[^\/]*$,\1,'
+ input_dir=/cygdrive/c/temp/setup/
echo "$input_dir" | sed 's,\\,\\\\,g;s,\.,\\.,g'
++ echo /cygdrive/c/temp/setup/
++ sed 's,\\,\\\\,g;s,\.,\\.,g'
+ input_rx=/cygdrive/c/temp/setup/
+ test 2 -ne 0
+ from=.c
+ test no = yes
+ test -f .c
+ test yes = yes
+ ret=1
+ shift
+ shift
+ first=no
+ test 0 -ne 0

# Remove the directory.
cd ..
+ cd ..
rm -rf $dirname
+ rm -rf ylwrap2440

exit $ret
+ exit 1
make[2]: *** [inilex.cc] Error 1
make[2]: Leaving directory `/cygdrive/c/temp/setup'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/cygdrive/c/temp/setup'
make: *** [all] Error 2


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

* Re: Patch for unattended setup (updated)
  2008-04-10  0:12       ` Dr. Frank Lee
@ 2008-04-10  0:39         ` Brian Dessent
  2008-04-10  0:52           ` Dr. Frank Lee
  0 siblings, 1 reply; 12+ messages in thread
From: Brian Dessent @ 2008-04-10  0:39 UTC (permalink / raw)
  To: Dr. Frank Lee; +Cc: cygwin-apps

"Dr. Frank Lee" wrote:

> 'which flex' suggests that flex is installed in /usr/bin/flex. 'which
> bison' suggests /usr/bin/bison is installed.

Did you add those packages after configure was run?  If so you'll need
to re-run configure (or delete config.cache and run ./config.status
--recheck) otherwise the autoconf variables will still be setup to
specify invoking the 'missing' script in place of flex/bison.

This 'missing' script is a feature of autoconf meant to help in
situations where the generated file is in fact distributed to the user
in the tarball (i.e. it doesn't need to be remade), but the timestamps
are not correctly preserved by the user or the filesystem in use, such
that 'make' thinks it needs to be remade.  Autoconf substitutes the
'missing' script in place of developer tools that the configure script
found to be missing, in the hope that such an attempt to regenerate the
file will succeed despite the missing tool, given that a sufficiently
up-to-date generated file does exist.

But none of the above applies in this case because the generated file
really doesn't exist, it's not just a case of timestamps being
incorrect.

Brian

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

* Re: Patch for unattended setup (updated)
  2008-04-10  0:39         ` Brian Dessent
@ 2008-04-10  0:52           ` Dr. Frank Lee
  2008-04-10 13:31             ` Dr. Frank Lee
  0 siblings, 1 reply; 12+ messages in thread
From: Dr. Frank Lee @ 2008-04-10  0:52 UTC (permalink / raw)
  To: cygwin-apps

>> 'which flex' suggests that flex is installed in /usr/bin/flex. 'which
>> bison' suggests /usr/bin/bison is installed.
>
> Did you add those packages after configure was run?  If so you'll need
> to re-run configure (or delete config.cache and run ./config.status
> --recheck) otherwise the autoconf variables will still be setup to
> specify invoking the 'missing' script in place of flex/bison.

Aha - bash_history suggests that I did exactly that. And re-running 
configure produces a sensible binary from the CVS. Thank you, Brian.

> This 'missing' script is a feature of autoconf meant to help in
> situations where the generated file is in fact distributed to the user
> in the tarball (i.e. it doesn't need to be remade), but the timestamps
> are not correctly preserved by the user or the filesystem in use, such
> that 'make' thinks it needs to be remade.  Autoconf substitutes the
> 'missing' script in place of developer tools that the configure script
> found to be missing, in the hope that such an attempt to regenerate the
> file will succeed despite the missing tool, given that a sufficiently
> up-to-date generated file does exist.
>
> But none of the above applies in this case because the generated file
> really doesn't exist, it's not just a case of timestamps being
> incorrect.

That makes sense, thanks.

I will provide an updated patch based on the current CVS with appropriate 
GNU coding style and using '-s' for the software package switch. (Unless 
there is a more appropriate suggestion?)

Yours,

Frank

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

* Re: Patch for unattended setup (updated)
  2008-04-10  0:52           ` Dr. Frank Lee
@ 2008-04-10 13:31             ` Dr. Frank Lee
  2008-04-10 16:00               ` Christopher Faylor
  0 siblings, 1 reply; 12+ messages in thread
From: Dr. Frank Lee @ 2008-04-10 13:31 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: TEXT/PLAIN, Size: 406 bytes --]

> I will provide an updated patch based on the current CVS with appropriate GNU 
> coding style and using '-s' for the software package switch.

I attach an updated patch which I believe conforms to the guidelines.

Yours,

Frank

(Brief summary: exit code 118 -> reboot needed; command line option '-s 
package1[,package2[,...]]' to install software packages; dialogue boxes 
with the user are suppressed)

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/X-DIFF; NAME=cygwin-setup-unattended-patch.diff, Size: 7592 bytes --]

Common subdirectories: setup-2.590-cvs/.deps and setup-2.590-rfl/.deps
Common subdirectories: setup-2.590-cvs/.libs and setup-2.590-rfl/.libs
Common subdirectories: setup-2.590-cvs/CVS and setup-2.590-rfl/CVS
diff -u setup-2.590-cvs/ChangeLog setup-2.590-rfl/ChangeLog
--- setup-2.590-cvs/ChangeLog	2008-04-10 13:36:07.000000000 +0100
+++ setup-2.590-rfl/ChangeLog	2008-04-10 14:08:16.090147800 +0100
@@ -1,3 +1,8 @@
+2008-04-10  Frank Lee  <rl201@cam.ac.uk>
+	* Add command-line option '-s' to select software packages.
+	* Intercept calls to message boxes if unattended flag (-q) is set.
+	* Exit code IDS_REBOOT_REQUIRED is returned if needed.
+
 2008-04-10  Brian Dessent  <brian@dessent.net>
 
 	* Makefile.am (setup_LDFLAGS): Make sure static libbz2 and zlib
Only in setup-2.590-rfl: ChangeLog.orig
Only in setup-2.590-rfl: ChangeLog.rej
Common subdirectories: setup-2.590-cvs/autom4te.cache and setup-2.590-rfl/autom4te.cache
Common subdirectories: setup-2.590-cvs/bz2lib and setup-2.590-rfl/bz2lib
Common subdirectories: setup-2.590-cvs/cfgaux and setup-2.590-rfl/cfgaux
Common subdirectories: setup-2.590-cvs/csu_util and setup-2.590-rfl/csu_util
diff -u setup-2.590-cvs/install.cc setup-2.590-rfl/install.cc
--- setup-2.590-cvs/install.cc	2008-04-09 03:25:27.000000000 +0100
+++ setup-2.590-rfl/install.cc	2008-04-10 14:07:25.542625800 +0100
@@ -135,7 +135,6 @@
 
 static int num_installs, num_uninstalls;
 static void md5_one (const packagesource& source);
-static bool rebootneeded;
 
 void
 Installer::preremoveOne (packagemeta & pkg)
@@ -636,6 +635,9 @@
     exit_msg = IDS_INSTALL_INCOMPLETE;
   else if (!unattended_mode)
     exit_msg = IDS_INSTALL_COMPLETE;
+
+  if (rebootneeded)
+    exit_msg = IDS_REBOOT_REQUIRED;
 }
 
 static DWORD WINAPI
Common subdirectories: setup-2.590-cvs/libgetopt++ and setup-2.590-rfl/libgetopt++
Common subdirectories: setup-2.590-cvs/libmd5-rfc and setup-2.590-rfl/libmd5-rfc
diff -u setup-2.590-cvs/main.cc setup-2.590-rfl/main.cc
--- setup-2.590-cvs/main.cc	2007-02-28 00:55:04.000000000 +0000
+++ setup-2.590-rfl/main.cc	2008-04-10 14:07:25.542625800 +0100
@@ -200,8 +200,11 @@
 
     // Clean exit.. save user options.
     UserSettings::Instance().saveAllSettings();
-
-    theLog->exit (0);
+    if (rebootneeded) {
+      theLog->exit (IDS_REBOOT_REQUIRED);
+    } else {
+      theLog->exit (0);
+    }
   }
   TOPLEVEL_CATCH("main");
 
diff -u setup-2.590-cvs/msg.cc setup-2.590-rfl/msg.cc
--- setup-2.590-cvs/msg.cc	2004-12-27 16:12:44.000000000 +0000
+++ setup-2.590-rfl/msg.cc	2008-04-10 14:07:25.542625800 +0100
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include "dialog.h"
+#include "state.h"
 
 void
 msg (const char *fmt, ...)
@@ -50,6 +51,27 @@
 
   vsnprintf (buf, 1000, fmt, args);
   log (LOG_PLAIN) << "mbox " << name << ": " << buf << endLog;
+  if (unattended_mode) {
+    // Return some default values.
+    log (LOG_PLAIN) << "unattended_mode is set at mbox: returning default value" << endLog;
+    switch (type & MB_TYPEMASK)
+    {
+      case MB_OK | MB_OKCANCEL:
+        return IDOK;
+        break;
+      case MB_YESNO | MB_YESNOCANCEL:
+        return IDYES;
+        break;
+      case MB_ABORTRETRYIGNORE:
+        return IDIGNORE;
+        break;
+      case MB_RETRYCANCEL:
+        return IDCANCEL;
+        break;
+      default:
+        return 0;
+    }
+  }
   return MessageBox (owner, buf, "Cygwin Setup", type);
 }
 
diff -u setup-2.590-cvs/package_db.cc setup-2.590-rfl/package_db.cc
--- setup-2.590-cvs/package_db.cc	2008-04-09 00:50:54.000000000 +0100
+++ setup-2.590-rfl/package_db.cc	2008-04-10 14:07:25.558251000 +0100
@@ -401,6 +401,7 @@
 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 setup-2.590-cvs/package_db.h setup-2.590-rfl/package_db.h
--- setup-2.590-cvs/package_db.h	2006-04-17 16:40:11.000000000 +0100
+++ setup-2.590-rfl/package_db.h	2008-04-10 14:07:25.558251000 +0100
@@ -47,6 +47,7 @@
   void fillMissingCategory();
   void markUnVisited();
   void setExistence();
+  void addFromCmdLine();
   /* all seen binary packages */
   static std::vector < packagemeta *> packages;
   /* all seen source packages */
diff -u setup-2.590-cvs/package_meta.cc setup-2.590-rfl/package_meta.cc
--- setup-2.590-cvs/package_meta.cc	2006-04-17 17:13:17.000000000 +0100
+++ setup-2.590-rfl/package_meta.cc	2008-04-10 14:07:25.558251000 +0100
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <strings.h>
+#include "getopt++/StringOption.h"
 
 #include "io_stream.h"
 #include "compress.h"
@@ -242,6 +243,26 @@
   return pkg.SDesc().size();
 }
 
+static StringOption PackageOption ("", 's', "software", "Software packages to include");
+
+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 in packages_option */
+  bReturn = bReturn || (name.compare(packages_option) == 0);
+  return bReturn;
+}
+
 const std::string
 packagemeta::SDesc () const
 {
@@ -647,6 +668,12 @@
        referenced are unselectable anyway.  */
 }
 
+void 
+packagemeta::addToCategoryBase() 
+{
+  add_category ("Base");
+}
+
 bool
 packagemeta::hasNoCategories() const
 {
diff -u setup-2.590-cvs/package_meta.h setup-2.590-rfl/package_meta.h
--- setup-2.590-cvs/package_meta.h	2006-04-17 17:13:17.000000000 +0100
+++ setup-2.590-rfl/package_meta.h	2008-04-10 14:07:25.573876200 +0100
@@ -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
   {
Common subdirectories: setup-2.590-cvs/rsync and setup-2.590-rfl/rsync
diff -u setup-2.590-cvs/state.cc setup-2.590-rfl/state.cc
--- setup-2.590-cvs/state.cc	2006-04-15 22:21:25.000000000 +0100
+++ setup-2.590-rfl/state.cc	2008-04-10 14:07:25.573876200 +0100
@@ -23,6 +23,7 @@
 #include "state.h"
 
 bool unattended_mode;
+bool rebootneeded;
 
 int source;
 
diff -u setup-2.590-cvs/state.h setup-2.590-rfl/state.h
--- setup-2.590-cvs/state.h	2006-04-15 22:21:25.000000000 +0100
+++ setup-2.590-rfl/state.h	2008-04-10 14:07:25.589501400 +0100
@@ -32,10 +32,12 @@
 #include <string>
 
 extern bool unattended_mode;
+extern bool rebootneeded;
 
 extern int source;
 
 extern std::string local_dir;
+extern std::string packages_option;
 
 extern int root_text;
 extern int root_scope;
Common subdirectories: setup-2.590-cvs/temp and setup-2.590-rfl/temp
Common subdirectories: setup-2.590-cvs/tests and setup-2.590-rfl/tests
Common subdirectories: setup-2.590-cvs/zlib and setup-2.590-rfl/zlib

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

* Re: Patch for unattended setup (updated)
  2008-04-10 13:31             ` Dr. Frank Lee
@ 2008-04-10 16:00               ` Christopher Faylor
  2008-04-10 16:54                 ` Dr. Frank Lee
  0 siblings, 1 reply; 12+ messages in thread
From: Christopher Faylor @ 2008-04-10 16:00 UTC (permalink / raw)
  To: cygwin-apps

On Thu, Apr 10, 2008 at 02:31:57PM +0100, Dr. Frank Lee wrote:
>> I will provide an updated patch based on the current CVS with appropriate 
>> GNU coding style and using '-s' for the software package switch.
>
> I attach an updated patch which I believe conforms to the guidelines.
>
> Yours,
>
> Frank
>
> (Brief summary: exit code 118 -> reboot needed; command line option '-s 
> package1[,package2[,...]]' to install software packages; dialogue boxes 
> with the user are suppressed)

>Common subdirectories: setup-2.590-cvs/.deps and setup-2.590-rfl/.deps
>Common subdirectories: setup-2.590-cvs/.libs and setup-2.590-rfl/.libs
>Common subdirectories: setup-2.590-cvs/CVS and setup-2.590-rfl/CVS
>diff -u setup-2.590-cvs/ChangeLog setup-2.590-rfl/ChangeLog
>--- setup-2.590-cvs/ChangeLog	2008-04-10 13:36:07.000000000 +0100
>+++ setup-2.590-rfl/ChangeLog	2008-04-10 14:08:16.090147800 +0100
>@@ -1,3 +1,8 @@
>+2008-04-10  Frank Lee  <rl201@cam.ac.uk>
>+	* Add command-line option '-s' to select software packages.
>+	* Intercept calls to message boxes if unattended flag (-q) is set.
>+	* Exit code IDS_REBOOT_REQUIRED is returned if needed.
>+
> 2008-04-10  Brian Dessent  <brian@dessent.net>
> 
> 	* Makefile.am (setup_LDFLAGS): Make sure static libbz2 and zlib

The above ChangeLog is not standard.  Just take a look at all of the other
entries in this file and you'll see things like it's missing a blank line after the
initial entry, it's missing filenames, and it is missing function names.  Also
the "voice" used is supposed to be active not passive, i.e., change:

	* Exit code IDS_REBOOT_REQUIRED is returned if needed.

to

	* install.cc (do_install_thread): Return exit code IDS_REBOOT_REQUIRED
	if needed.

See also:  http://www.gnu.org/prep/standards/html_node/Change-Logs.html .

cgf

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

* Re: Patch for unattended setup (updated)
  2008-04-10 16:00               ` Christopher Faylor
@ 2008-04-10 16:54                 ` Dr. Frank Lee
  2008-04-10 16:56                   ` Dr. Frank Lee
  0 siblings, 1 reply; 12+ messages in thread
From: Dr. Frank Lee @ 2008-04-10 16:54 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: TEXT/PLAIN, Size: 695 bytes --]

> The above ChangeLog is not standard.  Just take a look at all of the other
> entries in this file and you'll see things like it's missing a blank line after the
> initial entry, it's missing filenames, and it is missing function names.  Also
> the "voice" used is supposed to be active not passive, i.e., change:
> 	* Exit code IDS_REBOOT_REQUIRED is returned if needed.
> 	* install.cc (do_install_thread): Return exit code IDS_REBOOT_REQUIRED
> 	if needed.
> See also:  http://www.gnu.org/prep/standards/html_node/Change-Logs.html .

Thank you - a very useful link. I have followed it to produce the attached 
patch for consideration. Please do point out any further problems.

Yours,

Frank

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-diff; name=cygwin-setup-unattended-patch.diff, Size: 7592 bytes --]

Common subdirectories: setup-2.590-cvs/.deps and setup-2.590-rfl/.deps
Common subdirectories: setup-2.590-cvs/.libs and setup-2.590-rfl/.libs
Common subdirectories: setup-2.590-cvs/CVS and setup-2.590-rfl/CVS
diff -u setup-2.590-cvs/ChangeLog setup-2.590-rfl/ChangeLog
--- setup-2.590-cvs/ChangeLog	2008-04-10 13:36:07.000000000 +0100
+++ setup-2.590-rfl/ChangeLog	2008-04-10 14:08:16.090147800 +0100
@@ -1,3 +1,8 @@
+2008-04-10  Frank Lee  <rl201@cam.ac.uk>
+	* Add command-line option '-s' to select software packages.
+	* Intercept calls to message boxes if unattended flag (-q) is set.
+	* Exit code IDS_REBOOT_REQUIRED is returned if needed.
+
 2008-04-10  Brian Dessent  <brian@dessent.net>
 
 	* Makefile.am (setup_LDFLAGS): Make sure static libbz2 and zlib
Only in setup-2.590-rfl: ChangeLog.orig
Only in setup-2.590-rfl: ChangeLog.rej
Common subdirectories: setup-2.590-cvs/autom4te.cache and setup-2.590-rfl/autom4te.cache
Common subdirectories: setup-2.590-cvs/bz2lib and setup-2.590-rfl/bz2lib
Common subdirectories: setup-2.590-cvs/cfgaux and setup-2.590-rfl/cfgaux
Common subdirectories: setup-2.590-cvs/csu_util and setup-2.590-rfl/csu_util
diff -u setup-2.590-cvs/install.cc setup-2.590-rfl/install.cc
--- setup-2.590-cvs/install.cc	2008-04-09 03:25:27.000000000 +0100
+++ setup-2.590-rfl/install.cc	2008-04-10 14:07:25.542625800 +0100
@@ -135,7 +135,6 @@
 
 static int num_installs, num_uninstalls;
 static void md5_one (const packagesource& source);
-static bool rebootneeded;
 
 void
 Installer::preremoveOne (packagemeta & pkg)
@@ -636,6 +635,9 @@
     exit_msg = IDS_INSTALL_INCOMPLETE;
   else if (!unattended_mode)
     exit_msg = IDS_INSTALL_COMPLETE;
+
+  if (rebootneeded)
+    exit_msg = IDS_REBOOT_REQUIRED;
 }
 
 static DWORD WINAPI
Common subdirectories: setup-2.590-cvs/libgetopt++ and setup-2.590-rfl/libgetopt++
Common subdirectories: setup-2.590-cvs/libmd5-rfc and setup-2.590-rfl/libmd5-rfc
diff -u setup-2.590-cvs/main.cc setup-2.590-rfl/main.cc
--- setup-2.590-cvs/main.cc	2007-02-28 00:55:04.000000000 +0000
+++ setup-2.590-rfl/main.cc	2008-04-10 14:07:25.542625800 +0100
@@ -200,8 +200,11 @@
 
     // Clean exit.. save user options.
     UserSettings::Instance().saveAllSettings();
-
-    theLog->exit (0);
+    if (rebootneeded) {
+      theLog->exit (IDS_REBOOT_REQUIRED);
+    } else {
+      theLog->exit (0);
+    }
   }
   TOPLEVEL_CATCH("main");
 
diff -u setup-2.590-cvs/msg.cc setup-2.590-rfl/msg.cc
--- setup-2.590-cvs/msg.cc	2004-12-27 16:12:44.000000000 +0000
+++ setup-2.590-rfl/msg.cc	2008-04-10 14:07:25.542625800 +0100
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include "dialog.h"
+#include "state.h"
 
 void
 msg (const char *fmt, ...)
@@ -50,6 +51,27 @@
 
   vsnprintf (buf, 1000, fmt, args);
   log (LOG_PLAIN) << "mbox " << name << ": " << buf << endLog;
+  if (unattended_mode) {
+    // Return some default values.
+    log (LOG_PLAIN) << "unattended_mode is set at mbox: returning default value" << endLog;
+    switch (type & MB_TYPEMASK)
+    {
+      case MB_OK | MB_OKCANCEL:
+        return IDOK;
+        break;
+      case MB_YESNO | MB_YESNOCANCEL:
+        return IDYES;
+        break;
+      case MB_ABORTRETRYIGNORE:
+        return IDIGNORE;
+        break;
+      case MB_RETRYCANCEL:
+        return IDCANCEL;
+        break;
+      default:
+        return 0;
+    }
+  }
   return MessageBox (owner, buf, "Cygwin Setup", type);
 }
 
diff -u setup-2.590-cvs/package_db.cc setup-2.590-rfl/package_db.cc
--- setup-2.590-cvs/package_db.cc	2008-04-09 00:50:54.000000000 +0100
+++ setup-2.590-rfl/package_db.cc	2008-04-10 14:07:25.558251000 +0100
@@ -401,6 +401,7 @@
 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 setup-2.590-cvs/package_db.h setup-2.590-rfl/package_db.h
--- setup-2.590-cvs/package_db.h	2006-04-17 16:40:11.000000000 +0100
+++ setup-2.590-rfl/package_db.h	2008-04-10 14:07:25.558251000 +0100
@@ -47,6 +47,7 @@
   void fillMissingCategory();
   void markUnVisited();
   void setExistence();
+  void addFromCmdLine();
   /* all seen binary packages */
   static std::vector < packagemeta *> packages;
   /* all seen source packages */
diff -u setup-2.590-cvs/package_meta.cc setup-2.590-rfl/package_meta.cc
--- setup-2.590-cvs/package_meta.cc	2006-04-17 17:13:17.000000000 +0100
+++ setup-2.590-rfl/package_meta.cc	2008-04-10 14:07:25.558251000 +0100
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <strings.h>
+#include "getopt++/StringOption.h"
 
 #include "io_stream.h"
 #include "compress.h"
@@ -242,6 +243,26 @@
   return pkg.SDesc().size();
 }
 
+static StringOption PackageOption ("", 's', "software", "Software packages to include");
+
+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 in packages_option */
+  bReturn = bReturn || (name.compare(packages_option) == 0);
+  return bReturn;
+}
+
 const std::string
 packagemeta::SDesc () const
 {
@@ -647,6 +668,12 @@
        referenced are unselectable anyway.  */
 }
 
+void 
+packagemeta::addToCategoryBase() 
+{
+  add_category ("Base");
+}
+
 bool
 packagemeta::hasNoCategories() const
 {
diff -u setup-2.590-cvs/package_meta.h setup-2.590-rfl/package_meta.h
--- setup-2.590-cvs/package_meta.h	2006-04-17 17:13:17.000000000 +0100
+++ setup-2.590-rfl/package_meta.h	2008-04-10 14:07:25.573876200 +0100
@@ -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
   {
Common subdirectories: setup-2.590-cvs/rsync and setup-2.590-rfl/rsync
diff -u setup-2.590-cvs/state.cc setup-2.590-rfl/state.cc
--- setup-2.590-cvs/state.cc	2006-04-15 22:21:25.000000000 +0100
+++ setup-2.590-rfl/state.cc	2008-04-10 14:07:25.573876200 +0100
@@ -23,6 +23,7 @@
 #include "state.h"
 
 bool unattended_mode;
+bool rebootneeded;
 
 int source;
 
diff -u setup-2.590-cvs/state.h setup-2.590-rfl/state.h
--- setup-2.590-cvs/state.h	2006-04-15 22:21:25.000000000 +0100
+++ setup-2.590-rfl/state.h	2008-04-10 14:07:25.589501400 +0100
@@ -32,10 +32,12 @@
 #include <string>
 
 extern bool unattended_mode;
+extern bool rebootneeded;
 
 extern int source;
 
 extern std::string local_dir;
+extern std::string packages_option;
 
 extern int root_text;
 extern int root_scope;
Common subdirectories: setup-2.590-cvs/temp and setup-2.590-rfl/temp
Common subdirectories: setup-2.590-cvs/tests and setup-2.590-rfl/tests
Common subdirectories: setup-2.590-cvs/zlib and setup-2.590-rfl/zlib

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

* Re: Patch for unattended setup (updated)
  2008-04-10 16:54                 ` Dr. Frank Lee
@ 2008-04-10 16:56                   ` Dr. Frank Lee
  2008-06-22 17:09                     ` Brian Dessent
  0 siblings, 1 reply; 12+ messages in thread
From: Dr. Frank Lee @ 2008-04-10 16:56 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: TEXT/PLAIN, Size: 190 bytes --]

> Thank you - a very useful link. I have followed it to produce the attached 
> patch for consideration. Please do point out any further problems.

Apologies, _this_ is the new patch.

Frank

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: TEXT/x-diff; name=cygwin-setup-unattended-patch.diff, Size: 8297 bytes --]

Common subdirectories: setup-2.590-cvs/.deps and setup-2.590-rfl2/.deps
Common subdirectories: setup-2.590-cvs/.libs and setup-2.590-rfl2/.libs
Common subdirectories: setup-2.590-cvs/CVS and setup-2.590-rfl2/CVS
diff -u setup-2.590-cvs/ChangeLog setup-2.590-rfl2/ChangeLog
--- setup-2.590-cvs/ChangeLog	2008-04-10 13:36:07.000000000 +0100
+++ setup-2.590-rfl2/ChangeLog	2008-04-10 17:47:11.288728200 +0100
@@ -1,3 +1,26 @@
+2008-04-10  Frank Lee  <rl201@cam.ac.uk>
+
+	* state.h (rebootneeded): Declare as a global flag.
+	(packages_option): 
+	* state.cc (rebootneeded): Declare as a global flag.
+	* install.cc (rebootneeded): Remove declaration. 
+	(do_install_thread): Set exit_msg to IDS_REBOOT_REQUIRED if needed.
+	* main.cc: Call theLog->exit with IDS_REBOOT_REQUIRED if needed.
+	* msg.cc: Include state.h
+	(mbox): Define and return default values when running unattended
+	without displaying a message box.
+	* package_meta.cc: Include getopt++/StringOption.h.
+	New StringOption (PackageOption) This option (-s) allows 
+	specification of packages to be installed from the command line.
+	(packagemeta::isManuallyWanted): Return whether a package was
+	specified to be installed on the command line.
+	(packagemeta::addToCategoryBase): Add the package to the base 
+	category.
+	* package_meta.h (isManuallyWanted): Declaration.
+	(addToCategoryBase): Add prototype.
+	* package_db.cc (packagedb::fillMissingCategory): Test all packages
+	and add to the base category if listed on the command line.
+
 2008-04-10  Brian Dessent  <brian@dessent.net>
 
 	* Makefile.am (setup_LDFLAGS): Make sure static libbz2 and zlib
Common subdirectories: setup-2.590-cvs/autom4te.cache and setup-2.590-rfl2/autom4te.cache
Common subdirectories: setup-2.590-cvs/bz2lib and setup-2.590-rfl2/bz2lib
Common subdirectories: setup-2.590-cvs/cfgaux and setup-2.590-rfl2/cfgaux
Common subdirectories: setup-2.590-cvs/csu_util and setup-2.590-rfl2/csu_util
diff -u setup-2.590-cvs/install.cc setup-2.590-rfl2/install.cc
--- setup-2.590-cvs/install.cc	2008-04-09 03:25:27.000000000 +0100
+++ setup-2.590-rfl2/install.cc	2008-04-10 17:45:01.568237400 +0100
@@ -135,7 +135,6 @@
 
 static int num_installs, num_uninstalls;
 static void md5_one (const packagesource& source);
-static bool rebootneeded;
 
 void
 Installer::preremoveOne (packagemeta & pkg)
@@ -636,6 +635,9 @@
     exit_msg = IDS_INSTALL_INCOMPLETE;
   else if (!unattended_mode)
     exit_msg = IDS_INSTALL_COMPLETE;
+
+  if (rebootneeded)
+    exit_msg = IDS_REBOOT_REQUIRED;
 }
 
 static DWORD WINAPI
Common subdirectories: setup-2.590-cvs/libgetopt++ and setup-2.590-rfl2/libgetopt++
Common subdirectories: setup-2.590-cvs/libmd5-rfc and setup-2.590-rfl2/libmd5-rfc
diff -u setup-2.590-cvs/main.cc setup-2.590-rfl2/main.cc
--- setup-2.590-cvs/main.cc	2007-02-28 00:55:04.000000000 +0000
+++ setup-2.590-rfl2/main.cc	2008-04-10 17:45:01.568237400 +0100
@@ -200,8 +200,11 @@
 
     // Clean exit.. save user options.
     UserSettings::Instance().saveAllSettings();
-
-    theLog->exit (0);
+    if (rebootneeded) {
+      theLog->exit (IDS_REBOOT_REQUIRED);
+    } else {
+      theLog->exit (0);
+    }
   }
   TOPLEVEL_CATCH("main");
 
diff -u setup-2.590-cvs/msg.cc setup-2.590-rfl2/msg.cc
--- setup-2.590-cvs/msg.cc	2004-12-27 16:12:44.000000000 +0000
+++ setup-2.590-rfl2/msg.cc	2008-04-10 17:45:01.568237400 +0100
@@ -29,6 +29,7 @@
 #include <stdio.h>
 #include <stdarg.h>
 #include "dialog.h"
+#include "state.h"
 
 void
 msg (const char *fmt, ...)
@@ -50,6 +51,27 @@
 
   vsnprintf (buf, 1000, fmt, args);
   log (LOG_PLAIN) << "mbox " << name << ": " << buf << endLog;
+  if (unattended_mode) {
+    // Return some default values.
+    log (LOG_PLAIN) << "unattended_mode is set at mbox: returning default value" << endLog;
+    switch (type & MB_TYPEMASK)
+    {
+      case MB_OK | MB_OKCANCEL:
+        return IDOK;
+        break;
+      case MB_YESNO | MB_YESNOCANCEL:
+        return IDYES;
+        break;
+      case MB_ABORTRETRYIGNORE:
+        return IDIGNORE;
+        break;
+      case MB_RETRYCANCEL:
+        return IDCANCEL;
+        break;
+      default:
+        return 0;
+    }
+  }
   return MessageBox (owner, buf, "Cygwin Setup", type);
 }
 
diff -u setup-2.590-cvs/package_db.cc setup-2.590-rfl2/package_db.cc
--- setup-2.590-cvs/package_db.cc	2008-04-09 00:50:54.000000000 +0100
+++ setup-2.590-rfl2/package_db.cc	2008-04-10 17:45:01.568237400 +0100
@@ -401,6 +401,7 @@
 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 setup-2.590-cvs/package_db.h setup-2.590-rfl2/package_db.h
--- setup-2.590-cvs/package_db.h	2006-04-17 16:40:11.000000000 +0100
+++ setup-2.590-rfl2/package_db.h	2008-04-10 17:45:01.583849400 +0100
@@ -47,6 +47,7 @@
   void fillMissingCategory();
   void markUnVisited();
   void setExistence();
+  void addFromCmdLine();
   /* all seen binary packages */
   static std::vector < packagemeta *> packages;
   /* all seen source packages */
diff -u setup-2.590-cvs/package_meta.cc setup-2.590-rfl2/package_meta.cc
--- setup-2.590-cvs/package_meta.cc	2006-04-17 17:13:17.000000000 +0100
+++ setup-2.590-rfl2/package_meta.cc	2008-04-10 17:45:01.583849400 +0100
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <unistd.h>
 #include <strings.h>
+#include "getopt++/StringOption.h"
 
 #include "io_stream.h"
 #include "compress.h"
@@ -242,6 +243,26 @@
   return pkg.SDesc().size();
 }
 
+static StringOption PackageOption ("", 's', "software", "Software packages to include");
+
+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 in packages_option */
+  bReturn = bReturn || (name.compare(packages_option) == 0);
+  return bReturn;
+}
+
 const std::string
 packagemeta::SDesc () const
 {
@@ -647,6 +668,12 @@
        referenced are unselectable anyway.  */
 }
 
+void 
+packagemeta::addToCategoryBase() 
+{
+  add_category ("Base");
+}
+
 bool
 packagemeta::hasNoCategories() const
 {
diff -u setup-2.590-cvs/package_meta.h setup-2.590-rfl2/package_meta.h
--- setup-2.590-cvs/package_meta.h	2006-04-17 17:13:17.000000000 +0100
+++ setup-2.590-rfl2/package_meta.h	2008-04-10 17:45:01.583849400 +0100
@@ -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
   {
Common subdirectories: setup-2.590-cvs/rsync and setup-2.590-rfl2/rsync
diff -u setup-2.590-cvs/state.cc setup-2.590-rfl2/state.cc
--- setup-2.590-cvs/state.cc	2006-04-15 22:21:25.000000000 +0100
+++ setup-2.590-rfl2/state.cc	2008-04-10 17:45:01.599461400 +0100
@@ -23,6 +23,7 @@
 #include "state.h"
 
 bool unattended_mode;
+bool rebootneeded;
 
 int source;
 
diff -u setup-2.590-cvs/state.h setup-2.590-rfl2/state.h
--- setup-2.590-cvs/state.h	2006-04-15 22:21:25.000000000 +0100
+++ setup-2.590-rfl2/state.h	2008-04-10 17:47:35.612535800 +0100
@@ -32,6 +32,7 @@
 #include <string>
 
 extern bool unattended_mode;
+extern bool rebootneeded;
 
 extern int source;
 
Common subdirectories: setup-2.590-cvs/temp and setup-2.590-rfl2/temp
Common subdirectories: setup-2.590-cvs/tests and setup-2.590-rfl2/tests
Common subdirectories: setup-2.590-cvs/zlib and setup-2.590-rfl2/zlib

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

* Re: Patch for unattended setup (updated)
  2008-04-10 16:56                   ` Dr. Frank Lee
@ 2008-06-22 17:09                     ` Brian Dessent
  2008-06-22 18:33                       ` Dave Korn
  0 siblings, 1 reply; 12+ messages in thread
From: Brian Dessent @ 2008-06-22 17:09 UTC (permalink / raw)
  To: Dr. Frank Lee; +Cc: cygwin-apps

"Dr. Frank Lee" wrote:

> Apologies, _this_ is the new patch.

> -
> -    theLog->exit (0);
> +    if (rebootneeded) {
> +      theLog->exit (IDS_REBOOT_REQUIRED);
> +    } else {
> +      theLog->exit (0);
> +    }
>    }

The GNU style has a brace on its own line.

> +  if (unattended_mode) {

Likewise.

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

I'm not sure this is very performant.  'isManuallyWanted' is a rather
expensive function and it seems like a waste to have to perform all of
this:

> +static StringOption PackageOption ("", 's', "software", "Software packages to include");
> +
> +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 in packages_option */
> +  bReturn = bReturn || (name.compare(packages_option) == 0);
> +  return bReturn;
> +}

...once for every instance of every package, which is hundreds. 
Couldn't the string parsing stuff be done just once to convert it to a
vector or list, so that it doesn't have to be reparsed over and over?

Brian

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

* RE: Patch for unattended setup (updated)
  2008-06-22 17:09                     ` Brian Dessent
@ 2008-06-22 18:33                       ` Dave Korn
  0 siblings, 0 replies; 12+ messages in thread
From: Dave Korn @ 2008-06-22 18:33 UTC (permalink / raw)
  To: cygwin-apps, 'Dr. Frank Lee'

Brian Dessent wrote on 22 June 2008 18:12:

> "Dr. Frank Lee" wrote:

+    switch (type & MB_TYPEMASK)
+    {
+      case MB_OK | MB_OKCANCEL:
+        return IDOK;
+        break;
+      case MB_YESNO | MB_YESNOCANCEL:
+        return IDYES;
+        break;
+      case MB_ABORTRETRYIGNORE:
+        return IDIGNORE;
+        break;
+      case MB_RETRYCANCEL:
+        return IDCANCEL;
+        break;
+      default:
+        return 0;
+    }


  http://cygwin.com/acronyms/#IDTYRMTST  ;-)


  Reini, this could explain your lack of functionality!

    cheers,
      DaveK
-- 
Can't think of a witty .sigline today....

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

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

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-09 16:15 Patch for unattended setup (updated) Dr. Frank Lee
2008-04-09 22:02 ` Brian Dessent
     [not found]   ` <alpine.DEB.0.99.0804100029430.7705@gath>
2008-04-09 23:58     ` Brian Dessent
2008-04-10  0:12       ` Dr. Frank Lee
2008-04-10  0:39         ` Brian Dessent
2008-04-10  0:52           ` Dr. Frank Lee
2008-04-10 13:31             ` Dr. Frank Lee
2008-04-10 16:00               ` Christopher Faylor
2008-04-10 16:54                 ` Dr. Frank Lee
2008-04-10 16:56                   ` Dr. Frank Lee
2008-06-22 17:09                     ` Brian Dessent
2008-06-22 18:33                       ` Dave Korn

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