[PATCH] setup: Detect postinstall scripts correctly

Igor Pechtchanski pechtcha@cs.nyu.edu
Tue Sep 27 18:01:00 GMT 2005

-= WARNING =-  -= WARNING =-  -= WARNING =-  -= WARNING =-  -= WARNING =-
Do NOT apply this patch until all the consequences have been considered
and discussed.
-= WARNING =-  -= WARNING =-  -= WARNING =-  -= WARNING =-  -= WARNING =-

This is a trivial patch that fixes a bug in postinstall script detection.
You may have noticed that when all postinstall scripts are run, "No
package" is displayed in the progress window.  Here's some history:

When I first implemented the logging of postinstall script output, I
figured we'd run the known postinstall scripts (those coming from the
packages we just installed) first, in dependency order, and then run all
other postinstall scripts (e.g., custom ones, or those created by
postinstall scripts themselves) in alphanumeric order.  There is code in
setup to display the name of the package for which we are currently
running postinstall scripts, with "No package" displayed for those "other"

Unfortunately, there was a small bug in string comparison (which the
attached patch fixes) that failed to detect *any* postinstall scripts in
packages, causing everything in /etc/postinstall to be treated as "other".

As I understand, there are now some postinstall scripts that rely on the
current (buggy) behavior.  However, this is the only way to enforce a
deterministic order on the postinstall script execution in the presence of
circular dependencies.  Before we apply this patch, we ought to make sure
that the current postinstall script structure doesn't break.  It didn't
seem to break for me -- I've tested it on a relatively large fresh
install, but, as we all know, "one sample does not a statistic make"(tm).
I'd be more comfortable with, say, Eric signing off on this with respect
to the ash/bash postinstall scripts.

Discussion welcome.  As usual, the ChangeLog is below.
2005-09-27  Igor Pechtchanski  <pechtcha@cs.nyu.edu>

	* script.cc (isAScript): Fix string comparison.

      |\      _,,,---,,_		pechtcha@cs.nyu.edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor@watson.ibm.com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. /DA
-------------- next part --------------
Index: script.cc
RCS file: /cvs/cygwin-apps/setup/script.cc,v
retrieving revision 2.20
diff -u -p -r2.20 script.cc
--- script.cc	1 Sep 2005 16:39:27 -0000	2.20
+++ script.cc	27 Sep 2005 16:01:44 -0000
@@ -269,8 +269,8 @@ bool
 Script::isAScript (String const &file)
     /* file may be /etc/postinstall or etc/postinstall */
-    if (file.casecompare (ETCPostinstall, sizeof(ETCPostinstall)) &&
-	file.casecompare (ETCPostinstall+1, sizeof(ETCPostinstall)-1))
+    if (file.casecompare (ETCPostinstall, sizeof(ETCPostinstall)-1) &&
+	file.casecompare (ETCPostinstall+1, sizeof(ETCPostinstall)-2))
       return false;
     if (file.c_str()[file.size() - 1] == '/')
       return false;

More information about the Cygwin-apps mailing list