// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: sourcelist.cc,v 1.5 1998/07/26 04:49:33 jgg Exp $
+// $Id: sourcelist.cc,v 1.17 1999/10/17 07:30:23 jgg Exp $
/* ######################################################################
List of Sources
#include <apt-pkg/error.h>
#include <apt-pkg/fileutl.h>
#include <apt-pkg/configuration.h>
-#include <strutl.h>
+#include <apt-pkg/strutl.h>
#include <fstream.h>
#include <stdio.h>
/* */
bool pkgSourceList::ReadMainList()
{
- return Read(_config->FindDir("Dir::Etc::sourcelist"));
+ return Read(_config->FindFile("Dir::Etc::sourcelist"));
}
/*}}}*/
// SourceList::Read - Parse the sourcelist 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)
debugging. */
ostream &operator <<(ostream &O,pkgSourceList::Item &Itm)
{
- O << Itm.Type << ' ' << Itm.URI << ' ' << Itm.Dist << ' ' << Itm.Section;
+ O << (int)Itm.Type << ' ' << Itm.URI << ' ' << Itm.Dist << ' ' << Itm.Section;
return O;
}
/*}}}*/
return true;
}
- return true;
+ if (S == "deb-src")
+ {
+ Type = DebSrc;
+ return true;
+ }
+
+ return false;
}
/*}}}*/
// SourceList::Item::SetURI - Set the URI /*{{{*/
{
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") + '/';
Res += "Packages";
break;
+
+ case DebSrc:
+ if (Dist[Dist.size() - 1] == '/')
+ Res = URI + Dist;
+ else
+ Res = URI + "dists/" + Dist + '/' + Section +
+ "/source/";
+
+ Res += "Sources";
+ break;
};
return Res;
}
case Deb:
Res += SiteOnly(URI) + ' ';
if (Dist[Dist.size() - 1] == '/')
- Res += Dist;
+ {
+ if (Dist != "/")
+ Res += Dist;
+ }
else
Res += Dist + '/' + Section;
Res += " Packages";
break;
+
+ case DebSrc:
+ Res += SiteOnly(URI) + ' ';
+ if (Dist[Dist.size() - 1] == '/')
+ Res += Dist;
+ else
+ Res += Dist + '/' + Section;
+
+ Res += " Sources";
+ break;
+ };
+ return Res;
+}
+ /*}}}*/
+// SourceList::Item::ReleaseURI - Returns a URI to the release file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+string pkgSourceList::Item::ReleaseURI() const
+{
+ string Res;
+ switch (Type)
+ {
+ case Deb:
+ if (Dist[Dist.size() - 1] == '/')
+ {
+ if (Dist != "/")
+ Res = URI + Dist;
+ else
+ Res = URI;
+ }
+ else
+ Res = URI + "dists/" + Dist + '/' + Section +
+ "/binary-" + _config->Find("APT::Architecture") + '/';
+
+ Res += "Release";
+ break;
+
+ case DebSrc:
+ if (Dist[Dist.size() - 1] == '/')
+ Res = URI + Dist;
+ else
+ Res = URI + "dists/" + Dist + '/' + Section +
+ "/source/";
+
+ Res += "Release";
+ break;
+ };
+ return Res;
+}
+ /*}}}*/
+// SourceList::Item::ReleaseInfo - Shorter version of the URI /*{{{*/
+// ---------------------------------------------------------------------
+/* This is a shorter version that is designed to be < 60 chars or so */
+string pkgSourceList::Item::ReleaseInfo() const
+{
+ string Res;
+ switch (Type)
+ {
+ case Deb:
+ case DebSrc:
+ Res += SiteOnly(URI) + ' ';
+ if (Dist[Dist.size() - 1] == '/')
+ {
+ if (Dist != "/")
+ Res += Dist;
+ }
+ else
+ Res += Dist + '/' + Section;
+
+ Res += " Release";
+ break;
};
return Res;
}
string Res;
switch (Type)
{
+ case DebSrc:
case Deb:
Res += SiteOnly(URI) + ' ';
if (Dist[Dist.size() - 1] == '/')
- Res += Dist;
+ {
+ if (Dist != "/")
+ Res += Dist;
+ }
else
Res += Dist + '/' + Section;
Res += " ";
Res += Ver.ParentPkg().Name();
+ Res += " ";
+ Res += Ver.VerStr();
+
break;
};
return Res;
switch (Type)
{
case Deb:
+ case DebSrc:
Res = URI + File;
break;
};
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;
}
/*}}}*/