Mail Archives: cygwin/2001/07/09/06:42:02
Hi,
About three weeks ago I `tried my luck' as you suggest, and sent a
previous version of below patch to the general cygwin mailing list.
The least I expected to get was a reply. But I didn't even as much as
a:``update to latest cvs/go away -- not interested''. Was my message
just being overlooked, or should this text
Please feel free to ask questions about any of this. We would love
it if more people made useful contributions -- this can be one of
the big advantages of free software; we all benefit from everyone
else's work as well as our own...
be removed from http://cygwin.com/contrib.html?
Jan.
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 -urpN --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 <janneke AT gnu DOT org>
+
+ * 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 -urpN --exclude=*~ ../cinstall.orig/install.cc ./install.cc
--- ../cinstall.orig/install.cc Tue May 29 05:55:40 2001
+++ ./install.cc Mon Jul 9 12:15:25 2001
@@ -46,6 +46,7 @@ static char *cvsid = "\n%%% $Id: install
#include "log.h"
#include "hash.h"
#include "mount.h"
+#include "postinstall.h"
#include "port.h"
@@ -217,6 +218,15 @@ exists (char *file)
return 0;
}
+static void
+try_run_script (char *dir, char *fname)
+{
+ if (exists (concat (dir, "/", fname, ".sh", 0)))
+ run_script (dir, concat (fname, ".sh"));
+ else if (exists (concat (dir, "/", fname, ".bat", 0)))
+ run_script (dir, concat (fname, ".bat"));
+}
+
static int num_installs, num_uninstalls;
static void
@@ -266,6 +276,10 @@ uninstall_one (char *name, int action)
}
num_uninstalls++;
}
+
+ /* What about remove vs. purge; multiple installed versions; versioned
+ remove? */
+ try_run_script ("/etc/postremove", name);
}
@@ -389,6 +403,9 @@ do_install (HINSTANCE h)
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 -urpN --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 @@ run (char *sh, char *args, char *file)
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 @@ each (char *fname, unsigned int size)
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 @@ static char *shells [] = {
};
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 @@ do_postinstall (HINSTANCE h)
free (sh);
sh = 0;
}
-
+
char old_path[_MAX_PATH];
GetEnvironmentVariable ("PATH", old_path, sizeof (old_path));
SetEnvironmentVariable ("PATH",
@@ -130,6 +133,12 @@ do_postinstall (HINSTANCE h)
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 -urpN --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 <janneke AT gnu DOT org>
+ *
+ */
+#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 <janneke AT gnu DOT org> | GNU LilyPond - The music
typesetter http://www.xs4all.nl/~jantien | http://www.lilypond.org
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
- Raw text -