diff options
-rw-r--r-- | apt-pkg/acquire-method.cc | 13 | ||||
-rw-r--r-- | apt-pkg/acquire-method.h | 7 | ||||
-rw-r--r-- | apt-pkg/acquire-worker.cc | 8 | ||||
-rw-r--r-- | apt-pkg/acquire-worker.h | 3 | ||||
-rw-r--r-- | apt-pkg/acquire.cc | 77 | ||||
-rw-r--r-- | apt-pkg/acquire.h | 7 | ||||
-rw-r--r-- | cmdline/apt-get.cc | 6 | ||||
-rw-r--r-- | debian/changelog | 3 | ||||
-rw-r--r-- | doc/method.sgml | 8 | ||||
-rw-r--r-- | methods/cdrom.cc | 21 |
10 files changed, 95 insertions, 58 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc index 13b11c8db..5b7251a5f 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.20 1999/08/04 02:39:13 jgg Exp $ +// $Id: acquire-method.cc,v 1.21 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Method @@ -49,6 +49,9 @@ pkgAcqMethod::pkgAcqMethod(const char *Ver,unsigned long Flags) if ((Flags & LocalOnly) == LocalOnly) strcat(End,"Local-Only: true\n"); + + if ((Flags & NeedsCleanup) == NeedsCleanup) + strcat(End,"Needs-Cleanup: true\n"); strcat(End,"\n"); if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S)) @@ -309,10 +312,9 @@ int pkgAcqMethod::Run(bool Single) { if (Single == false) if (WaitFd(STDIN_FILENO) == false) - return 0; - + break; if (ReadMessages(STDIN_FILENO,Messages) == false) - return 0; + break; } // Single mode exits if the message queue is empty @@ -332,7 +334,7 @@ int pkgAcqMethod::Run(bool Single) } switch (Number) - { + { case 601: if (Configuration(Message) == false) return 100; @@ -365,6 +367,7 @@ int pkgAcqMethod::Run(bool Single) } } + Exit(); return 0; } /*}}}*/ diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h index 225ec15a8..ca03dd1d1 100644 --- a/apt-pkg/acquire-method.h +++ b/apt-pkg/acquire-method.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-method.h,v 1.11 1999/07/20 05:53:33 jgg Exp $ +// $Id: acquire-method.h,v 1.12 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Method - Method helper class + functions @@ -61,12 +61,13 @@ class pkgAcqMethod void URIStart(FetchResult &Res); void URIDone(FetchResult &Res,FetchResult *Alt = 0); bool MediaFail(string Required,string Drive); - + void Exit() {}; + public: enum CnfFlags {SingleInstance = (1<<0), Pipeline = (1<<1), SendConfig = (1<<2), - LocalOnly = (1<<3)}; + LocalOnly = (1<<3), NeedsCleanup = (1<<4)}; void Log(const char *Format,...); void Status(const char *Format,...); diff --git a/apt-pkg/acquire-worker.cc b/apt-pkg/acquire-worker.cc index 972ab2455..f6b14da3c 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.27 1999/08/28 01:49:56 jgg Exp $ +// $Id: acquire-worker.cc,v 1.28 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Worker @@ -86,7 +86,10 @@ pkgAcquire::Worker::~Worker() if (Process > 0) { - kill(Process,SIGINT); + /* Closing of stdin is the signal to exit and die when the process + indicates it needs cleanup */ + if (Config->NeedsCleanup == false) + kill(Process,SIGINT); ExecWait(Process,Access.c_str(),true); } } @@ -323,6 +326,7 @@ bool pkgAcquire::Worker::Capabilities(string Message) Config->Pipeline = StringToBool(LookupTag(Message,"Pipeline"),false); Config->SendConfig = StringToBool(LookupTag(Message,"Send-Config"),false); Config->LocalOnly = StringToBool(LookupTag(Message,"Local-Only"),false); + Config->NeedsCleanup = StringToBool(LookupTag(Message,"Needs-Cleanup"),false); // Some debug text if (Debug == true) diff --git a/apt-pkg/acquire-worker.h b/apt-pkg/acquire-worker.h index 4c3a666ae..797ea3f7c 100644 --- a/apt-pkg/acquire-worker.h +++ b/apt-pkg/acquire-worker.h @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: acquire-worker.h,v 1.10 1999/05/23 06:47:43 jgg Exp $ +// $Id: acquire-worker.h,v 1.11 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire Worker - Worker process manager @@ -79,6 +79,7 @@ class pkgAcquire::Worker bool QueueItem(pkgAcquire::Queue::QItem *Item); bool Start(); void Pulse(); + inline const MethodConfig *GetConf() const {return Config;}; Worker(Queue *OwnerQ,MethodConfig *Config,pkgAcquireStatus *Log); Worker(MethodConfig *Config); diff --git a/apt-pkg/acquire.cc b/apt-pkg/acquire.cc index 99dacf5be..7a93fbd8e 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.39 1999/10/16 19:53:18 jgg Exp $ +// $Id: acquire.cc,v 1.40 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -63,7 +63,7 @@ pkgAcquire::~pkgAcquire() Shutdown(); } /*}}}*/ -// pkgAcquire::Shutdown - Clean out the acquire object /*{{{*/ +// Acquire::Shutdown - Clean out the acquire object /*{{{*/ // --------------------------------------------------------------------- /* */ void pkgAcquire::Shutdown() @@ -345,11 +345,11 @@ pkgAcquire::RunResult pkgAcquire::Run() // Shut down the acquire bits Running = false; for (Queue *I = Queues; I != 0; I = I->Next) - I->Shutdown(); + I->Shutdown(false); // Shut down the items for (Item **I = Items.begin(); I != Items.end(); I++) - (*I)->Finished(); + (*I)->Finished(); if (_error->PendingError()) return Failed; @@ -453,7 +453,7 @@ unsigned long pkgAcquire::PartialPresent() return Total; } /*}}}*/ -// pkgAcquire::UriBegin - Start iterator for the uri list /*{{{*/ +// Acquire::UriBegin - Start iterator for the uri list /*{{{*/ // --------------------------------------------------------------------- /* */ pkgAcquire::UriIterator pkgAcquire::UriBegin() @@ -461,7 +461,7 @@ pkgAcquire::UriIterator pkgAcquire::UriBegin() return UriIterator(Queues); } /*}}}*/ -// pkgAcquire::UriEnd - End iterator for the uri list /*{{{*/ +// Acquire::UriEnd - End iterator for the uri list /*{{{*/ // --------------------------------------------------------------------- /* */ pkgAcquire::UriIterator pkgAcquire::UriEnd() @@ -501,7 +501,7 @@ pkgAcquire::Queue::Queue(string Name,pkgAcquire *Owner) : Name(Name), /* */ pkgAcquire::Queue::~Queue() { - Shutdown(); + Shutdown(true); while (Items != 0) { @@ -560,44 +560,53 @@ bool pkgAcquire::Queue::Dequeue(Item *Owner) /*}}}*/ // Queue::Startup - Start the worker processes /*{{{*/ // --------------------------------------------------------------------- -/* */ +/* It is possible for this to be called with a pre-existing set of + workers. */ bool pkgAcquire::Queue::Startup() { - Shutdown(); - - URI U(Name); - pkgAcquire::MethodConfig *Cnf = Owner->GetConfig(U.Access); - if (Cnf == 0) - return false; - - Workers = new Worker(this,Cnf,Owner->Log); - Owner->Add(Workers); - if (Workers->Start() == false) - return false; - - /* When pipelining we commit 10 items. This needs to change when we - added other source retry to have cycle maintain a pipeline depth - on its own. */ - if (Cnf->Pipeline == true) - MaxPipeDepth = 10; - else - MaxPipeDepth = 1; + if (Workers == 0) + { + URI U(Name); + pkgAcquire::MethodConfig *Cnf = Owner->GetConfig(U.Access); + if (Cnf == 0) + return false; + + Workers = new Worker(this,Cnf,Owner->Log); + Owner->Add(Workers); + if (Workers->Start() == false) + return false; + + /* When pipelining we commit 10 items. This needs to change when we + added other source retry to have cycle maintain a pipeline depth + on its own. */ + if (Cnf->Pipeline == true) + MaxPipeDepth = 10; + else + MaxPipeDepth = 1; + } return Cycle(); } /*}}}*/ // Queue::Shutdown - Shutdown the worker processes /*{{{*/ // --------------------------------------------------------------------- -/* */ -bool pkgAcquire::Queue::Shutdown() +/* If final is true then all workers are eliminated, otherwise only workers + that do not need cleanup are removed */ +bool pkgAcquire::Queue::Shutdown(bool Final) { // Delete all of the workers - while (Workers != 0) + pkgAcquire::Worker **Cur = &Workers; + while (*Cur != 0) { - pkgAcquire::Worker *Jnk = Workers; - Workers = Workers->NextQueue; - Owner->Remove(Jnk); - delete Jnk; + pkgAcquire::Worker *Jnk = *Cur; + if (Final == true || Jnk->GetConf()->NeedsCleanup == false) + { + *Cur = Jnk->NextQueue; + Owner->Remove(Jnk); + delete Jnk; + } + else + Cur = &(*Cur)->NextQueue; } return true; diff --git a/apt-pkg/acquire.h b/apt-pkg/acquire.h index 0d12b554f..e05ab3adc 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.24 1999/07/20 05:53:33 jgg Exp $ +// $Id: acquire.h,v 1.25 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### Acquire - File Acquiration @@ -175,7 +175,7 @@ class pkgAcquire::Queue bool ItemDone(QItem *Itm); bool Startup(); - bool Shutdown(); + bool Shutdown(bool Final); bool Cycle(); void Bump(); @@ -229,7 +229,8 @@ struct pkgAcquire::MethodConfig bool Pipeline; bool SendConfig; bool LocalOnly; - + bool NeedsCleanup; + MethodConfig(); }; diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc index aeb01485f..06422ada5 100644 --- a/cmdline/apt-get.cc +++ b/cmdline/apt-get.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-get.cc,v 1.79 1999/10/17 07:49:41 jgg Exp $ +// $Id: apt-get.cc,v 1.80 1999/10/18 00:37:35 jgg Exp $ /* ###################################################################### apt-get - Cover for dpkg @@ -660,7 +660,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey = while (1) { if (_config->FindB("APT::Get::No-Download",false) == false) - if( Fetcher.Run() == pkgAcquire::Failed) + if (Fetcher.Run() == pkgAcquire::Failed) return false; // Print out errors @@ -672,8 +672,6 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask = true,bool Saftey = (*I)->Complete == true) continue; - (*I)->Finished(); - if ((*I)->Status == pkgAcquire::Item::StatIdle) { Transient = true; diff --git a/debian/changelog b/debian/changelog index b4e5991b2..070ce3af7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,7 +2,7 @@ apt (0.3.13.1) unstable; urgency=low * Fix Perl or group pre-depends thing Closes: #46091, #46096, #46233, #45901 * Fix handling of dpkg's conversions from < -> <= Closes: #46094, #47088 - * Make unparsable priorities non-fatal Closes: #46266, #46267, #46293, #46298 + * Make unparsable priorities non-fatal Closes: #46266, #46267, #46293, #46298 * Fix handling of '/' for the dist name. Closes: #43830, #45640, #45692 * Fixed 'Method gave a blank filename' error from IMS queries onto CDs. Closes: #45034, #45695, #46537 @@ -16,6 +16,7 @@ apt (0.3.13.1) unstable; urgency=low * Tweaked Dselect 'update' script to re-gen the avail file even in the event of a failure Closes: #47112 * Retries for source archives too Closes: #47529 + * Unmounts CDROMs iff it mounted them Closes: #45299 -- Jason Gunthorpe <jgg@debian.org> Fri, 3 Sep 1999 09:04:28 -0700 diff --git a/doc/method.sgml b/doc/method.sgml index ae4b713f1..95fb8a52b 100644 --- a/doc/method.sgml +++ b/doc/method.sgml @@ -4,7 +4,7 @@ <title>APT Method Interface </title> <author>Jason Gunthorpe <email>jgg@debian.org</email></author> -<version>$Id: method.sgml,v 1.6 1998/12/14 04:00:34 jgg Exp $</version> +<version>$Id: method.sgml,v 1.7 1999/10/18 00:37:36 jgg Exp $</version> <abstract> This document describes the interface that APT uses to the archive @@ -219,6 +219,9 @@ the ones it wants. <tag>Pipeline<item>The method is capable of pipelining. <tag>Local<item>The method only returns Filename: feilds. <tag>Send-Config<item>Send configuration to the method. +<tag>Needs-Cleanup<item>The process is kept around while the files it returned +are being used. This is primarily intended for CDROM and File URIs that need +to unmount filesystems. <tag>Version<item>Version string for the method </taglist> @@ -229,7 +232,8 @@ This is a list of which headers each status code can use Displays the capabilities of the method. Methods should set the pipeline bit if their underlying protocol supports pipeling. The only known method that does support pipelining is http. -Fields: Version, Single-Instance, Pre-Scan, Pipeline, Send-Config +Fields: Version, Single-Instance, Pre-Scan, Pipeline, Send-Config, +Needs-Cleanup <tag>101 Log<item> A log message may be printed to the screen if debugging is enabled. This diff --git a/methods/cdrom.cc b/methods/cdrom.cc index befd531a6..e2eddf19e 100644 --- a/methods/cdrom.cc +++ b/methods/cdrom.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: cdrom.cc,v 1.15 1999/10/02 04:14:54 jgg Exp $ +// $Id: cdrom.cc,v 1.16 1999/10/18 00:37:36 jgg Exp $ /* ###################################################################### CDROM URI method for APT @@ -23,9 +23,12 @@ class CDROMMethod : public pkgAcqMethod bool DatabaseLoaded; ::Configuration Database; string CurrentID; + string CDROM; + bool Mounted; virtual bool Fetch(FetchItem *Itm); string GetID(string Name); + virtual void Exit(); public: @@ -36,10 +39,21 @@ class CDROMMethod : public pkgAcqMethod // --------------------------------------------------------------------- /* */ CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly | - SendConfig), DatabaseLoaded(false) + SendConfig | NeedsCleanup), + DatabaseLoaded(false), + Mounted(false) { }; /*}}}*/ +// CDROMMethod::Exit - Unmount the disc if necessary /*{{{*/ +// --------------------------------------------------------------------- +/* */ +void CDROMMethod::Exit() +{ + if (Mounted == true) + UnmountCdrom(CDROM); +} + /*}}}*/ // CDROMMethod::GetID - Search the database for a matching string /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -111,7 +125,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm) return true; } - string CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/"); + CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/"); if (CDROM[0] == '.') CDROM= SafeGetCWD() + '/' + CDROM; string NewID; @@ -149,6 +163,7 @@ bool CDROMMethod::Fetch(FetchItem *Itm) } MountCdrom(CDROM); + Mounted = true; } // Found a CD |