Preremove section in

Igor Pechtchanski
Tue Sep 16 18:16:00 GMT 2003


On Thu, 10 Jul 2003, Igor Pechtchanski wrote:

> Rob,
> Replies inline.
> On 10 Jul 2003, Robert Collins wrote:
> > Well, we haven't set a policy on the number of postinstall scripts.
> > I'd really prefer one package == one script. It feels cleaner to me that
> > way.
> It's a general rule of thumb, but it's just a policy, not an
> implementation limitation.  It might be cleaner sometimes to create
> multiple postinstall scripts to clearly separate the functionality -- see
> "base-files", for example.
> > Also, it's not guaranteed that all your depended-upon scripts will run
> > when a cycle is present.
> >
> > That is, if foo depends on bar, and bar on foo, only one of the two will
> > have the scripts run first. Might be an idea to mention that (and the
> > 'normal' approach of breaking the common stuff into a third package both
> > depend on).
> True.  I'll change that section.
> > Pre remove scripts are limited to -one- per package. Either .sh or .bat.
> > If setup supports both at once, it's an accident and is not guaranteed
> > to remain.  Again, for consistency, all scripts should be one per
> > package.
> Pre-remove scripts are invoked using try_run_script(), which will execute
> *both* .sh and .bat if present.
> > Other than those issues, it looks good to me.
> > Rob
> Ok, I'm attaching another iteration.  Incidentally, what's the official
> spelling of "postinstall" and "preremove"?  Is it with a hyphen, with a
> space, or as one word?
>         Igor
> > On Thu, 2003-07-10 at 12:25, Igor Pechtchanski wrote:
> > > On Sat, 24 May 2003, Sergey Okhapkin wrote:
> > >
> > > > > Actually, all us package maintainers ought to do a better job
> > > > > including "pre-remove" scripts in addition to post-install scripts,
> > > > > that would clean up anything created by the postinstaller.  Yep --
> > > > > setup supports this -- but most maintainers (I'm guilty here...) don't
> > > > > bother:
> > > >
> > > > I never heard about "pre-remove" support in setup,
> > > > has nothing about.
> > >
> > > Attached is a patch to <> that talks about
> > > preremove scripts and brings the postinstall section up to date.  I'm
> > > targeting it here rather than to the main cygwin list because IMO it is of
> > > more interest to this audience, having to do with package maintenance and
> > > setup.exe.  I can also check this in if it's approved.
> > >       Igor

      |\      _,,,---,,_
ZZZzz /,`.-'`'    -.  ;-;;,_
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski, Ph.D.
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

"I have since come to realize that being between your mentor and his route
to the bathroom is a major career booster."  -- Patrick Naughton
-------------- next part --------------
Index: setup.html
RCS file: /cvs/cygwin/htdocs/setup.html,v
retrieving revision 1.85
diff -u -p -r1.85 setup.html
--- setup.html	23 Mar 2003 16:27:44 -0000	1.85
+++ setup.html	10 Jul 2003 15:01:29 -0000
@@ -26,7 +26,7 @@ that. Setup.exe has it's own homepage <a
   <li><p><a href="#setup.hint">setup.hint</a></p></li>
   <li><p><a href="">setup.ini</a></p></li>
   <li><p><a href="#package_contents">making packages</a></p></li>
-  <li><p><a href="#postinstall">Creating a package postinstall script</a></p></li>
+  <li><p><a href="#postinstall">Creating package postinstall and preremove scripts</a></p></li>
   <li><p><a href="#submitting">Submitting a package</a></p></li>
@@ -621,12 +621,13 @@ directory, you must structure your packa
-<h2><a id="postinstall" name="postinstall">Creating a package postinstall script</a></h2>
+<h2><a id="postinstall" name="postinstall">Creating package postinstall and preremove scripts</a></h2>
 <p>If your package requires certain commands to be executed after the
-files in the package are installed, include them in a file in the
-package called /etc/postinstall/<var>package</var>.sh or
+files in the package are installed (e.g., create symbolic links),
+include them in a file in the package that resides in the
+/etc/postinstall/ directory.  The file may have either a .sh or a
+.bat suffix.</p>
 <p>If the file's name ends in ".sh", it is executed with the Cygwin
 shell; if it ends in ".bat", it is executed with the DOS command
@@ -637,13 +638,43 @@ ignored.</p>
 ".done" to its previous name, to prevent it from being run again the
 next time the user runs the setup program.</p>
+<p>There is no implementation-imposed limit on the number of
+postinstall scripts in any given package.  However, the general policy
+is one postinstall script per package, unless there is a clear
+advantage in having more than one.  Also, it is the responsibility of
+the package maintainer to make sure their postinstall scripts don't
+clash with postinstall scripts in other packages.  The easiest way to
+do this is to include the package name as part of the postinstall
+script name, or even name the postinstall script
+/etc/postinstall/<var>package</var>.sh or
 <p>Note that the setup program runs all the postinstall scripts after
 all desired packages have been installed, that is, it does not run
 each package's postinstall script immediately after installing that
-package.  Note, furthermore, that the order in which the scripts are
-run is not guaranteed.  Therefore, if your package depends on others
-which have their own postinstall scripts, you cannot assume in your
-script that the other packages' scripts have already been run.</p>
+package.  Note, furthermore, that the setup program runs scripts in
+order of package dependencies, so that if your package depends on
+others which have their own postinstall scripts, their postinstall
+scripts should have run by the time your script is executed.  However,
+the order of execution of postinstall scripts within a package, or in
+different packages in the presence of circular package dependencies
+(i.e., <var>foo</var> depends on <var>bar</var> and <var>bar</var>
+depends on <var>foo</var>), is <i>undefined</i>.  A suggested way to
+break circular dependencies is factoring out the mutually-dependent
+parts of the two packages into a third package and making both
+original packages require the new one.</p>
+<p>Some postinstall actions may need to be undone just before the
+package is uninstalled.  Setup supports this with preremove scripts,
+which go in /etc/preremove/.  Note that, unlike postinstall scripts,
+the preremove scripts have to have the same name as the package, i.e.,
+/etc/preremove/<var>package</var>.sh or
+/etc/preremove/<var>package</var>.bat, and thus are limited to 2 per
+package by the implementation.  The general policy is one preremove
+script per package.  Also note that preremove scripts are executed
+right in the middle of the package uninstall sequence, so some
+commands may not be available (because the corresponding packages
+have already been uninstalled).</p>
 <h2><a id="submitting" name="submitting">Submitting a package</a></h2>
 <p>So you've got a package you want to submit. Follow the following checklist before emailing and you'll almost certainly save time.</p>

More information about the Cygwin-apps mailing list