Преглед изворни кода

More fixes
Author: jgg
Date: 2000-01-16 05:36:17 GMT
More fixes

Arch Librarian пре 22 година
родитељ
комит
7834cb579f
8 измењених фајлова са 73 додато и 36 уклоњено
  1. 8 3
      apt-pkg/contrib/configuration.cc
  2. 19 6
      apt-pkg/contrib/strutl.cc
  3. 4 4
      apt-pkg/orderlist.cc
  4. 22 13
      cmdline/apt-cdrom.cc
  5. 4 4
      cmdline/indexcopy.cc
  6. 10 0
      debian/changelog
  7. 1 1
      doc/makefile
  8. 5 5
      dselect/install

+ 8 - 3
apt-pkg/contrib/configuration.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: configuration.cc,v 1.13 1999/07/02 23:17:00 jgg Exp $
+// $Id: configuration.cc,v 1.14 2000/01/16 05:36:17 jgg Exp $
 /* ######################################################################
 
    Configuration Class
@@ -322,8 +322,9 @@ bool ReadConfigFile(Configuration &Conf,string FName)
 	    break;
 	 }
       }
-      
+
       // Look for multi line comments
+      InQuote = false;
       for (char *I = Buffer; *I != 0; I++)
       {
 	 if (*I == '"')
@@ -357,9 +358,13 @@ bool ReadConfigFile(Configuration &Conf,string FName)
 	 continue;
       
       // We now have a valid line fragment
+      InQuote = false;
       for (char *I = Buffer; *I != 0;)
       {
-	 if (*I == '{' || *I == ';' || *I == '}')
+	 if (*I == '"')
+	    InQuote = !InQuote;
+	 
+	 if (InQuote == false && (*I == '{' || *I == ';' || *I == '}'))
 	 {
 	    // Put the last fragement into the buffer
 	    char *Start = Buffer;

+ 19 - 6
apt-pkg/contrib/strutl.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: strutl.cc,v 1.33 2000/01/14 06:26:37 jgg Exp $
+// $Id: strutl.cc,v 1.34 2000/01/16 05:36:17 jgg Exp $
 /* ######################################################################
 
    String Util - Some usefull string functions.
@@ -87,7 +87,8 @@ char *_strtabexpand(char *String,size_t Len)
 // ---------------------------------------------------------------------
 /* This grabs a single word, converts any % escaped characters to their
    proper values and advances the pointer. Double quotes are understood
-   and striped out as well. This is for URI/URL parsing. */
+   and striped out as well. This is for URI/URL parsing. It also can 
+   understand [] brackets.*/
 bool ParseQuoteWord(const char *&String,string &Res)
 {
    // Skip leading whitespace
@@ -101,7 +102,13 @@ bool ParseQuoteWord(const char *&String,string &Res)
    {
       if (*C == '"')
       {
-	 for (C++;*C != 0 && *C != '"'; C++);
+	 for (C++; *C != 0 && *C != '"'; C++);
+	 if (*C == 0)
+	    return false;
+      }
+      if (*C == '[')
+      {
+	 for (C++; *C != 0 && *C != ']'; C++);
 	 if (*C == 0)
 	    return false;
       }
@@ -867,10 +874,10 @@ URI::operator string()
       Res = Access + ':';
    
    if (Host.empty() == false)
-   {
+   {	 
       if (Access.empty() == false)
 	 Res += "//";
-      
+          
       if (User.empty() == false)
       {
 	 Res +=  User;
@@ -879,7 +886,13 @@ URI::operator string()
 	 Res += "@";
       }
       
-      Res += Host;
+      // Add RFC 2732 escaping characters
+      if (Access.empty() == false &&
+	  (Host.find('/') != string::npos || Host.find(':') != string::npos))
+	 Res += '[' + Host + ']';
+      else
+	 Res += Host;
+      
       if (Port != 0)
       {
 	 char S[30];

+ 4 - 4
apt-pkg/orderlist.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: orderlist.cc,v 1.9 1999/11/04 06:05:02 jgg Exp $
+// $Id: orderlist.cc,v 1.10 2000/01/16 05:36:17 jgg Exp $
 /* ######################################################################
 
    Order List - Represents and Manipulates an ordered list of packages.
@@ -209,7 +209,7 @@ bool pkgOrderList::OrderUnpack(string *FileList)
    for (iterator I = List; I != End; I++)
    {
       PkgIterator P(Cache,*I);
-      cout << P.Name() << endl;
+      cout << P.Name() << ' ' << IsMissing(P) << endl;
    }*/
 
    return true;
@@ -312,14 +312,14 @@ int pkgOrderList::OrderCompareA(const void *a, const void *b)
 
    // We order packages with a set state toward the front
    int Res;
-   if ((Res = BoolCompare(Me->IsNow(A),Me->IsNow(B))) == 0)
+   if ((Res = BoolCompare(Me->IsNow(A),Me->IsNow(B))) != 0)
       return -1*Res;
    
    // We order missing files to toward the end
    if (Me->FileList != 0)
    {
       if ((Res = BoolCompare(Me->IsMissing(A),
-			     Me->IsMissing(B))) == 0)
+			     Me->IsMissing(B))) != 0)
 	 return Res;
    }
    

+ 22 - 13
cmdline/apt-cdrom.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: apt-cdrom.cc,v 1.32 1999/09/03 05:46:48 jgg Exp $
+// $Id: apt-cdrom.cc,v 1.33 2000/01/16 05:36:17 jgg Exp $
 /* ######################################################################
    
    APT CDROM - Tool for handling APT's CDROM database.
@@ -189,6 +189,8 @@ int Score(string Path)
       Res += 2;
    if (Path.find("/source/") != string::npos)
       Res += 1;
+   if (Path.find("/debian/") != string::npos)
+      Res -= 1;
    return Res;
 }
 									/*}}}*/
@@ -366,7 +368,8 @@ bool WriteSourceList(string Name,vector<string> &List,bool Source)
 			   "Failed to open %s.new",File.c_str());
 
    // Create a short uri without the path
-   string ShortURI = "cdrom:" + Name + "/";   
+   string ShortURI = "cdrom:[" + Name + "]/";   
+   string ShortURI2 = "cdrom:" + Name + "/";     // For Compatibility
 
    const char *Type;
    if (Source == true)
@@ -398,8 +401,8 @@ bool WriteSourceList(string Name,vector<string> &List,bool Source)
 	    string::size_type Space = (*I).find(' ');
 	    if (Space == string::npos)
 	       return _error->Error("Internal error");
-	    Out << Type << " \"cdrom:" << Name << "/" << string(*I,0,Space) << 
-	       "\" " << string(*I,Space+1) << endl;
+	    Out << Type << " cdrom:[" << Name << "]/" << string(*I,0,Space) <<
+	       " " << string(*I,Space+1) << endl;
 	 }
       }
       First = false;
@@ -416,7 +419,8 @@ bool WriteSourceList(string Name,vector<string> &List,bool Source)
       }
 
       // Emit lines like this one
-      if (cType != Type || string(URI,0,ShortURI.length()) != ShortURI)
+      if (cType != Type || (string(URI,0,ShortURI.length()) != ShortURI &&
+	  string(URI,0,ShortURI.length()) != ShortURI2))
       {
 	 Out << Buffer << endl;
 	 continue;
@@ -432,8 +436,8 @@ bool WriteSourceList(string Name,vector<string> &List,bool Source)
 	 if (Space == string::npos)
 	    return _error->Error("Internal error");
 	 
-	 Out << "deb \"cdrom:" << Name << "/" << string(*I,0,Space) << 
-	    "\" " << string(*I,Space+1) << endl;
+	 Out << "deb cdrom:[" << Name << "]/" << string(*I,0,Space) << 
+	    " " << string(*I,Space+1) << endl;
       }
    }
    
@@ -597,11 +601,11 @@ bool DoAdd(CommandLine &)
    
    string::iterator J = Name.begin();
    for (; J != Name.end(); J++)
-      if (*J == '/' || *J == '"' || *J == ':')
+      if (*J == '"' || *J == ']' || *J == '[')
 	 *J = '_';
    
    Database.Set("CD::" + ID,Name);
-   cout << "This Disc is called '" << Name << "'" << endl;
+   cout << "This Disc is called:" << endl << " '" << Name << "'" << endl;
    
    // Copy the package files to the state directory
    PackageCopy Copy;
@@ -633,8 +637,8 @@ bool DoAdd(CommandLine &)
       if (Space == string::npos)
 	 return _error->Error("Internal error");
 
-      cout << "deb \"cdrom:" << Name << "/" << string(*I,0,Space) << 
-	 "\" " << string(*I,Space+1) << endl;
+      cout << "deb cdrom:[" << Name << "]/" << string(*I,0,Space) << 
+	 " " << string(*I,Space+1) << endl;
    }
 
    for (vector<string>::iterator I = sList.begin(); I != sList.end(); I++)
@@ -643,11 +647,16 @@ bool DoAdd(CommandLine &)
       if (Space == string::npos)
 	 return _error->Error("Internal error");
 
-      cout << "deb-src \"cdrom:" << Name << "/" << string(*I,0,Space) << 
-	 "\" " << string(*I,Space+1) << endl;
+      cout << "deb-src cdrom:[" << Name << "]/" << string(*I,0,Space) << 
+	 " " << string(*I,Space+1) << endl;
    }
 
    cout << "Repeat this process for the rest of the CDs in your set." << endl;
+
+   // Unmount and finish
+   if (_config->FindB("APT::CDROM::NoMount",false) == false)
+      UnmountCdrom(CDROM);
+   
    return true;
 }
 									/*}}}*/

+ 4 - 4
cmdline/indexcopy.cc

@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description								/*{{{*/
-// $Id: indexcopy.cc,v 1.3 1999/12/10 23:40:29 jgg Exp $
+// $Id: indexcopy.cc,v 1.4 2000/01/16 05:36:17 jgg Exp $
 /* ######################################################################
 
    Index Copying - Aid for copying and verifying the index files
@@ -113,7 +113,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List)
       
       // Open the output file
       char S[400];
-      sprintf(S,"cdrom:%s/%s%s",Name.c_str(),(*I).c_str() + CDROM.length(),
+      sprintf(S,"cdrom:[%s]/%s%s",Name.c_str(),(*I).c_str() + CDROM.length(),
 	      GetFileName());
       string TargetF = _config->FindDir("Dir::State::lists") + "partial/";
       TargetF += URItoFileName(S);
@@ -231,7 +231,7 @@ bool IndexCopy::CopyPackages(string CDROM,string Name,vector<string> &List)
 	    return _error->Errno("rename","Failed to rename");
 
 	 // Copy the release file
-	 sprintf(S,"cdrom:%s/%sRelease",Name.c_str(),(*I).c_str() + CDROM.length());
+	 sprintf(S,"cdrom:[%s]/%sRelease",Name.c_str(),(*I).c_str() + CDROM.length());
 	 string TargetF = _config->FindDir("Dir::State::lists") + "partial/";
 	 TargetF += URItoFileName(S);
 	 if (FileExists(*I + "Release") == true)
@@ -386,7 +386,7 @@ void IndexCopy::ConvertToSourceList(string CD,string &Path)
    // Not a dists type.
    if (stringcmp(Path.begin(),Path.begin()+strlen("dists/"),"dists/") != 0)
       return;
-
+      
    // Isolate the dist
    string::size_type Slash = strlen("dists/");
    string::size_type Slash2 = Path.find('/',Slash + 1);

+ 10 - 0
debian/changelog

@@ -1,3 +1,13 @@
+apt (0.3.16.1) unstable; urgency=low
+
+  * RFC 2732 usage for CDROM URIs and fixes to apt-cdrom
+  * Fixed the configuration parser to not blow up if ; is in the config 
+    string
+  * Applied visual patch to dselect install script . Closes #55214
+  * Included the configure-index example
+  
+ -- Ben Gertzfield <che@debian.org>  Fri, 14 Jan 2000 08:04:15 -0800
+ 
 apt (0.3.16) unstable; urgency=low
  
   * Made --no-download work. Closes: #52993

+ 1 - 1
doc/makefile

@@ -15,6 +15,6 @@ SOURCE = apt-cache.8 apt-get.8 apt-cdrom.8 apt.conf.5 sources.list.5 apt-config.
 include $(YODL_MANPAGE_H)
 
 # Examples
-SOURCE = examples/apt.conf examples/sources.list
+SOURCE = examples/apt.conf examples/sources.list examples/configure-index
 TO = $(DOC)
 include $(COPY_H)

+ 5 - 5
dselect/install

@@ -20,15 +20,15 @@ yesno() {
 	local ans def defp
 	if [ "$2" ];then
 		case $2 in
-			Y|y)	defp="(Y/n)" def=y;;
-			N|n)	defp="(y/N)" def=n;;
+			Y|y)	defp="[Y/n]" def=y;;
+			N|n)	defp="[y/N]" def=n;;
 			*)	echo "Bad default setting!" 1>&2; exit 1;;
 		esac
 	else
-		defp="(y/N)" def=n
+		defp="[y/N]" def=n
 	fi
 	while :;do
-		echo -n "$1$defp" 1>&3
+		echo -n "$1 $defp" 1>&3
 		read ans
 		case $ans in
 			Y|y|N|n)	break;;
@@ -72,7 +72,7 @@ if [ $RES -eq 0 ]; then
        ;;
      prompt)
        exec 3>&1
-       if [ `yesno "Do you want to erase the downloaded .deb files " y` = y ]; then
+       if [ `yesno "Do you want to erase the downloaded .deb files?" y` = y ]; then
           $APTGET clean && echo "Press enter to continue." && read RES && exit 0;
        fi
        ;;