]> cygwin.com Git - cygwin-apps/setup.git/commitdiff
* pkg.c: New file.
authorChristopher Faylor <me@cgf.cx>
Sat, 29 Apr 2000 04:28:59 +0000 (04:28 +0000)
committerChristopher Faylor <me@cgf.cx>
Sat, 29 Apr 2000 04:28:59 +0000 (04:28 +0000)
* setup.c (tarx): Skip already installed or older packages.  Report when a
package has been updated.
(processdirlisting): Skip already installed or older packages.
(main): Detect -f option for forced installation.  Initialize pkg stuff if
appropriate.
* setup.h: Add pkg definitions.

ChangeLog
Makefile.in
setup.c
setup.h

index 8d55054a89567aa507b7b287c001679de9106d6e..4aeea6049998c76eaec5138f319ca4c1787e7cd4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sat Apr 29 00:26:06 2000  Christopher Faylor <cgf@cygnus.com>
+
+       * pkg.c: New file.
+       * setup.c (tarx): Skip already installed or older packages.  Report
+       when a package has been updated.
+       (processdirlisting): Skip already installed or older packages.
+       (main): Detect -f option for forced installation.  Initialize pkg stuff
+       if appropriate.
+       * setup.h: Add pkg definitions.
+
 Thu Apr 27 14:21:30 2000  Christopher Faylor <cgf@cygnus.com>
 
        * setup.c (findhref): Return NULL on empty string.  Eat any trailing
index 8a155b52884bf315e6b691a501935aba28d86e68..a2dda0c67d358e7a5649125661a79ed00195930f 100644 (file)
@@ -67,7 +67,7 @@ ALL_LDFLAGS:=${filter-out -I%, \
 
 PROGS:=setup$(EXEEXT)
 
-OBJS:=error.o memory.o setup.o strarry.o cinstall.o path.o xsystem.o
+OBJS:=error.o memory.o setup.o strarry.o cinstall.o path.o pkg.o xsystem.o
 
 BUNDLED_FILES:=cygwin1.dll.gz $(srcdir)/tar.exe.gz $(srcdir)/gzip.exe.gz \
               mount.exe.gz cygpath.exe.gz umount.exe.gz
diff --git a/setup.c b/setup.c
index c664d28f1929e389a20416729c5aba1a5ddf1ada..0df90fd29d4eeacc9594d60d4c051c0018687fbe 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -58,6 +58,8 @@ static FILE *logfp = NULL;
 static HANDLE devnull = NULL;
 static HINTERNET session = NULL;
 static SA deleteme = {NULL, 0, 0};
+static pkg *pkgstuff;
+static int forceinstall;
 
 static void
 filedel (void)
@@ -218,6 +220,16 @@ tarx (const char *dir, const char *fn)
   HANDLE hproc;
   FILE *fp;
   int filehere;
+  char *pkgname, *pkgversion;
+  pkg *pkg;
+
+  normalize_version (fn, &pkgname, &pkgversion);
+  pkg = find_pkg (pkgstuff, pkgname);
+  if (!newer_pkg (pkg, pkgversion))
+    {
+      warning ("Skipping extraction of package '%s'\n", pkgname);
+      return 1;
+    }
 
   dpath = pathcat (dir, fn);
   path = dtoupath (dpath);
@@ -285,6 +297,9 @@ tarx (const char *dir, const char *fn)
       warning ("Unable to reset protection on '%s' - %s\n",
               files.array[filehere], _strerror (""));
 
+  warning ("%s package '%s'\n", write_pkg (pkg, pkgname, pkgversion) ?
+                             "Updated" : "Refreshed", pkgname);
+
   return 1;
 }
 
@@ -781,8 +796,19 @@ processdirlisting (const char *urlbase, const char *file)
        {
          int download = 0;
          char *filename = strrchr (url, '/') + 1;
+         char *pkgname, *pkgversion;
+         pkg *pkg;
+
          retval++;
 
+         normalize_version (filename, &pkgname, &pkgversion);
+         pkg = find_pkg (pkgstuff, pkgname);
+         if (!newer_pkg (pkg, pkgversion))
+           {
+             warning ("Skipping %s\n", filename);
+             continue;
+           }
+
          if (download_when == ALWAYS || needfile (filename, filedate, filesize))
            download = 1;
          else
@@ -965,6 +991,7 @@ create_uninstall (const char *wd, const char *folder, const char *shellscut,
 
          fprintf (uninst,
                   "@echo off\n" "%c:\n" "cd \"%s\"\n", *cwd, cwd);
+         fprintf (uninst, "bin\\regtool remove /HKLM/SOFTWARE/'Cygnus Solutions'/cygwin/'Installed Components'\n");
          for (n = 0; n < files.count; ++n)
            {
              char *dpath;
@@ -1237,7 +1264,7 @@ mkmount (const char *mountexedir, const char *root, const char *dospath,
 static char rev[] = "$Revision$ ";
 
 int
-main ()
+main (int argc, char **argv)
 {
   int retval = 1;              /* Default to error code */
   clock_t start;
@@ -1245,6 +1272,13 @@ main ()
   char *revn, *p;
   int fd = _open ("nul", _O_WRONLY | _O_BINARY);
 
+  while (*++argv)
+    if (strstr (*argv, "-f") != NULL)
+      {
+       forceinstall = 1;
+       break;
+      }
+
   devnull = (HANDLE) _get_osfhandle (fd);
 
   setbuf (stdout, NULL);
@@ -1359,6 +1393,14 @@ those as the basis for your installation.\n\n"
 
       update =
        prompt ("Install from the current directory (d) or from the Internet (i)", "i");
+
+      pkgstuff = init_pkgs ();
+      if (forceinstall)
+       {
+         static pkg dummy = {NULL, NULL};
+         pkgstuff = &dummy;
+       }
+
       if (toupper (*update) == 'I')
        {
          char *dir = getdownloadsource ();
diff --git a/setup.h b/setup.h
index 9fa8e4186f0692ca4ba9cbde3a879693eab31322..d8724ef8f4ac39121e9d1f72b9b906c3392c062b 100644 (file)
--- a/setup.h
+++ b/setup.h
 
 #include <stddef.h>
 
+/* Package versioning stuff */
+
+typedef struct
+{
+  char *name;
+  char *version;
+} pkg;
+
+pkg *init_pkgs (void);
+pkg * find_pkg (pkg *stuff, char *name);
+int write_pkg (pkg *pkg, char *name, char *version);
+int newer_pkg (pkg *pkg, char *version);
+void normalize_version (const char *fn, char **prod, char **version);
+void close_pkgs (void);
+
 /* Routines in error.c. */
 void lowmem ();                        /* Report low memory and exit the
                                   application. */
This page took 0.087875 seconds and 5 git commands to generate.