diff options
author | David Kalnischkies <kalnischkies@gmail.com> | 2011-02-03 14:22:32 +0100 |
---|---|---|
committer | David Kalnischkies <kalnischkies@gmail.com> | 2011-02-03 14:22:32 +0100 |
commit | 3eb9e257855d83d0486d7a5fa7cc5e2edebb6aaa (patch) | |
tree | 4739355d87bcbf8f49fa634b692e48e4aee6746d /methods/rred.cc | |
parent | 7c748f4aa1bd47089672353fd1a401d1c5c94723 (diff) | |
parent | 875bcb3670c43bd4450e27934ba105611e534df0 (diff) |
merge 'after squeeze release'-stuff
[ David Kalnischkies ]
* apt-pkg/depcache.cc:
- add SetCandidateRelease() to set a candidate version and
the candidates of dependencies if needed to a specified
release (Closes: #572709)
* cmdline/apt-get.cc:
- if --print-uris is used don't setup downloader as we don't need
progress, lock nor the directories it would create otherwise
- show dependencies of essential packages which are going to remove
only if they cause the remove of this essential (Closes: #601961)
- keep not installed garbage packages uninstalled instead of showing
in the autoremove section and installing those (Closes: #604222)
- change pkg/release behavior to use the new SetCandidateRelease
so installing packages from experimental or backports is easier
- really do not show packages in the extra section if they were
requested on the commandline, e.g. with a modifier (Closes: #184730)
* debian/control:
- add Vcs-Browser now that loggerhead works again (Closes: #511168)
- depend on debhelper 7 to raise compat level
- depend on dpkg-dev (>= 1.15.8) to have c++ symbol mangling
* apt-pkg/contrib/fileutl.cc:
- add a RealFileExists method and check that your configuration files
are real files to avoid endless loops if not (Closes: #604401)
- ignore non-regular files in GetListOfFilesInDir (Closes: #594694)
* apt-pkg/contrib/weakptr.h:
- include stddefs.h to fix compile error (undefined NULL) with gcc-4.6
* methods/https.cc:
- fix CURLOPT_SSL_VERIFYHOST by really passing 2 to it if enabled
* deb/dpkgpm.cc:
- fix popen/fclose mismatch reported by cppcheck. Thanks to Petter
Reinholdtsen for report and patch! (Closes: #607803)
* doc/apt.conf.5.xml:
- fix multipl{y,e} spelling error reported by Jakub Wilk (Closes: #607636)
* apt-inst/contrib/extracttar.cc:
- let apt-utils work with encoded tar headers if uid/gid are large.
Thanks to Nobuhiro Hayashi for the patch! (Closes: #330162)
* apt-pkg/cacheiterator.h:
- do not segfault if cache is not build (Closes: #254770)
* doc/apt-get.8.xml:
- remove duplicated mentioning of --install-recommends
* doc/sources.list.5.xml:
- remove obsolete references to non-us (Closes: #594495)
* debian/rules:
- use -- instead of deprecated -u for dh_gencontrol
- remove shlibs.local creation and usage
- show differences in the symbol files, but never fail
* pre-build.sh:
- remove as it is not needed for a working 'bzr bd'
* debian/{apt,apt-utils}.symbols:
- ship experimental unmangled c++ symbol files
* methods/rred.cc:
- operate optional on gzip compressed pdiffs
* apt-pkg/acquire-item.cc:
- don't uncompress downloaded pdiff files before feeding it to rred
- try downloading clearsigned InRelease before trying Release.gpg
- change the internal handling of Extensions in pkgAcqIndex
- add a special uncompressed compression type to prefer those files
- download and use i18n/Index to choose which Translations to download
* cmdline/apt-key:
- don't set trustdb-name as non-root so 'list' and 'finger'
can be used without being root (Closes: #393005, #592107)
* apt-pkg/deb/deblistparser.cc:
- rewrite LoadReleaseInfo to cope with clearsigned Releasefiles
* ftparchive/writer.cc:
- add config option to search for more patterns in release command
- include Index files by default in the Release file
* methods/{gzip,bzip}.cc:
- print a good error message if FileSize() is zero
* apt-pkg/aptconfiguration.cc:
- remove the inbuilt Translation files whitelist
Diffstat (limited to 'methods/rred.cc')
-rw-r--r-- | methods/rred.cc | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/methods/rred.cc b/methods/rred.cc index d51c45c85..1a18a381c 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -12,6 +12,7 @@ #include <utime.h> #include <stdio.h> #include <errno.h> +#include <zlib.h> #include <apti18n.h> /*}}}*/ /** \brief RredMethod - ed-style incremential patch method {{{ @@ -33,11 +34,14 @@ class RredMethod : public pkgAcqMethod { // return values enum State {ED_OK, ED_ORDERING, ED_PARSER, ED_FAILURE, MMAP_FAILED}; - State applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_file, + State applyFile(gzFile &ed_cmds, FILE *in_file, FILE *out_file, unsigned long &line, char *buffer, Hashes *hash) const; void ignoreLineInFile(FILE *fin, char *buffer) const; + void ignoreLineInFile(gzFile &fin, char *buffer) const; void copyLinesFromFileToFile(FILE *fin, FILE *fout, unsigned int lines, Hashes *hash, char *buffer) const; + void copyLinesFromFileToFile(gzFile &fin, FILE *fout, unsigned int lines, + Hashes *hash, char *buffer) const; State patchFile(FileFd &Patch, FileFd &From, FileFd &out_file, Hashes *hash) const; State patchMMap(FileFd &Patch, FileFd &From, FileFd &out_file, Hashes *hash) const; @@ -65,10 +69,10 @@ public: * \param hash the created file for correctness * \return the success State of the ed command executor */ -RredMethod::State RredMethod::applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_file, +RredMethod::State RredMethod::applyFile(gzFile &ed_cmds, FILE *in_file, FILE *out_file, unsigned long &line, char *buffer, Hashes *hash) const { // get the current command and parse it - if (fgets(buffer, BUF_SIZE, ed_cmds) == NULL) { + if (gzgets(ed_cmds, buffer, BUF_SIZE) == NULL) { if (Debug == true) std::clog << "rred: encounter end of file - we can start patching now." << std::endl; line = 0; @@ -123,7 +127,7 @@ RredMethod::State RredMethod::applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_ unsigned char mode = *idx; // save the current position - unsigned const long pos = ftell(ed_cmds); + unsigned const long pos = gztell(ed_cmds); // if this is add or change then go to the next full stop unsigned int data_length = 0; @@ -157,7 +161,7 @@ RredMethod::State RredMethod::applyFile(FILE *ed_cmds, FILE *in_file, FILE *out_ // include data from ed script if (mode == MODE_CHANGED || mode == MODE_ADDED) { - fseek(ed_cmds, pos, SEEK_SET); + gzseek(ed_cmds, pos, SEEK_SET); copyLinesFromFileToFile(ed_cmds, out_file, data_length, hash, buffer); } @@ -183,6 +187,18 @@ void RredMethod::copyLinesFromFileToFile(FILE *fin, FILE *fout, unsigned int lin } } /*}}}*/ +void RredMethod::copyLinesFromFileToFile(gzFile &fin, FILE *fout, unsigned int lines,/*{{{*/ + Hashes *hash, char *buffer) const { + while (0 < lines--) { + do { + gzgets(fin, buffer, BUF_SIZE); + size_t const written = fwrite(buffer, 1, strlen(buffer), fout); + hash->Add((unsigned char*)buffer, written); + } while (strlen(buffer) == (BUF_SIZE - 1) && + buffer[BUF_SIZE - 2] != '\n'); + } +} + /*}}}*/ void RredMethod::ignoreLineInFile(FILE *fin, char *buffer) const { /*{{{*/ fgets(buffer, BUF_SIZE, fin); while (strlen(buffer) == (BUF_SIZE - 1) && @@ -192,11 +208,20 @@ void RredMethod::ignoreLineInFile(FILE *fin, char *buffer) const { /*{{{*/ } } /*}}}*/ +void RredMethod::ignoreLineInFile(gzFile &fin, char *buffer) const { /*{{{*/ + gzgets(fin, buffer, BUF_SIZE); + while (strlen(buffer) == (BUF_SIZE - 1) && + buffer[BUF_SIZE - 2] != '\n') { + gzgets(fin, buffer, BUF_SIZE); + buffer[0] = ' '; + } +} + /*}}}*/ RredMethod::State RredMethod::patchFile(FileFd &Patch, FileFd &From, /*{{{*/ FileFd &out_file, Hashes *hash) const { char buffer[BUF_SIZE]; FILE* fFrom = fdopen(From.Fd(), "r"); - FILE* fPatch = fdopen(Patch.Fd(), "r"); + gzFile fPatch = Patch.gzFd(); FILE* fTo = fdopen(out_file.Fd(), "w"); /* we do a tail recursion to read the commands in the right order */ @@ -228,6 +253,12 @@ RredMethod::State RredMethod::patchMMap(FileFd &Patch, FileFd &From, /*{{{*/ FileFd &out_file, Hashes *hash) const { #ifdef _POSIX_MAPPED_FILES MMap ed_cmds(Patch, MMap::ReadOnly); + if (Patch.gzFd() != NULL) { + unsigned long mapSize = Patch.Size(); + DynamicMMap dyn(0, mapSize, 0); + gzread(Patch.gzFd(), dyn.Data(), mapSize); + ed_cmds = dyn; + } MMap in_file(From, MMap::ReadOnly); if (ed_cmds.Size() == 0 || in_file.Size() == 0) @@ -445,7 +476,7 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/ // Open the source and destination files (the d'tor of FileFd will do // the cleanup/closing of the fds) FileFd From(Path,FileFd::ReadOnly); - FileFd Patch(Path+".ed",FileFd::ReadOnly); + FileFd Patch(Path+".ed",FileFd::ReadOnlyGzip); FileFd To(Itm->DestFile,FileFd::WriteAtomic); To.EraseOnFailure(); if (_error->PendingError() == true) @@ -456,8 +487,8 @@ bool RredMethod::Fetch(FetchItem *Itm) /*{{{*/ State const result = patchMMap(Patch, From, To, &Hash); if (result == MMAP_FAILED) { // retry with patchFile - lseek(Patch.Fd(), 0, SEEK_SET); - lseek(From.Fd(), 0, SEEK_SET); + Patch.Seek(0); + From.Seek(0); To.Open(Itm->DestFile,FileFd::WriteAtomic); if (_error->PendingError() == true) return false; |