Re: RFC: [PATCH] Retry replacing in-use files in setup

2006-03-09 Thread Igor Peshansky
The recent messages about in-use files and hosed postinstall reminded me
of this pending patch.

Ping.

Lapo liked it.  Any comments from anyone else?  Should we scrap the idea?
What's left to do, besides the obvious cleanup?
Igor

On Tue, 14 Feb 2006, Igor Peshansky wrote:

 Hi,

 Here's a quick and dirty patch to retry replacing in-use files.  Unless
 setup is running in unattended mode, it will show an Abort/Retry/Ignore
 dialog warning the user that a particular file was in-use.  The user can
 Retry indefinitely, though the second and subsequent messages are going
 to be a bit more stringent.  Ignore will prevent any further pop-ups
 (the logic being that if even one file was set to be replaced on reboot,
 might as well do all of them).

 This worked for me in some limited testing, but is obviously not complete
 (e.g., Abort doesn't work -- do we even need it?).

 I'd like some comments from people on both the behavior and my
 assumptions.  The patch was intentionally done in whitespace-indifferent
 mode to make the actual changes easier to see, so please don't mention the
 sloppy indentation. :-)  Just in case this gets passed with flying colors
 and accepted into the codebase, I've included the ChangeLog below.
   Igor
 ==
 2006-02-14  Igor Peshansky  [EMAIL PROTECTED]

   * install.cc (Installer::installOne): If file is in use, ask the user
   to stop processes and retry.

-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte.
But no -- you are no fool; you call yourself a fool, there's proof enough in
that! -- Rostand, Cyrano de BergeracIndex: install.cc
===
RCS file: /cvs/cygwin-apps/setup/install.cc,v
retrieving revision 2.77
diff -u -p -w -r2.77 install.cc
--- install.cc  1 Sep 2005 16:39:27 -   2.77
+++ install.cc  15 Feb 2006 02:44:52 -
@@ -206,6 +206,7 @@ Installer::installOne (packagemeta pkgm
   io_stream *tmp = io_stream::open (source.Cached (), rb);
   io_stream *tmp2 = 0;
   archive *thefile = 0;
+  bool ignoreExtractErrors = unattended_mode;
   if (tmp)
 {
   tmp2 = compress::decompress (tmp);
@@ -253,8 +254,38 @@ Installer::installOne (packagemeta pkgm
  Progress.SetText3 (canonicalfn.c_str());
  log (LOG_BABBLE)  Installing file   prefixURL  prefixPath 
  fn  endLog;
- if (archive::extract_file (thefile, prefixURL, prefixPath) != 0)
+ bool firstIteration = true;
+ while (archive::extract_file (thefile, prefixURL, prefixPath) != 0)
{
+ if (!ignoreExtractErrors)
+   {
+ char msg[fn.size() + 300];
+ sprintf (msg,
+  %snable to extract %s -- the file is in use.\r\n
+  Please stop %s Cygwin processes and select 
\Retry\,\r\n
+  or select \Ignore\ to go on anyway (you will need 
to reboot).\r\n
+  Select \Abort\ to stop the installation\r\n,
+  firstIteration?U:Still u, fn.c_str(), 
firstIteration?all:ALL);
+ switch (MessageBox
+ (NULL, msg, In-use files detected,
+  MB_ABORTRETRYIGNORE | MB_ICONWARNING | MB_TASKMODAL))
+   {
+   case IDRETRY:
+ // retry
+ firstIteration = false;
+ continue;
+   case IDABORT:
+ MessageBox(NULL, This option is ignored for now,
+Option ignored, MB_OK | MB_ICONINFORMATION | 
MB_TASKMODAL);
+ break;
+   case IDIGNORE:
+ ignoreExtractErrors = true;
+ break;
+   default:
+ break;
+   }
+ // fall through to previous functionality
+   }
  if (NoReplaceOnReboot)
{
  ++errors;
@@ -324,6 +355,8 @@ Installer::installOne (packagemeta pkgm
}
}
}
+ // We're done with this file
+ break;
}
  progress (tmp-tell ());
  num_installs++;


RE: RFC: [PATCH] Retry replacing in-use files in setup

2006-02-17 Thread Dave Korn
On 16 February 2006 20:16, Lapo Luchini wrote:

 Dave Korn wrote:
 Why must they?  Why not just alt-tab to them and press enter?
 
 Not so easy to send an alt-tab thru VNC, not using the X client, at least.

  That would be a bug/limitation.  The win32 version has a config option to
send command-key combinations to the other end.

 Anyway, I'd consider the fact that the window sometimes appears behind,
 being invisible and all, a bug wherever it had a work around or not ;-)

  True, but I think it's an XP bug rather than a cygwin one, it does that all
the time, particularly if you happen to be holding down a key or anything.  MS
have done something bd to the alt-tab-ordering/vs/minimize-and-restore
behaviour in between 2k and xp.  I'm always alt-tabbing these days and finding
some window I thought I'd minimized jumps up instead of the next-most-recent
one I was expecting...

  This is OT for cygwin apps now.  Fup-To set, bock-bock-b'gaaawk!
http://cygwin.com/acronyms#TITTTL


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



Re: RFC: [PATCH] Retry replacing in-use files in setup

2006-02-16 Thread Lapo Luchini
Igor Peshansky wrote:
 Umm, now I'm confused.  There is nothing in the setup source that would
 explain this behavior.  Which version of setup are you using?  Which OS is
 this happening on?  We *are* talking about the -r/--no-replaceonreboot
 option, right?
As I hate rebooting unless strictly necessary I always use -rNd, yes.
As of the version.. well, I got that behaviour from the very beginning,
when I was told of -r in the first place. I don't quote remember when,
but at least one year ago (searching this mailing list I could probably
find the exact day, tell me if you need it) and up to today.
I'm using WinXP x64 now, but it was just the same on the good old plain
WinXP I used until august.

Lapo

BTW: do -N and -d /really/ need to warn me with a modal windows each
time? if I went to the extent to add them I guess I do know I do not
want those installed, quietly avoiding that would be the expected
behaviour... moreover in latest setup release those modal windows
sometimes appear /under/ the main windows and are closable only with a
combination of alt-tab and enter, and must be killed altogether if
using setup thru VNC


Re: RFC: [PATCH] Retry replacing in-use files in setup (+[PATCH])

2006-02-16 Thread Igor Peshansky
On Thu, 16 Feb 2006, Lapo Luchini wrote:

 Igor Peshansky wrote:
  Umm, now I'm confused.  There is nothing in the setup source that
  would explain this behavior.  Which version of setup are you using?
  Which OS is this happening on?  We *are* talking about the
  -r/--no-replaceonreboot option, right?

 As I hate rebooting unless strictly necessary I always use -rNd, yes.
 As of the version.. well, I got that behaviour from the very beginning,
 when I was told of -r in the first place. I don't quote remember when,
 but at least one year ago (searching this mailing list I could probably
 find the exact day, tell me if you need it) and up to today. I'm using
 WinXP x64 now, but it was just the same on the good old plain WinXP I
 used until august.

Eek.  This is a bug that became a feature, apparently.  I just reproduced
this behavior.  Basically, what I didn't realize was that the archive_tar
class wouldn't even try extracting a file if it wasn't able to open the
destination for writing, keeping the archive cursor the same, so the
next_file_name() call will keep returning the same file over and over.
Don't know if this behavior is intentional (doesn't look like it, based on
the error tracking in the rest of the code -- I think it was expected to
fail and go on to the next file).  Brian, any comments on this?  Should
this be fixed (after my patch goes in effect, that is, so that people who
rely on this behavior have an alternative)?

 BTW: do -N and -d /really/ need to warn me with a modal windows each
 time? if I went to the extent to add them I guess I do know I do not
 want those installed, quietly avoiding that would be the expected
 behaviour...

This is a leftover debugging MessageBox for '-N', apparently.  You can use
'-n'/'--no-shortcuts' as a workaround for this (it's supposed to have the
same effect as '-Nd', and does, with an added benefit of skipping the
MessageBox code).  This should be fixed (with a patch below).

 moreover in latest setup release those modal windows sometimes appear
 /under/ the main windows and are closable only with a combination of
 alt-tab and enter, and must be killed altogether if using setup thru
 VNC

The '-n' option should solve this for you until the below patch is
applied.
Igor


2006-02-16  Igor Peshansky  [EMAIL PROTECTED]

* desktop.cc (DesktopSetupPage::OnInit): Remove stray MessageBox.


Index: desktop.cc
===
RCS file: /cvs/cygwin-apps/setup/desktop.cc,v
retrieving revision 2.41
diff -u -p -r2.41 desktop.cc
--- desktop.cc  5 May 2005 22:48:34 -   2.41
+++ desktop.cc  16 Feb 2006 15:01:08 -
@@ -355,7 +355,6 @@ DesktopSetupPage::OnInit ()
   if (NoStartMenuOption)
{
  root_menu = 0;
- MessageBox(NULL, NoStartMenuOption, NoStartMenuOption, MB_OK);
}
   else
{

-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte.
But no -- you are no fool; you call yourself a fool, there's proof enough in
that! -- Rostand, Cyrano de Bergerac


RE: RFC: [PATCH] Retry replacing in-use files in setup

2006-02-16 Thread Dave Korn
On 16 February 2006 08:50, Lapo Luchini wrote:

 behaviour... moreover in latest setup release those modal windows
 sometimes appear /under/ the main windows and are closable only with a
 combination of alt-tab and enter, and must be killed altogether if
 using setup thru VNC


  Why must they?  Why not just alt-tab to them and press enter?

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



Re: RFC: [PATCH] Retry replacing in-use files in setup

2006-02-16 Thread Lapo Luchini
Dave Korn wrote:
 Why must they?  Why not just alt-tab to them and press enter?
   
Not so easy to send an alt-tab thru VNC, not using the X client, at least.
Anyway, I'd consider the fact that the window sometimes appears behind,
being invisible and all, a bug wherever it had a work around or not ;-)

Lapo


Re: RFC: [PATCH] Retry replacing in-use files in setup

2006-02-15 Thread Igor Peshansky
On Wed, 15 Feb 2006, Lapo Luchini wrote:

 Igor Peshansky wrote:
  I'd like some comments from people on both the behavior and my
  assumptions.

 I like the idea.

 I guess/hope this also solves the bug that also if the command line
 option to waiting for files (i.e. NOT putting them on the reboot-list)
 they are marked as not correctly installed? (but they in fact are)

No, this does not fix that bug.  I assume you mean the
--no-replaceonreboot option -- as I understand it, the way it was
designed to work is to mark the files as failed to install instead of
putting them on the replace-on-reboot list if they could not be replaced
right away.  It was not designed to wait for files -- that's what my patch
is doing.  I did not change the meaning of that option -- if the user runs
setup with the --no-replaceonreboot, and then chooses Ignore at my
prompt, the old behavior will still be in effect (i.e., the file will be
marked as failed and not replaced).

I'm not sure what you meant by but they in fact are -- if setup cannot
replace the file and --no-replaceonreboot is in effect, the file will not
be replaced at all.
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte.
But no -- you are no fool; you call yourself a fool, there's proof enough in
that! -- Rostand, Cyrano de Bergerac


Re: RFC: [PATCH] Retry replacing in-use files in setup

2006-02-15 Thread Lapo Luchini
Igor Peshansky wrote:
 On Wed, 15 Feb 2006, Lapo Luchini wrote:

   
 Igor Peshansky wrote:
 
 I'd like some comments from people on both the behavior and my
 assumptions.
   
 I like the idea.

 I guess/hope this also solves the bug that also if the command line
 option to waiting for files (i.e. NOT putting them on the reboot-list)
 they are marked as not correctly installed? (but they in fact are)
 

 No, this does not fix that bug.  I assume you mean the
 --no-replaceonreboot option -- as I understand it, the way it was
 designed to work is to mark the files as failed to install instead of
 putting them on the replace-on-reboot list if they could not be replaced
 right away.  It was not designed to wait for files -- that's what my patch
 is doing.
Err... strange... in fact that option *does* indeed wait for files: the
modal window is open continually trying to write the file until I
unlock it (usually with a net stop sshd), and only then it continues
installing other files.
That's way I thought it was a bug and not a meant feature. ^_^

Lapo


Re: RFC: [PATCH] Retry replacing in-use files in setup

2006-02-15 Thread Igor Peshansky
On Wed, 15 Feb 2006, Lapo Luchini wrote:

 Igor Peshansky wrote:
  On Wed, 15 Feb 2006, Lapo Luchini wrote:
 
  Igor Peshansky wrote:
 
  I'd like some comments from people on both the behavior and my
  assumptions.
 
  I like the idea.
 
  I guess/hope this also solves the bug that also if the command line
  option to waiting for files (i.e. NOT putting them on the reboot-list)
  they are marked as not correctly installed? (but they in fact are)
 
  No, this does not fix that bug.  I assume you mean the
  --no-replaceonreboot option -- as I understand it, the way it was
  designed to work is to mark the files as failed to install instead of
  putting them on the replace-on-reboot list if they could not be replaced
  right away.  It was not designed to wait for files -- that's what my patch
  is doing.

 Err... strange... in fact that option *does* indeed wait for files: the
 modal window is open continually trying to write the file until I
 unlock it (usually with a net stop sshd), and only then it continues
 installing other files.

 That's way I thought it was a bug and not a meant feature. ^_^

Umm, now I'm confused.  There is nothing in the setup source that would
explain this behavior.  Which version of setup are you using?  Which OS is
this happening on?  We *are* talking about the -r/--no-replaceonreboot
option, right?
Igor
-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte.
But no -- you are no fool; you call yourself a fool, there's proof enough in
that! -- Rostand, Cyrano de Bergerac


RFC: [PATCH] Retry replacing in-use files in setup

2006-02-14 Thread Igor Peshansky
Hi,

Here's a quick and dirty patch to retry replacing in-use files.  Unless
setup is running in unattended mode, it will show an Abort/Retry/Ignore
dialog warning the user that a particular file was in-use.  The user can
Retry indefinitely, though the second and subsequent messages are going
to be a bit more stringent.  Ignore will prevent any further pop-ups
(the logic being that if even one file was set to be replaced on reboot,
might as well do all of them).

This worked for me in some limited testing, but is obviously not complete
(e.g., Abort doesn't work -- do we even need it?).

I'd like some comments from people on both the behavior and my
assumptions.  The patch was intentionally done in whitespace-indifferent
mode to make the actual changes easier to see, so please don't mention the
sloppy indentation. :-)  Just in case this gets passed with flying colors
and accepted into the codebase, I've included the ChangeLog below.
Igor
==
2006-02-14  Igor Peshansky  [EMAIL PROTECTED]

* install.cc (Installer::installOne): If file is in use, ask the user
to stop processes and retry.

-- 
http://cs.nyu.edu/~pechtcha/
  |\  _,,,---,,_[EMAIL PROTECTED] | [EMAIL PROTECTED]
ZZZzz /,`.-'`'-.  ;-;;,_Igor Peshansky, Ph.D. (name changed!)
 |,4-  ) )-,_. ,\ (  `'-'   old name: Igor Pechtchanski
'---''(_/--'  `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Las! je suis sot... -Mais non, tu ne l'es pas, puisque tu t'en rends compte.
But no -- you are no fool; you call yourself a fool, there's proof enough in
that! -- Rostand, Cyrano de BergeracIndex: install.cc
===
RCS file: /cvs/cygwin-apps/setup/install.cc,v
retrieving revision 2.77
diff -u -p -w -r2.77 install.cc
--- install.cc  1 Sep 2005 16:39:27 -   2.77
+++ install.cc  15 Feb 2006 02:44:52 -
@@ -206,6 +206,7 @@ Installer::installOne (packagemeta pkgm
   io_stream *tmp = io_stream::open (source.Cached (), rb);
   io_stream *tmp2 = 0;
   archive *thefile = 0;
+  bool ignoreExtractErrors = unattended_mode;
   if (tmp)
 {
   tmp2 = compress::decompress (tmp);
@@ -253,8 +254,38 @@ Installer::installOne (packagemeta pkgm
  Progress.SetText3 (canonicalfn.c_str());
  log (LOG_BABBLE)  Installing file   prefixURL  prefixPath 
  fn  endLog;
- if (archive::extract_file (thefile, prefixURL, prefixPath) != 0)
+ bool firstIteration = true;
+ while (archive::extract_file (thefile, prefixURL, prefixPath) != 0)
{
+ if (!ignoreExtractErrors)
+   {
+ char msg[fn.size() + 300];
+ sprintf (msg,
+  %snable to extract %s -- the file is in use.\r\n
+  Please stop %s Cygwin processes and select 
\Retry\,\r\n
+  or select \Ignore\ to go on anyway (you will need 
to reboot).\r\n
+  Select \Abort\ to stop the installation\r\n,
+  firstIteration?U:Still u, fn.c_str(), 
firstIteration?all:ALL);
+ switch (MessageBox
+ (NULL, msg, In-use files detected,
+  MB_ABORTRETRYIGNORE | MB_ICONWARNING | MB_TASKMODAL))
+   {
+   case IDRETRY:
+ // retry
+ firstIteration = false;
+ continue;
+   case IDABORT:
+ MessageBox(NULL, This option is ignored for now,
+Option ignored, MB_OK | MB_ICONINFORMATION | 
MB_TASKMODAL);
+ break;
+   case IDIGNORE:
+ ignoreExtractErrors = true;
+ break;
+   default:
+ break;
+   }
+ // fall through to previous functionality
+   }
  if (NoReplaceOnReboot)
{
  ++errors;
@@ -324,6 +355,8 @@ Installer::installOne (packagemeta pkgm
}
}
}
+ // We're done with this file
+ break;
}
  progress (tmp-tell ());
  num_installs++;