summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/cacheiterators.h2
-rw-r--r--apt-pkg/deb/dpkgpm.cc73
-rw-r--r--apt-pkg/depcache.cc7
-rw-r--r--apt-pkg/packagemanager.cc2
-rw-r--r--apt-pkg/pkgcache.cc44
5 files changed, 92 insertions, 36 deletions
diff --git a/apt-pkg/cacheiterators.h b/apt-pkg/cacheiterators.h
index 5382f3838..e6a0fddb0 100644
--- a/apt-pkg/cacheiterators.h
+++ b/apt-pkg/cacheiterators.h
@@ -283,6 +283,8 @@ class pkgCache::DepIterator : public Iterator<Dependency, DepIterator> {
inline bool Reverse() const {return Type == DepRev;};
bool IsCritical() const;
bool IsNegative() const;
+ bool IsIgnorable(PrvIterator const &Prv) const;
+ bool IsIgnorable(PkgIterator const &Pkg) const;
void GlobOr(DepIterator &Start,DepIterator &End);
Version **AllTargets() const;
bool SmartTargetPkg(PkgIterator &Result) const;
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 7c0ed5639..4dc0baa50 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -108,7 +108,7 @@ ionice(int PID)
{
if (!FileExists("/usr/bin/ionice"))
return false;
- pid_t Process = ExecFork();
+ pid_t Process = ExecFork();
if (Process == 0)
{
char buf[32];
@@ -829,6 +829,40 @@ static int racy_pselect(int nfds, fd_set *readfds, fd_set *writefds,
*/
bool pkgDPkgPM::Go(int OutStatusFd)
{
+ // Generate the base argument list for dpkg
+ std::vector<const char *> Args;
+ unsigned long StartSize = 0;
+ string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
+ Args.push_back(Tmp.c_str());
+ StartSize += Tmp.length();
+
+ // Stick in any custom dpkg options
+ Configuration::Item const *Opts = _config->Tree("DPkg::Options");
+ if (Opts != 0)
+ {
+ Opts = Opts->Child;
+ for (; Opts != 0; Opts = Opts->Next)
+ {
+ if (Opts->Value.empty() == true)
+ continue;
+ Args.push_back(Opts->Value.c_str());
+ StartSize += Opts->Value.length();
+ }
+ }
+
+ size_t const BaseArgs = Args.size();
+ // we need to detect if we can qualify packages with the architecture or not
+ Args.push_back("--assert-multi-arch");
+ Args.push_back(NULL);
+
+ pid_t dpkgAssertMultiArch = ExecFork();
+ if (dpkgAssertMultiArch == 0)
+ {
+ execv(Args[0], (char**) &Args[0]);
+ _error->WarningE("dpkgGo", "Can't detect if dpkg supports multi-arch!");
+ _exit(2);
+ }
+
fd_set rfds;
struct timespec tv;
sigset_t sigmask;
@@ -905,27 +939,20 @@ bool pkgDPkgPM::Go(int OutStatusFd)
// create log
OpenLog();
- // Generate the base argument list for dpkg
- std::vector<const char *> Args;
- unsigned long StartSize = 0;
- string const Tmp = _config->Find("Dir::Bin::dpkg","dpkg");
- Args.push_back(Tmp.c_str());
- StartSize += Tmp.length();
-
- // Stick in any custom dpkg options
- Configuration::Item const *Opts = _config->Tree("DPkg::Options");
- if (Opts != 0)
+ bool dpkgMultiArch = false;
+ if (dpkgAssertMultiArch > 0)
{
- Opts = Opts->Child;
- for (; Opts != 0; Opts = Opts->Next)
+ int Status = 0;
+ while (waitpid(dpkgAssertMultiArch, &Status, 0) != dpkgAssertMultiArch)
{
- if (Opts->Value.empty() == true)
+ if (errno == EINTR)
continue;
- Args.push_back(Opts->Value.c_str());
- StartSize += Opts->Value.length();
+ _error->WarningE("dpkgGo", _("Waited for %s but it wasn't there"), "dpkg --assert-multi-arch");
+ break;
}
+ if (WIFEXITED(Status) == true && WEXITSTATUS(Status) == 0)
+ dpkgMultiArch = true;
}
- size_t const BaseArgs = Args.size();
// this loop is runs once per operation
for (vector<Item>::const_iterator I = List.begin(); I != List.end();)
@@ -965,14 +992,17 @@ bool pkgDPkgPM::Go(int OutStatusFd)
if (J - I > (signed)MaxArgs)
{
J = I + MaxArgs;
- Args.reserve(MaxArgs + 10);
+ unsigned long const size = MaxArgs + 10;
+ Args.reserve(size);
+ Packages.reserve(size);
}
else
{
- Args.reserve((J - I) + 10);
+ unsigned long const size = (J - I) + 10;
+ Args.reserve(size);
+ Packages.reserve(size);
}
-
int fd[2];
pipe(fd);
@@ -1047,7 +1077,8 @@ bool pkgDPkgPM::Go(int OutStatusFd)
continue;
if (I->Op == Item::Configure && disappearedPkgs.find(I->Pkg.Name()) != disappearedPkgs.end())
continue;
- if (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all"))
+ // We keep this here to allow "smooth" transitions from e.g. multiarch dpkg/ubuntu to dpkg/debian
+ if (dpkgMultiArch == false && (I->Pkg.Arch() == nativeArch || !strcmp(I->Pkg.Arch(), "all")))
{
char const * const name = I->Pkg.Name();
ADDARG(name);
diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc
index 031fca5c0..085159711 100644
--- a/apt-pkg/depcache.cc
+++ b/apt-pkg/depcache.cc
@@ -371,14 +371,11 @@ bool pkgDepCache::CheckDep(DepIterator Dep,int Type,PkgIterator &Res)
// Check the providing packages
PrvIterator P = Dep.TargetPkg().ProvidesList();
- PkgIterator Pkg = Dep.ParentPkg();
for (; P.end() != true; ++P)
{
- /* Provides may never be applied against the same package (or group)
- if it is a conflicts. See the comment above. */
- if (P.OwnerPkg()->Group == Pkg->Group && Dep.IsNegative() == true)
+ if (Dep.IsIgnorable(P) == true)
continue;
-
+
// Check if the provides is a hit
if (Type == NowVersion)
{
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 4f9762701..c9d7a3024 100644
--- a/apt-pkg/packagemanager.cc
+++ b/apt-pkg/packagemanager.cc
@@ -250,7 +250,7 @@ bool pkgPackageManager::CheckRConflicts(PkgIterator Pkg,DepIterator D,
continue;
// Ignore self conflicts, ignore conflicts from irrelevent versions
- if (D.ParentPkg() == Pkg || D.ParentVer() != D.ParentPkg().CurrentVer())
+ if (D.IsIgnorable(Pkg) || D.ParentVer() != D.ParentPkg().CurrentVer())
continue;
if (Cache.VS().CheckDep(Ver,D->CompareOp,D.TargetVer()) == false)
diff --git a/apt-pkg/pkgcache.cc b/apt-pkg/pkgcache.cc
index c854249e4..997c70768 100644
--- a/apt-pkg/pkgcache.cc
+++ b/apt-pkg/pkgcache.cc
@@ -619,13 +619,12 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
// Walk along the actual package providing versions
for (VerIterator I = DPkg.VersionList(); I.end() == false; ++I)
{
- if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
+ if (IsIgnorable(I.ParentPkg()) == true)
continue;
- if (IsNegative() == true &&
- ParentPkg() == I.ParentPkg())
+ if (Owner->VS->CheckDep(I.VerStr(),S->CompareOp,TargetVer()) == false)
continue;
-
+
Size++;
if (Res != 0)
*End++ = I;
@@ -634,13 +633,12 @@ pkgCache::Version **pkgCache::DepIterator::AllTargets() const
// Follow all provides
for (PrvIterator I = DPkg.ProvidesList(); I.end() == false; ++I)
{
- if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
+ if (IsIgnorable(I) == true)
continue;
-
- if (IsNegative() == true &&
- ParentPkg()->Group == I.OwnerPkg()->Group)
+
+ if (Owner->VS->CheckDep(I.ProvideVersion(),S->CompareOp,TargetVer()) == false)
continue;
-
+
Size++;
if (Res != 0)
*End++ = I.OwnerVer();
@@ -682,6 +680,34 @@ void pkgCache::DepIterator::GlobOr(DepIterator &Start,DepIterator &End)
}
}
/*}}}*/
+// DepIterator::IsIgnorable - should this packag/providr be ignored? /*{{{*/
+// ---------------------------------------------------------------------
+/* Deps like self-conflicts should be ignored as well as implicit conflicts
+ on virtual packages. */
+bool pkgCache::DepIterator::IsIgnorable(PkgIterator const &Pkg) const
+{
+ if (ParentPkg() == TargetPkg())
+ return IsNegative();
+
+ return false;
+}
+bool pkgCache::DepIterator::IsIgnorable(PrvIterator const &Prv) const
+{
+ if (IsNegative() == false)
+ return false;
+
+ PkgIterator const Pkg = ParentPkg();
+ /* Provides may never be applied against the same package (or group)
+ if it is a conflicts. See the comment above. */
+ if (Prv.OwnerPkg()->Group == Pkg->Group)
+ return true;
+ // Implicit group-conflicts should not be applied on providers of other groups
+ if (Pkg->Group == TargetPkg()->Group && Prv.OwnerPkg()->Group != Pkg->Group)
+ return true;
+
+ return false;
+}
+ /*}}}*/
// ostream operator to handle string representation of a dependecy /*{{{*/
// ---------------------------------------------------------------------
/* */