]> git.saurik.com Git - apt.git/commitdiff
- add libbz2-dev as new build-dependency
authorDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 5 Apr 2012 18:51:36 +0000 (20:51 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Thu, 5 Apr 2012 18:51:36 +0000 (20:51 +0200)
  - remove the libz-dev alternative from zlib1g-dev build-dependency
  - do the same for bz2 builtin if available
* apt-pkg/contrib/fileutl.cc:
  - use libz2 library for (de)compression instead of the bzip2 binary as
    the first is a dependency of dpkg and the later just priority:optional
    so we gain 'easier' access to bz2-compressed Translation files this way

apt-pkg/aptconfiguration.cc
apt-pkg/contrib/fileutl.cc
apt-pkg/makefile
buildlib/config.h.in
buildlib/environment.mak.in
configure.in
debian/changelog
debian/control

index f00852775bac76ec3645dd51ab77e81617a2a181..d6691e39256818732449bf3dd8209c846ac446cd 100644 (file)
@@ -479,10 +479,14 @@ const Configuration::getCompressors(bool const Cached) {
                compressors.push_back(Compressor("gzip",".gz","gzip","-9n","-d",2));
 #ifdef HAVE_ZLIB
        else
                compressors.push_back(Compressor("gzip",".gz","gzip","-9n","-d",2));
 #ifdef HAVE_ZLIB
        else
-               compressors.push_back(Compressor("gzip",".gz","/bin/false", "", "", 2));
+               compressors.push_back(Compressor("gzip",".gz","false", "", "", 2));
 #endif
        if (_config->Exists("Dir::Bin::bzip2") == false || FileExists(_config->FindFile("Dir::Bin::bzip2")) == true)
                compressors.push_back(Compressor("bzip2",".bz2","bzip2","-9","-d",3));
 #endif
        if (_config->Exists("Dir::Bin::bzip2") == false || FileExists(_config->FindFile("Dir::Bin::bzip2")) == true)
                compressors.push_back(Compressor("bzip2",".bz2","bzip2","-9","-d",3));
+#ifdef HAVE_BZ2
+       else
+               compressors.push_back(Compressor("bzip2",".bz2","false", "", "", 3));
+#endif
        if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
                compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4));
        if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
        if (_config->Exists("Dir::Bin::xz") == false || FileExists(_config->FindFile("Dir::Bin::xz")) == true)
                compressors.push_back(Compressor("xz",".xz","xz","-6","-d",4));
        if (_config->Exists("Dir::Bin::lzma") == false || FileExists(_config->FindFile("Dir::Bin::lzma")) == true)
index 30d0b6662e7986c55febeb59ed7c573e6002bc0b..536571fee1ecc58fe90b6b704b448c9566f4f51e 100644 (file)
@@ -47,6 +47,9 @@
 #ifdef HAVE_ZLIB
        #include <zlib.h>
 #endif
 #ifdef HAVE_ZLIB
        #include <zlib.h>
 #endif
+#ifdef HAVE_BZ2
+       #include <bzlib.h>
+#endif
 
 #ifdef WORDS_BIGENDIAN
 #include <inttypes.h>
 
 #ifdef WORDS_BIGENDIAN
 #include <inttypes.h>
@@ -63,6 +66,11 @@ class FileFdPrivate {
        gzFile gz;
 #else
        void* gz;
        gzFile gz;
 #else
        void* gz;
+#endif
+#ifdef HAVE_BZ2
+       BZFILE* bz2;
+#else
+       void* bz2;
 #endif
        int compressed_fd;
        pid_t compressor_pid;
 #endif
        int compressed_fd;
        pid_t compressor_pid;
@@ -70,7 +78,8 @@ class FileFdPrivate {
        APT::Configuration::Compressor compressor;
        unsigned int openmode;
        unsigned long long seekpos;
        APT::Configuration::Compressor compressor;
        unsigned int openmode;
        unsigned long long seekpos;
-       FileFdPrivate() : gz(NULL), compressed_fd(-1), compressor_pid(-1), pipe(false),
+       FileFdPrivate() : gz(NULL), bz2(NULL),
+                         compressed_fd(-1), compressor_pid(-1), pipe(false),
                          openmode(0), seekpos(0) {};
 };
 
                          openmode(0), seekpos(0) {};
 };
 
@@ -1017,13 +1026,29 @@ bool FileFd::OpenInternDescriptor(unsigned int const Mode, APT::Configuration::C
       else if ((Mode & WriteOnly) == WriteOnly)
         d->gz = gzdopen(iFd, "w");
       else
       else if ((Mode & WriteOnly) == WriteOnly)
         d->gz = gzdopen(iFd, "w");
       else
-        d->gz = gzdopen (iFd, "r");
+        d->gz = gzdopen(iFd, "r");
       if (d->gz == NULL)
         return false;
       Flags |= Compressed;
       return true;
    }
 #endif
       if (d->gz == NULL)
         return false;
       Flags |= Compressed;
       return true;
    }
 #endif
+#ifdef HAVE_BZ2
+   else if (compressor.Name == "bzip2")
+   {
+      if ((Mode & ReadWrite) == ReadWrite)
+        d->bz2 = BZ2_bzdopen(iFd, "r+");
+      else if ((Mode & WriteOnly) == WriteOnly)
+        d->bz2 = BZ2_bzdopen(iFd, "w");
+      else
+        d->bz2 = BZ2_bzdopen(iFd, "r");
+      if (d->bz2 == NULL)
+        return false;
+      Flags |= Compressed;
+      return true;
+   }
+#endif
+
 
    if ((Mode & ReadWrite) == ReadWrite)
       return _error->Error("ReadWrite mode is not supported for file %s", FileName.c_str());
 
    if ((Mode & ReadWrite) == ReadWrite)
       return _error->Error("ReadWrite mode is not supported for file %s", FileName.c_str());
@@ -1132,7 +1157,12 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
    {
 #ifdef HAVE_ZLIB
       if (d->gz != NULL)
    {
 #ifdef HAVE_ZLIB
       if (d->gz != NULL)
-         Res = gzread(d->gz,To,Size);
+        Res = gzread(d->gz,To,Size);
+      else
+#endif
+#ifdef HAVE_BZ2
+      if (d->bz2 != NULL)
+        Res = BZ2_bzread(d->bz2,To,Size);
       else
 #endif
          Res = read(iFd,To,Size);
       else
 #endif
          Res = read(iFd,To,Size);
@@ -1150,6 +1180,15 @@ bool FileFd::Read(void *To,unsigned long long Size,unsigned long long *Actual)
            if (err != Z_ERRNO)
               return _error->Error("gzread: %s (%d: %s)", _("Read error"), err, errmsg);
         }
            if (err != Z_ERRNO)
               return _error->Error("gzread: %s (%d: %s)", _("Read error"), err, errmsg);
         }
+#endif
+#ifdef HAVE_BZ2
+        if (d->bz2 != NULL)
+        {
+           int err;
+           char const * const errmsg = BZ2_bzerror(d->bz2, &err);
+           if (err != BZ_IO_ERROR)
+              return _error->Error("BZ2_bzread: %s (%d: %s)", _("Read error"), err, errmsg);
+        }
 #endif
         return _error->Errno("read",_("Read error"));
       }
 #endif
         return _error->Errno("read",_("Read error"));
       }
@@ -1218,6 +1257,11 @@ bool FileFd::Write(const void *From,unsigned long long Size)
       if (d->gz != NULL)
          Res = gzwrite(d->gz,From,Size);
       else
       if (d->gz != NULL)
          Res = gzwrite(d->gz,From,Size);
       else
+#endif
+#ifdef HAVE_BZ2
+      if (d->bz2 != NULL)
+         Res = BZ2_bzwrite(d->bz2,(void*)From,Size);
+      else
 #endif
          Res = write(iFd,From,Size);
       if (Res < 0 && errno == EINTR)
 #endif
          Res = write(iFd,From,Size);
       if (Res < 0 && errno == EINTR)
@@ -1225,6 +1269,24 @@ bool FileFd::Write(const void *From,unsigned long long Size)
       if (Res < 0)
       {
         Flags |= Fail;
       if (Res < 0)
       {
         Flags |= Fail;
+#ifdef HAVE_ZLIB
+        if (d->gz != NULL)
+        {
+           int err;
+           char const * const errmsg = gzerror(d->gz, &err);
+           if (err != Z_ERRNO)
+              return _error->Error("gzwrite: %s (%d: %s)", _("Write error"), err, errmsg);
+        }
+#endif
+#ifdef HAVE_BZ2
+        if (d->bz2 != NULL)
+        {
+           int err;
+           char const * const errmsg = BZ2_bzerror(d->bz2, &err);
+           if (err != BZ_IO_ERROR)
+              return _error->Error("BZ2_bzwrite: %s (%d: %s)", _("Write error"), err, errmsg);
+        }
+#endif
         return _error->Errno("write",_("Write error"));
       }
       
         return _error->Errno("write",_("Write error"));
       }
       
@@ -1246,7 +1308,11 @@ bool FileFd::Write(const void *From,unsigned long long Size)
 /* */
 bool FileFd::Seek(unsigned long long To)
 {
 /* */
 bool FileFd::Seek(unsigned long long To)
 {
-   if (d->pipe == true)
+   if (d->pipe == true
+#ifdef HAVE_BZ2
+       || d->bz2 != NULL
+#endif
+       )
    {
       // Our poor man seeking in pipes is costly, so try to avoid it
       unsigned long long seekpos = Tell();
    {
       // Our poor man seeking in pipes is costly, so try to avoid it
       unsigned long long seekpos = Tell();
@@ -1257,6 +1323,10 @@ bool FileFd::Seek(unsigned long long To)
 
       if ((d->openmode & ReadOnly) != ReadOnly)
         return _error->Error("Reopen is only implemented for read-only files!");
 
       if ((d->openmode & ReadOnly) != ReadOnly)
         return _error->Error("Reopen is only implemented for read-only files!");
+#ifdef HAVE_BZ2
+      if (d->bz2 != NULL)
+        BZ2_bzclose(d->bz2);
+#endif
       close(iFd);
       iFd = 0;
       if (TemporaryFileName.empty() == false)
       close(iFd);
       iFd = 0;
       if (TemporaryFileName.empty() == false)
@@ -1303,7 +1373,11 @@ bool FileFd::Seek(unsigned long long To)
 /* */
 bool FileFd::Skip(unsigned long long Over)
 {
 /* */
 bool FileFd::Skip(unsigned long long Over)
 {
-   if (d->pipe == true)
+   if (d->pipe == true
+#ifdef HAVE_BZ2
+       || d->bz2 != NULL
+#endif
+       )
    {
       d->seekpos += Over;
       char buffer[1024];
    {
       d->seekpos += Over;
       char buffer[1024];
@@ -1339,11 +1413,13 @@ bool FileFd::Skip(unsigned long long Over)
 /* */
 bool FileFd::Truncate(unsigned long long To)
 {
 /* */
 bool FileFd::Truncate(unsigned long long To)
 {
-   if (d->gz != NULL)
+#if defined HAVE_ZLIB || defined HAVE_BZ2
+   if (d->gz != NULL || d->bz2 != NULL)
    {
       Flags |= Fail;
    {
       Flags |= Fail;
-      return _error->Error("Truncating gzipped files is not implemented (%s)", FileName.c_str());
+      return _error->Error("Truncating compressed files is not implemented (%s)", FileName.c_str());
    }
    }
+#endif
    if (ftruncate(iFd,To) != 0)
    {
       Flags |= Fail;
    if (ftruncate(iFd,To) != 0)
    {
       Flags |= Fail;
@@ -1362,7 +1438,11 @@ unsigned long long FileFd::Tell()
    // seeking around, but not all users of FileFd use always Seek() and co
    // so d->seekpos isn't always true and we can just use it as a hint if
    // we have nothing else, but not always as an authority…
    // seeking around, but not all users of FileFd use always Seek() and co
    // so d->seekpos isn't always true and we can just use it as a hint if
    // we have nothing else, but not always as an authority…
-   if (d->pipe == true)
+   if (d->pipe == true
+#ifdef HAVE_BZ2
+       || d->bz2 != NULL
+#endif
+       )
       return d->seekpos;
 
    off_t Res;
       return d->seekpos;
 
    off_t Res;
@@ -1409,7 +1489,11 @@ unsigned long long FileFd::Size()
 
    // for compressor pipes st_size is undefined and at 'best' zero,
    // so we 'read' the content and 'seek' back - see there
 
    // for compressor pipes st_size is undefined and at 'best' zero,
    // so we 'read' the content and 'seek' back - see there
-   if (d->pipe == true)
+   if (d->pipe == true
+#ifdef HAVE_BZ2
+       || (d->bz2 && size > 0)
+#endif
+       )
    {
       unsigned long long const oldSeek = Tell();
       char ignore[1000];
    {
       unsigned long long const oldSeek = Tell();
       char ignore[1000];
@@ -1500,6 +1584,11 @@ bool FileFd::Close()
         if (e != 0 && e != Z_BUF_ERROR)
            Res &= _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
       } else
         if (e != 0 && e != Z_BUF_ERROR)
            Res &= _error->Errno("close",_("Problem closing the gzip file %s"), FileName.c_str());
       } else
+#endif
+#ifdef HAVE_BZ2
+      if (d != NULL && d->bz2 != NULL)
+        BZ2_bzclose(d->bz2);
+      else
 #endif
         if (iFd > 0 && close(iFd) != 0)
            Res &= _error->Errno("close",_("Problem closing the file %s"), FileName.c_str());
 #endif
         if (iFd > 0 && close(iFd) != 0)
            Res &= _error->Errno("close",_("Problem closing the file %s"), FileName.c_str());
index e1f69dd655d6d52acf5580fb7334677abd44fe8e..27d7ead2485d15c8d273286a86955a26f1ebb919 100644 (file)
@@ -14,7 +14,13 @@ include ../buildlib/libversion.mak
 LIBRARY=apt-pkg
 MAJOR=$(LIBAPTPKG_MAJOR)
 MINOR=$(LIBAPTPKG_RELEASE)
 LIBRARY=apt-pkg
 MAJOR=$(LIBAPTPKG_MAJOR)
 MINOR=$(LIBAPTPKG_RELEASE)
-SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil -ldl -lz
+SLIBS=$(PTHREADLIB) $(INTLLIBS) -lutil -ldl
+ifeq ($(HAVE_ZLIB),yes)
+SLIBS+= -lz
+endif
+ifeq ($(HAVE_BZ2),yes)
+SLIBS+= -lbz2
+endif
 APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR)
 
 # Source code for the contributed non-core things
 APT_DOMAIN:=libapt-pkg$(LIBAPTPKG_MAJOR)
 
 # Source code for the contributed non-core things
index 43d39d30403d2a1eaacb4656c9e8732775c38ce0..b07d4f77f9d04d72a166a95322d1587ac5aa930b 100644 (file)
@@ -22,6 +22,9 @@
 /* Define if we have the zlib library for gzip */
 #undef HAVE_ZLIB
 
 /* Define if we have the zlib library for gzip */
 #undef HAVE_ZLIB
 
+/* Define if we have the bz2 library for bzip2 */
+#undef HAVE_BZ2
+
 /* These two are used by the statvfs shim for glibc2.0 and bsd */
 /* Define if we have sys/vfs.h */
 #undef HAVE_VFS_H
 /* These two are used by the statvfs shim for glibc2.0 and bsd */
 /* Define if we have sys/vfs.h */
 #undef HAVE_VFS_H
index b8ddb34a2a3fb3019c33efaade74210fdc5705f5..0f0fac09503a9c872e94e29d6bd14904da0f24e0 100644 (file)
@@ -55,7 +55,8 @@ INTLLIBS = @INTLLIBS@
 # Shim Headerfile control
 HAVE_C9X = @HAVE_C9X@
 HAVE_STATVFS = @HAVE_STATVFS@
 # Shim Headerfile control
 HAVE_C9X = @HAVE_C9X@
 HAVE_STATVFS = @HAVE_STATVFS@
-HAVE_TIMEGM = @HAVE_TIMEGM@
+HAVE_ZLIB = @HAVE_ZLIB@
+HAVE_BZ2 = @HAVE_BZ2@
 NEED_SOCKLEN_T_DEFINE = @NEED_SOCKLEN_T_DEFINE@
 
 # Shared library things
 NEED_SOCKLEN_T_DEFINE = @NEED_SOCKLEN_T_DEFINE@
 
 # Shared library things
index ec98ba4ef57da4563233b707a6c064cea929ed98..b974b9eb94ff37559e57de24077df70a9e4193b8 100644 (file)
@@ -88,9 +88,21 @@ AC_CHECK_LIB(curl, curl_easy_init,
 
 AC_SUBST(BDBLIB)
 
 
 AC_SUBST(BDBLIB)
 
+HAVE_ZLIB=no
 AC_CHECK_LIB(z, gzopen,
 AC_CHECK_LIB(z, gzopen,
-       [AC_CHECK_HEADER(zlib.h, [AC_DEFINE(HAVE_ZLIB)], AC_MSG_ERROR([failed: zlib.h not found]))],
+       [AC_CHECK_HEADER(zlib.h, [HAVE_ZLIB=yes], AC_MSG_ERROR([failed: zlib.h not found]))],
        AC_MSG_ERROR([failed: Need libz]))
        AC_MSG_ERROR([failed: Need libz]))
+AC_SUBST(HAVE_ZLIB)
+if test "x$HAVE_ZLIB" = "xyes"; then
+       AC_DEFINE(HAVE_ZLIB)
+fi
+
+HAVE_BZ2=no
+AC_CHECK_LIB(bz2, BZ2_bzopen,[AC_CHECK_HEADER(bzlib.h, [HAVE_BZ2=yes], [])], [])
+AC_SUBST(HAVE_BZ2)
+if test "x$HAVE_BZ2" = "xyes"; then
+       AC_DEFINE(HAVE_BZ2)
+fi
 
 dnl Converts the ARCH to be something singular for this general CPU family
 dnl This is often the dpkg architecture string.
 
 dnl Converts the ARCH to be something singular for this general CPU family
 dnl This is often the dpkg architecture string.
index f40b425f8d929997770b84580da9d7e670dc5672..01750765ee7b440a236ca1903bad66d8633b9bc4 100644 (file)
@@ -49,6 +49,8 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low
       this transparently now
   * debian/control:
     - bump Standards-Version to 3.9.3 (no changes needed)
       this transparently now
   * debian/control:
     - bump Standards-Version to 3.9.3 (no changes needed)
+    - add libbz2-dev as new build-dependency
+    - remove the libz-dev alternative from zlib1g-dev build-dependency
   * doc/apt-get.8.xml:
     - typofix: respect → respecting, thanks Mike Erickson! (Closes: #664833)
   * debian/rules:
   * doc/apt-get.8.xml:
     - typofix: respect → respecting, thanks Mike Erickson! (Closes: #664833)
   * debian/rules:
@@ -62,9 +64,14 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low
   * apt-pkg/aptconfiguration.cc:
     - if present, prefer xz binary over lzma
     - if we have zlib builtin insert add a dummy gzip compressor for FileFD
   * apt-pkg/aptconfiguration.cc:
     - if present, prefer xz binary over lzma
     - if we have zlib builtin insert add a dummy gzip compressor for FileFD
+    - do the same for bz2 builtin if available
   * methods/bzip2.cc:
     - remove it as the functionality for all compressors can be
       provided by gzip.cc now with the usage of FileFD
   * methods/bzip2.cc:
     - remove it as the functionality for all compressors can be
       provided by gzip.cc now with the usage of FileFD
+  * apt-pkg/contrib/fileutl.cc:
+    - use libz2 library for (de)compression instead of the bzip2 binary as
+      the first is a dependency of dpkg and the later just priority:optional
+      so we gain 'easier' access to bz2-compressed Translation files this way
 
   [ Bogdan Purcareata ]
   * doc/apt-get.8.xml:
 
   [ Bogdan Purcareata ]
   * doc/apt-get.8.xml:
@@ -74,7 +81,7 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low
       number of auto-removed packages both before and after the list
       of packages (Closes: #665833)
 
       number of auto-removed packages both before and after the list
       of packages (Closes: #665833)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 05 Apr 2012 19:00:43 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 05 Apr 2012 20:51:01 +0200
 
 apt (0.8.16~exp13) experimental; urgency=low
 
 
 apt (0.8.16~exp13) experimental; urgency=low
 
index 528468c7cae4e424d785193680505b09c4f4ed4d..5604bbe5563eaceac40cd2695e707a48c5a81947 100644 (file)
@@ -8,7 +8,7 @@ Uploaders: Michael Vogt <mvo@debian.org>, Otavio Salvador <otavio@debian.org>,
 Standards-Version: 3.9.3
 Build-Depends: dpkg-dev (>= 1.15.8), debhelper (>= 8.1.3~), libdb-dev,
  gettext (>= 0.12), libcurl4-gnutls-dev (>= 7.19.0),
 Standards-Version: 3.9.3
 Build-Depends: dpkg-dev (>= 1.15.8), debhelper (>= 8.1.3~), libdb-dev,
  gettext (>= 0.12), libcurl4-gnutls-dev (>= 7.19.0),
- zlib1g-dev | libz-dev, debiandoc-sgml, xsltproc, docbook-xsl, docbook-xml,
+ zlib1g-dev, libbz2-dev, debiandoc-sgml, xsltproc, docbook-xsl, docbook-xml,
  po4a (>= 0.34-2), autotools-dev, autoconf, automake, doxygen
 Build-Conflicts: autoconf2.13, automake1.4
 Vcs-Bzr: http://bzr.debian.org/apt/debian-sid/
  po4a (>= 0.34-2), autotools-dev, autoconf, automake, doxygen
 Build-Conflicts: autoconf2.13, automake1.4
 Vcs-Bzr: http://bzr.debian.org/apt/debian-sid/