mirror of
git://sourceware.org/git/newlib-cygwin.git
synced 2025-02-20 16:01:10 +08:00
* dump_setup.cc (version_len): New static variable.
(could_not_access,directory_exists): New static function. (file_exists): Ditto. (check_package_files): Ditto. (dump_setup): Check the contents of each package if check_files is true and output the result in the "Status" column. Flush output after each package. * dump_setup.cc (dump_setup): Remove redundant null check. Add informative message if package info not found.
This commit is contained in:
parent
9d77d53601
commit
58d4b72d33
@ -1,3 +1,20 @@
|
||||
2003-08-07 Igor Pechtchanski <pechtcha@cs.nyu.edu>
|
||||
Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* dump_setup.cc (version_len): New static variable.
|
||||
(could_not_access,directory_exists): New static function.
|
||||
(file_exists): Ditto.
|
||||
(check_package_files): Ditto.
|
||||
(dump_setup): Check the contents of each package if check_files is true
|
||||
and output the result in the "Status" column. Flush output after each
|
||||
package.
|
||||
|
||||
2003-08-07 Igor Pechtchanski <pechtcha@cs.nyu.edu>
|
||||
Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* dump_setup.cc (dump_setup): Remove redundant null check. Add
|
||||
informative message if package info not found.
|
||||
|
||||
2003-07-26 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
* mount.cc (do_mount): Issue warning when using managed mount option on
|
||||
@ -66,7 +83,7 @@
|
||||
and free servername in the loop.
|
||||
* mkgroup.c (enum_groups): Do not free servername.
|
||||
(usage): Update to allow several domains. Change uid to gid.
|
||||
(main): Only print specials when -l is specified. Add a
|
||||
(main): Only print specials when -l is specified. Add a
|
||||
loop to allow several domains and free servername in the loop.
|
||||
|
||||
2003-03-24 Christopher Faylor <cgf@redhat.com>
|
||||
@ -91,11 +108,11 @@
|
||||
|
||||
2003-03-01 Pierre Humblet <pierre.humblet@ieee.org>
|
||||
|
||||
* mkpasswd.cc (main): On Win95, output both a default line and a
|
||||
* mkpasswd.cc (main): On Win95, output both a default line and a
|
||||
line for the current user (if known) with a pseudorandom uid. If
|
||||
the -u switch is given, produce a line for the specified user.
|
||||
* mkgroup.cc (main): On Win95 change the group name from "unknown" to
|
||||
"all".
|
||||
* mkgroup.cc (main): On Win95 change the group name from "unknown" to
|
||||
"all".
|
||||
|
||||
2003-02-28 Christopher Faylor <cgf@redhat.com>
|
||||
|
||||
@ -149,11 +166,11 @@
|
||||
Win95/98/ME and to call current_user. Add username in gecos field
|
||||
on Win95/98/ME.
|
||||
* mkgroup.c (enum_groups): Print gid with %u.
|
||||
(print_win_error): Create from passwd.cc.
|
||||
(print_win_error): Create from passwd.cc.
|
||||
(current_group): Create.
|
||||
(usage): Reorganize to support Win95/98/ME.
|
||||
(main): Add option for -c. Reorganize to parse options for
|
||||
Win95/98/ME and to call current_group.
|
||||
Win95/98/ME and to call current_group.
|
||||
|
||||
2002-12-14 Pierre Humblet <pierre.humblet@ieee.org>
|
||||
|
||||
@ -556,7 +573,7 @@
|
||||
|
||||
* mkgroup.c (main): Change call to exit() to a return statement.
|
||||
* mkpasswd.c (main): Ditto.
|
||||
|
||||
|
||||
2002-03-27 Joshua Daniel Franklin joshuadfranklin@yahoo.com
|
||||
|
||||
* mkpasswd.c (usage): Simplify usage output. Generalize to allow use
|
||||
@ -870,7 +887,7 @@ Fri Dec 14 12:10:39 2001 Jason Tishler <jason@tishler.net>
|
||||
Tolerate whitespace and comment chars in input.
|
||||
(usage): Add more user friendly help text.
|
||||
(main): Add --help option.
|
||||
|
||||
|
||||
2001-11-04 Egor Duda <deo@logos-m.ru>
|
||||
|
||||
* strace.cc (main): New option '-w'. Start traced process in separate
|
||||
|
@ -15,9 +15,12 @@ details. */
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <io.h>
|
||||
#include <sys/stat.h>
|
||||
#include <errno.h>
|
||||
#include "path.h"
|
||||
|
||||
static int package_len = 20;
|
||||
static unsigned int version_len = 10;
|
||||
|
||||
|
||||
typedef struct
|
||||
@ -173,14 +176,113 @@ match_argv (char **argv, const char *name)
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
could_not_access (int verbose, char *filename, char *package, const char *type)
|
||||
{
|
||||
switch (errno)
|
||||
{
|
||||
case ENOTDIR:
|
||||
break;
|
||||
case ENOENT:
|
||||
if (verbose)
|
||||
printf ("Missing %s: /%s from package %s\n",
|
||||
type, filename, package);
|
||||
return true;
|
||||
case EACCES:
|
||||
if (verbose)
|
||||
printf ("Unable to access %s /%s from package %s\n",
|
||||
type, filename, package);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool
|
||||
directory_exists (int verbose, char *filename, char *package)
|
||||
{
|
||||
struct stat status;
|
||||
if (stat(cygpath("/", filename, ".", NULL), &status))
|
||||
{
|
||||
if (could_not_access (verbose, filename, package, "directory"))
|
||||
return false;
|
||||
}
|
||||
else if (!S_ISDIR(status.st_mode))
|
||||
{
|
||||
if (verbose)
|
||||
printf ("Directory/file mismatch: /%s from package %s\n", filename, package);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
file_exists (int verbose, char *filename, const char *alt, char *package)
|
||||
{
|
||||
struct stat status;
|
||||
if (stat(cygpath("/", filename, NULL), &status) &&
|
||||
(!alt || stat(cygpath("/", filename, alt, NULL), &status)))
|
||||
{
|
||||
if (could_not_access (verbose, filename, package, "file"))
|
||||
return false;
|
||||
}
|
||||
else if (!S_ISREG(status.st_mode))
|
||||
{
|
||||
if (verbose)
|
||||
printf ("File type mismatch: /%s from package %s\n", filename, package);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool
|
||||
check_package_files (int verbose, char *package)
|
||||
{
|
||||
bool result = true;
|
||||
char filelist[4096] = " -dc /etc/setup/";
|
||||
strcat(strcat(filelist, package), ".lst.gz");
|
||||
char *zcat = cygpath("/bin/gzip.exe", NULL);
|
||||
char command[4096];
|
||||
while (char *p = strchr (zcat, '/'))
|
||||
*p = '\\';
|
||||
strcat(strcpy(command, zcat), filelist);
|
||||
FILE *fp = popen (command, "rt");
|
||||
char buf[4096];
|
||||
while (fgets (buf, 4096, fp))
|
||||
{
|
||||
char *filename = strtok(buf, "\n");
|
||||
if (filename[strlen(filename)-1] == '/')
|
||||
{
|
||||
if (!directory_exists(verbose, filename, package))
|
||||
result = false;
|
||||
}
|
||||
else if (!strncmp(filename, "etc/postinstall/", 16))
|
||||
{
|
||||
if (!file_exists(verbose, filename, ".done", package))
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!file_exists(verbose, filename, ".lnk", package))
|
||||
result = false;
|
||||
}
|
||||
}
|
||||
fclose(fp);
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
dump_setup (int verbose, char **argv, bool /*check_files*/)
|
||||
dump_setup (int verbose, char **argv, bool check_files)
|
||||
{
|
||||
char *setup = cygpath ("/etc/setup/installed.db", NULL);
|
||||
FILE *fp = fopen (setup, "rt");
|
||||
|
||||
puts ("Cygwin Package Information");
|
||||
if (fp == NULL)
|
||||
goto err;
|
||||
{
|
||||
puts ("No package information found");
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (verbose)
|
||||
{
|
||||
bool need_nl = dump_file ("Last downloaded files to: ", "last-cache");
|
||||
@ -188,9 +290,6 @@ dump_setup (int verbose, char **argv, bool /*check_files*/)
|
||||
puts ("");
|
||||
}
|
||||
|
||||
if (!fp)
|
||||
goto err;
|
||||
|
||||
int nlines;
|
||||
nlines = 0;
|
||||
char buf[4096];
|
||||
@ -226,6 +325,8 @@ dump_setup (int verbose, char **argv, bool /*check_files*/)
|
||||
if (f.what[0])
|
||||
strcat (strcat (packages[n].name, "-"), f.what);
|
||||
packages[n].ver = strdup (f.ver);
|
||||
if (strlen(f.ver) > version_len)
|
||||
version_len = strlen(f.ver);
|
||||
n++;
|
||||
if (strtok (NULL, " ") == NULL)
|
||||
break;
|
||||
@ -234,9 +335,14 @@ dump_setup (int verbose, char **argv, bool /*check_files*/)
|
||||
|
||||
qsort (packages, n, sizeof (packages[0]), compar);
|
||||
|
||||
printf ("%-*s %s\n", package_len, "Package", "Version");
|
||||
printf ("%-*s %-*s %s\n", package_len, "Package", version_len, "Version", check_files?"Status":"");
|
||||
for (int i = 0; i < n; i++)
|
||||
printf ("%-*s %s\n", package_len, packages[i].name, packages[i].ver);
|
||||
{
|
||||
printf ("%-*s %-*s %s\n", package_len, packages[i].name, version_len,
|
||||
packages[i].ver, check_files ?
|
||||
(check_package_files (verbose, packages[i].name) ? "OK" : "Incomplete") : "");
|
||||
fflush(stdout);
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
return;
|
||||
|
Loading…
x
Reference in New Issue
Block a user