// -*- 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
// 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;
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;
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..
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];
+ }
}
}
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);
}
Done = true;
}
+ // Try some more
+ if (InOr == true)
+ continue;
+
delete [] VList;
if (Done == true)
break;
// -*- 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
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 /*{{{*/
// ---------------------------------------------------------------------
/* */
// -*- 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
// File string manipulators
string flNotDir(string File);
string flNotFile(string File);
+string flNoLink(string File);
#endif
// -*- 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.
{"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)
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);
}
// -*- 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
/* 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++)
{
}
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);
// -*- 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
{
if (Dist != "/")
Res = URI + Dist;
+ else
+ Res = URI;
}
else
Res = URI + "dists/" + Dist + '/' + Section +
{
if (Dist != "/")
Res = URI + Dist;
+ else
+ Res = URI;
}
else
Res = URI + "dists/" + Dist + '/' + Section +
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-get.cc,v 1.76 1999/09/16 02:08:09 jgg Exp $
+// $Id: apt-get.cc,v 1.77 1999/09/30 06:30:34 jgg Exp $
/* ######################################################################
apt-get - Cover for dpkg
/* This prints out the names of all the packages that are broken along
with the name of each each broken dependency and a quite version
description. */
-void ShowBroken(ostream &out,CacheFile &Cache)
+void ShowBroken(ostream &out,CacheFile &Cache,bool Now)
{
out << "Sorry, but the following packages have unmet dependencies:" << endl;
for (unsigned J = 0; J < Cache->Head().PackageCount; J++)
")";
/* Show a summary of the target package if possible. In the case
- of virtual packages we show nothing */
-
+ of virtual packages we show nothing */
pkgCache::PkgIterator Targ = End.TargetPkg();
if (Targ->ProvidesList == 0)
{
out << " but ";
pkgCache::VerIterator Ver = Cache[Targ].InstVerIter(Cache);
if (Ver.end() == false)
- out << Ver.VerStr() << " is installed";
+ out << Ver.VerStr() << (Now?" is installed":" is to be installed");
else
{
if (Cache[Targ].CandidateVerIter(Cache).end() == true)
out << "it is a virtual package";
}
else
- out << "it is not installed";
+ out << (Now?"it is not installed":"it is not going to be installed");
}
}
if (pkgFixBroken(*Cache) == false || Cache->BrokenCount() != 0)
{
c1out << " failed." << endl;
- ShowBroken(c1out,*this);
+ ShowBroken(c1out,*this,true);
return _error->Error("Unable to correct dependencies");
}
else
{
c1out << "You might want to run `apt-get -f install' to correct these." << endl;
- ShowBroken(c1out,*this);
+ ShowBroken(c1out,*this,true);
return _error->Error("Unmet dependencies. Try using -f.");
}
// Sanity check
if (Cache->BrokenCount() != 0)
{
- ShowBroken(c1out,Cache);
+ ShowBroken(c1out,Cache,false);
return _error->Error("Internal Error, InstallPackages was called with broken packages!");
}
// Do the upgrade
if (pkgAllUpgrade(Cache) == false)
{
- ShowBroken(c1out,Cache);
+ ShowBroken(c1out,Cache,false);
return _error->Error("Internal Error, AllUpgrade broke stuff");
}
if (BrokenFix == true && Cache->BrokenCount() != 0)
{
c1out << "You might want to run `apt-get -f install' to correct these:" << endl;
- ShowBroken(c1out,Cache);
+ ShowBroken(c1out,Cache,false);
return _error->Error("Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).");
}
c1out << "The following information may help to resolve the situation:" << endl;
c1out << endl;
- ShowBroken(c1out,Cache);
+ ShowBroken(c1out,Cache,false);
return _error->Error("Sorry, broken packages");
}
if (pkgDistUpgrade(*Cache) == false)
{
c0out << "Failed" << endl;
- ShowBroken(c1out,Cache);
+ ShowBroken(c1out,Cache,false);
return false;
}
if (Fix.Resolve() == false)
{
- ShowBroken(c1out,Cache);
+ ShowBroken(c1out,Cache,false);
return _error->Error("Internal Error, problem resolver broke stuff");
}
}
// Now upgrade everything
if (pkgAllUpgrade(Cache) == false)
{
- ShowBroken(c1out,Cache);
+ ShowBroken(c1out,Cache,false);
return _error->Error("Internal Error, problem resolver broke stuff");
}
AC_CONFIG_HEADER(include/config.h:buildlib/config.h.in)
dnl -- SET THIS TO THE RELEASE VERSION --
-AC_DEFINE_UNQUOTED(VERSION,"0.3.12")
+AC_DEFINE_UNQUOTED(VERSION,"0.3.12.1")
AC_DEFINE_UNQUOTED(PACKAGE,"apt")
dnl Tom's host stuff
+apt (0.3.13.1) unstable; urgency=low
+
+ * Fix Perl or group pre-depends thing Closes: #46091, #46096, #46233
+ * Fix handling of dpkg's conversions from < -> <= Closes: #46094
+ * Make unparsable priorities non-fatal Closes: #46266, #46267
+ * Fix handling of '/' for the dist name. Closes: #43830, #45640, #45692
+
+ -- Jason Gunthorpe <jgg@debian.org> Fri, 3 Sep 1999 09:04:28 -0700
+
apt (0.3.12.1) unstable; urgency=low
* Fix timestamp miss in FTP. Closes: #44363
* Fix sorting of Kept packages. Closes: #44377
* Fix Segfault for dselect-upgrade. Closes: #44436
- * Fix handling of '/' for the dist name. Closes #43830
- * Added APT::Get::Diff-Only and Tar-Only options. Closes #44384
+ * Added APT::Get::Diff-Only and Tar-Only options. Closes: #44384
+
+ * Fix dpkg-preexec. Closes: #44706
-- Jason Gunthorpe <jgg@debian.org> Fri, 3 Sep 1999 09:04:28 -0700
# Scratch program to test incomplete code fragments in
PROGRAM=scratch-test
-SLIBS = -lapt-pkg
-LIB_MAKES = apt-pkg/makefile
+SLIBS = -lapt-inst -lapt-pkg
+LIB_MAKES = apt-pkg/makefile apt-inst/makefile
SOURCE = scratch.cc
include $(PROGRAM_H)
+PROGRAM=testextract
+SLIBS = -lapt-inst -lapt-pkg
+LIB_MAKES = apt-pkg/makefile apt-inst/makefile
+SOURCE = testextract.cc
+include $(PROGRAM_H)
+
# Version compare tester
PROGRAM=versiontest
SLIBS = -lapt-pkg
-#include <string>
-/*void basic_string<char,string_char_traits<char>,alloc>::Rep::release()
-{
- cout << "Release " << (void *)this << ' ' << ref << endl;
- if (--ref == 0) delete this;
-}
-
-basic_string<char,string_char_traits<char>,alloc>::~basic_string()
-{
- cout << "Destroy " << (void *)this << ',' << rep()->ref << endl;
- rep ()->release ();
-}*/
-
-
-
-#include <apt-pkg/tagfile.h>
-#include <apt-pkg/strutl.h>
-
-#include <apt-pkg/cachefile.h>
-#include <apt-pkg/pkgrecords.h>
+#include <apt-pkg/dpkgdb.h>
+#include <apt-pkg/debfile.h>
#include <apt-pkg/error.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/extract.h>
#include <apt-pkg/init.h>
-
-#include <signal.h>
-#include <stdio.h>
-#include <malloc.h>
-
-struct Rep
-{
- size_t len, res, ref;
- bool selfish;
-};
+#include <apt-pkg/fileutl.h>
int main(int argc,char *argv[])
{
- pkgCacheFile Cache;
- OpProgress Prog;
pkgInitialize(*_config);
- if (Cache.Open(Prog,false) == false)
+
+ cout << flNoLink(argv[1]) << endl;
+
+ #if 0
+/* DynamicMMap *FileMap = new DynamicMMap(MMap::Public);
+ pkgFLCache *FList = new pkgFLCache(*FileMap);
+
+ char *Name = "/tmp/test";
+ pkgFLCache::PkgIterator Pkg(*FList,0);
+ pkgFLCache::NodeIterator Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
+ cout << (pkgFLCache::Node *)Node << endl;
+ Node = FList->GetNode(Name,Name+strlen(Name),Pkg.Offset(),true,false);
+ cout << (pkgFLCache::Node *)Node << endl;
+*/
+// #if 0
+ _config->Set("Dir::State::status","/tmp/testing/status");
+
+ debDpkgDB Db;
+
+ {
+ OpTextProgress Prog;
+
+ if (Db.ReadyPkgCache(Prog) == false)
+ cerr << "Error!" << endl;
+ Prog.Done();
+
+ if (Db.ReadyFileList(Prog) == false)
+ cerr << "Error!" << endl;
+ }
+
+ if (_error->PendingError() == true)
{
_error->DumpErrors();
return 0;
}
- pkgRecords rec(*Cache);
- while (1)
+/* Db.GetFLCache().BeginDiverLoad();
+ pkgFLCache::PkgIterator Pkg(Db.GetFLCache(),0);
+ if (Db.GetFLCache().AddDiversion(Pkg,"/usr/include/linux/kerneld.h","/usr/bin/nslookup") == false)
+ cerr << "Error!" << endl;
+
+ const char *Tmp = "/usr/include/linux/kerneld.h";
+ pkgFLCache::NodeIterator Nde = Db.GetFLCache().GetNode(Tmp,Tmp+strlen(Tmp),0,false,false);
+ map_ptrloc Loc = Nde->File;
+
+ for (; Nde.end() == false && Nde->File == Loc; Nde++)
+ cout << Nde->Flags << ',' << Nde->Pointer << ',' << Nde.File() << endl;
+ Db.GetFLCache().FinishDiverLoad();*/
+
+/* unsigned int I = 0;
+ pkgFLCache &Fl = Db.GetFLCache();
+ while (I < Fl.HeaderP->HashSize)
+ {
+ cout << I << endl;
+ pkgFLCache::NodeIterator Node(Fl,Fl.NodeP + Fl.HeaderP->FileHash + I++);
+ if (Node->Pointer == 0)
+ continue;
+ for (; Node.end() == false; Node++)
+ {
+ cout << Node.DirN() << '/' << Node.File();
+ if (Node->Flags == pkgFLCache::Node::Diversion)
+ cout << " (div)";
+ if (Node->Flags == pkgFLCache::Node::ConfFile)
+ cout << " (conf)";
+ cout << endl;
+ }
+ }*/
+
+ for (int I = 1; I < argc; I++)
{
- pkgCache::VerIterator V = (*Cache)[Cache->PkgBegin()].CandidateVerIter(*Cache);
- pkgRecords::Parser &Parse = rec.Lookup(V.FileList());
- string Foo = Parse.ShortDesc();
+ FileFd F(argv[I],FileFd::ReadOnly);
+ debDebFile Deb(F);
- cout << (reinterpret_cast<Rep *>(Foo.begin()) - 1)[0].ref << endl;
+ if (Deb.ExtractControl(Db) == false)
+ cerr << "Error!" << endl;
+ cout << argv[I] << endl;
-// cout << Foo << endl;
+ pkgCache::VerIterator Ver = Deb.MergeControl(Db);
+ if (Ver.end() == true)
+ cerr << "Failed" << endl;
+ else
+ cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl;
-// cout << rec.Lookup(V.FileList()).ShortDesc() << endl;
- malloc_stats();
+ pkgExtract Extract(Db.GetFLCache(),Ver);
+ Deb.ExtractArchive(Extract);
}
-
-#if 0
- URI U(argv[1]);
- cout << U.Access << endl;
- cout << U.User << endl;
- cout << U.Password << endl;
- cout << U.Host << endl;
- cout << U.Path << endl;
- cout << U.Port << endl;
-
-/*
- FileFd F(argv[1],FileFd::ReadOnly);
- pkgTagFile Reader(F);
-
- pkgTagSection Sect;
- while (Reader.Step(Sect) == true)
- {
- Sect.FindS("Package");
- Sect.FindS("Section");
- Sect.FindS("Version");
- Sect.FindI("Size");
- };*/
-#endif
- return 0;
+// #endif
+#endif
+ _error->DumpErrors();
}