summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorMichael Vogt <egon@tas>2006-12-07 12:06:54 +0100
committerMichael Vogt <egon@tas>2006-12-07 12:06:54 +0100
commit3ca658384917297fdb75112a2b2df26054678934 (patch)
treedeadcb5d3688dc15ecc95b0c54941191b90ea513 /apt-pkg/deb
parentc7d9068f8c352b1ba6b43bd1fffb88542bee19a9 (diff)
parent1c05ebd6da9491d316997a98db1451f7b0526603 (diff)
merged from apt--mvo
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debindexfile.cc2
-rw-r--r--apt-pkg/deb/debsrcrecords.cc28
-rw-r--r--apt-pkg/deb/debsrcrecords.h10
-rw-r--r--apt-pkg/deb/dpkgpm.cc44
4 files changed, 45 insertions, 39 deletions
diff --git a/apt-pkg/deb/debindexfile.cc b/apt-pkg/deb/debindexfile.cc
index 38ecdd16a..9f435bba5 100644
--- a/apt-pkg/deb/debindexfile.cc
+++ b/apt-pkg/deb/debindexfile.cc
@@ -305,7 +305,7 @@ pkgCache::PkgFileIterator debPackagesIndex::FindInCache(pkgCache &Cache) const
pkgCache::PkgFileIterator File = Cache.FileBegin();
for (; File.end() == false; File++)
{
- if (FileName != File.FileName())
+ if (File.FileName() == NULL || FileName != File.FileName())
continue;
struct stat St;
diff --git a/apt-pkg/deb/debsrcrecords.cc b/apt-pkg/deb/debsrcrecords.cc
index cac36c2e6..9e87ee5da 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 long)4000, max((unsigned long)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..f4e2cb46c 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 long 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 f66962387..cebdafe7d 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -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)
{
@@ -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;
}
}