From 36591a07051ef4cc21121df800bbf826b3d51d4e Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sat, 29 Apr 2000 04:28:59 +0000 Subject: [PATCH] * 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. --- ChangeLog | 10 ++++++++++ Makefile.in | 2 +- setup.c | 44 +++++++++++++++++++++++++++++++++++++++++++- setup.h | 15 +++++++++++++++ 4 files changed, 69 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 8d55054a..4aeea604 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Sat Apr 29 00:26:06 2000 Christopher Faylor + + * 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 * setup.c (findhref): Return NULL on empty string. Eat any trailing diff --git a/Makefile.in b/Makefile.in index 8a155b52..a2dda0c6 100644 --- a/Makefile.in +++ b/Makefile.in @@ -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 c664d28f..0df90fd2 100644 --- 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 9fa8e418..d8724ef8 100644 --- a/setup.h +++ b/setup.h @@ -15,6 +15,21 @@ #include +/* 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. */ -- 2.43.5