diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:54:47 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:54:47 +0000 |
commit | 421c8d109932a2615b9327c8b69aad715d4b1162 (patch) | |
tree | 598bab85a1d54cda33ef75662b5287b2c47f7be0 /apt-pkg | |
parent | eecf9bf7744f44f011234bccfc35218f80ae3526 (diff) |
Bug fixes
Author: jgg
Date: 1999-09-30 06:30:34 GMT
Bug fixes
Diffstat (limited to 'apt-pkg')
-rw-r--r-- | apt-pkg/algorithms.cc | 65 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.cc | 41 | ||||
-rw-r--r-- | apt-pkg/contrib/fileutl.h | 3 | ||||
-rw-r--r-- | apt-pkg/deb/deblistparser.cc | 13 | ||||
-rw-r--r-- | apt-pkg/packagemanager.cc | 31 | ||||
-rw-r--r-- | apt-pkg/sourcelist.cc | 6 |
6 files changed, 118 insertions, 41 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index d84ce2e21..dd0928562 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: algorithms.cc,v 1.23 1999/07/30 02:54:25 jgg Exp $ +// $Id: algorithms.cc,v 1.24 1999/09/30 06:30:34 jgg Exp $ /* ###################################################################### Algorithms - A set of misc algorithms @@ -715,13 +715,18 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) // Isolate the problem dependency PackageKill KillList[100]; PackageKill *LEnd = KillList; - for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); D.end() == false;) + bool InOr = false; + pkgCache::DepIterator Start; + pkgCache::DepIterator End; + for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); + D.end() == false || InOr == true;) { // Compute a single dependency element (glob or) - pkgCache::DepIterator Start; - pkgCache::DepIterator End; - D.GlobOr(Start,End); - + if (InOr == false) + D.GlobOr(Start,End); + else + Start++; + // We only worry about critical deps. if (End.IsCritical() != true) continue; @@ -730,25 +735,27 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) if ((Cache[End] & pkgDepCache::DepGInstall) == pkgDepCache::DepGInstall) continue; + InOr = Start != End; + // Hm, the group is broken.. I have no idea how to handle this - if (Start != End) +/* if (Start != End) { if (Debug == true) clog << "Note, a broken or group was found in " << I.Name() << "." << endl; if ((Flags[I->ID] & Protected) != Protected) Cache.MarkDelete(I); break; - } + }*/ if (Debug == true) - clog << "Package " << I.Name() << " has broken dep on " << End.TargetPkg().Name() << endl; + clog << "Package " << I.Name() << " has broken dep on " << Start.TargetPkg().Name() << endl; /* Look across the version list. If there are no possible targets then we keep the package and bail. This is necessary if a package has a dep on another package that cant be found */ - pkgCache::Version **VList = End.AllTargets(); + pkgCache::Version **VList = Start.AllTargets(); if (*VList == 0 && (Flags[I->ID] & Protected) != Protected && - End->Type != pkgCache::Dep::Conflicts && + Start->Type != pkgCache::Dep::Conflicts && Cache[I].NowBroken() == false) { Change = true; @@ -763,10 +770,10 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) pkgCache::PkgIterator Pkg = Ver.ParentPkg(); if (Debug == true) - clog << " Considering " << Pkg.Name() << ' ' << (int)Scores[Pkg->ID] << + clog << " Considering " << Pkg.Name() << ' ' << (int)Scores[Pkg->ID] << " as a solution to " << I.Name() << ' ' << (int)Scores[I->ID] << endl; if (Scores[I->ID] <= Scores[Pkg->ID] || - ((Cache[End] & pkgDepCache::DepGNow) == 0 && + ((Cache[Start] & pkgDepCache::DepNow) == 0 && End->Type != pkgCache::Dep::Conflicts)) { // Try a little harder to fix protected packages.. @@ -783,17 +790,21 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) if (Cache[I].InstBroken() == false) { if (Debug == true) - clog << " Holding Back " << I.Name() << " rather than change " << End.TargetPkg().Name() << endl; + clog << " Holding Back " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; } else - { + { if (BrokenFix == false || DoUpgrade(I) == false) { - if (Debug == true) - clog << " Removing " << I.Name() << " rather than change " << End.TargetPkg().Name() << endl; - Cache.MarkDelete(I); - if (Counter > 1) - Scores[I->ID] = Scores[Pkg->ID]; + // Consider other options + if (InOr == false) + { + if (Debug == true) + clog << " Removing " << I.Name() << " rather than change " << Start.TargetPkg().Name() << endl; + Cache.MarkDelete(I); + if (Counter > 1) + Scores[I->ID] = Scores[Pkg->ID]; + } } } @@ -811,25 +822,25 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) LEnd->Dep = End; LEnd++; - if (End->Type != pkgCache::Dep::Conflicts) + if (Start->Type != pkgCache::Dep::Conflicts) break; } } // Hm, nothing can possibly satisify this dep. Nuke it. - if (VList[0] == 0 && End->Type != pkgCache::Dep::Conflicts && - (Flags[I->ID] & Protected) != Protected) + if (VList[0] == 0 && Start->Type != pkgCache::Dep::Conflicts && + (Flags[I->ID] & Protected) != Protected && InOr == false) { Cache.MarkKeep(I); if (Cache[I].InstBroken() == false) { if (Debug == true) - clog << " Holding Back " << I.Name() << " because I can't find " << End.TargetPkg().Name() << endl; + clog << " Holding Back " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl; } else { if (Debug == true) - clog << " Removing " << I.Name() << " because I can't find " << End.TargetPkg().Name() << endl; + clog << " Removing " << I.Name() << " because I can't find " << Start.TargetPkg().Name() << endl; Cache.MarkDelete(I); } @@ -837,6 +848,10 @@ bool pkgProblemResolver::Resolve(bool BrokenFix) Done = true; } + // Try some more + if (InOr == true) + continue; + delete [] VList; if (Done == true) break; diff --git a/apt-pkg/contrib/fileutl.cc b/apt-pkg/contrib/fileutl.cc index a2c6ab370..ddb07532d 100644 --- a/apt-pkg/contrib/fileutl.cc +++ b/apt-pkg/contrib/fileutl.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.cc,v 1.30 1999/07/26 17:46:08 jgg Exp $ +// $Id: fileutl.cc,v 1.31 1999/09/30 06:30:34 jgg Exp $ /* ###################################################################### File Utilities @@ -150,6 +150,45 @@ string flNotFile(string File) return string(File,0,Res); } /*}}}*/ +// flNoLink - If file is a symlink then deref it /*{{{*/ +// --------------------------------------------------------------------- +/* If the name is not a link then the returned path is the input. */ +string flNoLink(string File) +{ + struct stat St; + if (lstat(File.c_str(),&St) != 0 || S_ISLNK(St.st_mode) == 0) + return File; + if (stat(File.c_str(),&St) != 0) + return File; + + /* Loop resolving the link. There is no need to limit the number of + loops because the stat call above ensures that the symlink is not + circular */ + char Buffer[1024]; + string NFile = File; + while (1) + { + // Read the link + int Res; + if ((Res = readlink(NFile.c_str(),Buffer,sizeof(Buffer))) <= 0 || + (unsigned)Res >= sizeof(Buffer)) + return File; + + // Append or replace the previous path + Buffer[Res] = 0; + if (Buffer[0] == '/') + NFile = Buffer; + else + NFile = flNotFile(NFile) + Buffer; + + // See if we are done + if (lstat(NFile.c_str(),&St) != 0) + return File; + if (S_ISLNK(St.st_mode) == 0) + return NFile; + } +} + /*}}}*/ // SetCloseExec - Set the close on exec flag /*{{{*/ // --------------------------------------------------------------------- /* */ diff --git a/apt-pkg/contrib/fileutl.h b/apt-pkg/contrib/fileutl.h index fe904acf5..7ad630ce3 100644 --- a/apt-pkg/contrib/fileutl.h +++ b/apt-pkg/contrib/fileutl.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: fileutl.h,v 1.21 1999/07/26 17:46:08 jgg Exp $ +// $Id: fileutl.h,v 1.22 1999/09/30 06:30:34 jgg Exp $ /* ###################################################################### File Utilities @@ -83,5 +83,6 @@ bool ExecWait(int Pid,const char *Name,bool Reap = false); // File string manipulators string flNotDir(string File); string flNotFile(string File); +string flNoLink(string File); #endif diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc index 59d15f7d0..9da03a7f6 100644 --- a/apt-pkg/deb/deblistparser.cc +++ b/apt-pkg/deb/deblistparser.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: deblistparser.cc,v 1.22 1999/07/30 02:54:25 jgg Exp $ +// $Id: deblistparser.cc,v 1.23 1999/09/30 06:30:34 jgg Exp $ /* ###################################################################### Package Cache Generator - Generator for the cache structure. @@ -88,7 +88,7 @@ bool debListParser::NewVersion(pkgCache::VerIterator Ver) {"extra",pkgCache::State::Extra}}; if (GrabWord(string(Start,Stop-Start),PrioList, _count(PrioList),Ver->Priority) == false) - return _error->Error("Malformed Priority line"); + Ver->Priority = pkgCache::State::Extra; } if (ParseDepends(Ver,"Depends",pkgCache::Dep::Depends) == false) @@ -154,11 +154,18 @@ unsigned short debListParser::VersionHash() continue; /* Strip out any spaces from the text, this undoes dpkgs reformatting - of certain fields */ + of certain fields. dpkg also has the rather interesting notion of + reformatting depends operators < -> <= */ char *I = S; for (; Start != End; Start++) + { if (isspace(*Start) == 0) *I++ = tolower(*Start); + if (*Start == '<' && Start[1] != '<' && Start[1] != '=') + *I++ = '='; + if (*Start == '>' && Start[1] != '>' && Start[1] != '=') + *I++ = '='; + } Result = AddCRC16(Result,S,I - S); } diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc index 28a8d7fb2..b76f78b3c 100644 --- a/apt-pkg/packagemanager.cc +++ b/apt-pkg/packagemanager.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: packagemanager.cc,v 1.20 1999/08/12 05:59:54 jgg Exp $ +// $Id: packagemanager.cc,v 1.21 1999/09/30 06:30:34 jgg Exp $ /* ###################################################################### Package Manager - Abstacts the package manager @@ -414,12 +414,17 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) /* See if this packages install version has any predependencies that are not met by 'now' packages. */ for (DepIterator D = Cache[Pkg].InstVerIter(Cache).DependsList(); - D.end() == false; D++) + D.end() == false; ) { - if (D->Type == pkgCache::Dep::PreDepends) + // Compute a single dependency element (glob or) + pkgCache::DepIterator Start; + pkgCache::DepIterator End; + D.GlobOr(Start,End); + + while (End->Type == pkgCache::Dep::PreDepends) { // Look for possible ok targets. - Version **VList = D.AllTargets(); + Version **VList = Start.AllTargets(); bool Bad = true; for (Version **I = VList; *I != 0 && Bad == true; I++) { @@ -450,18 +455,24 @@ bool pkgPackageManager::SmartUnPack(PkgIterator Pkg) } delete [] VList; - - if (Bad == true) - return _error->Error("Internal Error, Couldn't configure a pre-depend"); - continue; + /* If this or element did not match then continue on to the + next or element until a matching element is found*/ + if (Bad == true) + { + if (Start == End) + return _error->Error("Internal Error, Couldn't configure a pre-depend"); + Start++; + } + else + break; } - if (D->Type == pkgCache::Dep::Conflicts) + if (End->Type == pkgCache::Dep::Conflicts) { /* Look for conflicts. Two packages that are both in the install state cannot conflict so we don't check.. */ - Version **VList = D.AllTargets(); + Version **VList = End.AllTargets(); for (Version **I = VList; *I != 0; I++) { VerIterator Ver(Cache,*I); diff --git a/apt-pkg/sourcelist.cc b/apt-pkg/sourcelist.cc index 77f2acbc0..48d32f908 100644 --- a/apt-pkg/sourcelist.cc +++ b/apt-pkg/sourcelist.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: sourcelist.cc,v 1.15 1999/09/09 06:15:51 jgg Exp $ +// $Id: sourcelist.cc,v 1.16 1999/09/30 06:30:34 jgg Exp $ /* ###################################################################### List of Sources @@ -172,6 +172,8 @@ string pkgSourceList::Item::PackagesURI() const { if (Dist != "/") Res = URI + Dist; + else + Res = URI; } else Res = URI + "dists/" + Dist + '/' + Section + @@ -240,6 +242,8 @@ string pkgSourceList::Item::ReleaseURI() const { if (Dist != "/") Res = URI + Dist; + else + Res = URI; } else Res = URI + "dists/" + Dist + '/' + Section + |