* Makefile.in: Detect existence of mingw zlib headers and libraries. Build

cygcheck wihtout package checking if they are unavailable.
* dump_setup.cc: Generate dummy zlib macros when zlib is not available.
(open_package_list): Use zlib functions to uncompress package lists.  Return
gzFile rather than FILE *.
(check_package_files): Change fp to gzFile to accommodate zlib functions.  Use
gzgets to read from package file.  Use gzclose to close the handle.
(package_list): Ditto.
(package_find): Ditto.
This commit is contained in:
Christopher Faylor 2003-09-08 02:50:02 +00:00
parent 2e5228f964
commit d31c5928dd
3 changed files with 59 additions and 30 deletions

View File

@ -1,3 +1,16 @@
2003-09-07 Christopher Faylor <cgf@redhat.com>
* Makefile.in: Detect existence of mingw zlib headers and libraries.
Build cygcheck wihtout package checking if they are unavailable.
* dump_setup.cc: Generate dummy zlib macros when zlib is not available.
(open_package_list): Use zlib functions to uncompress package lists.
Return gzFile rather than FILE *.
(check_package_files): Change fp to gzFile to accommodate zlib
functions. Use gzgets to read from package file. Use gzclose to close
the handle.
(package_list): Ditto.
(package_find): Ditto.
2003-09-05 Igor Pechtchanski <pechtcha@cs.nyu.edu> 2003-09-05 Igor Pechtchanski <pechtcha@cs.nyu.edu>
* dump_setup.cc (check_package_files): Don't fail on empty package. * dump_setup.cc (check_package_files): Don't fail on empty package.

View File

@ -40,6 +40,15 @@ libbfd:=${shell $(CC) -B$(bupdir2)/bfd/ --print-file-name=libbfd.a}
libintl:=${shell $(CC) -B$(bupdir2)/intl/ --print-file-name=libintl.a} libintl:=${shell $(CC) -B$(bupdir2)/intl/ --print-file-name=libintl.a}
build_dumper:=${shell test -r $(libbfd) && test -r ${libintl} && echo 1} build_dumper:=${shell test -r $(libbfd) && test -r ${libintl} && echo 1}
libz:=${shell $(CC) -mno-cygwin --print-file-name=libz.a}
zlib_h:=-include ${patsubst %/lib/libz.a,%/include/libz.h,$(libz)}
zconf_h:=-include ${patsubst %/lib/libz.a,%/include/zconf.h,$(libz)}
ifeq "${dir $(libz)}" "./"
zlib_h:=
zconf_h:=
libz:=
endif
DUMPER_INCLUDES:=-I$(bupdir2)/bfd -I$(updir1)/include DUMPER_INCLUDES:=-I$(bupdir2)/bfd -I$(updir1)/include
libcygwin:=$(cygwin_build)/libcygwin.a libcygwin:=$(cygwin_build)/libcygwin.a
@ -90,11 +99,14 @@ else
endif endif
cygcheck.exe: cygcheck.o mingw_getopt.o path.o dump_setup.o $(MINGW_DEP_LDLIBS) cygcheck.exe: cygcheck.o mingw_getopt.o path.o dump_setup.o $(MINGW_DEP_LDLIBS)
ifeq "$(libz)" ""
echo '*** Building cygcheck without package content checking due to missing mingw libz.a.'
endif
ifdef VERBOSE ifdef VERBOSE
$(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,4,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS) $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,4,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS) $(libz)
else else
@echo $(CXX) -o $@ ${wordlist 1,2,$^} ${filter-out -B%, $(MINGW_CXXFLAGS) $(MINGW_LDFLAGS)};\ @echo $(CXX) -o $@ ${wordlist 1,2,$^} ${filter-out -B%, $(MINGW_CXXFLAGS) $(MINGW_LDFLAGS)} $(libz);\
$(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,4,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS) $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,4,$^} -B$(mingw_build)/ $(MINGW_LDFLAGS) $(libz)
endif endif
dumper.o: dumper.cc dumper.h dumper.o: dumper.cc dumper.h
@ -139,10 +151,10 @@ endif
dump_setup.o: dump_setup.cc dump_setup.o: dump_setup.cc
ifdef VERBOSE ifdef VERBOSE
${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $< ${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $(zconf_h) $(zlib_h) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
else else
@echo $(CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) ... $^;\ @echo $(CXX) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) ... $^;\
${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $< ${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $(zconf_h) $(zlib_h) $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
endif endif
cygcheck.o: cygcheck.cc cygcheck.o: cygcheck.cc

View File

@ -18,6 +18,15 @@ details. */
#include <sys/stat.h> #include <sys/stat.h>
#include <errno.h> #include <errno.h>
#include "path.h" #include "path.h"
#if 0
#include "zlib.h"
#endif
#ifndef ZLIB_VERSION
typedef void * gzFile;
#define gzgets(fp, buf, size) ({0;})
#define gzclose(fp) ({0;})
#endif
static int package_len = 20; static int package_len = 20;
static unsigned int version_len = 10; static unsigned int version_len = 10;
@ -234,27 +243,22 @@ file_exists (int verbose, char *filename, const char *alt, char *package)
return true; return true;
} }
static FILE * static gzFile
open_package_list (char *package) open_package_list (char *package)
{ {
char filelist[MAX_PATH + 1] = "etc/setup/"; char filelist[MAX_PATH + 1] = "/etc/setup/";
strcat (strcat (filelist, package), ".lst.gz"); strcat (strcat (filelist, package), ".lst.gz");
if (!file_exists (false, filelist, NULL, NULL)) if (!file_exists (false, filelist + 1, NULL, NULL))
return NULL; return NULL;
static char *zcat; gzFile fp;
static char *zcat_end; #ifndef ZLIB_VERSION
if (!zcat) fp = NULL;
{ #else
zcat = cygpath ("/bin/gzip.exe", NULL); char *fn = cygpath (filelist, NULL);
while (char *p = strchr (zcat, '/')) fp = gzopen (fn, "rb9");
*p = '\\'; free (fn);
zcat = (char *) realloc (zcat, strlen (zcat) + sizeof (" -dc /") + MAX_PATH); #endif
zcat_end = strchr (strcat (zcat, " -dc /"), '\0');
}
strcpy (zcat_end, filelist);
FILE *fp = popen (zcat, "rt");
return fp; return fp;
} }
@ -262,7 +266,7 @@ open_package_list (char *package)
static bool static bool
check_package_files (int verbose, char *package) check_package_files (int verbose, char *package)
{ {
FILE *fp = open_package_list (package); gzFile fp = open_package_list (package);
if (!fp) if (!fp)
{ {
if (verbose) if (verbose)
@ -272,7 +276,7 @@ check_package_files (int verbose, char *package)
bool result = true; bool result = true;
char buf[MAX_PATH + 1]; char buf[MAX_PATH + 1];
while (fgets (buf, MAX_PATH, fp)) while (gzgets (fp, buf, MAX_PATH))
{ {
char *filename = strtok(buf, "\n"); char *filename = strtok(buf, "\n");
@ -298,7 +302,7 @@ check_package_files (int verbose, char *package)
} }
} }
fclose (fp); gzclose (fp);
return result; return result;
} }
@ -414,7 +418,7 @@ package_list (int verbose, char **argv)
for (int i = 0; packages[i].name; i++) for (int i = 0; packages[i].name; i++)
{ {
FILE *fp = open_package_list (packages[i].name); gzFile fp = open_package_list (packages[i].name);
if (!fp) if (!fp)
{ {
if (verbose) if (verbose)
@ -427,14 +431,14 @@ package_list (int verbose, char **argv)
printf ("Package: %s-%s\n", packages[i].name, packages[i].ver); printf ("Package: %s-%s\n", packages[i].name, packages[i].ver);
char buf[MAX_PATH + 1]; char buf[MAX_PATH + 1];
while (fgets (buf, MAX_PATH, fp)) while (gzgets (fp, buf, MAX_PATH))
{ {
char *lastchar = strchr(buf, '\n'); char *lastchar = strchr(buf, '\n');
if (lastchar[-1] != '/') if (lastchar[-1] != '/')
printf ("%s/%s", (verbose?" ":""), buf); printf ("%s/%s", (verbose?" ":""), buf);
} }
fclose (fp); gzclose (fp);
} }
free (packages); free (packages);
@ -454,13 +458,13 @@ package_find (int verbose, char **argv)
for (int i = 0; packages[i].name; i++) for (int i = 0; packages[i].name; i++)
{ {
FILE *fp = open_package_list (packages[i].name); gzFile fp = open_package_list (packages[i].name);
if (!fp) if (!fp)
continue; continue;
char buf[MAX_PATH + 2]; char buf[MAX_PATH + 2];
buf[0] = '/'; buf[0] = '/';
while (fgets (buf + 1, MAX_PATH, fp)) while (gzgets (fp, buf + 1, MAX_PATH))
{ {
char *filename = strtok(buf, "\n"); char *filename = strtok(buf, "\n");
int flen = strlen (filename); int flen = strlen (filename);
@ -488,7 +492,7 @@ package_find (int verbose, char **argv)
} }
} }
fclose (fp); gzclose (fp);
} }
free (packages); free (packages);