From 8e9aa511bb14af6cfccc4dd7e7a319703f7fdd8f Mon Sep 17 00:00:00 2001 From: Robert Collins Date: Thu, 3 Jan 2002 11:42:30 +0000 Subject: [PATCH] 2002-01-04 Jan Nieuwenhuizen * Makefile.in (realclean): more clean. (OBJS): Add script.o. * postinstall.cc (run_script_in_etc_postinstall): New function. (do_postinstall): Split off new funtion init_run_script (). (init_run_script): (run): (run_script): Move to script.cc. Replace some deprecated remove and move calls. * script.h: * script.cc: New file. * Forward port cygwin-20010707.jcn3.patch. * package_meta.cc (uninstall): Run pre- and postremove scripts. * install.cc: Typo fix. (do_install): Run script initialisation. --- ChangeLog | 17 ++++++++ Makefile.in | 5 ++- install.cc | 6 ++- package_meta.cc | 4 ++ postinstall.cc | 104 +++--------------------------------------------- 5 files changed, 34 insertions(+), 102 deletions(-) diff --git a/ChangeLog b/ChangeLog index 5945c9ed..422edbf5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,20 @@ +2002-01-04 Jan Nieuwenhuizen + + * Makefile.in (realclean): more clean. + (OBJS): Add script.o. + * postinstall.cc (run_script_in_etc_postinstall): New function. + (do_postinstall): Split off new funtion init_run_script (). + (init_run_script): + (run): + (run_script): Move to script.cc. Replace some deprecated remove + and move calls. + * script.h: + * script.cc: New file. + * Forward port cygwin-20010707.jcn3.patch. + * package_meta.cc (uninstall): Run pre- and postremove scripts. + * install.cc: Typo fix. + (do_install): Run script initialisation. + 2001-01-04 Gary R. Van Sickle * cistring.cc: Run d2u. diff --git a/Makefile.in b/Makefile.in index 2cec0d1b..41a3dedd 100644 --- a/Makefile.in +++ b/Makefile.in @@ -124,7 +124,6 @@ OBJS = \ nio-file.o \ nio-ftp.o \ nio-http.o \ - other.o \ package_db.o \ package_meta.o \ package_source.o \ @@ -135,6 +134,7 @@ OBJS = \ res.o \ rfc1738.o \ root.o \ + script.o \ setup_version.o \ simpsock.o \ site.o \ @@ -175,7 +175,8 @@ clean: $(MAKE) -C zlib clean realclean: clean - rm -f Makefile config.cache + rm -f Makefile + rm -f config.cache config.log config.status install: all $(SHELL) $(updir1)/mkinstalldirs $(bindir) $(etcdir) diff --git a/install.cc b/install.cc index b53c39ca..fa40f1f9 100644 --- a/install.cc +++ b/install.cc @@ -13,7 +13,7 @@ * */ -/* The purpose of this file is to intall all the packages selected in +/* The purpose of this file is to install all the packages selected in the install list (in ini.h). Note that we use a separate thread to maintain the progress dialog, so we avoid the complexity of handling two tasks in one thread. We also create or update all the @@ -55,6 +55,7 @@ static const char *cvsid = #include "compress_gz.h" #include "archive.h" #include "archive_tar.h" +#include "script.h" #include "package_db.h" #include "package_meta.h" @@ -338,6 +339,9 @@ do_install_thread (HINSTANCE h, HWND owner) 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 (); + packagedb db; for (size_t n = 1; n < db.packages.number (); n++) { diff --git a/package_meta.cc b/package_meta.cc index dd795907..8abc89bb 100644 --- a/package_meta.cc +++ b/package_meta.cc @@ -37,6 +37,7 @@ static const char *cvsid = #include "category.h" +#include "script.h" #include "package_version.h" #include "cygpackage.h" @@ -113,6 +114,8 @@ packagemeta::uninstall () */ hash dirs; const char *line = installed->getfirstfile (); + + try_run_script ("/etc/preremove/", name); while (line) { dirs.add_subdirs (line); @@ -136,6 +139,7 @@ packagemeta::uninstall () if (RemoveDirectory (d)) log (LOG_BABBLE, "rmdir %s", d); } + try_run_script ("/etc/postremove/", name); } installed = 0; } diff --git a/postinstall.cc b/postinstall.cc index 10e4980d..4b67db1f 100644 --- a/postinstall.cc +++ b/postinstall.cc @@ -24,118 +24,24 @@ static const char *cvsid = #include "win32.h" #include -#include #include "state.h" #include "dialog.h" #include "find.h" -#include "concat.h" #include "mount.h" - -#include "port.h" - -static char *sh = 0; -static const char *cmd = 0; -static OSVERSIONINFO verinfo; - -static void -run (const char *sh, const char *args, const char *file) -{ - BOOL b; - char cmdline[_MAX_PATH]; - STARTUPINFO si; - PROCESS_INFORMATION pi; - - sprintf (cmdline, "%s %s %s", sh, args, file); - memset (&pi, 0, sizeof (pi)); - memset (&si, 0, sizeof (si)); - si.cb = sizeof (si); - si.lpTitle = (char *) "Cygwin Setup Post-Install Script"; - si.dwFlags = STARTF_USEPOSITION; - - b = CreateProcess (0, cmdline, 0, 0, 0, - CREATE_NEW_CONSOLE, 0, get_root_dir (), &si, &pi); - - if (b) - WaitForSingleObject (pi.hProcess, INFINITE); -} +#include "script.h" static void -each (char *fname, unsigned int size) +run_script_in_etc_postinstall (char *fname, unsigned int size) { - char *ext = strrchr (fname, '.'); - if (!ext) - return; - - if (sh && strcmp (ext, ".sh") == 0) - { - char *f2 = concat ("/etc/postinstall/", fname, 0); - run (sh, "-c", f2); - free (f2); - } - else if (cmd && strcmp (ext, ".bat") == 0) - { - char *f2 = backslash (cygpath ("/etc/postinstall/", fname, 0)); - run (cmd, "/c", f2); - free (f2); - } - else - return; - - /* if file exists then delete it otherwise just ignore no file error */ - remove (cygpath ("/etc/postinstall/", fname, ".done", 0)); - - rename (cygpath ("/etc/postinstall/", fname, 0), - cygpath ("/etc/postinstall/", fname, ".done", 0)); + run_script ("/etc/postinstall/", fname); } -static const char *shells[] = { - "/bin/sh.exe", - "/usr/bin/sh.exe", - "/bin/bash.exe", - "/usr/bin/bash.exe", - 0 -}; - void do_postinstall (HINSTANCE h, HWND owner) { next_dialog = 0; - int i; - for (i = 0; shells[i]; i++) - { - sh = backslash (cygpath (shells[i], 0)); - if (_access (sh, 0) == 0) - break; - free (sh); - sh = 0; - } - - char old_path[_MAX_PATH]; - GetEnvironmentVariable ("PATH", old_path, sizeof (old_path)); - SetEnvironmentVariable ("PATH", - backslash (cygpath ("/bin;", - get_root_dir (), "/usr/bin;", - old_path, 0))); - - SetEnvironmentVariable ("CYGWINROOT", get_root_dir ()); + init_run_script (); SetCurrentDirectory (get_root_dir ()); - - verinfo.dwOSVersionInfoSize = sizeof (verinfo); - GetVersionEx (&verinfo); - - switch (verinfo.dwPlatformId) - { - case VER_PLATFORM_WIN32_NT: - cmd = "cmd.exe"; - break; - case VER_PLATFORM_WIN32_WINDOWS: - cmd = "command.com"; - break; - default: - cmd = "command.com"; - break; - } - - find (cygpath ("/etc/postinstall", 0), each); + find (cygpath ("/etc/postinstall", 0), run_script_in_etc_postinstall); } -- 2.43.5