From 1304023e23c2ad26ccbf141972a2de01c80da269 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Sun, 30 Apr 2000 03:40:05 +0000 Subject: [PATCH] * pkg.c: New file. * error.c (winerror): Respond to gcc warning. * path.c (cygpath_pipe): Ditto. * setup.c (filedel): Call sa_cleanup on deleteme. (create_shortcut): Coerce argument to eliminate compiler warning. (tarx): Use installed version of cygwin1.dll, overriding tar file name. (refmatches): New function. Tests if ref is contained in a list of packages to install. (filematches): New function. Tests if filename matches one of a list of packages to install. (recurse_dirs): Accept list of packages to install. Generalize tar.gz test to accomodate _tar.gz. (prompt): Ensure that stdout is flushed prior to asking for input. (findhref): Initialize variables to quiet a compiler warning. (processdirlisting): Accept list of packages to install. Special case cygwin tar file version number. (downloaddir): Accept list of packages to install. (downloadfrom): Ditto. (create_uninstall): Eliminate unneeded variables. Quote arguments to regtool. (do_start_menu): Don't create uninstall bat file if updating or user specified a list of packages. (mkmount): Eliminate unneeded variables. (get_pkg_stuff): New function. Checks for previous unversioned installation. (main): Accept -u and -f options and package names on the command line. Use get_pkg_stuff to initialize package information. Umount /etc. Call recurse_dirs and downloadfrom with list of package to install. Ensure that all /usr/local directories are created. Output installation time to setup.log. * setup.h: Add some prototypes. * xsystem.c (xcreate_process): Eliminate unneeded variable. --- error.c | 2 +- path.c | 2 +- pkg.c | 296 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ setup.c | 267 ++++++++++++++++++++++++++++++------------------ setup.h | 3 + xsystem.c | 1 - 6 files changed, 471 insertions(+), 100 deletions(-) create mode 100644 pkg.c diff --git a/error.c b/error.c index 4951a23b..b7f782bf 100644 --- a/error.c +++ b/error.c @@ -42,7 +42,7 @@ winerror () (LPTSTR) & msgbuf, 0, NULL); if (msgbuf) { - fprintf (stderr, "%s\n", msgbuf); + fprintf (stderr, "%s\n", (char *) msgbuf); LocalFree (msgbuf); } else diff --git a/path.c b/path.c index 1e56fd0e..7a6eebfe 100644 --- a/path.c +++ b/path.c @@ -68,7 +68,7 @@ cygpath_pipe () hin = (HANDLE) _get_osfhandle (hpipein[1]); hout = (HANDLE) _get_osfhandle (hpipeout[0]); - sprintf (buffer, "cygpath -a -o -f - -c %x", _get_osfhandle (hpipeout[1])); + sprintf (buffer, "cygpath -a -o -f - -c %lx", (unsigned long) _get_osfhandle (hpipeout[1])); hcygpath = (HANDLE) xcreate_process (0, hout, hin, hin, buffer); if (!hcygpath) return 0; diff --git a/pkg.c b/pkg.c new file mode 100644 index 00000000..bf011f13 --- /dev/null +++ b/pkg.c @@ -0,0 +1,296 @@ +/* + * Copyright (c) 2000, Red Hat, Inc. + * + * 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 Christopher Faylor + * + */ + +#include +#include +#include +#include +#include "setup.h" +#include + +#define CYGMAJOR "%%% Cygwin dll major: " +#define CYGMAJOR_LEN (sizeof (CYGMAJOR) - 1) +#define CYGMINOR "%%% Cygwin dll minor: " +#define CYGMINOR_LEN (sizeof (CYGMINOR) - 1) + +void +normalize_version (const char *fn_in, char **prod, char **version) +{ + char *p; + char *fn, *origfn; + char *dot; + static char buf1[1024]; + static char buf2[1024]; + + origfn = buf1; + strcpy (buf1, fn_in); + fn = origfn = buf1; + + if ((p = strstr (fn, ".tar.gz")) != NULL) + *p = '\0'; + else if ((p = strstr (fn, "_tar.gz")) != NULL) + *p = '\0'; + + while (isalpha (*fn)) + fn++; + if (*fn) + *fn++ = '\0'; + + *prod = origfn; + if (!*fn) + { + *version = strcpy (buf2, "0000"); + return; + } + + dot = ""; + buf2[0] = '\0'; + while (*fn) + { + int n; + fn += strspn (fn, "-_.+,"); + if (!*fn) + break; + n = strcspn (fn, "-_.+,"); + sprintf (strchr (buf2, '\0'), "%s%04.*s", dot, n, fn); + fn += n; + dot = "."; + } + + *version = buf2; + return; +} + +static HKEY hkpkg; + +static pkg default_pkgs[] = +{ + {"diff", "0000"}, + {"ash", "0000"}, + {"bash", "0000"}, + {"binutils", "19990818.0001"}, + {"bison", "0000"}, + {"byacc", "0000"}, + {"bzip", "0000"}, + {"clear", "0001.0000"}, + {"dejagnu", "0000"}, + {"expect", "0000"}, + {"fileutils", "0000"}, + {"findutils", "0000"}, + {"flex", "0000"}, + {"gawk", "0000"}, + {"gcc", "0002.0095.0002.0001"}, + {"gdb", "20000415"}, + {"gperf", "0000"}, + {"grep", "0000"}, + {"groff", "0001.011a.0001"}, + {"gzip", "0000"}, + {"less", "0000"}, + {"m", "0000"}, + {"make", "0000"}, + {"man", "0001.005g.0001"}, + {"patch", "0000"}, + {"sed", "0000"}, + {"shellutils", "0000"}, + {"tar", "0000"}, + {"tcltk", "0000"}, + {"termcap", "0002"}, + {"texinfo", "0000"}, + {"textutils", "0000"}, + {"time", "0000"}, + {NULL, NULL} +}; + +pkg * +use_default_pkgs (pkg *stuff) +{ + pkg *def, *stf; + int sawend; + def = default_pkgs; + + sawend = 0; + for (stf = stuff, def = default_pkgs; def->name != NULL; stf++) + { + if (sawend || !stf->name) + { + stf->name = xstrdup (def->name); + stf->version = xstrdup (def->version); + def++; + sawend = 1; + } + (void) write_pkg (NULL, stf->name, stf->version); + } + stf->name = NULL; + stf->version = NULL; + return stuff; +} + +pkg * +find_pkg (pkg *stuff, char *name) +{ + int i; + + for (i = 0; stuff[i].name; i++) + if (stricmp (stuff[i].name, name) == 0) + return stuff + i; + + return NULL; +} + +const char * +check_for_installed (const char *root, pkg *stuff) +{ + char *cygwin = pathcat (root, "bin\\cygwin1.dll"); + FILE *fp = fopen (cygwin, "rb"); + char *buf, *bufend; + struct _stat st; + char *major, *minor; + pkg *pkg; + static char buf1[256]; + + xfree (cygwin); + + if (fp == NULL) + return NULL; + + if (_fstat (fileno (fp), &st)) + goto err; + + buf = xmalloc (st.st_size); + if (!buf) + goto err; + + if (fread (buf, st.st_size, 1, fp) <= 0) + goto err; + + fclose (fp); + + bufend = buf + st.st_size; + major = minor = NULL; + while (buf < bufend) + if ((buf = memchr (buf, '%', bufend - buf)) == NULL) + return 0; + else if (strncmp (buf, CYGMAJOR, CYGMAJOR_LEN) == 0) + major = buf += CYGMAJOR_LEN; + else if (strncmp (buf, CYGMINOR, CYGMINOR_LEN) != 0) + buf++; + else + { + minor = buf + CYGMINOR_LEN; + break; + } + + if (!minor) + return NULL; + + sprintf (buf1, "%04d.%04d.%04d", atoi (major) / 1000, atoi (major) % 1000, atoi (minor)); + + pkg = find_pkg (stuff, "cygwin"); + if (pkg) + xfree (pkg->version); + else + { + pkg = stuff; + stuff[1].name = stuff[1].version = NULL; + } + + pkg->name = xstrdup ("cygwin"); + pkg->version = xstrdup (buf1); + + sprintf (buf1, "%d.%d.%d", atoi (major) / 1000, atoi (major) % 1000, atoi (minor)); + + return buf1; + +err: + fclose (fp); + return NULL; +} + +pkg * +init_pkgs () +{ + LONG res; + DWORD what; + char empty[] = ""; + char buf[4096]; + DWORD ty, sz; + DWORD nc = 0; + static pkg stuff[1000]; + + res = RegCreateKeyEx (HKEY_LOCAL_MACHINE, + "SOFTWARE\\Cygnus Solutions\\Cygwin\\Installed Components", + 0, empty, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hkpkg, &what); + + for (nc = 0, sz = sizeof (buf); + RegEnumValue (hkpkg, nc, buf, &sz, NULL, &ty, NULL, NULL) == ERROR_SUCCESS; + nc++, sz = sizeof (buf)) + { + DWORD sz = sizeof (buf); + stuff[nc].name = xstrdup (buf); + + if (RegQueryValueEx (hkpkg, stuff[nc].name, NULL, + &ty, buf, &sz) == ERROR_SUCCESS) + stuff[nc].version = xstrdup (buf); + else + stuff[nc].version = xstrdup (""); + } + + stuff[nc].version = stuff[nc].name = NULL; + return stuff; +} + +int +write_pkg (pkg *pkg, char *name, char *version) +{ + if (pkg != NULL && stricmp (pkg->version, version) >= 0) + return 0; + + RegSetValueEx (hkpkg, name, 0, REG_SZ, version, strlen (version) + 1); + return 1; +} + +int +newer_pkg (pkg *pkg, char *version) +{ + if (pkg != NULL && stricmp (pkg->version, version) >= 0) + return 0; + return 1; +} + +void +close_pkgs () +{ + RegCloseKey (hkpkg); +} + +#ifdef check +int +main (int argc, char **argv) +{ + pkg *stuff = init_pkgs (); + + while (*++argv) + { + char *stub, *ver; + pkg *pkg; + normalize_version (*argv, &stub, &ver); + printf ("%s = %s, %s\n", *argv, stub, ver); + if ((pkg = find_pkg (stuff, stub)) != NULL) + printf ("found pkg %s = %s\n", pkg->name, pkg->version); + printf ("write_pkg returns %d\n", write_pkg (pkg, stub, ver)); + } + exit (0); +} +#endif diff --git a/setup.c b/setup.c index a998a8cc..a279ac7d 100644 --- a/setup.c +++ b/setup.c @@ -51,7 +51,7 @@ char *wd = NULL; static char *tarpgm; -static int downloaddir (const char *url); +static int downloaddir (SA *installme, const char *url); static SA files = {NULL, 0, 0}; static FILE *logfp = NULL; @@ -59,7 +59,8 @@ static HANDLE devnull = NULL; static HINTERNET session = NULL; static SA deleteme = {NULL, 0, 0}; static pkg *pkgstuff; -static int forceinstall = 1; +static int updating = 0; +static SA installme = {NULL, 0, 0}; static void filedel (void) @@ -67,6 +68,7 @@ filedel (void) int i; for (i = 0; i < deleteme.count; i++) (void) _unlink (deleteme.array[i]); + sa_cleanup (&deleteme); } void @@ -117,7 +119,7 @@ create_shortcut (const char *target, const char *shortcut) sl->lpVtbl->SetArguments (sl, args); xfree (path); - hres = sl->lpVtbl->QueryInterface (sl, &IID_IPersistFile, &pf); + hres = sl->lpVtbl->QueryInterface (sl, &IID_IPersistFile, (void **) &pf); if (SUCCEEDED (hres)) { @@ -269,7 +271,6 @@ tarx (const char *dir, const char *fn) } else { - char *e; if (++files.index >= files.count) files.array = realloc (files.array, NFILE_SLOP + (files.count += NFILE_LIST)); @@ -284,7 +285,7 @@ tarx (const char *dir, const char *fn) xumount (wd, s); } #endif - + s = files.array[files.index] = utodpath (s); } @@ -297,6 +298,11 @@ tarx (const char *dir, const char *fn) warning ("Unable to reset protection on '%s' - %s\n", files.array[filehere], _strerror ("")); + /* Use the version of the cygwin that was just installed rather than the + tar file name. (kludge) */ + if (stricmp (pkgname, "cygwin") == 0) + (void) check_for_installed (".", pkgstuff); + warning ("%s package '%s'\n", write_pkg (pkg, pkgname, pkgversion) ? "Updated" : "Refreshed", pkgname); @@ -304,7 +310,43 @@ tarx (const char *dir, const char *fn) } static int -recurse_dirs (const char *dir) +refmatches (SA *installme, char *ref, char *refend) +{ + int i; + char *p, *q; + char filebuf[4096]; + if (!installme->count) + return 1; + + for (p = ref; (q = strchr (p, '/')) != refend; p = q + 1) + continue; + + strcpy (filebuf, p); + strchr (filebuf, '\0')[-1] = '\0'; + for (i = 0; i < installme->count; i++) + if (stricmp (installme->array[i], filebuf) == 0) + return 1; + + return 0; +} + +static int +filematches (SA *installme, char *fn) +{ + int i; + + if (!installme->count) + return 1; + + for (i = 0; i < installme->count; i++) + if (strnicmp (installme->array[i], fn, strlen (installme->array[i])) == 0) + return 1; + + return 0; +} + +static int +recurse_dirs (SA *installme, const char *dir) { int err = 0; int retval = 0; @@ -322,7 +364,8 @@ recurse_dirs (const char *dir) do { if (strcmp (find_data.cFileName, ".") == 0 - || strcmp (find_data.cFileName, "..") == 0) + || strcmp (find_data.cFileName, "..") == 0 + || !filematches (installme, find_data.cFileName)) continue; if (find_data.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY @@ -331,7 +374,7 @@ recurse_dirs (const char *dir) char *subdir = pathcat (dir, find_data.cFileName); if (subdir) { - if (!recurse_dirs (subdir)) + if (!recurse_dirs (installme, subdir)) { xfree (subdir); err = 1; @@ -351,7 +394,7 @@ recurse_dirs (const char *dir) if (!err) { xfree (pattern); - pattern = pathcat (dir, "*.tar.gz"); + pattern = pathcat (dir, "*tar.gz"); handle = FindFirstFile (pattern, &find_data); if (handle != INVALID_HANDLE_VALUE) { @@ -360,10 +403,10 @@ recurse_dirs (const char *dir) do { /* Skip source archives and meta-directories */ - if (strstr (find_data.cFileName, "-src.tar.gz") - || strstr (find_data.cFileName, "-src-") + if (strstr (find_data.cFileName, "-src") || strcmp (find_data.cFileName, ".") == 0 - || strcmp (find_data.cFileName, "..") == 0) + || strcmp (find_data.cFileName, "..") == 0 + || !filematches (installme, find_data.cFileName)) { continue; } @@ -409,6 +452,7 @@ prompt (const char *text, const char *def) printf ((def ? "%s? [%s] " : "%s? "), text, def); + fflush (stdout); fgets (buffer, sizeof (buffer), stdin); buffer[strcspn (buffer, "\r\n")] = '\0'; @@ -419,7 +463,7 @@ prompt (const char *text, const char *def) static int optionprompt (const char *text, SA * options) { - size_t n, lbound, response; + size_t n, response = 1; char buf[5]; size_t base; @@ -491,7 +535,7 @@ geturl (const char *url, const char *file, int verbose) { const char *hosthere, *hostend; int n; - + hosthere = strstr (url, "//"); if (!hosthere) hosthere = url; /* huh? */ @@ -679,7 +723,7 @@ static char * findhref (char *buffer, char *date, size_t *filesize) { char *ref = NULL; - char *anchor; + char *anchor = NULL; char *p; int eatspace; char *q; @@ -709,7 +753,7 @@ findhref (char *buffer, char *date, size_t *filesize) anchor = q; } } - + if (!ref) return NULL; @@ -762,7 +806,7 @@ needfile (const char *filename, char *date, size_t filesize) } static int -processdirlisting (const char *urlbase, const char *file) +processdirlisting (SA *installme, const char *urlbase, const char *file) { int retval = 0; char buffer[4096]; @@ -778,7 +822,7 @@ processdirlisting (const char *urlbase, const char *file) char *ref = findhref (buffer[0] ? buffer : buffer + 1, filedate, &filesize); char url[256]; DWORD urlspace = sizeof (url); - struct _stat st; + char *refend; if (!ref || strnicmp (ref, "http:", 5) == 0) continue; @@ -793,8 +837,13 @@ processdirlisting (const char *urlbase, const char *file) else if (strlen (url) == urllen || strnicmp (urlbase, url, urllen) != 0 || strstr (url, "/.") || strstr (url, "./")) continue; - else if (ref[strlen (ref) - 1] == '/') - retval += downloaddir (url); + + refend = ref + strlen (ref) - 1; + if (*refend == '/') + { + if (refmatches (installme, ref, refend)) + retval += downloaddir (installme, url); + } else if (strstr (url, ".tar.gz") && !strstr (url, "-src")) { int download = 0; @@ -802,10 +851,17 @@ processdirlisting (const char *urlbase, const char *file) char *pkgname, *pkgversion; pkg *pkg; + if (!filematches (installme, filename)) + continue; + retval++; - normalize_version (filename, &pkgname, &pkgversion); + if (stricmp (filename, "cygwin-20000301.tar.gz") == 0) + normalize_version ("cygwin-1.1.0.tar.gz", &pkgname, &pkgversion); + else + normalize_version (filename, &pkgname, &pkgversion); pkg = find_pkg (pkgstuff, pkgname); + if (!newer_pkg (pkg, pkgversion)) { warning ("Skipped download of %s\n", filename); @@ -870,7 +926,7 @@ processdirlisting (const char *urlbase, const char *file) if (!res) warning ("Download failed.\n"); else - fprintf (logfp, "Downloaded file size does not match (%ld).\n", + fprintf (logfp, "Downloaded file size does not match (%d).\n", filesize); answer = prompt (res ? "Downloaded file size does not match (Abort, Retry, Fail)" : "Download failed (Abort, Retry, Fail)", "R"); @@ -884,7 +940,7 @@ processdirlisting (const char *urlbase, const char *file) exit (1); /* abort program */ case 'F': warning ("Deleting %s.\n", filename); - _unlink (filename); + _unlink (filename); goto noget; /* Keep trying to download the rest */ default: continue; /* erroneous response */ @@ -915,14 +971,14 @@ tmpfilename () } static int -downloaddir (const char *url) +downloaddir (SA *installme, const char *url) { int retval = 0; char *file = tmpfilename (); if (geturl (url, file, 1)) { - retval = processdirlisting (url, file); + retval = processdirlisting (installme, url, file); _unlink (file); } xfree (file); @@ -939,14 +995,14 @@ opensession () } static int -downloadfrom (const char *url) +downloadfrom (SA *installme, const char *url) { int retval = 0; char *file = tmpfilename (); if (geturl (url, file, 1)) { - retval = processdirlisting (url, file); + retval = processdirlisting (installme, url, file); _unlink (file); } @@ -966,10 +1022,7 @@ create_uninstall (const char *wd, const char *folder, const char *shellscut, const char *shortcut) { int retval = 0; - char buffer[MAX_PATH]; - clock_t start; - HINSTANCE lib; - + warning ("Creating the uninstall file..."); fflush (stdout); if (files.array) @@ -985,7 +1038,6 @@ create_uninstall (const char *wd, const char *folder, const char *shellscut, if (uninst) { - unsigned percent = 0; struct _stat st; files.array[++files.index] = pathcat (cwd, "bin\\cygwin.bat"); @@ -994,7 +1046,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"); + fprintf (uninst, "bin\\regtool remove '/HKLM/SOFTWARE/Cygnus Solutions/cygwin/Installed Components'\n"); for (n = 0; n < files.count; ++n) { char *dpath; @@ -1027,9 +1079,6 @@ create_uninstall (const char *wd, const char *folder, const char *shellscut, retval = 1; } - if (lib) - FreeLibrary (lib); - warning ("Done.\n"); return retval; } @@ -1098,7 +1147,8 @@ do_start_menu (const char *root) xfree (pccmd); } - if (create_shortcut (cmdline, shortcut)) + if (create_shortcut (cmdline, shortcut) + && (!updating || installme.count)) { char *uninstscut = pathcat (folder, "Uninstall Cygwin 1.1.0.lnk"); @@ -1116,7 +1166,6 @@ do_start_menu (const char *root) xfree (folder); } } - xfree (batch_name); } return retval; @@ -1240,7 +1289,7 @@ static int mkmount (const char *mountexedir, const char *root, const char *dospath, const char *unixpath, int force) { - char *mount, *bslashed, *fulldospath, *p; + char *mount, *fulldospath; char buffer[1024]; if (*root == '\0') @@ -1268,6 +1317,41 @@ mkmount (const char *mountexedir, const char *root, const char *dospath, return xcreate_process (1, NULL, NULL, NULL, buffer) != 0; } +static pkg * +get_pkg_stuff (const char *root, int updating) +{ + const char *ver, *ans; + pkg *pkgstuff = init_pkgs (); + static pkg dummy = {NULL, NULL}; + + if (!updating) + return &dummy; + + if (pkgstuff->name != NULL) + return pkgstuff; + + ver = check_for_installed (root, pkgstuff); + if (!ver || stricmp (ver, "1.1.0") != 0) + return &dummy; + + puts ("\nHmm. You seem to have a previous cygwin version installed but there is no\n" + "package version information in the registry. This is probably due to the fact\n" + "that previous versions of setup.exe did not update this information."); + + ans = prompt ("Should I update the registry with default information now", "y"); + puts (""); + if (toupper (*ans) != 'Y') + { + warning ("Not writing default package information to the registry.\n"); + puts (""); + return pkgstuff; + } + + warning ("Writing default package information to the registry.\n"); + puts (""); + return use_default_pkgs (pkgstuff); +} + static char rev[] = "$Revision$ "; int @@ -1280,10 +1364,18 @@ main (int argc, char **argv) int fd = _open ("nul", _O_WRONLY | _O_BINARY); while (*++argv) - if (strstr (*argv, "-f") != NULL) - forceinstall = 1; - else if (strstr (*argv, "-u") != NULL) - forceinstall = 0; + if (stricmp (*argv, "-f") == 0) + updating = 0; + else if (stricmp (*argv, "-u") == 0) + updating = 1; + else + break; + + sa_init (&installme); + if (*argv) + do + sa_add (&installme, *argv); + while (*++argv); devnull = (HANDLE) _get_osfhandle (fd); @@ -1350,8 +1442,8 @@ those as the basis for your installation.\n\n" printf ("Press to accept the default value.\n"); /* If some Cygnus software has been installed, assume there is a root - mount in the registry. Otherwise use C:\cygwin for the default root - directory. */ + mount in the registry. Otherwise use C:\cygwin for the default root + directory. */ if (RegOpenKey (HKEY_CURRENT_USER, CYGNUS_KEY, &cu) == ERROR_SUCCESS || RegOpenKey (HKEY_LOCAL_MACHINE, CYGNUS_KEY, &lm) == ERROR_SUCCESS) @@ -1366,7 +1458,7 @@ those as the basis for your installation.\n\n" defroot = xstrdup (DEF_ROOT); /* Get the root directory and warn the user if there are any spaces in - the path. */ + the path. */ for (done = 0; !done;) { root = prompt ("Root directory", defroot); @@ -1393,20 +1485,15 @@ those as the basis for your installation.\n\n" xfree (defroot); /* Create the root directory. */ - mkdir (root); /* Ignore any return value since it may + mkdirp (root); /* Ignore any return value since it may already exist. */ mkmount (wd, "", root, "/", 1); + pkgstuff = get_pkg_stuff (root, updating); + 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 (); @@ -1417,9 +1504,13 @@ those as the basis for your installation.\n\n" exit (1); } - if (!downloadfrom (dir)) + if (!downloadfrom (&installme, dir)) { - warning ("Error: No files found to download. Choose another mirror site?\n"); + warning ("Error: No files found to download."); + if (!installme.count) + warning(" Choose another mirror site?\n"); + else + warning ("\n"); goto out; } InternetCloseHandle (session); @@ -1428,7 +1519,7 @@ those as the basis for your installation.\n\n" xfree (update); /* Make the root directory the current directory so that recurse_dirs - will * extract the packages into the correct path. */ + will * extract the packages into the correct path. */ if (chdir (root) == -1) { warning ("Unable to make \"%s\" the current directory: %s\n", @@ -1444,6 +1535,7 @@ those as the basis for your installation.\n\n" xumount (wd, "/var"); xumount (wd, "/lib"); xumount (wd, "/bin"); + xumount (wd, "/etc"); /* Make /bin point to /usr/bin and /lib point to /usr/lib. */ mkmount (wd, root, "bin", "/usr/bin", 1); @@ -1461,45 +1553,25 @@ those as the basis for your installation.\n\n" /* Extract all of the packages that are stored with setup or in subdirectories of its location */ - if (recurse_dirs (wd)) + if (recurse_dirs (&installme, wd)) { - char *mount; - char buffer[1024]; - - /* Mount the new root directory. */ - mount = pathcat (wd, "mount"); - sprintf (buffer, "%s -f -b \"%s\" /", mount, root); - xfree (mount); - if (xsystem (buffer)) - { - printf - ("Unable to mount \"%s\" as the root directory: %s", - root, _strerror ("")); - } - else - { - char **a; - /* bash expects a /tmp */ - char *tmpdir = pathcat (root, "tmp"); - - if (tmpdir) - { - files.array[++files.index] = tmpdir; - mkdir (tmpdir); /* Ignore the result, it may - exist. */ - } - - files.array[++files.index] = pathcat (root, "usr\\local"); - files.array[++files.index] = pathcat (root, "usr\\local\\bin"); - files.array[++files.index] = pathcat (root, "usr\\local\\lib"); - files.array[++files.index] = pathcat (root, "usr\\local\\etc"); - mkdirp (files.array[files.index]); - mkdir (files.array[files.index - 1]); - - if (do_start_menu (root)) - retval = 0; /* Everything worked return - successful code */ - } + /* bash expects a /tmp */ + char *tmpdir = pathcat (root, "tmp"); + + if (tmpdir && mkdir (tmpdir) == 0) + files.array[++files.index] = tmpdir; + + files.array[++files.index] = pathcat (root, "usr\\local"); + files.array[++files.index] = pathcat (root, "usr\\local\\bin"); + files.array[++files.index] = pathcat (root, "usr\\local\\lib"); + files.array[++files.index] = pathcat (root, "usr\\local\\etc"); + mkdirp (files.array[files.index]); + mkdir (files.array[files.index - 1]); + mkdir (files.array[files.index - 2]); + + if (do_start_menu (root)) + retval = 0; /* Everything worked return + successful code */ } } @@ -1511,8 +1583,9 @@ those as the basis for your installation.\n\n" } out: - printf ("\nInstallation took %.0f seconds.\n", - (double) (clock () - start) / CLK_TCK); + puts (""); + warning ("Installation took %.0f seconds.\n", + (double) (clock () - start) / CLK_TCK); if (logpath) { diff --git a/setup.h b/setup.h index d8724ef8..3facdf80 100644 --- a/setup.h +++ b/setup.h @@ -30,6 +30,9 @@ int newer_pkg (pkg *pkg, char *version); void normalize_version (const char *fn, char **prod, char **version); void close_pkgs (void); +pkg *use_default_pkgs (pkg *stuff); +const char * check_for_installed (const char *root, pkg *stuff); + /* Routines in error.c. */ void lowmem (); /* Report low memory and exit the application. */ diff --git a/xsystem.c b/xsystem.c index de31d7fa..8172792b 100644 --- a/xsystem.c +++ b/xsystem.c @@ -41,7 +41,6 @@ xcreate_process (int wait, HANDLE in, HANDLE out, HANDLE err, const char *cmd) char *command; STARTUPINFO si; PROCESS_INFORMATION pi; - DWORD flags = 0; extern char *wd; if (cmd[1] != ':' && strncmp (cmd, "\\\\", 2) != 0) -- 2.43.5