ソースを参照

detect zlib correctly. We still don't allow to build without it to remain
compatible with users accessing it directly, but this prepares for a drop
of this strict requirement in the future

David Kalnischkies 14 年 前
コミット
7efb8c8ef1
共有3 個のファイルを変更した17 個の追加20 個の削除を含む
  1. 13 19
      apt-pkg/contrib/fileutl.cc
  2. 3 0
      buildlib/config.h.in
  3. 1 1
      configure.in

+ 13 - 19
apt-pkg/contrib/fileutl.cc

@@ -44,14 +44,8 @@
 #include <set>
 #include <set>
 #include <algorithm>
 #include <algorithm>
 
 
-// FIXME: Compressor Fds have some speed disadvantages and are a bit buggy currently,
-// so while the current implementation satisfies the testcases it is not a real option
-// to disable it for now
-#define APT_USE_ZLIB 1
-#if APT_USE_ZLIB
-#include <zlib.h>
-#else
-#pragma message "Usage of zlib is DISABLED!"
+#ifdef HAVE_ZLIB
+	#include <zlib.h>
 #endif
 #endif
 
 
 #ifdef WORDS_BIGENDIAN
 #ifdef WORDS_BIGENDIAN
@@ -65,7 +59,7 @@ using namespace std;
 
 
 class FileFdPrivate {
 class FileFdPrivate {
 	public:
 	public:
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
 	gzFile gz;
 	gzFile gz;
 #else
 #else
 	void* gz;
 	void* gz;
@@ -1016,7 +1010,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
    d->compressor = compressor;
    d->compressor = compressor;
    if (compressor.Name == "." || compressor.Binary.empty() == true)
    if (compressor.Name == "." || compressor.Binary.empty() == true)
       return true;
       return true;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
    else if (compressor.Name == "gzip")
    else if (compressor.Name == "gzip")
    {
    {
       if ((Mode & ReadWrite) == ReadWrite)
       if ((Mode & ReadWrite) == ReadWrite)
@@ -1137,7 +1131,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
    *((char *)To) = '\0';
    *((char *)To) = '\0';
    do
    do
    {
    {
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
       if (d->gz != NULL)
       if (d->gz != NULL)
          Res = gzread(d->gz,To,Size);
          Res = gzread(d->gz,To,Size);
       else
       else
@@ -1149,7 +1143,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
 	 if (errno == EINTR)
 	 if (errno == EINTR)
 	    continue;
 	    continue;
 	 Flags |= Fail;
 	 Flags |= Fail;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
 	 if (d->gz != NULL)
 	 if (d->gz != NULL)
 	 {
 	 {
 	    int err;
 	    int err;
@@ -1190,7 +1184,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
 char* FileFd::ReadLine(char *To, unsigned long long const Size)
 char* FileFd::ReadLine(char *To, unsigned long long const Size)
 {
 {
    *To = '\0';
    *To = '\0';
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
    if (d->gz != NULL)
    if (d->gz != NULL)
       return gzgets(d->gz, To, Size);
       return gzgets(d->gz, To, Size);
 #endif
 #endif
@@ -1221,7 +1215,7 @@ bool FileFd::Write(const void *From,unsigned long long Size)
    errno = 0;
    errno = 0;
    do
    do
    {
    {
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
       if (d->gz != NULL)
       if (d->gz != NULL)
          Res = gzwrite(d->gz,From,Size);
          Res = gzwrite(d->gz,From,Size);
       else
       else
@@ -1289,7 +1283,7 @@ bool FileFd::Seek(unsigned long long To)
       return true;
       return true;
    }
    }
    int res;
    int res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
    if (d->gz)
    if (d->gz)
       res = gzseek(d->gz,To,SEEK_SET);
       res = gzseek(d->gz,To,SEEK_SET);
    else
    else
@@ -1325,7 +1319,7 @@ bool FileFd::Skip(unsigned long long Over)
    }
    }
 
 
    int res;
    int res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
    if (d->gz != NULL)
    if (d->gz != NULL)
       res = gzseek(d->gz,Over,SEEK_CUR);
       res = gzseek(d->gz,Over,SEEK_CUR);
    else
    else
@@ -1373,7 +1367,7 @@ unsigned long long FileFd::Tell()
       return d->seekpos;
       return d->seekpos;
 
 
    off_t Res;
    off_t Res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
    if (d->gz != NULL)
    if (d->gz != NULL)
      Res = gztell(d->gz);
      Res = gztell(d->gz);
    else
    else
@@ -1427,7 +1421,7 @@ unsigned long long FileFd::Size()
       size = Tell();
       size = Tell();
       Seek(oldSeek);
       Seek(oldSeek);
    }
    }
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
    // only check gzsize if we are actually a gzip file, just checking for
    // only check gzsize if we are actually a gzip file, just checking for
    // "gz" is not sufficient as uncompressed files could be opened with
    // "gz" is not sufficient as uncompressed files could be opened with
    // gzopen in "direct" mode as well
    // gzopen in "direct" mode as well
@@ -1500,7 +1494,7 @@ bool FileFd::Close()
    bool Res = true;
    bool Res = true;
    if ((Flags & AutoClose) == AutoClose)
    if ((Flags & AutoClose) == AutoClose)
    {
    {
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
       if (d != NULL && d->gz != NULL) {
       if (d != NULL && d->gz != NULL) {
 	 int const e = gzclose(d->gz);
 	 int const e = gzclose(d->gz);
 	 // gzdclose() on empty files always fails with "buffer error" here, ignore that
 	 // gzdclose() on empty files always fails with "buffer error" here, ignore that

+ 3 - 0
buildlib/config.h.in

@@ -19,6 +19,9 @@
 /* Define if we have the timegm() function */
 /* Define if we have the timegm() function */
 #undef HAVE_TIMEGM
 #undef HAVE_TIMEGM
 
 
+/* Define if we have the zlib library for gzip */
+#undef HAVE_ZLIB
+
 /* These two are used by the statvfs shim for glibc2.0 and bsd */
 /* These two are used by the statvfs shim for glibc2.0 and bsd */
 /* Define if we have sys/vfs.h */
 /* Define if we have sys/vfs.h */
 #undef HAVE_VFS_H
 #undef HAVE_VFS_H

+ 1 - 1
configure.in

@@ -89,7 +89,7 @@ AC_CHECK_LIB(curl, curl_easy_init,
 AC_SUBST(BDBLIB)
 AC_SUBST(BDBLIB)
 
 
 AC_CHECK_LIB(z, gzopen,
 AC_CHECK_LIB(z, gzopen,
-	[AC_CHECK_HEADER(zlib.h, [], AC_MSG_ERROR([failed: zlib.h not found]))],
+	[AC_CHECK_HEADER(zlib.h, [AC_DEFINE(HAVE_ZLIB)], AC_MSG_ERROR([failed: zlib.h not found]))],
 	AC_MSG_ERROR([failed: Need libz]))
 	AC_MSG_ERROR([failed: Need libz]))
 
 
 dnl Converts the ARCH to be something singular for this general CPU family
 dnl Converts the ARCH to be something singular for this general CPU family