summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/acquire-item.cc21
-rw-r--r--apt-pkg/acquire-item.h4
-rw-r--r--apt-pkg/algorithms.cc4
-rw-r--r--apt-pkg/contrib/configuration.cc7
-rw-r--r--apt-pkg/contrib/strutl.cc6
-rw-r--r--apt-pkg/deb/dpkgpm.cc8
6 files changed, 34 insertions, 16 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index c8ac84f56..7cae6c8b7 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -770,16 +770,19 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
Desc.Owner = this;
Desc.ShortDesc = ShortDesc;
Desc.URI = URI;
-
string Final = _config->FindDir("Dir::State::lists");
Final += URItoFileName(RealURI);
struct stat Buf;
if (stat(Final.c_str(),&Buf) == 0)
{
- // File was already in place. It needs to be re-verified
- // because Release might have changed, so Move it into partial
- Rename(Final,DestFile);
+ // File was already in place. It needs to be re-downloaded/verified
+ // because Release might have changed, we do give it a differnt
+ // name than DestFile because otherwise the http method will
+ // send If-Range requests and there are too many broken servers
+ // out there that do not understand them
+ LastGoodSig = DestFile+".reverify";
+ Rename(Final,LastGoodSig);
}
QueueURI(Desc);
@@ -791,7 +794,7 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire *Owner,
string pkgAcqMetaSig::Custom600Headers()
{
struct stat Buf;
- if (stat(DestFile.c_str(),&Buf) != 0)
+ if (stat(LastGoodSig.c_str(),&Buf) != 0)
return "\nIndex-File: true";
return "\nIndex-File: true\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
@@ -821,6 +824,12 @@ void pkgAcqMetaSig::Done(string Message,unsigned long Size,string MD5,
Complete = true;
+ // put the last known good file back on i-m-s hit (it will
+ // be re-verified again)
+ // Else do nothing, we have the new file in DestFile then
+ if(StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
+ Rename(LastGoodSig, DestFile);
+
// queue a pkgAcqMetaIndex to be verified against the sig we just retrieved
new pkgAcqMetaIndex(Owner, MetaIndexURI, MetaIndexURIDesc, MetaIndexShortDesc,
DestFile, IndexTargets, MetaIndexParser);
@@ -837,7 +846,7 @@ void pkgAcqMetaSig::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
Item::Failed(Message,Cnf);
// move the sigfile back on transient network failures
if(FileExists(DestFile))
- Rename(DestFile,Final);
+ Rename(LastGoodSig,Final);
// set the status back to , Item::Failed likes to reset it
Status = pkgAcquire::Item::StatTransientNetworkError;
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index edd910230..a48f7f7e5 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -609,6 +609,10 @@ struct IndexTarget
class pkgAcqMetaSig : public pkgAcquire::Item
{
protected:
+ /** \brief The last good signature file */
+ string LastGoodSig;
+
+
/** \brief The fetch request that is currently being processed. */
pkgAcquire::ItemDesc Desc;
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 62727a852..158f9c258 100644
--- a/apt-pkg/algorithms.cc
+++ b/apt-pkg/algorithms.cc
@@ -1261,8 +1261,8 @@ void pkgProblemResolver::InstallProtect()
Cache.MarkDelete(I);
else
{
- // preserver the information if the package was auto
- // or manual installed
+ // preserve the information whether the package was auto
+ // or manually installed
bool autoInst = (Cache[I].Flags & pkgCache::Flag::Auto);
Cache.MarkInstall(I, false, 0, !autoInst);
}
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 3109fd7a5..e8301d918 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -173,6 +173,11 @@ string Configuration::Find(const char *Name,const char *Default) const
*/
string Configuration::FindFile(const char *Name,const char *Default) const
{
+ const Item *RootItem = Lookup("RootDir");
+ std::string rootDir = (RootItem == 0) ? "" : RootItem->Value;
+ if(rootDir.size() > 0 && rootDir[rootDir.size() - 1] != '/')
+ rootDir.push_back('/');
+
const Item *Itm = Lookup(Name);
if (Itm == 0 || Itm->Value.empty() == true)
{
@@ -204,7 +209,7 @@ string Configuration::FindFile(const char *Name,const char *Default) const
Itm = Itm->Parent;
}
- return val;
+ return rootDir + val;
}
/*}}}*/
// Configuration::FindDir - Find a directory name /*{{{*/
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index 006452af4..a04c266ba 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -331,19 +331,19 @@ string TimeToStr(unsigned long Sec)
{
if (Sec > 60*60*24)
{
- sprintf(S,"%lid %lih%lim%lis",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60);
+ sprintf(S,"%lid %lih%limin%lis",Sec/60/60/24,(Sec/60/60) % 24,(Sec/60) % 60,Sec % 60);
break;
}
if (Sec > 60*60)
{
- sprintf(S,"%lih%lim%lis",Sec/60/60,(Sec/60) % 60,Sec % 60);
+ sprintf(S,"%lih%limin%lis",Sec/60/60,(Sec/60) % 60,Sec % 60);
break;
}
if (Sec > 60)
{
- sprintf(S,"%lim%lis",Sec/60,Sec % 60);
+ sprintf(S,"%limin%lis",Sec/60,Sec % 60);
break;
}
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index d796146fa..11bf827d7 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -342,8 +342,8 @@ bool pkgDPkgPM::RunScriptsWithPkgs(const char *Cnf)
*/
void pkgDPkgPM::DoStdin(int master)
{
- char input_buf[256] = {0,};
- int len = read(0, input_buf, sizeof(input_buf));
+ unsigned char input_buf[256] = {0,};
+ ssize_t len = read(0, input_buf, sizeof(input_buf));
if (len)
write(master, input_buf, len);
else
@@ -357,9 +357,9 @@ void pkgDPkgPM::DoStdin(int master)
*/
void pkgDPkgPM::DoTerminalPty(int master)
{
- char term_buf[1024] = {0,};
+ unsigned char term_buf[1024] = {0,0, };
- int len=read(master, term_buf, sizeof(term_buf));
+ ssize_t len=read(master, term_buf, sizeof(term_buf));
if(len == -1 && errno == EIO)
{
// this happens when the child is about to exit, we