summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-08-11 09:14:02 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-08-11 09:14:02 +0200
commit180691bee7484f25d9879a77f577537ae1d98907 (patch)
tree845c06c2fdf0215902b7b08cf8c91dcdbad6c20d /apt-pkg
parent5368af78fb6c996c8ee24e5cf8f645cf00259ead (diff)
parent22041bd2864b8d0b401b45dde9eda4003a11fec4 (diff)
merged from the debian-experimental-ma branch
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/contrib/fileutl.cc11
-rw-r--r--apt-pkg/contrib/fileutl.h3
-rw-r--r--apt-pkg/depcache.cc11
-rw-r--r--apt-pkg/indexcopy.cc6
-rw-r--r--apt-pkg/pkgcachegen.cc4
5 files changed, 24 insertions, 11 deletions
diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc
index 2a3b8a87d..91aecee65 100644
--- a/apt-pkg/contrib/fileutl.cc
+++ b/apt-pkg/contrib/fileutl.cc
@@ -669,7 +669,7 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
}
break;
- case WriteEmpty:
+ case WriteAtomic:
{
Flags |= Replace;
char *name = strdup((FileName + ".XXXXXX").c_str());
@@ -678,6 +678,15 @@ bool FileFd::Open(string FileName,OpenMode Mode, unsigned long Perms)
free(name);
break;
}
+
+ case WriteEmpty:
+ {
+ struct stat Buf;
+ if (lstat(FileName.c_str(),&Buf) == 0 && S_ISLNK(Buf.st_mode))
+ unlink(FileName.c_str());
+ iFd = open(FileName.c_str(),O_RDWR | O_CREAT | O_TRUNC,Perms);
+ break;
+ }
case WriteExists:
iFd = open(FileName.c_str(),O_RDWR);
diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h
index 62705478d..cb4655798 100644
--- a/apt-pkg/contrib/fileutl.h
+++ b/apt-pkg/contrib/fileutl.h
@@ -46,7 +46,8 @@ class FileFd
gzFile gz;
public:
- enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip};
+ enum OpenMode {ReadOnly,WriteEmpty,WriteExists,WriteAny,WriteTemp,ReadOnlyGzip,
+ WriteAtomic};
inline bool Read(void *To,unsigned long Size,bool AllowEof)
{
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index bc663a8e9..00bf68af1 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -227,7 +227,7 @@ bool pkgDepCache::writeStateFile(OpProgress *prog, bool InstalledOnly) /*{{{*/
// if it does not exist, create a empty one
if(!FileExists(state))
{
- StateFile.Open(state, FileFd::WriteEmpty);
+ StateFile.Open(state, FileFd::WriteAtomic);
StateFile.Close();
}
@@ -1425,10 +1425,13 @@ void pkgDepCache::MarkInstall(PkgIterator const &Pkg,bool AutoInst,
VerIterator Ver(*this,*I);
PkgIterator Pkg = Ver.ParentPkg();
- if (Start->Type != Dep::DpkgBreaks)
- MarkDelete(Pkg,false,Depth + 1, false);
- else if (PkgState[Pkg->ID].CandidateVer != *I)
+
+
+ if (PkgState[Pkg->ID].CandidateVer != *I &&
+ Start->Type == Dep::DpkgBreaks)
MarkInstall(Pkg,true,Depth + 1, false, ForceImportantDeps);
+ else
+ MarkDelete(Pkg,false,Depth + 1, false);
}
continue;
}
diff --git a/apt-pkg/indexcopy.cc b/apt-pkg/indexcopy.cc
index 621c18716..b4e587d7b 100644
--- a/apt-pkg/indexcopy.cc
+++ b/apt-pkg/indexcopy.cc
@@ -134,7 +134,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List,
TargetF += URItoFileName(S);
if (_config->FindB("APT::CDROM::NoAct",false) == true)
TargetF = "/dev/null";
- FileFd Target(TargetF,FileFd::WriteEmpty);
+ FileFd Target(TargetF,FileFd::WriteAtomic);
FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
if (_error->PendingError() == true)
return false;
@@ -565,7 +565,7 @@ bool SigVerify::CopyMetaIndex(string CDROM, string CDName, /*{{{*/
FileFd Target;
FileFd Rel;
- Target.Open(TargetF,FileFd::WriteEmpty);
+ Target.Open(TargetF,FileFd::WriteAtomic);
Rel.Open(prefix + file,FileFd::ReadOnly);
if (_error->PendingError() == true)
return false;
@@ -840,7 +840,7 @@ bool TranslationsCopy::CopyTranslations(string CDROM,string Name, /*{{{*/
TargetF += URItoFileName(S);
if (_config->FindB("APT::CDROM::NoAct",false) == true)
TargetF = "/dev/null";
- FileFd Target(TargetF,FileFd::WriteEmpty);
+ FileFd Target(TargetF,FileFd::WriteAtomic);
FILE *TargetFl = fdopen(dup(Target.Fd()),"w");
if (_error->PendingError() == true)
return false;
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index c9a9a753c..ed35174bb 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -1192,7 +1192,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
if (Writeable == true && CacheFile.empty() == false)
{
unlink(CacheFile.c_str());
- CacheF = new FileFd(CacheFile,FileFd::WriteEmpty);
+ CacheF = new FileFd(CacheFile,FileFd::WriteAtomic);
fchmod(CacheF->Fd(),0644);
Map = CreateDynamicMMap(CacheF, MMap::Public);
if (_error->PendingError() == true)
@@ -1254,7 +1254,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
// Write it back
if (Writeable == true && SrcCacheFile.empty() == false)
{
- FileFd SCacheF(SrcCacheFile,FileFd::WriteEmpty);
+ FileFd SCacheF(SrcCacheFile,FileFd::WriteAtomic);
if (_error->PendingError() == true)
return false;