// -*- 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
Item(Owner), Location(Location)
{
Decompression = false;
+ Erase = false;
DestFile = _config->FindDir("Dir::State::lists") + "partial/";
DestFile += URItoFileName(Location->PackagesURI());
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)
// The files timestamp matches
if (StringToBool(LookupTag(Message,"IMS-Hit"),false) == true)
return;
+
+ if (FileName == DestFile)
+ Erase = true;
Decompression = true;
DestFile += ".decomp";
// -*- 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
const pkgSourceList::Item *Location;
bool Decompression;
+ bool Erase;
public:
// -*- 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
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;
}
}
// -*- 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
pkgAcquire::Queue::QItem *Itm = 0;
if (URI.empty() == false)
Itm = OwnerQ->FindItem(URI,this);
-
+
// Determine the message number and dispatch
switch (Number)
{
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;
}
break;
}
+ pkgAcquire::Item *Owner = Itm->Owner;
OwnerQ->ItemDone(Itm);
- Itm->Owner->Failed(Message);
+ Owner->Failed(Message);
break;
}
// -*- 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
if (Running == true)
I->Startup();
}
+
+ Itm->Status = Item::StatIdle;
// Queue it into the named queue
I->Enqueue(Itm,URI,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 /*{{{*/
/*}}}*/
// 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;)
{
*I = (*I)->Next;
Owner->QueueCounter--;
delete Jnk;
+ Res = true;
}
else
I = &(*I)->Next;
}
+
+ return Res;
}
/*}}}*/
// Queue::Startup - Start the worker processes /*{{{*/
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)
I->Worker = Workers;
I->Owner->Status = pkgAcquire::Item::StatFetching;
+ cout << "Item has been queued!" << endl;
return Workers->QueueItem(I);
}
/*}}}*/
// -*- 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
// 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);
// -*- 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
}
// 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;
// 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;
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)
// -*- 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.
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());
// -*- 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
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");
// 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)
(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
-
-// $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.
{
Queue-Mode "access"; // host|access
- http
+/* http
{
Proxy "http://127.0.0.1:3128";
- };
+ };*/
};
// Directory layout
// -*- 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
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);
// -*- 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.
// Decide what to do.
FetchResult Res;
+ Res.Filename = Queue->DestFile;
switch (DealWithHeaders(Res,Server))
{
// Ok, the file is Open
{
signal(SIGPIPE,SIG_IGN);
- URI Foo(argv[1]);
+/* URI Foo(argv[1]);
cout << Foo.Access << '\'' << endl;
cout << Foo.Host << '\'' << endl;
cout << Foo.Path << '\'' << endl;
cout << Foo.Password << '\'' << endl;
cout << Foo.Port << endl;
- return 0;
+ return 0;*/
pkgInitialize(*_config);