summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArch Librarian <arch@canonical.com>2004-09-20 16:51:49 +0000
committerArch Librarian <arch@canonical.com>2004-09-20 16:51:49 +0000
commitf46e768107c0250eb0609a89a74b66ab3c9d8cec (patch)
treea7321ca9fa202a9f0555c3a378170398dba88640
parentf00ce0aee4cc79f7511ab942b5e02dddf86beae6 (diff)
CDROM method
Author: jgg Date: 1998-12-03 07:29:16 GMT CDROM method
-rw-r--r--apt-pkg/acquire-method.cc55
-rw-r--r--apt-pkg/acquire-method.h5
-rw-r--r--apt-pkg/contrib/strutl.cc9
-rw-r--r--doc/Bugs5
-rw-r--r--methods/cdrom.cc144
-rw-r--r--methods/makefile6
-rw-r--r--test/scratch.cc4
-rw-r--r--test/versions.lst2
8 files changed, 221 insertions, 9 deletions
diff --git a/apt-pkg/acquire-method.cc b/apt-pkg/acquire-method.cc
index bf2de5448..7c3fdecb3 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.9 1998/11/29 01:24:15 jgg Exp $
+// $Id: acquire-method.cc,v 1.10 1998/12/03 07:29:16 jgg Exp $
/* ######################################################################
Acquire Method
@@ -185,6 +185,59 @@ void pkgAcqMethod::URIDone(FetchResult &Res, FetchResult *Alt)
delete Tmp;
}
/*}}}*/
+// AcqMethod::MediaFail - Syncronous request for new media /*{{{*/
+// ---------------------------------------------------------------------
+/* This sends a 403 Media Failure message to the APT and waits for it
+ to be ackd */
+void pkgAcqMethod::MediaFail(string Required,string Drive)
+{
+ char S[1024];
+ snprintf(S,sizeof(S),"403 Media Failure\nMedia: %s\nDrive: %s\n\n",
+ Required.c_str(),Drive.c_str());
+
+ if (write(STDOUT_FILENO,S,strlen(S)) != (signed)strlen(S))
+ exit(100);
+
+ vector<string> MyMessages;
+
+ /* Here we read messages until we find a 603, each non 603 message is
+ appended to the main message list for later processing */
+ while (1)
+ {
+ if (WaitFd(STDIN_FILENO) == false)
+ exit(0);
+
+ if (ReadMessages(STDIN_FILENO,MyMessages) == false)
+ exit(0);
+
+ string Message = MyMessages.front();
+ MyMessages.erase(MyMessages.begin());
+
+ // Fetch the message number
+ char *End;
+ int Number = strtol(Message.c_str(),&End,10);
+ if (End == Message.c_str())
+ {
+ cerr << "Malformed message!" << endl;
+ exit(100);
+ }
+
+ // Change ack
+ if (Number == 603)
+ {
+ while (Message.empty() == false)
+ {
+ Messages.push_back(MyMessages.front());
+ MyMessages.erase(MyMessages.begin());
+ }
+
+ return;
+ }
+
+ Messages.push_back(Message);
+ }
+}
+ /*}}}*/
// AcqMethod::Configuration - Handle the configuration message /*{{{*/
// ---------------------------------------------------------------------
/* This parses each configuration entry and puts it into the _config
diff --git a/apt-pkg/acquire-method.h b/apt-pkg/acquire-method.h
index 9e4ac65b6..08c88265c 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.4 1998/11/29 01:24:16 jgg Exp $
+// $Id: acquire-method.h,v 1.5 1998/12/03 07:29:17 jgg Exp $
/* ######################################################################
Acquire Method - Method helper class + functions
@@ -58,7 +58,8 @@ class pkgAcqMethod
void Fail(string Why, bool Transient = false);
void URIStart(FetchResult &Res);
void URIDone(FetchResult &Res,FetchResult *Alt = 0);
-
+ void MediaFail(string Required,string Drive);
+
public:
enum CnfFlags {SingleInstance = (1<<0),
diff --git a/apt-pkg/contrib/strutl.cc b/apt-pkg/contrib/strutl.cc
index d5f765dd4..273118e9d 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.13 1998/11/05 07:21:44 jgg Exp $
+// $Id: strutl.cc,v 1.14 1998/12/03 07:29:18 jgg Exp $
/* ######################################################################
String Util - Some usefull string functions.
@@ -630,7 +630,7 @@ void URI::CopyFrom(string U)
SingleSlash += 3;
for (; SingleSlash < U.end() && *SingleSlash != '/'; SingleSlash++);
if (SingleSlash > U.end())
- SingleSlash = U.end();
+ SingleSlash = U.end();
// We can now write the access and path specifiers
Access = string(U,0,FirstColon - U.begin());
@@ -640,7 +640,10 @@ void URI::CopyFrom(string U)
Path = "/";
// Now we attempt to locate a user:pass@host fragment
- FirstColon += 3;
+ if (U[1] == '/' && U[2] == '/')
+ FirstColon += 3;
+ else
+ FirstColon += 1;
if (FirstColon >= U.end())
return;
diff --git a/doc/Bugs b/doc/Bugs
index 8513de5b9..89a5a3f71 100644
--- a/doc/Bugs
+++ b/doc/Bugs
@@ -110,7 +110,10 @@
#30027: apt: version comparison bug
Summary: Version compare differs from dpkg
Status: Fixed in all CVS versions.
-
+#30260: apt: wishlist: do not return to main menu without prompting for return
+ Summary: Wants to prompt after dselect update
+ Status: Fixed in v3, use dselect::promptafterupdate "true";
+
-- Silly things
#26592: apt: Problems with ftpd in SunOS 5.6
#29903: apt-get insists onto sending a SIZE command
diff --git a/methods/cdrom.cc b/methods/cdrom.cc
new file mode 100644
index 000000000..0d1e8f031
--- /dev/null
+++ b/methods/cdrom.cc
@@ -0,0 +1,144 @@
+// -*- mode: cpp; mode: fold -*-
+// Description /*{{{*/
+// $Id: cdrom.cc,v 1.1 1998/12/03 07:29:21 jgg Exp $
+/* ######################################################################
+
+ CDROM URI method for APT
+
+ ##################################################################### */
+ /*}}}*/
+// Include Files /*{{{*/
+#include <apt-pkg/acquire-method.h>
+#include <apt-pkg/cdromutl.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/fileutl.h>
+
+#include <sys/stat.h>
+#include <unistd.h>
+ /*}}}*/
+
+class CDROMMethod : public pkgAcqMethod
+{
+ Configuration Database;
+ string CurrentID;
+
+ virtual bool Fetch(FetchItem *Itm);
+ string GetID(string Name);
+
+ public:
+
+ CDROMMethod();
+};
+
+// CDROMMethod::CDROMethod - Constructor /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+CDROMMethod::CDROMMethod() : pkgAcqMethod("1.0",SingleInstance | LocalOnly)
+{
+ // Read the database
+ string DFile = _config->FindFile("Dir::State::cdroms");
+ if (FileExists(DFile) == true)
+ {
+ if (ReadConfigFile(Database,DFile) == false)
+ {
+ _error->Error("Unable to read the cdrom database %s",
+ DFile.c_str());
+ Fail();
+ }
+ }
+};
+ /*}}}*/
+// CDROMMethod::GetID - Get the ID hash for /*{{{*/
+// ---------------------------------------------------------------------
+/* We search the configuration space for the name and then return the ID
+ tag associated with it. */
+string CDROMMethod::GetID(string Name)
+{
+ const Configuration::Item *Top = Database.Tree(0);
+ for (; Top != 0;)
+ {
+ if (Top->Value == Name)
+ return Top->Tag;
+
+ Top = Top->Next;
+ }
+
+ return string();
+}
+ /*}}}*/
+// CDROMMethod::Fetch - Fetch a file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool CDROMMethod::Fetch(FetchItem *Itm)
+{
+ URI Get = Itm->Uri;
+ string File = Get.Path;
+ FetchResult Res;
+
+ /* All IMS queries are returned as a hit, CDROMs are readonly so
+ time stamps never change */
+ if (Itm->LastModified != 0)
+ {
+ Res.LastModified = Itm->LastModified;
+ Res.IMSHit = true;
+ URIDone(Res);
+ return true;
+ }
+
+ string ID = GetID(Get.Host);
+
+ // All non IMS queries for package files fail.
+ if (Itm->IndexFile == true || ID.empty() == false)
+ {
+ Fail("Please use apt-cdrom to make this CD recognized by APT."
+ " apt-get update cannot be used to add new CDs");
+ return true;
+ }
+
+ // We already have a CD inserted, but it is the wrong one
+ if (CurrentID.empty() == false && ID != CurrentID)
+ {
+ Fail("Wrong CD",true);
+ return true;
+ }
+
+ string CDROM = _config->FindDir("Acquire::cdrom::mount","/cdrom/");
+ string NewID;
+ while (1)
+ {
+ if (IdentCdrom(CDROM,NewID) == false)
+ return false;
+
+ // A hit
+ if (NewID == ID)
+ break;
+
+ UnmountCdrom(CDROM);
+ MediaFail(Get.Host,CDROM);
+ MountCdrom(CDROM);
+ }
+
+ // ID matches
+ if (NewID == ID)
+ {
+ Res.Filename = CDROM + File;
+ if (FileExists(Res.Filename) == false)
+ return _error->Error("File not found");
+
+ CurrentID = ID;
+ Res.LastModified = Itm->LastModified;
+ Res.IMSHit = true;
+ URIDone(Res);
+ return true;
+ }
+
+ return _error->Error("CDROM not found");
+}
+ /*}}}*/
+
+int main()
+{
+ CDROMMethod Mth;
+ return Mth.Run();
+}
diff --git a/methods/makefile b/methods/makefile
index b05356bb4..2940b891d 100644
--- a/methods/makefile
+++ b/methods/makefile
@@ -24,6 +24,12 @@ SLIBS = -lapt-pkg
SOURCE = gzip.cc
include $(PROGRAM_H)
+# The cdrom method
+PROGRAM=cdrom
+SLIBS = -lapt-pkg
+SOURCE = cdrom.cc
+include $(PROGRAM_H)
+
# The http method
PROGRAM=http
SLIBS = -lapt-pkg
diff --git a/test/scratch.cc b/test/scratch.cc
index 74c976700..6783f3796 100644
--- a/test/scratch.cc
+++ b/test/scratch.cc
@@ -201,7 +201,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;
@@ -209,7 +209,7 @@ int main(int argc,char *argv[])
cout << Foo.Password << '\'' << endl;
cout << Foo.Port << endl;
- return 0;*/
+ return 0;
pkgInitialize(*_config);
diff --git a/test/versions.lst b/test/versions.lst
index d5d343ba2..5f53f8b2f 100644
--- a/test/versions.lst
+++ b/test/versions.lst
@@ -6,6 +6,8 @@
# 0 means that ver1 = ver2
7.6p2-4 7.6-0 1
1.0.3-3 1.0-1 1
+1.3 1.2.2-2 1
+1.3 1.2.2 1
# Important attributes
- . -1