summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:51:03 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:51:03 +0000
commit7e798dd739883c1f47216578ba8df34dced24777 (patch)
treed756274fb10d7bb3a6b14306d46390139ce60da2 /apt-pkg
parent7e54a6d6f1d500a4e26dbe34952ff3af65d0b0b7 (diff)
Sync
Author: jgg Date: 1998-10-08 04:54:58 GMT Sync
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/algorithms.cc43
-rw-r--r--apt-pkg/algorithms.h3
-rw-r--r--apt-pkg/contrib/cmndline.cc14
-rw-r--r--apt-pkg/deb/debrecords.cc58
-rw-r--r--apt-pkg/deb/debrecords.h17
-rw-r--r--apt-pkg/pkgrecords.h18
6 files changed, 140 insertions, 13 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc
index 2e4ca5c2c..126318b59 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.4 1998/10/02 04:39:42 jgg Exp $
+// $Id: algorithms.cc,v 1.5 1998/10/08 04:54:58 jgg Exp $
/* ######################################################################
Algorithms - A set of misc algorithms
@@ -197,7 +197,7 @@ bool pkgFixBroken(pkgDepCache &Cache)
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
if (Cache[I].NowBroken() == true)
Cache.MarkInstall(I,true);
-
+
/* Fix packages that are in a NeedArchive state but don't have a
downloadable install version */
for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
@@ -209,7 +209,7 @@ bool pkgFixBroken(pkgDepCache &Cache)
if (Cache[I].InstVerIter(Cache).Downloadable() == false)
continue;
- Cache.MarkInstall(I,true);
+ Cache.MarkInstall(I,true);
}
pkgProblemResolver Fix(Cache);
@@ -287,6 +287,43 @@ bool pkgAllUpgrade(pkgDepCache &Cache)
return Fix.ResolveByKeep();
}
/*}}}*/
+// MinimizeUpgrade - Minimizes the set of packages to be upgraded /*{{{*/
+// ---------------------------------------------------------------------
+/* This simply goes over the entire set of packages and tries to keep
+ each package marked for upgrade. If a conflict is generated then
+ the package is restored. */
+bool pkgMinimizeUpgrade(pkgDepCache &Cache)
+{
+ if (Cache.BrokenCount() != 0)
+ return false;
+
+ // We loop indefinately to get the minimal set size.
+ bool Change = false;
+ do
+ {
+ Change = false;
+ for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
+ {
+ // Not interesting
+ if (Cache[I].Upgrade() == false || Cache[I].NewInstall() == true)
+ continue;
+
+ // Keep it and see if that is OK
+ Cache.MarkKeep(I);
+ if (Cache.BrokenCount() != 0)
+ Cache.MarkInstall(I,false);
+ else
+ Change = true;
+ }
+ }
+ while (Change == true);
+
+ if (Cache.BrokenCount() != 0)
+ return _error->Error("Internal Error in pkgMinimizeUpgrade");
+
+ return true;
+}
+ /*}}}*/
// ProblemResolver::pkgProblemResolver - Constructor /*{{{*/
// ---------------------------------------------------------------------
diff --git a/apt-pkg/algorithms.h b/apt-pkg/algorithms.h
index 0379357c2..bd0a1f7bd 100644
--- a/apt-pkg/algorithms.h
+++ b/apt-pkg/algorithms.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: algorithms.h,v 1.4 1998/10/02 04:39:43 jgg Exp $
+// $Id: algorithms.h,v 1.5 1998/10/08 04:54:59 jgg Exp $
/* ######################################################################
Algorithms - A set of misc algorithms
@@ -103,5 +103,6 @@ bool pkgDistUpgrade(pkgDepCache &Cache);
bool pkgApplyStatus(pkgDepCache &Cache);
bool pkgFixBroken(pkgDepCache &Cache);
bool pkgAllUpgrade(pkgDepCache &Cache);
+bool pkgMinimizeUpgrade(pkgDepCache &Cache);
#endif
diff --git a/apt-pkg/contrib/cmndline.cc b/apt-pkg/contrib/cmndline.cc
index 8e25d395f..7f5ab59a5 100644
--- a/apt-pkg/contrib/cmndline.cc
+++ b/apt-pkg/contrib/cmndline.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: cmndline.cc,v 1.2 1998/09/26 05:34:24 jgg Exp $
+// $Id: cmndline.cc,v 1.3 1998/10/08 04:55:01 jgg Exp $
/* ######################################################################
Command Line Class - Sophisticated command line parser
@@ -184,9 +184,17 @@ bool CommandLine::HandleOpt(int &I,int argc,const char *argv[],
const char *J;
for (J = Argument; *J != 0 && *J != '='; J++);
if (*J == 0)
- return _error->Error("Option %s: Configuration item sepecification must have an =.",argv[I]);
+ return _error->Error("Option %s: Configuration item sepecification must have an =<val>.",argv[I]);
- Conf->Set(string(Argument,J-Argument),string(J+1));
+ // = is trailing
+ if (J[1] == 0)
+ {
+ if (I+1 >= argc)
+ return _error->Error("Option %s: Configuration item sepecification must have an =<val>.",argv[I]);
+ Conf->Set(string(Argument,J-Argument),string(argv[I++ +1]));
+ }
+ else
+ Conf->Set(string(Argument,J-Argument),string(J+1));
return true;
}
diff --git a/apt-pkg/deb/debrecords.cc b/apt-pkg/deb/debrecords.cc
index ae0acce18..c28e11afb 100644
--- a/apt-pkg/deb/debrecords.cc
+++ b/apt-pkg/deb/debrecords.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debrecords.cc,v 1.1 1998/08/09 00:51:36 jgg Exp $
+// $Id: debrecords.cc,v 1.2 1998/10/08 04:55:02 jgg Exp $
/* ######################################################################
Debian Package Records - Parser for debian package records
@@ -30,3 +30,59 @@ bool debRecordParser::Jump(pkgCache::VerFileIterator &Ver)
return Tags.Jump(Section,Ver->Offset);
}
/*}}}*/
+// RecordParser::FindTag - Locate a tag and return a string /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string debRecordParser::FindTag(const char *Tag)
+{
+ const char *Start;
+ const char *Stop;
+ if (Section.Find(Tag,Start,Stop) == false)
+ return string();
+ return string(Start,Stop - Start);
+}
+ /*}}}*/
+// RecordParser::FileName - Return the archive filename on the site /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string debRecordParser::FileName()
+{
+ return FindTag("Filename");
+}
+ /*}}}*/
+// RecordParser::MD5Hash - Return the archive hash /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string debRecordParser::MD5Hash()
+{
+ return FindTag("MD5sum");
+}
+ /*}}}*/
+// RecordParser::Maintainer - Return the maintainer email /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string debRecordParser::Maintainer()
+{
+ return FindTag("Maintainer");
+}
+ /*}}}*/
+// RecordParser::ShortDesc - Return a 1 line description /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string debRecordParser::ShortDesc()
+{
+ string Res = FindTag("Description");
+ string::size_type Pos = Res.find('\n');
+ if (Pos == string::npos)
+ return Res;
+ return string(Res,0,Pos);
+}
+ /*}}}*/
+// RecordParser::LongDesc - Return a longer description /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string debRecordParser::LongDesc()
+{
+ return string();
+}
+ /*}}}*/
diff --git a/apt-pkg/deb/debrecords.h b/apt-pkg/deb/debrecords.h
index 0bd8da921..6255d79ed 100644
--- a/apt-pkg/deb/debrecords.h
+++ b/apt-pkg/deb/debrecords.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: debrecords.h,v 1.1 1998/08/09 00:51:36 jgg Exp $
+// $Id: debrecords.h,v 1.2 1998/10/08 04:55:04 jgg Exp $
/* ######################################################################
Debian Package Records - Parser for debian package records
@@ -26,10 +26,23 @@ class debRecordParser : public pkgRecords::Parser
{
pkgTagFile Tags;
pkgTagSection Section;
+
+ string FindTag(const char *Tag);
+
+ protected:
+
+ virtual bool Jump(pkgCache::VerFileIterator &Ver);
public:
+
+ // These refer to the archive file for the Version
+ virtual string FileName();
+ virtual string MD5Hash();
- virtual bool Jump(pkgCache::VerFileIterator &Ver);
+ // These are some general stats about the package
+ virtual string Maintainer();
+ virtual string ShortDesc();
+ virtual string LongDesc();
debRecordParser(FileFd &File);
};
diff --git a/apt-pkg/pkgrecords.h b/apt-pkg/pkgrecords.h
index e129c65eb..28cb728c6 100644
--- a/apt-pkg/pkgrecords.h
+++ b/apt-pkg/pkgrecords.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: pkgrecords.h,v 1.1 1998/08/09 00:51:35 jgg Exp $
+// $Id: pkgrecords.h,v 1.2 1998/10/08 04:55:00 jgg Exp $
/* ######################################################################
Package Records - Allows access to complete package description records
@@ -49,7 +49,7 @@ class pkgRecords
// Lookup function
Parser &Lookup(pkgCache::VerFileIterator &Ver);
-
+
// Construct destruct
pkgRecords(pkgCache &Cache);
~pkgRecords();
@@ -57,10 +57,22 @@ class pkgRecords
class pkgRecords::Parser
{
- public:
+ protected:
virtual bool Jump(pkgCache::VerFileIterator &Ver) = 0;
+ public:
+ friend pkgRecords;
+
+ // These refer to the archive file for the Version
+ virtual string FileName() {return string();};
+ virtual string MD5Hash() {return string();};
+
+ // These are some general stats about the package
+ virtual string Maintainer() {return string();};
+ virtual string ShortDesc() {return string();};
+ virtual string LongDesc() {return string();};
+
virtual ~Parser() {};
};