summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc2
-rw-r--r--apt-pkg/deb/debsrcrecords.cc28
-rw-r--r--apt-pkg/deb/debsrcrecords.h10
-rw-r--r--apt-pkg/deb/dpkgpm.cc66
-rw-r--r--apt-pkg/tagfile.cc119
-rw-r--r--apt-pkg/tagfile.h9
6 files changed, 120 insertions, 114 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index 2ecb77814..94288a132 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -672,7 +672,7 @@ bool pkgAcqMetaIndex::VerifyVendor(string Message)
// check for missing sigs (that where not fatal because otherwise we had
// bombed earlier)
string missingkeys;
- string msg = _("There are no public key available for the "
+ string msg = _("There is no public key available for the "
"following key IDs:\n");
pos = Message.find("NO_PUBKEY ");
if (pos != std::string::npos)
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index cac36c2e6..7d5dab747 100644
--- a/apt-pkg/deb/debsrcrecords.cc
+++ b/apt-pkg/deb/debsrcrecords.cc
@@ -18,6 +18,8 @@
#include <apt-pkg/error.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/configuration.h>
+
+using std::max;
/*}}}*/
// SrcRecordParser::Binaries - Return the binaries field /*{{{*/
@@ -34,31 +36,19 @@ const char **debSrcRecordParser::Binaries()
if (Bins.empty() == true || Bins.length() >= 102400)
return 0;
- // Workaround for #236688. Only allocate a new buffer if the field
- // is large, to avoid a performance penalty
- char *BigBuf = NULL;
- char *Buf;
- if (Bins.length() > sizeof(Buffer))
- {
- BigBuf = new char[Bins.length()];
- Buf = BigBuf;
- }
- else
+ if (Bins.length() >= BufSize)
{
- Buf = Buffer;
+ delete [] Buffer;
+ // allocate new size based on buffer (but never smaller than 4000)
+ BufSize = max((unsigned int)4000, max((unsigned int)Bins.length()+1,2*BufSize));
+ Buffer = new char[BufSize];
}
- strcpy(Buf,Bins.c_str());
- if (TokSplitString(',',Buf,StaticBinList,
+ strcpy(Buffer,Bins.c_str());
+ if (TokSplitString(',',Buffer,StaticBinList,
sizeof(StaticBinList)/sizeof(StaticBinList[0])) == false)
- {
- if (BigBuf != NULL)
- delete BigBuf;
return 0;
- }
- if (BigBuf != NULL)
- delete BigBuf;
return (const char **)StaticBinList;
}
/*}}}*/
diff --git a/apt-pkg/deb/debsrcrecords.h b/apt-pkg/deb/debsrcrecords.h
index f899993df..7645dc564 100644
--- a/apt-pkg/deb/debsrcrecords.h
+++ b/apt-pkg/deb/debsrcrecords.h
@@ -24,9 +24,10 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
FileFd Fd;
pkgTagFile Tags;
pkgTagSection Sect;
- char Buffer[10000];
char *StaticBinList[400];
unsigned long iOffset;
+ char *Buffer;
+ unsigned int BufSize;
public:
@@ -49,10 +50,9 @@ class debSrcRecordParser : public pkgSrcRecords::Parser
};
virtual bool Files(vector<pkgSrcRecords::File> &F);
- debSrcRecordParser(string File,pkgIndexFile const *Index) :
- Parser(Index),
- Fd(File,FileFd::ReadOnly),
- Tags(&Fd,102400) {};
+ debSrcRecordParser(string File,pkgIndexFile const *Index)
+ : Parser(Index), Fd(File,FileFd::ReadOnly), Tags(&Fd,102400),
+ Buffer(0), BufSize(0) {}
};
#endif
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 93dff390d..cebdafe7d 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -355,28 +355,28 @@ bool pkgDPkgPM::Go(int OutStatusFd)
static const struct DpkgState DpkgStatesOpMap[][5] = {
// Install operation
{
- {"half-installed", _("Preparing %s")},
- {"unpacked", _("Unpacking %s") },
+ {"half-installed", N_("Preparing %s")},
+ {"unpacked", N_("Unpacking %s") },
{NULL, NULL}
},
// Configure operation
{
- {"unpacked",_("Preparing to configure %s") },
- {"half-configured", _("Configuring %s") },
- { "installed", _("Installed %s")},
+ {"unpacked",N_("Preparing to configure %s") },
+ {"half-configured", N_("Configuring %s") },
+ { "installed", N_("Installed %s")},
{NULL, NULL}
},
// Remove operation
{
- {"half-configured", _("Preparing for removal of %s")},
- {"half-installed", _("Removing %s")},
- {"config-files", _("Removed %s")},
+ {"half-configured", N_("Preparing for removal of %s")},
+ {"half-installed", N_("Removing %s")},
+ {"config-files", N_("Removed %s")},
{NULL, NULL}
},
// Purge operation
{
- {"config-files", _("Preparing to completely remove %s")},
- {"not-installed", _("Completely removed %s")},
+ {"config-files", N_("Preparing to completely remove %s")},
+ {"not-installed", N_("Completely removed %s")},
{NULL, NULL}
},
};
@@ -626,15 +626,22 @@ bool pkgDPkgPM::Go(int OutStatusFd)
*/
char* list[5];
- if(!TokSplitString(':', line, list, sizeof(list)/sizeof(list[0])))
- // FIXME: dpkg sends multiline error messages sometimes (see
- // #374195 for a example. we should support this by
- // either patching dpkg to not send multiline over the
- // statusfd or by rewriting the code here to deal with
- // it. for now we just ignore it and not crash
- continue;
+ // dpkg sends multiline error messages sometimes (see
+ // #374195 for a example. we should support this by
+ // either patching dpkg to not send multiline over the
+ // statusfd or by rewriting the code here to deal with
+ // it. for now we just ignore it and not crash
+ TokSplitString(':', line, list, sizeof(list)/sizeof(list[0]));
char *pkg = list[1];
char *action = _strstrip(list[2]);
+ if( pkg == NULL || action == NULL)
+ {
+ if (_config->FindB("Debug::pkgDPkgProgressReporting",false) == true)
+ std::clog << "ignoring line: not enough ':'" << std::endl;
+ // reset the line buffer
+ line[0]=0;
+ continue;
+ }
if(strncmp(action,"error",strlen("error")) == 0)
{
@@ -672,7 +679,7 @@ bool pkgDPkgPM::Go(int OutStatusFd)
{
// only read the translation if there is actually a next
// action
- const char *translation = states[PackageOpsDone[pkg]].str;
+ const char *translation = _(states[PackageOpsDone[pkg]].str);
char s[200];
snprintf(s, sizeof(s), translation, pkg);
@@ -706,14 +713,23 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// Check for an error code.
if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
{
- RunScripts("DPkg::Post-Invoke");
- if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
- return _error->Error("Sub-process %s received a segmentation fault.",Args[0]);
-
- if (WIFEXITED(Status) != 0)
- return _error->Error("Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
+ // if it was set to "keep-dpkg-runing" then we won't return
+ // here but keep the loop going and just report it as a error
+ // for later
+ bool stopOnError = _config->FindB("Dpkg::StopOnError",true);
- return _error->Error("Sub-process %s exited unexpectedly",Args[0]);
+ if(stopOnError)
+ RunScripts("DPkg::Post-Invoke");
+
+ if (WIFSIGNALED(Status) != 0 && WTERMSIG(Status) == SIGSEGV)
+ _error->Error("Sub-process %s received a segmentation fault.",Args[0]);
+ else if (WIFEXITED(Status) != 0)
+ _error->Error("Sub-process %s returned an error code (%u)",Args[0],WEXITSTATUS(Status));
+ else
+ _error->Error("Sub-process %s exited unexpectedly",Args[0]);
+
+ if(stopOnError)
+ return false;
}
}
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc
index 146829566..649c93aee 100644
--- a/apt-pkg/tagfile.cc
+++ b/apt-pkg/tagfile.cc
@@ -33,33 +33,22 @@ using std::string;
/* */
pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) :
Fd(*pFd),
- Size(Size),
- Map(NULL),
- Buffer(0)
+ Size(Size)
{
if (Fd.IsOpen() == false)
{
+ Buffer = 0;
Start = End = Buffer = 0;
Done = true;
iOffset = 0;
- Map = NULL;
return;
}
- // check if we can MMap it
- if(Fd.Size() == 0)
- {
- Buffer = new char[Size];
- Start = End = Buffer;
- Done = false;
- Fill();
- } else {
- Map = new MMap (Fd, MMap::Public | MMap::ReadOnly);
- Buffer = (char *) Map->Data ();
- Start = Buffer;
- End = Buffer + Map->Size ();
- }
+ Buffer = new char[Size];
+ Start = End = Buffer;
+ Done = false;
iOffset = 0;
+ Fill();
}
/*}}}*/
// TagFile::~pkgTagFile - Destructor /*{{{*/
@@ -67,30 +56,55 @@ pkgTagFile::pkgTagFile(FileFd *pFd,unsigned long Size) :
/* */
pkgTagFile::~pkgTagFile()
{
- if(!Map) delete [] Buffer;
- delete Map;
+ delete [] Buffer;
}
/*}}}*/
-// TagFile::Step - Advance to the next section /*{{{*/
+// TagFile::Resize - Resize the internal buffer /*{{{*/
// ---------------------------------------------------------------------
-/* If the Section Scanner fails we refill the buffer and try again. */
-bool pkgTagFile::Step(pkgTagSection &Tag)
+/* Resize the internal buffer (double it in size). Fail if a maximum size
+ * size is reached.
+ */
+bool pkgTagFile::Resize()
{
- if ((Map != NULL) && (Start == End))
+ char *tmp;
+ unsigned long EndSize = End - Start;
+
+ // fail is the buffer grows too big
+ if(Size > 1024*1024+1)
return false;
- if (Tag.Scan(Start,End - Start) == false)
- {
- if (Map != NULL)
- return _error->Error(_("Unable to parse package file %s (1)"),
- Fd.Name().c_str());
+ // get new buffer and use it
+ tmp = new char[2*Size];
+ memcpy(tmp, Buffer, Size);
+ Size = Size*2;
+ delete [] Buffer;
+ Buffer = tmp;
+ // update the start/end pointers to the new buffer
+ Start = Buffer;
+ End = Start + EndSize;
+ return true;
+}
+
+// TagFile::Step - Advance to the next section /*{{{*/
+// ---------------------------------------------------------------------
+/* If the Section Scanner fails we refill the buffer and try again.
+ * If that fails too, double the buffer size and try again until a
+ * maximum buffer is reached.
+ */
+bool pkgTagFile::Step(pkgTagSection &Tag)
+{
+ while (Tag.Scan(Start,End - Start) == false)
+ {
if (Fill() == false)
return false;
- if (Tag.Scan(Start,End - Start) == false)
+ if(Tag.Scan(Start,End - Start))
+ break;
+
+ if (Resize() == false)
return _error->Error(_("Unable to parse package file %s (1)"),
- Fd.Name().c_str());
+ Fd.Name().c_str());
}
Start += Tag.size();
iOffset += Tag.size();
@@ -158,30 +172,23 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
return Step(Tag);
}
+ // Reposition and reload..
iOffset = Offset;
- if (Map != NULL)
- {
- Start = Buffer + iOffset;
- }
- else
- {
- // Reposition and reload..
- Done = false;
- if (Fd.Seek(Offset) == false)
- return false;
- End = Start = Buffer;
+ Done = false;
+ if (Fd.Seek(Offset) == false)
+ return false;
+ End = Start = Buffer;
- if (Fill() == false)
- return false;
+ if (Fill() == false)
+ return false;
- if (Tag.Scan(Start,End - Start) == true)
- return true;
+ if (Tag.Scan(Start,End - Start) == true)
+ return true;
+
+ // This appends a double new line (for the real eof handling)
+ if (Fill() == false)
+ return false;
- // This appends a double new line (for the real eof handling)
- if (Fill() == false)
- return false;
- }
-
if (Tag.Scan(Start,End - Start) == false)
return _error->Error(_("Unable to parse package file %s (2)"),Fd.Name().c_str());
@@ -192,12 +199,12 @@ bool pkgTagFile::Jump(pkgTagSection &Tag,unsigned long Offset)
// ---------------------------------------------------------------------
/* This looks for the first double new line in the data stream. It also
indexes the tags in the section. This very simple hash function for the
- first 3 letters gives very good performance on the debian package files */
+ last 8 letters gives very good performance on the debian package files */
inline static unsigned long AlphaHash(const char *Text, const char *End = 0)
{
unsigned long Res = 0;
for (; Text != End && *Text != ':' && *Text != 0; Text++)
- Res = (unsigned long)(*Text) ^ (Res << 2);
+ Res = ((unsigned long)(*Text) & 0xDF) ^ (Res << 1);
return Res & 0xFF;
}
@@ -207,7 +214,7 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
Stop = Section = Start;
memset(AlphaIndexes,0,sizeof(AlphaIndexes));
- if (Stop == 0 || MaxLength == 0)
+ if (Stop == 0)
return false;
TagCount = 0;
@@ -238,12 +245,6 @@ bool pkgTagSection::Scan(const char *Start,unsigned long MaxLength)
Stop++;
}
- if ((Stop+1 >= End) && (End[-1] == '\n' || End[-1] == '\r'))
- {
- Indexes[TagCount] = (End - 1) - Section;
- return true;
- }
-
return false;
}
/*}}}*/
diff --git a/apt-pkg/tagfile.h b/apt-pkg/tagfile.h
index dd481ba51..70381ad13 100644
--- a/apt-pkg/tagfile.h
+++ b/apt-pkg/tagfile.h
@@ -25,7 +25,6 @@
#endif
#include <apt-pkg/fileutl.h>
-#include <apt-pkg/mmap.h>
#include <stdio.h>
class pkgTagSection
@@ -70,23 +69,23 @@ class pkgTagSection
class pkgTagFile
{
FileFd &Fd;
- MMap *Map;
char *Buffer;
char *Start;
char *End;
bool Done;
unsigned long iOffset;
unsigned long Size;
-
+
bool Fill();
-
+ bool Resize();
+
public:
bool Step(pkgTagSection &Section);
inline unsigned long Offset() {return iOffset;};
bool Jump(pkgTagSection &Tag,unsigned long Offset);
- pkgTagFile(FileFd *F,unsigned long Size = 64*1024);
+ pkgTagFile(FileFd *F,unsigned long Size = 32*1024);
~pkgTagFile();
};