summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:52:54 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:52:54 +0000
commit9dbb421ffcf7da89f4010a14e64903189c5e472a (patch)
tree70755a8c46e8d5706bbed1ae297c1083ad1a7e8c
parent1084d58ae9a56d7d4c8a274112128f56302a3edc (diff)
Fixed weird to-configure inconsitency and added apt-cac...
Author: jgg Date: 1999-02-19 07:56:06 GMT Fixed weird to-configure inconsitency and added apt-cache search
-rw-r--r--apt-pkg/acquire-item.cc5
-rw-r--r--apt-pkg/packagemanager.cc28
-rw-r--r--cmdline/apt-cache.cc49
3 files changed, 74 insertions, 8 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index ebef611d8..37ce9bb2d 100644
--- a/apt-pkg/acquire-item.cc
+++ b/apt-pkg/acquire-item.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-item.cc,v 1.23 1999/02/01 08:11:57 jgg Exp $
+// $Id: acquire-item.cc,v 1.24 1999/02/19 07:56:06 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
@@ -448,7 +448,7 @@ bool pkgAcqArchive::QueueNext()
}
DestFile = _config->FindDir("Dir::Cache::Archives") + "partial/" + flNotDir(StoreFilename);
-
+
// Create the item
Desc.URI = Location->ArchiveURI(PkgFile);
Desc.Description = Location->ArchiveInfo(Version);
@@ -541,6 +541,7 @@ void pkgAcqArchive::Failed(string Message,pkgAcquire::MethodConfig *Cnf)
return;
}
+ StoreFilename = string();
Item::Failed(Message,Cnf);
}
}
diff --git a/apt-pkg/packagemanager.cc b/apt-pkg/packagemanager.cc
index 0222b4445..1b58cc25d 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.12 1999/01/31 06:24:46 jgg Exp $
+// $Id: packagemanager.cc,v 1.13 1999/02/19 07:56:07 jgg Exp $
/* ######################################################################
Package Manager - Abstacts the package manager
@@ -66,7 +66,8 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
continue;
// Skip Packages that need configure only.
- if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure)
+ if (Pkg.State() == pkgCache::PkgIterator::NeedsConfigure &&
+ Cache[Pkg].Keep() == true)
continue;
new pkgAcqArchive(Owner,Sources,Recs,Cache[Pkg].InstVerIter(Cache),
@@ -83,16 +84,33 @@ bool pkgPackageManager::GetArchives(pkgAcquire *Owner,pkgSourceList *Sources,
bool pkgPackageManager::FixMissing()
{
pkgProblemResolver Resolve(Cache);
-
+
+ bool Bad = false;
for (PkgIterator I = Cache.PkgBegin(); I.end() == false; I++)
{
- if (Cache[I].Keep() == true)
+ // These don't need files
+ if (Cache[I].Keep() == true)
+ continue;
+ if (Cache[I].Delete() == true)
+ continue;
+
+ // We have a filename
+ if (FileNames[I->ID].empty() == false)
continue;
- if (FileNames[I->ID].empty() == false || Cache[I].Delete() == true)
+
+ // Skip Packages that need configure only.
+ if (I.State() == pkgCache::PkgIterator::NeedsConfigure &&
+ Cache[I].Keep() == true)
continue;
+
+ // Okay, this file is missing and we need it. Mark it for keep
+ Bad = true;
Cache.MarkKeep(I);
}
+ if (Bad == false)
+ return true;
+
// Now downgrade everything that is broken
return Resolve.ResolveByKeep() == true && Cache.BrokenCount() == 0;
}
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 6c1f972c6..f9ba327fa 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cache.cc,v 1.26 1999/02/15 04:48:09 jgg Exp $
+// $Id: apt-cache.cc,v 1.27 1999/02/19 07:56:07 jgg Exp $
/* ######################################################################
apt-cache - Manages the cache files
@@ -23,11 +23,13 @@
#include <apt-pkg/sourcelist.h>
#include <apt-pkg/cmndline.h>
#include <apt-pkg/strutl.h>
+#include <apt-pkg/pkgrecords.h>
#include <config.h>
#include <iostream.h>
#include <unistd.h>
#include <errno.h>
+#include <regex.h>
/*}}}*/
pkgCache *GCache = 0;
@@ -448,6 +450,49 @@ bool DoAdd(CommandLine &CmdL)
return true;
}
/*}}}*/
+// Search - Perform a search /*{{{*/
+// ---------------------------------------------------------------------
+/* This searches the package names and pacakge descriptions for a pattern */
+bool Search(CommandLine &CmdL)
+{
+ pkgCache &Cache = *GCache;
+
+ // Make sure there is at least one argument
+ if (CmdL.FileSize() != 2)
+ return _error->Error("You must give exactly one pattern");
+
+ // Compile the regex pattern
+ regex_t Pattern;
+ if (regcomp(&Pattern,CmdL.FileList[1],REG_EXTENDED | REG_ICASE |
+ REG_NOSUB) != 0)
+ return _error->Error("Regex compilation error");
+
+ // Create the text record parser
+ pkgRecords Recs(Cache);
+ if (_error->PendingError() == true)
+ return false;
+
+ // Search package names
+ pkgCache::PkgIterator I = Cache.PkgBegin();
+ for (;I.end() != true; I++)
+ {
+ if (regexec(&Pattern,I.Name(),0,0,0) == 0)
+ {
+ cout << I.Name();
+ if (I->VersionList != 0)
+ {
+ pkgRecords::Parser &P = Recs.Lookup(I.VersionList().FileList());
+ cout << " - " << P.ShortDesc() << endl;
+ }
+ else
+ cout << " [virtual package]" << endl;
+ }
+ }
+
+ regfree(&Pattern);
+ return true;
+}
+ /*}}}*/
// GenCaches - Call the main cache generator /*{{{*/
// ---------------------------------------------------------------------
/* */
@@ -487,6 +532,7 @@ bool ShowHelp(CommandLine &Cmd)
cout << " dumpavail - Print an available file to stdout" << endl;
cout << " unmet - Show unmet dependencies" << endl;
cout << " check - Check the cache a bit" << endl;
+ cout << " search - Search the package list for a regex pattern" << endl;
cout << endl;
cout << "Options:" << endl;
cout << " -h This help text." << endl;
@@ -532,6 +578,7 @@ int main(int argc,const char *argv[])
{"dumpavail",&DumpAvail},
{"unmet",&UnMet},
{"check",&Check},
+ {"search",&Search},
{0,0}};
CacheInitialize();