summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:54:23 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:54:23 +0000
commitddc1d8d08eaff6c71c6062654ddd9d8981799ae9 (patch)
tree745d470d679bf169cab6da3f3322f40121e1f81c /apt-pkg/deb
parent727f18afe9c2eec15ee446cb667d9561644b5bf6 (diff)
Minor cleanups, fix for checksum lowercase bug
Author: jgg Date: 1999-07-26 17:46:07 GMT Minor cleanups, fix for checksum lowercase bug
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/deblistparser.cc13
-rw-r--r--apt-pkg/deb/deblistparser.h3
-rw-r--r--apt-pkg/deb/dpkginit.cc88
-rw-r--r--apt-pkg/deb/dpkginit.h9
-rw-r--r--apt-pkg/deb/dpkgpm.cc4
5 files changed, 67 insertions, 50 deletions
diff --git a/apt-pkg/deb/deblistparser.cc b/apt-pkg/deb/deblistparser.cc
index 182d46829..86cd526fb 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.20 1999/06/04 05:54:20 jgg Exp $
+// $Id: deblistparser.cc,v 1.21 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
Package Cache Generator - Generator for the cache structure.
@@ -24,6 +24,7 @@
/* */
debListParser::debListParser(FileFd &File) : Tags(File)
{
+ Arch = _config->Find("APT::architecture");
}
/*}}}*/
// ListParser::UniqFindTagWrite - Find the tag and write a unq string /*{{{*/
@@ -157,7 +158,7 @@ unsigned short debListParser::VersionHash()
char *I = S;
for (; Start != End; Start++)
if (isspace(*Start) == 0)
- *I++ = *Start;
+ *I++ = tolower(*Start);
Result = AddCRC16(Result,S,I - S);
}
@@ -466,11 +467,11 @@ bool debListParser::GrabWord(string Word,WordList *List,int Count,
bool debListParser::Step()
{
iOffset = Tags.Offset();
- string Arch = _config->Find("APT::architecture");
while (Tags.Step(Section) == true)
- {
- /* See if this is the correct Architecture, if it isnt then we
- drop the whole section */
+ {
+ /* See if this is the correct Architecture, if it isn't then we
+ drop the whole section. A missing arch tag only happens (in theory)
+ inside the Status file, so that is a positive return */
const char *Start;
const char *Stop;
if (Section.Find("Architecture",Start,Stop) == false)
diff --git a/apt-pkg/deb/deblistparser.h b/apt-pkg/deb/deblistparser.h
index 3c8ea5b0a..6e2c5ef94 100644
--- a/apt-pkg/deb/deblistparser.h
+++ b/apt-pkg/deb/deblistparser.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: deblistparser.h,v 1.7 1999/05/23 22:55:55 jgg Exp $
+// $Id: deblistparser.h,v 1.8 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
Debian Package List Parser - This implements the abstract parser
@@ -20,6 +20,7 @@ class debListParser : public pkgCacheGenerator::ListParser
pkgTagFile Tags;
pkgTagSection Section;
unsigned long iOffset;
+ string Arch;
// Parser Helper
struct WordList
diff --git a/apt-pkg/deb/dpkginit.cc b/apt-pkg/deb/dpkginit.cc
index 518d18f59..5327de0e1 100644
--- a/apt-pkg/deb/dpkginit.cc
+++ b/apt-pkg/deb/dpkginit.cc
@@ -1,10 +1,14 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: dpkginit.cc,v 1.2 1999/04/18 06:36:36 jgg Exp $
+// $Id: dpkginit.cc,v 1.3 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
DPKG init - Initialize the dpkg stuff
+ This class provides the locking mechanism used by dpkg for its
+ database area. It does the proper consistency checks and acquires the
+ correct kind of lock.
+
##################################################################### */
/*}}}*/
// Includes /*{{{*/
@@ -24,10 +28,10 @@
// DpkgLock::pkgDpkgLock - Constructor /*{{{*/
// ---------------------------------------------------------------------
/* */
-pkgDpkgLock::pkgDpkgLock()
+pkgDpkgLock::pkgDpkgLock(bool WithUpdates)
{
LockFD = -1;
- GetLock();
+ GetLock(WithUpdates);
}
/*}}}*/
// DpkgLock::~pkgDpkgLock - Destructor /*{{{*/
@@ -42,7 +46,7 @@ pkgDpkgLock::~pkgDpkgLock()
// ---------------------------------------------------------------------
/* This mirrors the operations dpkg does when it starts up. Note the
checking of the updates directory. */
-bool pkgDpkgLock::GetLock()
+bool pkgDpkgLock::GetLock(bool WithUpdates)
{
// Disable file locking
if (_config->FindB("Debug::NoLocking",false) == true)
@@ -56,41 +60,15 @@ bool pkgDpkgLock::GetLock()
if (LockFD == -1)
return _error->Error("Unable to lock the administration directory, "
"are you root?");
-
- // Check for updates.. (dirty)
- string File = AdminDir + "updates/";
- DIR *DirP = opendir(File.c_str());
- if (DirP != 0)
+
+ // See if we need to abort with a dirty journal
+ if (WithUpdates == true && CheckUpdates() == false)
{
- /* We ignore any files that are not all digits, this skips .,.. and
- some tmp files dpkg will leave behind.. */
- bool Damaged = false;
- for (struct dirent *Ent = readdir(DirP); Ent != 0; Ent = readdir(DirP))
- {
- Damaged = true;
- for (unsigned int I = 0; Ent->d_name[I] != 0; I++)
- {
- // Check if its not a digit..
- if (isdigit(Ent->d_name[I]) == 0)
- {
- Damaged = false;
- break;
- }
- }
- if (Damaged == true)
- break;
- }
- closedir(DirP);
-
- // Woops, we have to run dpkg to rewrite the status file
- if (Damaged == true)
- {
- Close();
- return _error->Error("dpkg was interrupted, you must manually "
- "run 'dpkg --configure -a' to correct the problem. ");
- }
+ Close();
+ return _error->Error("dpkg was interrupted, you must manually "
+ "run 'dpkg --configure -a' to correct the problem. ");
}
-
+
return true;
}
/*}}}*/
@@ -103,3 +81,39 @@ void pkgDpkgLock::Close()
LockFD = -1;
}
/*}}}*/
+// DpkgLock::CheckUpdates - Check if the updates dir is dirty /*{{{*/
+// ---------------------------------------------------------------------
+/* This does a check of the updates directory to see if it has any entries
+ in it. */
+bool pkgDpkgLock::CheckUpdates()
+{
+ // Check for updates.. (dirty)
+ string File = flNotFile(_config->Find("Dir::State::status")) + "updates/";
+ DIR *DirP = opendir(File.c_str());
+ if (DirP == 0)
+ return true;
+
+ /* We ignore any files that are not all digits, this skips .,.. and
+ some tmp files dpkg will leave behind.. */
+ bool Damaged = false;
+ for (struct dirent *Ent = readdir(DirP); Ent != 0; Ent = readdir(DirP))
+ {
+ Damaged = true;
+ for (unsigned int I = 0; Ent->d_name[I] != 0; I++)
+ {
+ // Check if its not a digit..
+ if (isdigit(Ent->d_name[I]) == 0)
+ {
+ Damaged = false;
+ break;
+ }
+ }
+ if (Damaged == true)
+ break;
+ }
+ closedir(DirP);
+
+ return Damaged;
+}
+ /*}}}*/
+
diff --git a/apt-pkg/deb/dpkginit.h b/apt-pkg/deb/dpkginit.h
index 288f50d04..532ff6236 100644
--- a/apt-pkg/deb/dpkginit.h
+++ b/apt-pkg/deb/dpkginit.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: dpkginit.h,v 1.1 1998/11/23 07:03:11 jgg Exp $
+// $Id: dpkginit.h,v 1.2 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
DPKG init - Initialize the dpkg stuff
@@ -23,10 +23,11 @@ class pkgDpkgLock
public:
- bool GetLock();
+ bool CheckUpdates();
+ bool GetLock(bool WithUpdates);
void Close();
-
- pkgDpkgLock();
+
+ pkgDpkgLock(bool WithUpdates = true);
~pkgDpkgLock();
};
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 4e108c419..7645929db 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: dpkgpm.cc,v 1.11 1999/07/09 04:11:34 jgg Exp $
+// $Id: dpkgpm.cc,v 1.12 1999/07/26 17:46:08 jgg Exp $
/* ######################################################################
DPKG Package Manager - Provide an interface to dpkg
@@ -121,7 +121,7 @@ bool pkgDPkgPM::RunScripts(const char *Cnf)
// Restore sig int/quit
signal(SIGQUIT,SIG_DFL);
signal(SIGINT,SIG_DFL);
-
+
// Check for an error code.
if (WIFEXITED(Status) == 0 || WEXITSTATUS(Status) != 0)
{