]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/sourcelist.cc
Moved time handling, fixed makefiles
[apt.git] / apt-pkg / sourcelist.cc
index bea2d91c82f8dff333f756c998063e4ce2ec8a9b..1fdbd834e7589f7facd0608c78fc962f0c5eda0a 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: sourcelist.cc,v 1.12 1999/03/05 19:36:49 jgg Exp $
+// $Id: sourcelist.cc,v 1.17 1999/10/17 07:30:23 jgg Exp $
 /* ######################################################################
 
    List of Sources
@@ -73,7 +73,7 @@ bool pkgSourceList::Read(string File)
       string Type;
       string URI;
       Item Itm;
-      char *C = Buffer;
+      const char *C = Buffer;
       if (ParseQuoteWord(C,Type) == false)
         return _error->Error("Malformed line %u in source list %s (type)",CurLine,File.c_str());
       if (ParseQuoteWord(C,URI) == false)
@@ -169,7 +169,12 @@ string pkgSourceList::Item::PackagesURI() const
    {
       case Deb:
       if (Dist[Dist.size() - 1] == '/')
-        Res = URI + Dist;
+      {
+        if (Dist != "/")
+           Res = URI + Dist;
+        else 
+           Res = URI;
+      }      
       else
         Res = URI + "dists/" + Dist + '/' + Section +
         "/binary-" + _config->Find("APT::Architecture") + '/';
@@ -201,7 +206,10 @@ string pkgSourceList::Item::PackagesInfo() const
       case Deb:
       Res += SiteOnly(URI) + ' ';
       if (Dist[Dist.size() - 1] == '/')
-        Res += Dist;
+      {
+        if (Dist != "/")
+           Res += Dist;
+      }      
       else
         Res += Dist + '/' + Section;
       
@@ -231,7 +239,12 @@ string pkgSourceList::Item::ReleaseURI() const
    {
       case Deb:
       if (Dist[Dist.size() - 1] == '/')
-        Res = URI + Dist;
+      {
+        if (Dist != "/")
+           Res = URI + Dist;
+        else
+           Res = URI;
+      }      
       else
         Res = URI + "dists/" + Dist + '/' + Section +
         "/binary-" + _config->Find("APT::Architecture") + '/';
@@ -264,7 +277,10 @@ string pkgSourceList::Item::ReleaseInfo() const
       case DebSrc:
       Res += SiteOnly(URI) + ' ';
       if (Dist[Dist.size() - 1] == '/')
-        Res += Dist;
+      {
+        if (Dist != "/")
+           Res += Dist;
+      }      
       else
         Res += Dist + '/' + Section;
       
@@ -286,7 +302,10 @@ string pkgSourceList::Item::ArchiveInfo(pkgCache::VerIterator Ver) const
       case Deb:
       Res += SiteOnly(URI) + ' ';
       if (Dist[Dist.size() - 1] == '/')
-        Res += Dist;
+      {
+        if (Dist != "/")
+           Res += Dist;
+      }      
       else
         Res += Dist + '/' + Section;
       
@@ -316,20 +335,46 @@ string pkgSourceList::Item::ArchiveURI(string File) const
    return Res;
 }
                                                                        /*}}}*/
+// SourceList::Item::SourceInfo        - Returns an info line for a source     /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgSourceList::Item::SourceInfo(string Pkg,string Ver,string Comp) const
+{
+   string Res;
+   switch (Type)
+   {
+      case DebSrc:
+      case Deb:
+      Res += SiteOnly(URI) + ' ';
+      if (Dist[Dist.size() - 1] == '/')
+      {
+        if (Dist != "/")
+           Res += Dist;
+      }      
+      else
+        Res += Dist + '/' + Section;
+      
+      Res += " ";
+      Res += Pkg;
+      Res += " ";
+      Res += Ver;
+      if (Comp.empty() == false)
+        Res += " (" + Comp + ")";
+      break;
+   };
+   return Res;
+}
+                                                                       /*}}}*/
 // SourceList::Item::SiteOnly - Strip off the path part of a URI       /*{{{*/
 // ---------------------------------------------------------------------
 /* */
 string pkgSourceList::Item::SiteOnly(string URI) const
 {
-   unsigned int Pos = URI.find(':');
-   if (Pos == string::npos || Pos + 3 > URI.length())
-      return URI;
-   if (URI[Pos + 1] != '/' || URI[Pos + 2] != '/')
-      return URI;
-
-   Pos = URI.find('/',Pos + 3);
-   if (Pos == string::npos)
-      return URI;
-   return string(URI,0,Pos);
+   ::URI U(URI);
+   U.User = string();
+   U.Password = string();
+   U.Path = string();
+   U.Port = 0;
+   return U;
 }
                                                                        /*}}}*/