Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com To: cygwin AT sources DOT redhat DOT com Subject: [PATCH] setup.exe uninstall Organization: Jan at Appel From: Jan Nieuwenhuizen Date: 21 Jun 2001 15:54:04 +0200 Message-ID: Lines: 203 User-Agent: Gnus/5.090003 (Oort Gnus v0.03) Emacs/20.7 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Hi List, We had complaints that setup leaves stuff behind when uninstalling [LilyPond] or related packages http://mail.gnu.org/pipermail/gnu-music-discuss/2001-June/001987.html but we can't fix any of that until setup has some notion of removal scripts. Below is a patch with a fairly simplistic approach. It's untested, main purpose is to find out how you want to attack this problem. I've got more than a bit ambiguous feelings about this; setup would have to do more and be more intelligent/fool prove, otoh, setup could be enhanced until it's another rpm, dpkg, whatnot (Red Carpet plugins, anyone?). Greetings, Jan. (I'm not on this list) diff -urN --exclude=*~ ../cinstall.orig/ChangeLog ./ChangeLog --- ../cinstall.orig/ChangeLog Fri Jun 1 05:56:01 2001 +++ ./ChangeLog Thu Jun 21 15:47:22 2001 @@ -1,3 +1,11 @@ +2001-06-21 Jan Nieuwenhuizen + + * postinstall.h: New file. + * postinstall.cc (init_run_script): New function, share shell init. + (run_script): New function, more generic run-script functionality. + * install.cc (uninstall_one): Added handling of /etc/postremove + scripts. + 2001-05-31 Michael Chase mchase AT ix DOT netcom DOT com * main.cc (WinMain): Add setup version to starting setup.log entry diff -urN --exclude=*~ ../cinstall.orig/install.cc ./install.cc --- ../cinstall.orig/install.cc Tue May 29 05:55:40 2001 +++ ./install.cc Thu Jun 21 15:29:04 2001 @@ -46,6 +46,7 @@ #include "log.h" #include "hash.h" #include "mount.h" +#include "postinstall.h" #include "port.h" @@ -217,6 +218,13 @@ return 0; } +static void +try_run_script (char *dir, char *fname) +{ + if (exists (concat (dir, "/", fname, 0))) + run_script (dir, fname); +} + static int num_installs, num_uninstalls; static void @@ -266,6 +274,10 @@ } num_uninstalls++; } + + /* What about remove vs. purge; multiple installed versions; versioned + remove? */ + try_run_script ("/etc/postremove", name); } @@ -389,6 +401,9 @@ create_mount ("/usr/lib", cygpath ("/lib", 0), istext, issystem); set_cygdrive_flags (istext, issystem); + /* Let's hope people won't uninstall packages before installing [b]ash */ + init_run_script (); + LOOP_PACKAGES { if (package[i].action != ACTION_SRC_ONLY) diff -urN --exclude=*~ ../cinstall.orig/postinstall.cc ./postinstall.cc --- ../cinstall.orig/postinstall.cc Tue May 29 05:55:41 2001 +++ ./postinstall.cc Thu Jun 21 14:57:03 2001 @@ -57,8 +57,8 @@ WaitForSingleObject (pi.hProcess, INFINITE); } -static void -each (char *fname, unsigned int size) +void +run_script (char *dir, char *fname) { char *ext = strrchr (fname, '.'); if (!ext) @@ -66,21 +66,26 @@ if (sh && strcmp (ext, ".sh") == 0) { - char *f2 = concat ("/etc/postinstall/", fname, 0); + char *f2 = concat (dir, fname, 0); run (sh, "-c", f2); free (f2); } else if (cmd && strcmp (ext, ".bat") == 0) { - char *f2 = backslash (cygpath ("/etc/postinstall/", fname, 0)); + char *f2 = backslash (cygpath (dir, fname, 0)); run (cmd, "/c", f2); free (f2); } else return; - rename (cygpath ("/etc/postinstall/", fname, 0), - cygpath ("/etc/postinstall/", fname, ".done", 0)); + rename (cygpath (dir, fname, 0), cygpath (dir, fname, ".done", 0)); +} + +static void +run_script_in_etc_postinstall (char *fname, unsigned int size) +{ + run_script ("/etc/postinstall", fname); } static char *shells [] = { @@ -92,11 +97,9 @@ }; void -do_postinstall (HINSTANCE h) +init_run_script () { - next_dialog = 0; - int i; - for (i=0; shells[i]; i++) + for (int i=0; shells[i]; i++) { sh = backslash (cygpath (shells[i], 0)); if (_access (sh, 0) == 0) @@ -104,7 +107,7 @@ free (sh); sh = 0; } - + char old_path[_MAX_PATH]; GetEnvironmentVariable ("PATH", old_path, sizeof (old_path)); SetEnvironmentVariable ("PATH", @@ -130,6 +133,12 @@ cmd = "command.com"; break; } +} - find (cygpath ("/etc/postinstall", 0), each); +void +do_postinstall (HINSTANCE h) +{ + next_dialog = 0; + init_run_script (); + find (cygpath ("/etc/postinstall", 0), run_script_in_etc_postinstall); } diff -urN --exclude=*~ ../cinstall.orig/postinstall.h ./postinstall.h --- ../cinstall.orig/postinstall.h Thu Jan 1 01:00:00 1970 +++ ./postinstall.h Thu Jun 21 14:57:57 2001 @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2001, Jan Nieuwenhuizen. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * A copy of the GNU General Public License can be found at + * http://www.gnu.org/ + * + * Written by Jan Nieuwenhuizen + * + */ +#ifndef POSTINSTALL_H +#define POSTINSTALL_H + +/* Run the script fname, found in dir. If fname has suffix .sh, and + we have a Bourne shell, execute it using sh. Otherwise, if fname + has suffix .bat, execute using cmd */ + +void run_script (char *dir, char *fname); + +/* Initialisation stuff for run_script: sh, cmd, CYGWINROOT and PATH */ +void init_run_script (); + +#endif /* POSTINSTALL_H */ + -- Jan Nieuwenhuizen | GNU LilyPond - The music typesetter http://www.xs4all.nl/~jantien | http://www.lilypond.org -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple