summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <kalnischkies@gmail.com>2012-04-05 15:18:03 +0200
committerDavid Kalnischkies <kalnischkies@gmail.com>2012-04-05 15:18:03 +0200
commit7efb8c8ef10c1d0b9479c24a6a5b4e96fc0e6286 (patch)
tree0b707ca7c07780eb20f4ad5028936fc371f99b8e
parentbacc49dfe278f16859b43d159e7042e9fc22d603 (diff)
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
-rw-r--r--apt-pkg/contrib/fileutl.cc32
-rw-r--r--buildlib/config.h.in3
-rw-r--r--configure.in2
3 files changed, 17 insertions, 20 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 1808489d7..691657cb4 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -44,14 +44,8 @@
#include <set>
#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
#ifdef WORDS_BIGENDIAN
@@ -65,7 +59,7 @@ using namespace std;
class FileFdPrivate {
public:
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
gzFile gz;
#else
void* gz;
@@ -1016,7 +1010,7 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
d->compressor = compressor;
if (compressor.Name == "." || compressor.Binary.empty() == true)
return true;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
else if (compressor.Name == "gzip")
{
if ((Mode & ReadWrite) == ReadWrite)
@@ -1137,7 +1131,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
*((char *)To) = '\0';
do
{
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
Res = gzread(d->gz,To,Size);
else
@@ -1149,7 +1143,7 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
if (errno == EINTR)
continue;
Flags |= Fail;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
{
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)
{
*To = '\0';
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
return gzgets(d->gz, To, Size);
#endif
@@ -1221,7 +1215,7 @@ bool FileFd::Write(const void *From,unsigned long long Size)
errno = 0;
do
{
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
Res = gzwrite(d->gz,From,Size);
else
@@ -1289,7 +1283,7 @@ bool FileFd::Seek(unsigned long long To)
return true;
}
int res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz)
res = gzseek(d->gz,To,SEEK_SET);
else
@@ -1325,7 +1319,7 @@ bool FileFd::Skip(unsigned long long Over)
}
int res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
res = gzseek(d->gz,Over,SEEK_CUR);
else
@@ -1373,7 +1367,7 @@ unsigned long long FileFd::Tell()
return d->seekpos;
off_t Res;
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d->gz != NULL)
Res = gztell(d->gz);
else
@@ -1427,7 +1421,7 @@ unsigned long long FileFd::Size()
size = Tell();
Seek(oldSeek);
}
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
// only check gzsize if we are actually a gzip file, just checking for
// "gz" is not sufficient as uncompressed files could be opened with
// gzopen in "direct" mode as well
@@ -1500,7 +1494,7 @@ bool FileFd::Close()
bool Res = true;
if ((Flags & AutoClose) == AutoClose)
{
-#if APT_USE_ZLIB
+#ifdef HAVE_ZLIB
if (d != NULL && d->gz != NULL) {
int const e = gzclose(d->gz);
// gzdclose() on empty files always fails with "buffer error" here, ignore that
diff --git a/buildlib/config.h.in b/buildlib/config.h.in
index 87918bbec..43d39d304 100644
--- a/buildlib/config.h.in
+++ b/buildlib/config.h.in
@@ -19,6 +19,9 @@
/* Define if we have the timegm() function */
#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 */
/* Define if we have sys/vfs.h */
#undef HAVE_VFS_H
diff --git a/configure.in b/configure.in
index 78ad06b72..ec98ba4ef 100644
--- a/configure.in
+++ b/configure.in
@@ -89,7 +89,7 @@ AC_CHECK_LIB(curl, curl_easy_init,
AC_SUBST(BDBLIB)
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]))
dnl Converts the ARCH to be something singular for this general CPU family