summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:51:20 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:51:20 +0000
commitbfd22fc0ac2632c6196f5149dc3b3671d9ff15e0 (patch)
tree2affe097f22065e344d2fc8921049ea7e3185d9b
parent46976ca4e7393625fb25728d876e0c15b7e55c15 (diff)
Working acquire code
Author: jgg Date: 1998-11-05 07:21:35 GMT Working acquire code
-rw-r--r--apt-pkg/acquire-item.cc18
-rw-r--r--apt-pkg/acquire-item.h3
-rw-r--r--apt-pkg/acquire-method.cc7
-rw-r--r--apt-pkg/acquire-worker.cc10
-rw-r--r--apt-pkg/acquire.cc22
-rw-r--r--apt-pkg/acquire.h4
-rw-r--r--apt-pkg/contrib/configuration.cc15
-rw-r--r--apt-pkg/contrib/strutl.cc23
-rw-r--r--apt-pkg/init.cc8
-rw-r--r--buildlib/configure.mak9
-rw-r--r--doc/examples/apt.conf6
-rw-r--r--methods/gzip.cc4
-rw-r--r--methods/http.cc3
-rw-r--r--test/scratch.cc4
14 files changed, 81 insertions, 55 deletions
diff --git a/apt-pkg/acquire-item.cc b/apt-pkg/acquire-item.cc
index f8cc7a0de..9f9d082fe 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.6 1998/10/30 07:53:34 jgg Exp $
+// $Id: acquire-item.cc,v 1.7 1998/11/05 07:21:35 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
@@ -94,6 +94,7 @@ pkgAcqIndex::pkgAcqIndex(pkgAcquire *Owner,const pkgSourceList::Item *Location)
Item(Owner), Location(Location)
{
Decompression = false;
+ Erase = false;
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(Location->PackagesURI());
@@ -136,9 +137,19 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
string FinalFile = _config->FindDir("Dir::State::lists");
FinalFile += URItoFileName(Location->PackagesURI());
Rename(DestFile,FinalFile);
+
+ // Remove the compressed version.
+ if (Erase == true)
+ {
+ DestFile = _config->FindDir("Dir::State::lists") + "partial/";
+ DestFile += URItoFileName(Location->PackagesURI());
+ unlink(DestFile.c_str());
+ }
return;
}
-
+
+ Erase = false;
+
// Handle the unzipd case
string FileName = LookupTag(Message,"Alt-Filename");
if (FileName.empty() == false)
@@ -163,6 +174,9 @@ void pkgAcqIndex::Done(string Message,unsigned long Size,string MD5)
// The files timestamp matches
if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
return;
+
+ if (FileName == DestFile)
+ Erase = true;
Decompression = true;
DestFile += ".decomp";
diff --git a/apt-pkg/acquire-item.h b/apt-pkg/acquire-item.h
index bdd4d3581..9ead29c9a 100644
--- a/apt-pkg/acquire-item.h
+++ b/apt-pkg/acquire-item.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-item.h,v 1.4 1998/10/26 07:11:44 jgg Exp $
+// $Id: acquire-item.h,v 1.5 1998/11/05 07:21:36 jgg Exp $
/* ######################################################################
Acquire Item - Item to acquire
@@ -63,6 +63,7 @@ class pkgAcqIndex : public pkgAcquire::Item
const pkgSourceList::Item *Location;
bool Decompression;
+ bool Erase;
public:
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index 8d26537fa..681015910 100644
--- a/apt-pkg/acquire-method.cc
+++ b/apt-pkg/acquire-method.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-method.cc,v 1.3 1998/11/01 08:07:11 jgg Exp $
+// $Id: acquire-method.cc,v 1.4 1998/11/05 07:21:38 jgg Exp $
/* ######################################################################
Acquire Method
@@ -263,10 +263,11 @@ int pkgAcqMethod::Run(bool Single)
FetchItem **I = &Queue;
for (; *I != 0; I = &(*I)->Next);
*I = Tmp;
- cout << "GOT " << Tmp->Uri << endl;
-
+
+ // Notify that this item is to be fetched.
if (Fetch(Tmp) == false)
Fail();
+
break;
}
}
diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc
index a02c6bc04..2cbab7720 100644
--- a/apt-pkg/acquire-worker.cc
+++ b/apt-pkg/acquire-worker.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire-worker.cc,v 1.9 1998/11/01 05:27:33 jgg Exp $
+// $Id: acquire-worker.cc,v 1.10 1998/11/05 07:21:39 jgg Exp $
/* ######################################################################
Acquire Worker
@@ -192,7 +192,7 @@ bool pkgAcquire::Worker::RunMessages()
pkgAcquire::Queue::QItem *Itm = 0;
if (URI.empty() == false)
Itm = OwnerQ->FindItem(URI,this);
-
+
// Determine the message number and dispatch
switch (Number)
{
@@ -237,8 +237,9 @@ bool pkgAcquire::Worker::RunMessages()
break;
}
+ pkgAcquire::Item *Owner = Itm->Owner;
OwnerQ->ItemDone(Itm);
- Itm->Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
+ Owner->Done(Message,atoi(LookupTag(Message,"Size","0").c_str()),
LookupTag(Message,"MD5-Hash"));
break;
}
@@ -252,8 +253,9 @@ bool pkgAcquire::Worker::RunMessages()
break;
}
+ pkgAcquire::Item *Owner = Itm->Owner;
OwnerQ->ItemDone(Itm);
- Itm->Owner->Failed(Message);
+ Owner->Failed(Message);
break;
}
diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc
index 91b2a7590..16adf3ae2 100644
--- a/apt-pkg/acquire.cc
+++ b/apt-pkg/acquire.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire.cc,v 1.7 1998/11/01 05:27:34 jgg Exp $
+// $Id: acquire.cc,v 1.8 1998/11/05 07:21:40 jgg Exp $
/* ######################################################################
Acquire - File Acquiration
@@ -143,6 +143,8 @@ void pkgAcquire::Enqueue(Item *Itm,string URI,string Description)
if (Running == true)
I->Startup();
}
+
+ Itm->Status = Item::StatIdle;
// Queue it into the named queue
I->Enqueue(Itm,URI,Description);
@@ -164,12 +166,14 @@ void pkgAcquire::Enqueue(Item *Itm,string URI,string Description)
void pkgAcquire::Dequeue(Item *Itm)
{
Queue *I = Queues;
+ bool Res = false;
for (; I != 0; I = I->Next)
- I->Dequeue(Itm);
+ Res |= I->Dequeue(Itm);
if (Debug == true)
clog << "Dequeuing " << Itm->DestFile << endl;
- ToFetch--;
+ if (Res == true)
+ ToFetch--;
}
/*}}}*/
// Acquire::QueueName - Return the name of the queue for this URI /*{{{*/
@@ -371,9 +375,11 @@ void pkgAcquire::Queue::Enqueue(Item *Owner,string URI,string Description)
/*}}}*/
// Queue::Dequeue - Remove an item from the queue /*{{{*/
// ---------------------------------------------------------------------
-/* */
-void pkgAcquire::Queue::Dequeue(Item *Owner)
+/* We return true if we hit something*/
+bool pkgAcquire::Queue::Dequeue(Item *Owner)
{
+ bool Res = false;
+
QItem **I = &Items;
for (; *I != 0;)
{
@@ -383,10 +389,13 @@ void pkgAcquire::Queue::Dequeue(Item *Owner)
*I = (*I)->Next;
Owner->QueueCounter--;
delete Jnk;
+ Res = true;
}
else
I = &(*I)->Next;
}
+
+ return Res;
}
/*}}}*/
// Queue::Startup - Start the worker processes /*{{{*/
@@ -463,6 +472,8 @@ bool pkgAcquire::Queue::Cycle()
if (Items == 0 || Workers == 0)
return true;
+ cout << "Cylce for " << Name << endl;
+
// Look for a queable item
QItem *I = Items;
for (; I != 0; I = I->Next)
@@ -475,6 +486,7 @@ bool pkgAcquire::Queue::Cycle()
I->Worker = Workers;
I->Owner->Status = pkgAcquire::Item::StatFetching;
+ cout << "Item has been queued!" << endl;
return Workers->QueueItem(I);
}
/*}}}*/
diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h
index 25fe4b761..a4ea45bff 100644
--- a/apt-pkg/acquire.h
+++ b/apt-pkg/acquire.h
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: acquire.h,v 1.7 1998/11/01 05:27:35 jgg Exp $
+// $Id: acquire.h,v 1.8 1998/11/05 07:21:41 jgg Exp $
/* ######################################################################
Acquire - File Acquiration
@@ -124,7 +124,7 @@ class pkgAcquire::Queue
// Put an item into this queue
void Enqueue(Item *Owner,string URI,string Description);
- void Dequeue(Item *Owner);
+ bool Dequeue(Item *Owner);
// Find a Queued item
QItem *FindItem(string URI,pkgAcquire::Worker *Owner);
diff --git a/apt-pkg/contrib/configuration.cc b/apt-pkg/contrib/configuration.cc
index 27299ec6a..da026f0f6 100644
--- a/apt-pkg/contrib/configuration.cc
+++ b/apt-pkg/contrib/configuration.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: configuration.cc,v 1.9 1998/10/30 07:53:42 jgg Exp $
+// $Id: configuration.cc,v 1.10 1998/11/05 07:21:43 jgg Exp $
/* ######################################################################
Configuration Class
@@ -292,8 +292,14 @@ bool ReadConfigFile(Configuration &Conf,string FName)
}
// Discard single line comments
+ bool InQuote = false;
for (char *I = Buffer; *I != 0; I++)
{
+ if (*I == '"')
+ InQuote = !InQuote;
+ if (InQuote == true)
+ continue;
+
if (*I == '/' && I[1] == '/')
{
*I = 0;
@@ -304,6 +310,11 @@ bool ReadConfigFile(Configuration &Conf,string FName)
// Look for multi line comments
for (char *I = Buffer; *I != 0; I++)
{
+ if (*I == '"')
+ InQuote = !InQuote;
+ if (InQuote == true)
+ continue;
+
if (*I == '/' && I[1] == '*')
{
InComment = true;
@@ -398,7 +409,7 @@ bool ReadConfigFile(Configuration &Conf,string FName)
string Word;
if (ParseCWord(LineBuffer.c_str()+Pos,Word) == false)
return _error->Error("Syntax error %s:%u: Malformed value",FName.c_str(),CurLine);
-
+
// Generate the item name
string Item;
if (ParentTag.empty() == true)
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index c99f88c3f..d5f765dd4 100644
--- a/apt-pkg/contrib/strutl.cc
+++ b/apt-pkg/contrib/strutl.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: strutl.cc,v 1.12 1998/11/04 07:11:13 jgg Exp $
+// $Id: strutl.cc,v 1.13 1998/11/05 07:21:44 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
@@ -623,23 +623,14 @@ void URI::CopyFrom(string U)
for (; I < U.end() && *I != ':' ; I++);
string::const_iterator FirstColon = I;
- // Determine if this is a host type URI with a leading double //
+ /* Determine if this is a host type URI with a leading double //
+ and then search for the first single / */
string::const_iterator SingleSlash = I;
if (I + 3 < U.end() && I[1] == '/' && I[2] == '/')
- {
- // Locate the single / that starts the path
- for (; I < U.end(); I++)
- {
- if (*I == '/' && I+1 < U.end() && I[1] == '/')
- I += 2;
- else
- if (*I == '/')
- break;
- }
- if (I > U.end())
- I = U.end();
- SingleSlash = I;
- }
+ SingleSlash += 3;
+ for (; SingleSlash < U.end() && *SingleSlash != '/'; SingleSlash++);
+ if (SingleSlash > U.end())
+ SingleSlash = U.end();
// We can now write the access and path specifiers
Access = string(U,0,FirstColon - U.begin());
diff --git a/apt-pkg/init.cc b/apt-pkg/init.cc
index da11e3b40..f79668c54 100644
--- a/apt-pkg/init.cc
+++ b/apt-pkg/init.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: init.cc,v 1.9 1998/10/30 07:53:39 jgg Exp $
+// $Id: init.cc,v 1.10 1998/11/05 07:21:42 jgg Exp $
/* ######################################################################
Init - Initialize the package library
@@ -46,7 +46,7 @@ bool pkgInitialize(Configuration &Cnf)
Cnf.Set("Dir::Etc","/etc/apt/");
Cnf.Set("Dir::Etc::sourcelist","sources.list");
Cnf.Set("Dir::Etc::main","apt.conf");
- Cnf.Set("Dir::Bin::methods","/usr/lib/apt/metods");
+ Cnf.Set("Dir::Bin::methods","/usr/lib/apt/methods");
// Read the main config file
string FName = Cnf.FindFile("Dir::Etc::main");
@@ -57,7 +57,9 @@ bool pkgInitialize(Configuration &Cnf)
// Read an alternate config file
const char *Cfg = getenv("APT_CONFIG");
- if (ReadConfigFile(Cnf,FName) != true || ReadConfigFile(Cnf,Cfg) != true)
+ // Read both config files, either existing will be OK
+ if ((ReadConfigFile(Cnf,FName) != true) |
+ (ReadConfigFile(Cnf,Cfg) != true))
return false;
if (Cnf.FindB("Debug::pkgInitialize",false) == true)
diff --git a/buildlib/configure.mak b/buildlib/configure.mak
index 64c3179d1..70578a565 100644
--- a/buildlib/configure.mak
+++ b/buildlib/configure.mak
@@ -24,12 +24,3 @@ $(BUILD)/config.status: configure
(HERE=`pwd`; cd $(BUILD) && $$HERE/configure)
$(CONVERTED): $(BUILD)/config.status
(cd $(BUILD) && ./config.status)
-
-# We include the environment if it exists and re-export it to configure. This
-# allows someone to edit it and not have their changes blown away.
-Env = $(wildcard $(BUILD)/environment.mak)
-ifneq ($(words $(Env)),0)
-include $(Env)
-export CFLAGS CXXFLAGS CPPFLAGS LDFLAGS PICFLAGS
-endif
-
diff --git a/doc/examples/apt.conf b/doc/examples/apt.conf
index 2fd962c7f..4371c2b56 100644
--- a/doc/examples/apt.conf
+++ b/doc/examples/apt.conf
@@ -1,4 +1,4 @@
-// $Id: apt.conf,v 1.8 1998/11/04 23:22:24 jgg Exp $
+// $Id: apt.conf,v 1.9 1998/11/05 07:21:46 jgg Exp $
/* This file is an index of all APT configuration directives. It should
NOT actually be used as a real config file, though it is a completely
valid file.
@@ -37,10 +37,10 @@ Acquire
{
Queue-Mode "access"; // host|access
- http
+/* http
{
Proxy "http://127.0.0.1:3128";
- };
+ };*/
};
// Directory layout
diff --git a/methods/gzip.cc b/methods/gzip.cc
index be4f82e6f..a78fcb3ee 100644
--- a/methods/gzip.cc
+++ b/methods/gzip.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: gzip.cc,v 1.4 1998/11/01 05:27:43 jgg Exp $
+// $Id: gzip.cc,v 1.5 1998/11/05 07:21:47 jgg Exp $
/* ######################################################################
GZip method - Take a file URI in and decompress it into the target
@@ -36,7 +36,7 @@ class GzipMethod : public pkgAcqMethod
bool GzipMethod::Fetch(FetchItem *Itm)
{
URI Get = Itm->Uri;
-
+
// Open the source and destintation files
FileFd From(Get.Path,FileFd::ReadOnly);
FileFd To(Itm->DestFile,FileFd::WriteEmpty);
diff --git a/methods/http.cc b/methods/http.cc
index 4c773b064..b97d1dbc9 100644
--- a/methods/http.cc
+++ b/methods/http.cc
@@ -1,6 +1,6 @@
// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: http.cc,v 1.3 1998/11/04 07:10:49 jgg Exp $
+// $Id: http.cc,v 1.4 1998/11/05 07:21:48 jgg Exp $
/* ######################################################################
HTTP Aquire Method - This is the HTTP aquire method for APT.
@@ -951,6 +951,7 @@ int HttpMethod::Loop()
// Decide what to do.
FetchResult Res;
+ Res.Filename = Queue->DestFile;
switch (DealWithHeaders(Res,Server))
{
// Ok, the file is Open
diff --git a/test/scratch.cc b/test/scratch.cc
index 502b31db0..53681db16 100644
--- a/test/scratch.cc
+++ b/test/scratch.cc
@@ -8,7 +8,7 @@ int main(int argc,char *argv[])
{
signal(SIGPIPE,SIG_IGN);
- URI Foo(argv[1]);
+/* URI Foo(argv[1]);
cout << Foo.Access << '\'' << endl;
cout << Foo.Host << '\'' << endl;
cout << Foo.Path << '\'' << endl;
@@ -16,7 +16,7 @@ int main(int argc,char *argv[])
cout << Foo.Password << '\'' << endl;
cout << Foo.Port << endl;
- return 0;
+ return 0;*/
pkgInitialize(*_config);