aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2003-08-10 01:07:04 +0000
committerChristopher Faylor <me@cgf.cx>2003-08-10 01:07:04 +0000
commite41630b08a5ec7b1c348c6e27f66a236b822c2e9 (patch)
treea3834c9a34a04a1dd40fa1ac79b30a28b2c9d163
parent46258d6fb80517c94ea0fb73b601cbf3a9fc9edb (diff)
downloadnewlib-e41630b08a5ec7b1c348c6e27f66a236b822c2e9.zip
newlib-e41630b08a5ec7b1c348c6e27f66a236b822c2e9.tar.gz
newlib-e41630b08a5ec7b1c348c6e27f66a236b822c2e9.tar.bz2
* dump_setup.cc (dump_setup): Check for the existence of the package list file.
Rework slightly to use static buffer for popen commands.
-rw-r--r--winsup/utils/ChangeLog6
-rw-r--r--winsup/utils/dump_setup.cc46
2 files changed, 37 insertions, 15 deletions
diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog
index e5bd9aa..e8bf2f2 100644
--- a/winsup/utils/ChangeLog
+++ b/winsup/utils/ChangeLog
@@ -1,3 +1,9 @@
+2003-08-09 Igor Pechtchanski <pechtcha@cs.nyu.edu>
+ Christopher Faylor <cgf@redhat.com>
+
+ * dump_setup.cc (dump_setup): Check for the existence of the package
+ list file. Rework slightly to use static buffer for popen commands.
+
2003-08-07 Igor Pechtchanski <pechtcha@cs.nyu.edu>
Christopher Faylor <cgf@redhat.com>
diff --git a/winsup/utils/dump_setup.cc b/winsup/utils/dump_setup.cc
index 248e417..2a64b90 100644
--- a/winsup/utils/dump_setup.cc
+++ b/winsup/utils/dump_setup.cc
@@ -237,36 +237,52 @@ file_exists (int verbose, char *filename, const char *alt, char *package)
static bool
check_package_files (int verbose, char *package)
{
+ char filelist[MAX_PATH + 1] = "/etc/setup/";
+ strcat (strcat (filelist, package), ".lst.gz");
+ if (!file_exists (false, filelist, NULL, NULL))
+ {
+ if (verbose)
+ printf ("Missing file list /%s for package %s\n", filelist, package);
+ return false;
+ }
+
+ static char *zcat;
+ static char *zcat_end;
+ if (!zcat)
+ {
+ zcat = cygpath ("/bin/gzip.exe", NULL);
+ while (char *p = strchr (zcat, '/'))
+ *p = '\\';
+ zcat = (char *) realloc (zcat, strlen (zcat) + sizeof (" -dc ") + 4096);
+ zcat_end = strchr (strcat (zcat, " -dc "), '\0');
+ }
+
+ strcpy (zcat_end, filelist);
+ FILE *fp = popen (zcat, "rt");
+
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];
+ char buf[MAX_PATH + 1];
while (fgets (buf, 4096, fp))
{
char *filename = strtok(buf, "\n");
- if (filename[strlen(filename)-1] == '/')
+ if (filename[strlen (filename) - 1] == '/')
{
- if (!directory_exists(verbose, filename, package))
+ if (!directory_exists (verbose, filename, package))
result = false;
}
- else if (!strncmp(filename, "etc/postinstall/", 16))
+ else if (!strncmp (filename, "etc/postinstall/", 16))
{
- if (!file_exists(verbose, filename, ".done", package))
+ if (!file_exists (verbose, filename, ".done", package))
result = false;
}
else
{
- if (!file_exists(verbose, filename, ".lnk", package))
+ if (!file_exists (verbose, filename, ".lnk", package))
result = false;
}
}
- fclose(fp);
+
+ fclose (fp);
return result;
}