From 2c38625920fa67d52ade11fd7d28cdb5373dc31c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Mar 2005 09:07:12 +0000 Subject: * merged the apt--main with the 2004 bwlimit tree Patches applied: * michael.vogt@canonical.com--2004/apt--bwlimit--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-47 * michael.vogt@canonical.com--2004/apt--bwlimit--0--patch-1 * fist attempt for bwlimit * michael.vogt@canonical.com--2004/apt--bwlimit--0--patch-2 * add a nanosleep, making it less cpu intensive * michael.vogt@canonical.com--2004/apt--bwlimit--0--patch-3 * use SingleInstance when DlLimit is activated * michael.vogt@canonical.com--2004/apt--bwlimit--0--patch-4 * cleanups, no code changes --- methods/http.cc | 41 +++++++++++++++++++++++++++++++++++++++-- methods/http.h | 5 +++++ 2 files changed, 44 insertions(+), 2 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index 81a64d7a3..27f0dafef 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -58,6 +58,12 @@ unsigned long PipelineDepth = 10; unsigned long TimeOut = 120; bool Debug = false; + +unsigned long CircleBuf::BwReadLimit=0; +unsigned long CircleBuf::BwTickReadData=0; +struct timeval CircleBuf::BwReadTick={0,0}; +const unsigned int CircleBuf::BW_HZ=10; + // CircleBuf::CircleBuf - Circular input buffer /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -65,6 +71,8 @@ CircleBuf::CircleBuf(unsigned long Size) : Size(Size), Hash(0) { Buf = new unsigned char[Size]; Reset(); + + CircleBuf::BwReadLimit = _config->FindI("Acquire::http::DlLimit",0)*1024; } /*}}}*/ // CircleBuf::Reset - Reset to the default state /*{{{*/ @@ -90,16 +98,45 @@ void CircleBuf::Reset() is non-blocking.. */ bool CircleBuf::Read(int Fd) { + unsigned long BwReadMax; + while (1) { // Woops, buffer is full if (InP - OutP == Size) return true; - + + // what's left to read in this tick + BwReadMax = CircleBuf::BwReadLimit/BW_HZ; + + if(CircleBuf::BwReadLimit) { + struct timeval now; + gettimeofday(&now,0); + + unsigned long d = (now.tv_sec-CircleBuf::BwReadTick.tv_sec)*1000000 + + now.tv_usec-CircleBuf::BwReadTick.tv_usec; + if(d > 1000000/BW_HZ) { + CircleBuf::BwReadTick = now; + CircleBuf::BwTickReadData = 0; + } + + if(CircleBuf::BwTickReadData >= BwReadMax) { + usleep(1000000/BW_HZ); + return true; + } + } + // Write the buffer segment int Res; - Res = read(Fd,Buf + (InP%Size),LeftRead()); + if(CircleBuf::BwReadLimit) { + Res = read(Fd,Buf + (InP%Size), + BwReadMax > LeftRead() ? LeftRead() : BwReadMax); + } else + Res = read(Fd,Buf + (InP%Size),LeftRead()); + if(Res > 0 && BwReadLimit > 0) + CircleBuf::BwTickReadData += Res; + if (Res == 0) return false; if (Res < 0) diff --git a/methods/http.h b/methods/http.h index c5a4d0e86..541e2952c 100644 --- a/methods/http.h +++ b/methods/http.h @@ -31,6 +31,11 @@ class CircleBuf unsigned long MaxGet; struct timeval Start; + static unsigned long BwReadLimit; + static unsigned long BwTickReadData; + static struct timeval BwReadTick; + static const unsigned int BW_HZ; + unsigned long LeftRead() { unsigned long Sz = Size - (InP - OutP); -- cgit v1.2.3 From 3573e286ba001ef30f4871f3ed2e17ea905d6404 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 8 Jun 2005 15:58:38 +0000 Subject: * merged with apt--main and apt--fixes Patches applied: * apt@packages.debian.org/apt--main--0--patch-80 Merge michael.vogt@ubuntu.com--2005/apt--fixes--0 * apt@packages.debian.org/apt--main--0--patch-81 Open 0.6.37 * apt@packages.debian.org/apt--main--0--patch-82 merge bubulle@debian.org--2005/apt--main--0 * apt@packages.debian.org/apt--main--0--patch-83 Update changelog * apt@packages.debian.org/apt--main--0--patch-84 Fix build of French man pages (now using XML, not SGML) * apt@packages.debian.org/apt--main--0--patch-85 Merge patch from Philippe Batailler for French man page build * apt@packages.debian.org/apt--main--0--patch-86 add Welsh translations from Dafydd Harries * apt@packages.debian.org/apt--main--0--patch-87 Update changelog * apt@packages.debian.org/apt--misc-abi-changes--0--patch-4 Merge from mainline * apt@packages.debian.org/apt--misc-abi-changes--0--patch-5 Merge from mainline * apt@packages.debian.org/apt--misc-abi-changes--0--patch-6 Collapse both pkgAcquire::Run() methods into one, with a default value * bubulle@debian.org--2005/apt--main--0--patch-66 Italian translation complete * bubulle@debian.org--2005/apt--main--0--patch-67 Sync with Matt * bubulle@debian.org--2005/apt--main--0--patch-68 Sync with Matt * bubulle@debian.org--2005/apt--main--0--patch-69 Sync with Matt * bubulle@debian.org--2005/apt--main--0--patch-70 Re-generate the POT and PO files from sources * bubulle@debian.org--2005/apt--main--0--patch-71 Update French translation * bubulle@debian.org--2005/apt--main--0--patch-72 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-73 Basque translation update * bubulle@debian.org--2005/apt--main--0--patch-74 Hebres translation update * bubulle@debian.org--2005/apt--main--0--patch-75 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-76 Correct the Hebrew translation for #306658 * bubulle@debian.org--2005/apt--main--0--patch-77 Update French man pages translations * bubulle@debian.org--2005/apt--main--0--patch-78 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-79 Correct syntax errors in Hebrew translation * bubulle@debian.org--2005/apt--main--0--patch-80 Revert changes to debian/changelog and debian/apt.cron.daily * bubulle@debian.org--2005/apt--main--0--patch-81 Portuguese translation update * daf@muse.19inch.net--2005/apt--main--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-85 * daf@muse.19inch.net--2005/apt--main--0--patch-1 add Welsh translation * michael.vogt@ubuntu.com--2005/apt--fixes--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-79 * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-1 * merged obvious fixes into the tree to make it easy for matt to merge * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-2 * more merges from otavio that looks good/uncritical * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-3 * merged Matts misc-abi-changes tree * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-4 * finalized the changelog for a ubuntu build * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-5 * merged with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--fixes--0--patch-6 * build fix for apt--main--0 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-26 * fix the cache-control header generation * otavio@debian.org--2005/apt--fixes--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-71 * otavio@debian.org--2005/apt--fixes--0--patch-1 Fix comments about the need of xmlto * otavio@debian.org--2005/apt--fixes--0--patch-2 Fix a compile warning * otavio@debian.org--2005/apt--fixes--0--patch-3 Sync with apt--main--0--patch-76 * otavio@debian.org--2005/apt--fixes--0--patch-4 Sync with apt--main--0--patch-78 * otavio@debian.org--2005/apt--fixes--0--patch-5 Add fixes that was wrongly included on DDTP changes. * otavio@debian.org--2005/apt--fixes--0--patch-8 Add information about the other fixes include on this branch now. * otavio@debian.org--2005/apt--fixes--0--patch-9 Merge last changes from apt--main--0. * otavio@debian.org--2005/apt--fixes--0--patch-10 Fix warnings about min/max change in gcc-4.0 * otavio@debian.org--2005/apt--fixes--0--patch-11 Fix remaning warnings while compiling gcc-4.0 * otavio@debian.org--2005/apt--fixes--0--patch-12 Add changelog entry about the fixes for warnings while compiling using GCC 4.0 compiler. * philippe.batailler@free.fr--2005/apt--mainBubulle--0.1--patch-1 Passage sous arch * philippe.batailler@free.fr--2005/apt--mainMatt--0--patch-1 fix xml error --- methods/ftp.cc | 2 +- methods/http.cc | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) (limited to 'methods') diff --git a/methods/ftp.cc b/methods/ftp.cc index 8bf8a2ee6..f595e0ca4 100644 --- a/methods/ftp.cc +++ b/methods/ftp.cc @@ -1102,7 +1102,7 @@ int main(int argc,const char *argv[]) // Run the http method string Path = flNotFile(argv[0]) + "http"; - execl(Path.c_str(),Path.c_str(),0); + execl(Path.c_str(),Path.c_str(),(char *)NULL); cerr << _("Unable to invoke ") << Path << endl; exit(100); } diff --git a/methods/http.cc b/methods/http.cc index 27f0dafef..2ec1fe631 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -672,9 +672,9 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) and a no-store directive for archives. */ sprintf(Buf,"GET %s HTTP/1.1\r\nHost: %s\r\n", Itm->Uri.c_str(),ProperHost.c_str()); - if (_config->FindB("Acquire::http::No-Cache",false) == true) - strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n"); - else + // only generate a cache control header if we actually want to + // use a cache + if (_config->FindB("Acquire::http::No-Cache",false) == false) { if (Itm->IndexFile == true) sprintf(Buf+strlen(Buf),"Cache-Control: max-age=%u\r\n", @@ -686,6 +686,10 @@ void HttpMethod::SendReq(FetchItem *Itm,CircleBuf &Out) } } } + // generate a no-cache header if needed + if (_config->FindB("Acquire::http::No-Cache",false) == true) + strcat(Buf,"Cache-Control: no-cache\r\nPragma: no-cache\r\n"); + string Req = Buf; -- cgit v1.2.3 From 2e178d1c3e0035616b338d7597a0c9d33e3bc080 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 28 Jul 2005 16:25:42 +0000 Subject: * added methods/rred.cc (thanks to robertle) --- methods/makefile | 7 ++ methods/rred.cc | 221 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 methods/rred.cc (limited to 'methods') diff --git a/methods/makefile b/methods/makefile index 089300570..93ad6d875 100644 --- a/methods/makefile +++ b/methods/makefile @@ -59,6 +59,13 @@ LIB_MAKES = apt-pkg/makefile SOURCE = ftp.cc rfc2553emu.cc connect.cc include $(PROGRAM_H) +# The rred method +PROGRAM=rred +SLIBS = -lapt-pkg $(SOCKETLIBS) +LIB_MAKES = apt-pkg/makefile +SOURCE = rred +include $(PROGRAM_H) + # The rsh method PROGRAM=rsh SLIBS = -lapt-pkg diff --git a/methods/rred.cc b/methods/rred.cc new file mode 100644 index 000000000..37faab08a --- /dev/null +++ b/methods/rred.cc @@ -0,0 +1,221 @@ +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +const char *Prog; + +class RredMethod : public pkgAcqMethod +{ + virtual bool Fetch(FetchItem *Itm); + + public: + + RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig) {}; + +}; + +#define BUF_SIZE (1024) + +// XX use enums +#define MODE_CHANGED 0 +#define MODE_DELETED 1 +#define MODE_ADDED 2 + +#define ED_ORDERING 1 +#define ED_PARSER 2 +#define ED_FAILURE 3 + +int ed_rec(FILE *ed_cmds, FILE *in_file, FILE *out_file, int line, + char *buffer, unsigned int bufsize, Hashes *hash) { + int pos; + int startline; + int stopline; + int mode; + int written; + char *idx; + + /* get the current command and parse it*/ + if (fgets(buffer, bufsize, ed_cmds) == NULL) { + return line; + } + startline = strtol(buffer, &idx, 10); + if (startline < line) { + return ED_ORDERING; + } + if (*idx == ',') { + idx++; + stopline = strtol(idx, &idx, 10); + } + else { + stopline = startline; + } + if (*idx == 'c') { + mode = MODE_CHANGED; + } + else if (*idx == 'a') { + mode = MODE_ADDED; + } + else if (*idx == 'd') { + mode = MODE_DELETED; + } + else { + return ED_PARSER; + } + /* get the current position */ + pos = ftell(ed_cmds); + /* if this is add or change then go to the next full stop */ + if ((mode == MODE_CHANGED) || (mode == MODE_ADDED)) { + do { + fgets(buffer, bufsize, ed_cmds); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, ed_cmds); + buffer[0] = ' '; + } + } while (strncmp(buffer, ".", 1) != 0); + } + /* do the recursive call */ + line = ed_rec(ed_cmds, in_file, out_file, line, buffer, bufsize, + hash); + /* pass on errors */ + if (line < 0) { + return line; + } + /* apply our hunk */ + fseek(ed_cmds, pos, SEEK_SET); + /* first wind to the current position */ + if (mode != MODE_ADDED) { + startline -= 1; + } + while (line < startline) { + fgets(buffer, bufsize, in_file); + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, in_file); + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + } + line++; + } + /* include from ed script */ + if ((mode == MODE_ADDED) || (mode == MODE_CHANGED)) { + do { + fgets(buffer, bufsize, ed_cmds); + if (strncmp(buffer, ".", 1) != 0) { + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, ed_cmds); + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + } + } + else { + break; + } + } while (1); + } + /* ignore the corresponding number of lines from input */ + if ((mode == MODE_DELETED) || (mode == MODE_CHANGED)) { + while (line < stopline) { + fgets(buffer, bufsize, in_file); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, in_file); + } + line++; + } + } + return line; +} + +int ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, Hashes *hash) { + char buffer[BUF_SIZE]; + int result; + int written; + + /* we do a tail recursion to read the commands in the right order */ + result = ed_rec(ed_cmds, in_file, out_file, 0, buffer, BUF_SIZE, + hash); + + /* read the rest from infile */ + if (result > 0) { + while (fgets(buffer, BUF_SIZE, in_file) != NULL) { + written = fwrite(buffer, 1, strlen(buffer), out_file); + // XXX add to hash + // sha_process_bytes(buffer, written, &sha); + } + } + else { + // XXX better error handling + fprintf(stderr, "Error: %i\n", result); + return ED_FAILURE; + } + return 0; +} + + +// XXX do we need modification times as well? +bool RredMethod::Fetch(FetchItem *Itm) +{ + URI Get = Itm->Uri; + string Path = Get.Host + Get.Path; // To account for relative paths + // Path contains the filename to patch + FetchResult Res; + Res.Filename = Itm->DestFile; + URIStart(Res); + // Res.Filename the destination filename + + // Open the source and destination files + FileFd From(Path,FileFd::ReadOnly); + FileFd Patch(Path+".ed",FileFd::ReadOnly); + FileFd To(Itm->DestFile,FileFd::WriteEmpty); + To.EraseOnFailure(); + if (_error->PendingError() == true) + return false; + + Hashes Hash; + FILE* fFrom = fdopen(From.Fd(), "r"); + FILE* fPatch = fdopen(Patch.Fd(), "r"); + FILE* fTo = fdopen(To.Fd(), "w"); + // now do the actual patching + ed_file(fPatch, fFrom, fTo, &Hash); + + // clean up + fclose(fFrom); + fclose(fPatch); + fclose(fTo); + To.Close(); + From.Close(); + Patch.Close(); + + // XXX need to get the size + // Res.Size = Buf.st_size; + Res.TakeHashes(Hash); + URIDone(Res); + + return true; +} + /*}}}*/ + +int main(int argc, char *argv[]) +{ + RredMethod Mth; + + Prog = strrchr(argv[0],'/'); + Prog++; + + return Mth.Run(); +} -- cgit v1.2.3 From 4a0a786f45a78eb8631c0e2d39d804ab9fdea214 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 19 Aug 2005 15:07:53 +0000 Subject: * use the new cool rred method for the patchting --- methods/makefile | 2 +- methods/rred.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'methods') diff --git a/methods/makefile b/methods/makefile index 93ad6d875..bf8fc0dab 100644 --- a/methods/makefile +++ b/methods/makefile @@ -63,7 +63,7 @@ include $(PROGRAM_H) PROGRAM=rred SLIBS = -lapt-pkg $(SOCKETLIBS) LIB_MAKES = apt-pkg/makefile -SOURCE = rred +SOURCE = rred.cc include $(PROGRAM_H) # The rsh method diff --git a/methods/rred.cc b/methods/rred.cc index 37faab08a..e28dc6855 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -177,7 +177,7 @@ bool RredMethod::Fetch(FetchItem *Itm) Res.Filename = Itm->DestFile; URIStart(Res); // Res.Filename the destination filename - + // Open the source and destination files FileFd From(Path,FileFd::ReadOnly); FileFd Patch(Path+".ed",FileFd::ReadOnly); -- cgit v1.2.3 From 16176b647e76f316ec98f31f6dd806a49d7b8a77 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 19 Aug 2005 15:30:19 +0000 Subject: * merged with mainline Patches applied: * andrelop@debian.org/apt--translation--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-79 * andrelop@debian.org/apt--translation--0--patch-1 Sync with Matt version. * andrelop@debian.org/apt--translation--0--patch-2 Update pt_BR translation * andrelop@debian.org/apt--translation--0--patch-3 Sync with bubulle's branch. * apt@packages.debian.org/apt--main--0--patch-88 Change debian/bugscript to use #!/bin/bash (Closes: #313402) * apt@packages.debian.org/apt--main--0--patch-89 Branch for Debian * apt@packages.debian.org/apt--main--0--patch-90 Update version in configure * apt@packages.debian.org/apt--main--0--patch-91 Fix French man page build * apt@packages.debian.org/apt--main--0--patch-92 Add the current Debian archive signing key * apt@packages.debian.org/apt--main--0--patch-93 Merge with mvo * apt@packages.debian.org/apt--main--0--patch-94 Update changelog * apt@packages.debian.org/apt--main--0--patch-95 Merge Christian's branch * apt@packages.debian.org/apt--main--0--patch-96 Update changelog * apt@packages.debian.org/apt--main--0--patch-97 Update priority of apt-utils to important, to match the override file * apt@packages.debian.org/apt--main--0--patch-98 Install only one keyring on each branch (Closes: #316119) * apt@packages.debian.org/apt--main--0--patch-99 Finalize 0.6.39 * apt@packages.debian.org/apt--main--0--patch-100 Use debian.org address in mainline * apt@packages.debian.org/apt--main--0--patch-101 Update pot file * apt@packages.debian.org/apt--main--0--patch-102 Open 0.6.40 * apt@packages.debian.org/apt--main--0--patch-103 Patch from Jordi Mallach to mark some additional strings for translation * apt@packages.debian.org/apt--main--0--patch-104 Updated Catalan translation from Jordi Mallach * apt@packages.debian.org/apt--main--0--patch-105 Merge from bubulle@debian.org--2005/apt--main--0 * apt@packages.debian.org/apt--main--0--patch-106 Restore lost changelog entries * apt@packages.debian.org/apt--main--0--patch-107 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-108 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-109 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * apt@packages.debian.org/apt--main--0--patch-110 Merge michael.vogt@ubuntu.com--2005/apt--progress-reporting--0 * bubulle@debian.org--2005/apt--main--0--patch-82 Fix permissions * bubulle@debian.org--2005/apt--main--0--patch-83 French translation spellchecked * bubulle@debian.org--2005/apt--main--0--patch-84 Spell corrections in German translations * bubulle@debian.org--2005/apt--main--0--patch-85 Correct some file permissions * bubulle@debian.org--2005/apt--main--0--patch-86 Correct Hebrew translation * bubulle@debian.org--2005/apt--main--0--patch-87 Sync Portuguese translation with the POT file * bubulle@debian.org--2005/apt--main--0--patch-88 Updated Danish translation (not yet complete) * bubulle@debian.org--2005/apt--main--0--patch-89 Sync with Andre Luis Lopes and Otavio branches * bubulle@debian.org--2005/apt--main--0--patch-90 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-91 Updated Slovak translation * bubulle@debian.org--2005/apt--main--0--patch-92 Add apt-key French man page * bubulle@debian.org--2005/apt--main--0--patch-93 Update Greek translations * bubulle@debian.org--2005/apt--main--0--patch-94 Merge with Matt * bubulle@debian.org--2005/apt--main--0--patch-95 Sync PO files with the POT file/French translation update * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-22 * added myself to uploaders, changelog is signed with mvo@debian.org and in sync with the debian/experimental upload * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-23 * apt-cache show shows all virtual packages instead of nothing (thanks to otavio) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-24 * changelog updated * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-25 * make pinning on component work again (we just use the section, as apt-0.6 don't use per-section Release files anymore) * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-27 * updated the changelog * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-28 * merged with my apt--fixes--0 branch * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-29 * added a missing OpProgress::Done() in depCache::Init(), removed the show-virtual-packages patch in apt-cache because matt does not like him :/ * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-30 * fix a stupid bug in the depcache::Init() code * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-31 * merged/removed conflicts with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--mvo--0--patch-32 * merged apt--main and make sure that the po files come from apt--main (because they are more recent) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--base-0 tag of apt@packages.debian.org/apt--main--0--patch-85 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-1 * inital proof of concept code, understands what dpkg tells it already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-2 * progress reporting works now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-3 * added "APT::Status-Fd" variable * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-4 * do i18n now too * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-5 * define N_(x) if it is not defined already * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-6 * PackageManager::DoInstall(int status_fd) added (does not break the ABI) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-7 * merged with apt--fixes--0 to make it build again * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-8 * added support for "error" and "conffile-prompt" messages from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-9 merge with main * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-10 * use sizeof() for all snprintf() uses; fix a potential line break problem in the status reading code; changed the N_() to _() calls * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-11 * added APT::KeepFDs configuration list for file descriptors that apt should leave open (needed for various frontends like debconf, synaptic) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-12 * fixed a API breakage * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-13 * doc added, should be releasable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-14 * merged with apt--main--0 * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-15 * more source comments, added Debug::DpkgPM debug code to inspect the dpkg<->apt communication, broke the abi (ok with matt) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-16 * the progress reporting has it's own "Debug::pkgDPkgProgressReporting" debug variable now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-17 * merged PackageOps and TranslatedPackageOps into a single Map with the new DpkgState struct * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-18 * clear the APT::Keep-Fds configuration when it's no longer needed * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-19 * rewrote the reading from dpkg so that it never blocks * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-20 * merged the two status arrays into one * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-21 * added support for download progress reporting too (for Kamion and base-config) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-22 * ABI break; added Configuration::Clear(string List, {int,string} value) added (to remove a single Value from a list); test/conf_clear.cc added * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-23 * remvoed a debug string * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-24 * soname changed, fixed a bug in the parsing code when dpkg send the same state more than once (at the end) * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-25 * merged with apt@packages.debian.org/apt--main--0, added changelog entry for the 0.6.40.1 upload * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-26 * fix a bug when out-of-order states are send from dpkg * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-27 * changelog update * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-28 * a real changelog entry now * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-29 * changelog finalized * michael.vogt@ubuntu.com--2005/apt--progress-reporting--0--patch-30 * propper (and sane) support for pmerror and pmconffile added --- methods/gpgv.cc | 30 +++++++++++++++++------------- methods/makefile | 2 +- 2 files changed, 18 insertions(+), 14 deletions(-) (limited to 'methods') diff --git a/methods/gpgv.cc b/methods/gpgv.cc index 24e945b2c..5cb154f66 100644 --- a/methods/gpgv.cc +++ b/methods/gpgv.cc @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -88,7 +89,7 @@ const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, continue; Args[i++] = Opts->Value.c_str(); if(i >= 395) { - std::cerr << "E: Argument list from Acquire::gpgv::Options too long. Exiting." << std::endl; + std::cerr << _("E: Argument list from Acquire::gpgv::Options too long. Exiting.") << std::endl; exit(111); } } @@ -181,27 +182,28 @@ const char *GPGVMethod::VerifyGetSigners(const char *file, const char *outfile, waitpid(pid, &status, 0); if (_config->FindB("Debug::Acquire::gpgv", false)) { - std::cerr <<"gpgv exited\n"; + std::cerr << "gpgv exited\n"; } if (WEXITSTATUS(status) == 0) { if (GoodSigners.empty()) - return "Internal error: Good signature, but could not determine key fingerprint?!"; + return _("Internal error: Good signature, but could not determine key fingerprint?!"); return NULL; } else if (WEXITSTATUS(status) == 1) { - return "At least one invalid signature was encountered."; + return _("At least one invalid signature was encountered."); } else if (WEXITSTATUS(status) == 111) { - return (string("Could not execute ") + gpgvpath + - string(" to verify signature (is gnupg installed?)")).c_str(); + // FIXME String concatenation considered harmful. + return (string(_("Could not execute ")) + gpgvpath + + string(_(" to verify signature (is gnupg installed?)"))).c_str(); } else { - return "Unknown error executing gpgv"; + return _("Unknown error executing gpgv"); } } @@ -232,14 +234,14 @@ bool GPGVMethod::Fetch(FetchItem *Itm) { if (!BadSigners.empty()) { - errmsg += "The following signatures were invalid:\n"; + errmsg += _("The following signatures were invalid:\n"); for (vector::iterator I = BadSigners.begin(); I != BadSigners.end(); I++) errmsg += (*I + "\n"); } if (!NoPubKeySigners.empty()) { - errmsg += "The following signatures couldn't be verified because the public key is not available:\n"; + errmsg += _("The following signatures couldn't be verified because the public key is not available:\n"); for (vector::iterator I = NoPubKeySigners.begin(); I != NoPubKeySigners.end(); I++) errmsg += (*I + "\n"); @@ -251,16 +253,16 @@ bool GPGVMethod::Fetch(FetchItem *Itm) // Transfer the modification times struct stat Buf; if (stat(Path.c_str(),&Buf) != 0) - return _error->Errno("stat","Failed to stat %s", Path.c_str()); + return _error->Errno("stat",_("Failed to stat %s"), Path.c_str()); struct utimbuf TimeBuf; TimeBuf.actime = Buf.st_atime; TimeBuf.modtime = Buf.st_mtime; if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0) - return _error->Errno("utime","Failed to set modification time"); + return _error->Errno("utime",_("Failed to set modification time")); if (stat(Itm->DestFile.c_str(),&Buf) != 0) - return _error->Errno("stat","Failed to stat"); + return _error->Errno("stat",_("Failed to stat")); // Return a Done response Res.LastModified = Buf.st_mtime; @@ -275,7 +277,7 @@ bool GPGVMethod::Fetch(FetchItem *Itm) if (_config->FindB("Debug::Acquire::gpgv", false)) { - std::cerr <<"gpgv suceeded\n"; + std::cerr << "gpgv succeeded\n"; } return true; @@ -284,6 +286,8 @@ bool GPGVMethod::Fetch(FetchItem *Itm) int main() { + setlocale(LC_ALL, ""); + GPGVMethod Mth; return Mth.Run(); diff --git a/methods/makefile b/methods/makefile index bf8fc0dab..d0b5a28c0 100644 --- a/methods/makefile +++ b/methods/makefile @@ -7,7 +7,7 @@ include ../buildlib/defaults.mak BIN := $(BIN)/methods # FIXME.. -LIB_APT_PKG_MAJOR = 3.5 +LIB_APT_PKG_MAJOR = 3.11 APT_DOMAIN := libapt-pkg$(LIB_APT_PKG_MAJOR) # The file method -- cgit v1.2.3 From 59a704f0efe9cf243f1b27ac833558b89728aa9c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 22 Aug 2005 08:48:50 +0000 Subject: * rred.cc: use the d'tor of FileFd to close the file-fd; acquuire-item.cc: make the QueueNextDiff() code more robust --- methods/rred.cc | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'methods') diff --git a/methods/rred.cc b/methods/rred.cc index e28dc6855..3097fca02 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -178,7 +178,8 @@ bool RredMethod::Fetch(FetchItem *Itm) URIStart(Res); // Res.Filename the destination filename - // Open the source and destination files + // 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 To(Itm->DestFile,FileFd::WriteEmpty); @@ -193,14 +194,6 @@ bool RredMethod::Fetch(FetchItem *Itm) // now do the actual patching ed_file(fPatch, fFrom, fTo, &Hash); - // clean up - fclose(fFrom); - fclose(fPatch); - fclose(fTo); - To.Close(); - From.Close(); - Patch.Close(); - // XXX need to get the size // Res.Size = Buf.st_size; Res.TakeHashes(Hash); -- cgit v1.2.3 From 3de9ff77a811d67632c9948a953e628ed6a2b78a Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 22 Aug 2005 10:19:43 +0000 Subject: * bugfix/updates in the rred.cc code (big thanks for helping Robert!) --- methods/rred.cc | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) (limited to 'methods') diff --git a/methods/rred.cc b/methods/rred.cc index 3097fca02..ab73398f5 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -25,15 +25,17 @@ class RredMethod : public pkgAcqMethod #define BUF_SIZE (1024) -// XX use enums +// XXX use enums #define MODE_CHANGED 0 #define MODE_DELETED 1 #define MODE_ADDED 2 +#define ED_OK 0 #define ED_ORDERING 1 #define ED_PARSER 2 #define ED_FAILURE 3 +// XXX someone better go out and understand the error reporting/handling here... int ed_rec(FILE *ed_cmds, FILE *in_file, FILE *out_file, int line, char *buffer, unsigned int bufsize, Hashes *hash) { int pos; @@ -154,8 +156,7 @@ int ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, Hashes *hash) { if (result > 0) { while (fgets(buffer, BUF_SIZE, in_file) != NULL) { written = fwrite(buffer, 1, strlen(buffer), out_file); - // XXX add to hash - // sha_process_bytes(buffer, written, &sha); + hash->Add((unsigned char*)buffer, written); } } else { @@ -163,7 +164,7 @@ int ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, Hashes *hash) { fprintf(stderr, "Error: %i\n", result); return ED_FAILURE; } - return 0; + return ED_OK; } @@ -192,13 +193,38 @@ bool RredMethod::Fetch(FetchItem *Itm) FILE* fPatch = fdopen(Patch.Fd(), "r"); FILE* fTo = fdopen(To.Fd(), "w"); // now do the actual patching - ed_file(fPatch, fFrom, fTo, &Hash); - - // XXX need to get the size - // Res.Size = Buf.st_size; + if (ed_file(fPatch, fFrom, fTo, &Hash) != ED_OK) { + return false; + } + + // write out the result + fflush(fFrom); + fflush(fPatch); + fflush(fTo); + From.Close(); + Patch.Close(); + To.Close(); + + // Transfer the modification times + struct stat Buf; + if (stat(Path.c_str(),&Buf) != 0) + return _error->Errno("stat",_("Failed to stat")); + + struct utimbuf TimeBuf; + TimeBuf.actime = Buf.st_atime; + TimeBuf.modtime = Buf.st_mtime; + if (utime(Itm->DestFile.c_str(),&TimeBuf) != 0) + return _error->Errno("utime",_("Failed to set modification time")); + + if (stat(Itm->DestFile.c_str(),&Buf) != 0) + return _error->Errno("stat",_("Failed to stat")); + + // return done + Res.LastModified = Buf.st_mtime; + Res.Size = Buf.st_size; Res.TakeHashes(Hash); URIDone(Res); - + return true; } /*}}}*/ -- cgit v1.2.3 From d84cd8651bce12774b8bc5f471c4a3c59fe992de Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 23 Aug 2005 11:29:43 +0000 Subject: * method/rred.cc cleanup (thanks to robertle) --- methods/rred.cc | 292 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 149 insertions(+), 143 deletions(-) (limited to 'methods') diff --git a/methods/rred.cc b/methods/rred.cc index ab73398f5..f4d77c64c 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -11,164 +11,170 @@ #include #include +/* this method implements a patch functionality similar to "patch --ed" that is + * used by the "tiffany" incremental packages download stuff. it differs from + * "ed" insofar that it is way more restricted (and therefore secure). in the + * moment only the "c", "a" and "d" commands of ed are implemented (diff + * doesn't output any other). additionally the records must be reverse sorted + * by line number and may not overlap (diff *seems* to produce this kind of + * output). + * */ + const char *Prog; class RredMethod : public pkgAcqMethod { + // the size of this doesn't really matter (except for performance) + const static int BUF_SIZE = 1024; + // the ed commands + enum Mode {MODE_CHANGED, MODE_DELETED, MODE_ADDED}; + // return values + enum State {ED_OK, ED_ORDERING, ED_PARSER, ED_FAILURE}; + // this applies a single hunk, it uses a tail recursion to + // reverse the hunks in the file + int ed_rec(FILE *ed_cmds, FILE *in_file, FILE *out_file, int line, + char *buffer, unsigned int bufsize, Hashes *hash); + // apply a patch file + int ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, Hashes *hash); + // the methods main method virtual bool Fetch(FetchItem *Itm); public: RredMethod() : pkgAcqMethod("1.1",SingleInstance | SendConfig) {}; - }; -#define BUF_SIZE (1024) - -// XXX use enums -#define MODE_CHANGED 0 -#define MODE_DELETED 1 -#define MODE_ADDED 2 - -#define ED_OK 0 -#define ED_ORDERING 1 -#define ED_PARSER 2 -#define ED_FAILURE 3 - -// XXX someone better go out and understand the error reporting/handling here... -int ed_rec(FILE *ed_cmds, FILE *in_file, FILE *out_file, int line, - char *buffer, unsigned int bufsize, Hashes *hash) { - int pos; - int startline; - int stopline; - int mode; - int written; - char *idx; - - /* get the current command and parse it*/ - if (fgets(buffer, bufsize, ed_cmds) == NULL) { - return line; - } - startline = strtol(buffer, &idx, 10); - if (startline < line) { - return ED_ORDERING; - } - if (*idx == ',') { - idx++; - stopline = strtol(idx, &idx, 10); - } - else { - stopline = startline; - } - if (*idx == 'c') { - mode = MODE_CHANGED; - } - else if (*idx == 'a') { - mode = MODE_ADDED; - } - else if (*idx == 'd') { - mode = MODE_DELETED; - } - else { - return ED_PARSER; - } - /* get the current position */ - pos = ftell(ed_cmds); - /* if this is add or change then go to the next full stop */ - if ((mode == MODE_CHANGED) || (mode == MODE_ADDED)) { - do { - fgets(buffer, bufsize, ed_cmds); - while ((strlen(buffer) == (bufsize - 1)) - && (buffer[bufsize - 2] != '\n')) { - fgets(buffer, bufsize, ed_cmds); - buffer[0] = ' '; - } - } while (strncmp(buffer, ".", 1) != 0); - } - /* do the recursive call */ - line = ed_rec(ed_cmds, in_file, out_file, line, buffer, bufsize, - hash); - /* pass on errors */ - if (line < 0) { - return line; - } - /* apply our hunk */ - fseek(ed_cmds, pos, SEEK_SET); - /* first wind to the current position */ - if (mode != MODE_ADDED) { - startline -= 1; - } - while (line < startline) { - fgets(buffer, bufsize, in_file); - written = fwrite(buffer, 1, strlen(buffer), out_file); - hash->Add((unsigned char*)buffer, written); - while ((strlen(buffer) == (bufsize - 1)) - && (buffer[bufsize - 2] != '\n')) { - fgets(buffer, bufsize, in_file); - written = fwrite(buffer, 1, strlen(buffer), out_file); - hash->Add((unsigned char*)buffer, written); - } - line++; - } - /* include from ed script */ - if ((mode == MODE_ADDED) || (mode == MODE_CHANGED)) { - do { - fgets(buffer, bufsize, ed_cmds); - if (strncmp(buffer, ".", 1) != 0) { - written = fwrite(buffer, 1, strlen(buffer), out_file); - hash->Add((unsigned char*)buffer, written); - while ((strlen(buffer) == (bufsize - 1)) - && (buffer[bufsize - 2] != '\n')) { - fgets(buffer, bufsize, ed_cmds); - written = fwrite(buffer, 1, strlen(buffer), out_file); - hash->Add((unsigned char*)buffer, written); - } - } - else { - break; - } - } while (1); - } - /* ignore the corresponding number of lines from input */ - if ((mode == MODE_DELETED) || (mode == MODE_CHANGED)) { - while (line < stopline) { - fgets(buffer, bufsize, in_file); - while ((strlen(buffer) == (bufsize - 1)) - && (buffer[bufsize - 2] != '\n')) { - fgets(buffer, bufsize, in_file); - } - line++; - } - } - return line; +int RredMethod::ed_rec(FILE *ed_cmds, FILE *in_file, FILE *out_file, int line, + char *buffer, unsigned int bufsize, Hashes *hash) { + int pos; + int startline; + int stopline; + int mode; + int written; + char *idx; + + /* get the current command and parse it*/ + if (fgets(buffer, bufsize, ed_cmds) == NULL) { + return line; + } + startline = strtol(buffer, &idx, 10); + if (startline < line) { + return ED_ORDERING; + } + if (*idx == ',') { + idx++; + stopline = strtol(idx, &idx, 10); + } + else { + stopline = startline; + } + if (*idx == 'c') { + mode = MODE_CHANGED; + } + else if (*idx == 'a') { + mode = MODE_ADDED; + } + else if (*idx == 'd') { + mode = MODE_DELETED; + } + else { + return ED_PARSER; + } + /* get the current position */ + pos = ftell(ed_cmds); + /* if this is add or change then go to the next full stop */ + if ((mode == MODE_CHANGED) || (mode == MODE_ADDED)) { + do { + fgets(buffer, bufsize, ed_cmds); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, ed_cmds); + buffer[0] = ' '; + } + } while (strncmp(buffer, ".", 1) != 0); + } + /* do the recursive call */ + line = ed_rec(ed_cmds, in_file, out_file, line, buffer, bufsize, + hash); + /* pass on errors */ + if (line < 0) { + return line; + } + /* apply our hunk */ + fseek(ed_cmds, pos, SEEK_SET); + /* first wind to the current position */ + if (mode != MODE_ADDED) { + startline -= 1; + } + while (line < startline) { + fgets(buffer, bufsize, in_file); + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, in_file); + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + } + line++; + } + /* include from ed script */ + if ((mode == MODE_ADDED) || (mode == MODE_CHANGED)) { + do { + fgets(buffer, bufsize, ed_cmds); + if (strncmp(buffer, ".", 1) != 0) { + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, ed_cmds); + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + } + } + else { + break; + } + } while (1); + } + /* ignore the corresponding number of lines from input */ + if ((mode == MODE_DELETED) || (mode == MODE_CHANGED)) { + while (line < stopline) { + fgets(buffer, bufsize, in_file); + while ((strlen(buffer) == (bufsize - 1)) + && (buffer[bufsize - 2] != '\n')) { + fgets(buffer, bufsize, in_file); + } + line++; + } + } + return line; } -int ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, Hashes *hash) { - char buffer[BUF_SIZE]; - int result; - int written; - - /* we do a tail recursion to read the commands in the right order */ - result = ed_rec(ed_cmds, in_file, out_file, 0, buffer, BUF_SIZE, - hash); - - /* read the rest from infile */ - if (result > 0) { - while (fgets(buffer, BUF_SIZE, in_file) != NULL) { - written = fwrite(buffer, 1, strlen(buffer), out_file); - hash->Add((unsigned char*)buffer, written); - } - } - else { - // XXX better error handling - fprintf(stderr, "Error: %i\n", result); - return ED_FAILURE; - } - return ED_OK; +int RredMethod::ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, + Hashes *hash) { + char buffer[BUF_SIZE]; + int result; + int written; + + /* we do a tail recursion to read the commands in the right order */ + result = ed_rec(ed_cmds, in_file, out_file, 0, buffer, BUF_SIZE, + hash); + + /* read the rest from infile */ + if (result > 0) { + while (fgets(buffer, BUF_SIZE, in_file) != NULL) { + written = fwrite(buffer, 1, strlen(buffer), out_file); + hash->Add((unsigned char*)buffer, written); + } + } + else { + return ED_FAILURE; + } + return ED_OK; } -// XXX do we need modification times as well? bool RredMethod::Fetch(FetchItem *Itm) { URI Get = Itm->Uri; @@ -194,6 +200,7 @@ bool RredMethod::Fetch(FetchItem *Itm) FILE* fTo = fdopen(To.Fd(), "w"); // now do the actual patching if (ed_file(fPatch, fFrom, fTo, &Hash) != ED_OK) { + _error->Errno("rred", _("Could not patch file")); return false; } @@ -227,7 +234,6 @@ bool RredMethod::Fetch(FetchItem *Itm) return true; } - /*}}}*/ int main(int argc, char *argv[]) { -- cgit v1.2.3 From 6040f5893a85c0206d3fd234c46a608b87a5e9ac Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 29 Aug 2005 14:57:50 +0000 Subject: * debug support (Debug::pkgAcquire::RRed) for rred method added --- methods/rred.cc | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'methods') diff --git a/methods/rred.cc b/methods/rred.cc index f4d77c64c..6fa57f3a6 100644 --- a/methods/rred.cc +++ b/methods/rred.cc @@ -24,6 +24,7 @@ const char *Prog; class RredMethod : public pkgAcqMethod { + bool Debug; // the size of this doesn't really matter (except for performance) const static int BUF_SIZE = 1024; // the ed commands @@ -70,12 +71,23 @@ int RredMethod::ed_rec(FILE *ed_cmds, FILE *in_file, FILE *out_file, int line, } if (*idx == 'c') { mode = MODE_CHANGED; + if (Debug == true) { + std::clog << "changing from line " << startline + << " to " << stopline << std::endl; + } } else if (*idx == 'a') { mode = MODE_ADDED; + if (Debug == true) { + std::clog << "adding after line " << startline << std::endl; + } } else if (*idx == 'd') { mode = MODE_DELETED; + if (Debug == true) { + std::clog << "deleting from line " << startline + << " to " << stopline << std::endl; + } } else { return ED_PARSER; @@ -177,6 +189,7 @@ int RredMethod::ed_file(FILE *ed_cmds, FILE *in_file, FILE *out_file, bool RredMethod::Fetch(FetchItem *Itm) { + Debug = _config->FindB("Debug::pkgAcquire::RRed",false); URI Get = Itm->Uri; string Path = Get.Host + Get.Path; // To account for relative paths // Path contains the filename to patch @@ -185,6 +198,9 @@ bool RredMethod::Fetch(FetchItem *Itm) URIStart(Res); // Res.Filename the destination filename + if (Debug == true) + std::clog << "Patching " << Path << " with " << Path + << ".ed and putting result into " << Itm->DestFile << std::endl; // Open the source and destination files (the d'tor of FileFd will do // the cleanup/closing of the fds) FileFd From(Path,FileFd::ReadOnly); -- cgit v1.2.3 From cec6091772ae3463cb04c417e3f598f9b6814516 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 17 Oct 2005 14:33:58 +0000 Subject: * removed the URL-Reamp hack (we have pdiff support in the main archive now), removed bw-limit support (NO idea how that got into this archive in the first place) --- methods/http.cc | 38 +------------------------------------- methods/http.h | 5 ----- 2 files changed, 1 insertion(+), 42 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index 2ec1fe631..e2337a9ba 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -59,11 +59,6 @@ unsigned long TimeOut = 120; bool Debug = false; -unsigned long CircleBuf::BwReadLimit=0; -unsigned long CircleBuf::BwTickReadData=0; -struct timeval CircleBuf::BwReadTick={0,0}; -const unsigned int CircleBuf::BW_HZ=10; - // CircleBuf::CircleBuf - Circular input buffer /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -71,8 +66,6 @@ CircleBuf::CircleBuf(unsigned long Size) : Size(Size), Hash(0) { Buf = new unsigned char[Size]; Reset(); - - CircleBuf::BwReadLimit = _config->FindI("Acquire::http::DlLimit",0)*1024; } /*}}}*/ // CircleBuf::Reset - Reset to the default state /*{{{*/ @@ -98,45 +91,16 @@ void CircleBuf::Reset() is non-blocking.. */ bool CircleBuf::Read(int Fd) { - unsigned long BwReadMax; - while (1) { // Woops, buffer is full if (InP - OutP == Size) return true; - // what's left to read in this tick - BwReadMax = CircleBuf::BwReadLimit/BW_HZ; - - if(CircleBuf::BwReadLimit) { - struct timeval now; - gettimeofday(&now,0); - - unsigned long d = (now.tv_sec-CircleBuf::BwReadTick.tv_sec)*1000000 + - now.tv_usec-CircleBuf::BwReadTick.tv_usec; - if(d > 1000000/BW_HZ) { - CircleBuf::BwReadTick = now; - CircleBuf::BwTickReadData = 0; - } - - if(CircleBuf::BwTickReadData >= BwReadMax) { - usleep(1000000/BW_HZ); - return true; - } - } - // Write the buffer segment int Res; - if(CircleBuf::BwReadLimit) { - Res = read(Fd,Buf + (InP%Size), - BwReadMax > LeftRead() ? LeftRead() : BwReadMax); - } else - Res = read(Fd,Buf + (InP%Size),LeftRead()); + Res = read(Fd,Buf + (InP%Size),LeftRead()); - if(Res > 0 && BwReadLimit > 0) - CircleBuf::BwTickReadData += Res; - if (Res == 0) return false; if (Res < 0) diff --git a/methods/http.h b/methods/http.h index 541e2952c..c5a4d0e86 100644 --- a/methods/http.h +++ b/methods/http.h @@ -31,11 +31,6 @@ class CircleBuf unsigned long MaxGet; struct timeval Start; - static unsigned long BwReadLimit; - static unsigned long BwTickReadData; - static struct timeval BwReadTick; - static const unsigned int BW_HZ; - unsigned long LeftRead() { unsigned long Sz = Size - (InP - OutP); -- cgit v1.2.3 From 927c393f1305925c1456c931e1e7b45afd6f051d Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Sun, 23 Oct 2005 11:12:54 +0000 Subject: * added http data corruption fix patch (#280844) --- methods/http.cc | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) (limited to 'methods') diff --git a/methods/http.cc b/methods/http.cc index e2337a9ba..dbf2d1b43 100644 --- a/methods/http.cc +++ b/methods/http.cc @@ -205,28 +205,23 @@ bool CircleBuf::WriteTillEl(string &Data,bool Single) if (Buf[I%Size] != '\n') continue; ++I; - if (I < InP && Buf[I%Size] == '\r') - ++I; if (Single == false) { - if (Buf[I%Size] != '\n') - continue; - ++I; if (I < InP && Buf[I%Size] == '\r') ++I; + if (I >= InP || Buf[I%Size] != '\n') + continue; + ++I; } - if (I > InP) - I = InP; - Data = ""; while (OutP < I) { unsigned long Sz = LeftWrite(); if (Sz == 0) return false; - if (I - OutP < LeftWrite()) + if (I - OutP < Sz) Sz = I - OutP; Data += string((char *)(Buf + (OutP%Size)),Sz); OutP += Sz; -- cgit v1.2.3