]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/contrib/fileutl.cc
merge with debian-experimental 0.8.16~exp2 release
[apt.git] / apt-pkg / contrib / fileutl.cc
index 52f517ee07784ca2578e445b3041a8679a48ef1e..50019872e3d3e16fbe81df2698025644e5eac4b3 100644 (file)
 #include <errno.h>
 #include <set>
 #include <algorithm>
+
+#include <config.h>
+#ifdef WORDS_BIGENDIAN
+#include <inttypes.h>
+#endif
                                                                        /*}}}*/
 
 using namespace std;
@@ -62,6 +67,15 @@ bool RunScripts(const char *Cnf)
    // This is the child
    if (Child == 0)
    {
+      if (_config->FindDir("DPkg::Chroot-Directory","/") != "/") 
+      {
+         std::cerr << "Chrooting into " 
+                   << _config->FindDir("DPkg::Chroot-Directory") 
+                   << std::endl;
+         if (chroot(_config->FindDir("DPkg::Chroot-Directory","/").c_str()) != 0)
+            _exit(100);
+      }
+
       if (chdir("/tmp/") != 0)
         _exit(100);
         
@@ -962,9 +976,16 @@ unsigned long FileFd::Size()
        off_t orig_pos = lseek(iFd, 0, SEEK_CUR);
        if (lseek(iFd, -4, SEEK_END) < 0)
           return _error->Errno("lseek","Unable to seek to end of gzipped file");
+       size = 0L;
        if (read(iFd, &size, 4) != 4)
           return _error->Errno("read","Unable to read original size of gzipped file");
-       size &= 0xFFFFFFFF;
+
+#ifdef WORDS_BIGENDIAN
+       uint32_t tmp_size = size;
+       uint8_t const * const p = (uint8_t const * const) &tmp_size;
+       tmp_size = (p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0];
+       size = tmp_size;
+#endif
 
        if (lseek(iFd, orig_pos, SEEK_SET) < 0)
           return _error->Errno("lseek","Unable to seek in gzipped file");