Preremove section in http://cygwin.com/setup.html

Igor Pechtchanski pechtcha@cs.nyu.edu
Thu Jul 10 02:25:00 GMT 2003


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,
> http://cygwin.com/setup.html has nothing about.

Attached is a patch to <http://cygwin.com/setup.html> 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
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		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!

"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 02:14:32 -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="http://sources.redhat.com/cygwin-apps/setup.html#setup.ini">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>
 </ul>
 
@@ -621,12 +621,13 @@ directory, you must structure your packa
   </ul>
 </ul>
 
-<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
-/etc/postinstall/<var>package</var>.bat.</p>
+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,35 @@ 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 limit on the number of postinstall scripts in any
+given package.  However, 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
+/etc/postinstall/<var>package</var>.bat.</p>
+
 <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 will have run by the time your script is executed.  However,
+the order of execution of postinstall scripts within a package is
+undefined.</p>
+
+<p>Some actions in postinstall scripts 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 are limited to 2 per
+package, and have to have the same name as the package, i.e.,
+/etc/preremove/<var>package</var>.sh or
+/etc/preremove/<var>package</var>.bat.  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 cygwin-apps@cygwin.com and you'll almost certainly save time.</p>


More information about the Cygwin-apps mailing list