public inbox for cygwin-apps@cygwin.com
 help / color / mirror / Atom feed
* [PATCH]  Two fixes for setup postinstall handling.
@ 2008-08-10 13:22 Dave Korn
  2008-08-10 15:30 ` Christopher Faylor
  0 siblings, 1 reply; 11+ messages in thread
From: Dave Korn @ 2008-08-10 13:22 UTC (permalink / raw)
  To: cygwin-apps

[-- Attachment #1: Type: text/plain, Size: 2215 bytes --]



    Hi all,

  In case it's controversial, I thought I'd post these patches before
committing anything.  The two hunks I've included in one patchfile here are
in fact separate and orthogonal, I just posted them in one file for
convenience.

  The first hunk finds if bash is in the list of packages that have scripts
to run and swaps it with the first entry if so.  You may feel it's crude,
but it's also does-what-it-says-on-the-tin, and it's sane: we can't possibly
run postinstall scripts without a working shell, the postinstall script for
the shell is what guarantees we have what counts as "a working shell" for
that purpose, so why not just deliberately say "Hey, we have to do this
first and we know we have to do it first so let's just do it first"?

  The second hunk checks for the return code from bash that means 'bad
interpreter', i.e. when it has been unable to invoke the executable listed
after a shebang.  We can't know in the general case of an error during
execution whether the script run and/or how close it got to completion
before it failed, but in this one specific case we can know for absolute
certain that it didn't run not even a little bit, so let's do ourselves a
favour and not mark it done.  I think that means that people who have
failures could just re-run and click straight through setup.exe and get the
scripts to run without having to set everything to "Reinstall" as is
currently the case.  I'm not mad keen on a hardcoded 126 in there, but AFAI
could find out there's no public header with bash error codes in it -
someone please correct me if they know better.

  The first hunk could be obviated by doing away with postinstall scripts
for bash, but it a) is perhaps an easier change than respinning a fresh bash
release, and b) is defensive programming - it's always going to be the case
that, if there are any scripts needed to install the shell, they should be
the very first thing we do, and this means that should a situation ever
arise in the future where we find ourselves needing bash postinstall
scripts, they will just work and we won't regress to the situation we find
ourselves in now.



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

[-- Attachment #2: setup-postinstall-patch.diff --]
[-- Type: application/octet-stream, Size: 2060 bytes --]

? ChangeLog.new
? libgpg-error/autom4te.cache
Index: postinstall.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/postinstall.cc,v
retrieving revision 2.21
diff -p -u -r2.21 postinstall.cc
--- postinstall.cc	16 Apr 2006 22:26:44 -0000	2.21
+++ postinstall.cc	10 Aug 2008 13:01:38 -0000
@@ -107,6 +107,24 @@ do_postinstall_thread (HINSTANCE h, HWND
 	packages.push_back(&pkg);
       ++i;
     }
+
+  // Hard-coding this isn't great, but the shell is a special case.
+  for (i = packages.begin (); i != packages.end (); ++i)
+    {
+      if ((*i)->name == "bash")
+	{
+	  log (LOG_PLAIN) << "Found bash, swapping to first position." << endLog;
+	  // Found it!  Exchange it with first.
+	  if (i != packages.begin ())
+	    {
+	      packagemeta *temp = *i;
+	      *i = *packages.begin ();
+	      *packages.begin () = temp;
+	    }
+	    break;
+	}
+    }
+
   int numpkg = packages.size() + 1;
   int k = 0;
   for (i = packages.begin (); i != packages.end (); ++i)
Index: script.cc
===================================================================
RCS file: /cvs/cygwin-apps/setup/script.cc,v
retrieving revision 2.27
diff -p -u -r2.27 script.cc
--- script.cc	28 Feb 2007 00:55:04 -0000	2.27
+++ script.cc	10 Aug 2008 13:01:38 -0000
@@ -238,12 +238,16 @@ Script::run() const
 
   if (retval)
     log(LOG_PLAIN) << "abnormal exit: exit code=" << retval << endLog;
+
+  /* if the script failed with 'bad interpreter', leave it not done.  */
+  if (retval != 126)
+    {
+      /* if file exists then delete it otherwise just ignore no file error */
+      io_stream::remove ("cygfile://" + scriptName + ".done");
 
-  /* if file exists then delete it otherwise just ignore no file error */
-  io_stream::remove ("cygfile://" + scriptName + ".done");
-
-  io_stream::move ("cygfile://" + scriptName,
+      io_stream::move ("cygfile://" + scriptName,
                    "cygfile://" + scriptName + ".done");
+    }
 
   return retval;
 }

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

end of thread, other threads:[~2008-08-11  0:42 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-08-10 13:22 [PATCH] Two fixes for setup postinstall handling Dave Korn
2008-08-10 15:30 ` Christopher Faylor
2008-08-10 18:41   ` Dave Korn
2008-08-10 23:01     ` Christopher Faylor
2008-08-10 19:51   ` Brian Dessent
2008-08-10 21:52     ` Dave Korn
2008-08-10 22:00       ` Dave Korn
2008-08-10 22:05       ` Brian Dessent
2008-08-10 23:07         ` Christopher Faylor
2008-08-10 23:36           ` Brian Dessent
2008-08-11  0:42             ` Christopher Faylor

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