|
|
@@ -28,6 +28,8 @@ import ag.logging; |
|
|
import ag.backend.intf;
|
|
|
import ag.backend.debian.tagfile;
|
|
|
import ag.backend.debian.debpkg;
|
|
|
+import ag.config;
|
|
|
+import ag.utils : isRemote, downloadFile;
|
|
|
|
|
|
|
|
|
class DebianPackageIndex : PackageIndex
|
|
|
@@ -37,14 +39,18 @@ private: |
|
|
string rootDir;
|
|
|
Package[][string] pkgCache;
|
|
|
bool[string] indexChanged;
|
|
|
+ string tmpDir;
|
|
|
|
|
|
public:
|
|
|
|
|
|
this (string dir)
|
|
|
{
|
|
|
this.rootDir = dir;
|
|
|
- if (!std.file.exists (dir))
|
|
|
+ if (!dir.isRemote && !std.file.exists (dir))
|
|
|
throw new Exception ("Directory '%s' does not exist.".format (dir));
|
|
|
+
|
|
|
+ auto conf = Config.get ();
|
|
|
+ tmpDir = buildPath (conf.getTmpDir (), dir.baseName);
|
|
|
}
|
|
|
|
|
|
void release ()
|
|
|
@@ -55,7 +61,19 @@ public: |
|
|
|
|
|
private void loadPackageLongDescs (Package[string] pkgs, string suite, string section)
|
|
|
{
|
|
|
- auto enDescFname = buildPath (rootDir, "dists", suite, section, "i18n", "Translation-en.bz2");
|
|
|
+ immutable auto enDescPath = buildPath ("dists", suite, section, "i18n", "Translation-en.xz");
|
|
|
+
|
|
|
+ string enDescFname;
|
|
|
+
|
|
|
+ if (rootDir.isRemote) {
|
|
|
+ enDescFname = buildPath (tmpDir, enDescPath);
|
|
|
+ immutable auto uri = buildPath (rootDir, enDescPath);
|
|
|
+
|
|
|
+ downloadFile (uri, enDescFname);
|
|
|
+ } else {
|
|
|
+ enDescFname = buildPath (rootDir, enDescPath);
|
|
|
+ }
|
|
|
+
|
|
|
if (!std.file.exists (enDescFname)) {
|
|
|
logDebug ("No long descriptions for %s/%s", suite, section);
|
|
|
return;
|
|
|
@@ -116,10 +134,38 @@ public: |
|
|
|
|
|
private string getIndexFile (string suite, string section, string arch)
|
|
|
{
|
|
|
- auto binDistsPath = buildPath (rootDir, "dists", suite, section, "binary-%s".format (arch));
|
|
|
- auto indexFname = buildPath (binDistsPath, "Packages.gz");
|
|
|
- if (!std.file.exists (indexFname))
|
|
|
- indexFname = buildPath (binDistsPath, "Packages.xz");
|
|
|
+ auto path = buildPath ("dists", suite, section, "binary-%s".format (arch));
|
|
|
+ auto binDistsPath = buildPath (rootDir, path);
|
|
|
+
|
|
|
+ string indexFname;
|
|
|
+
|
|
|
+ if (rootDir.isRemote) {
|
|
|
+ import std.file;
|
|
|
+ import std.net.curl : CurlException;
|
|
|
+
|
|
|
+ foreach (string ext; ["xz", "gz"]) {
|
|
|
+ try {
|
|
|
+ indexFname = buildPath (tmpDir, path, format ("Packages.%s", ext));
|
|
|
+ immutable auto uri = buildPath (binDistsPath, format ("Packages.%s", ext));
|
|
|
+
|
|
|
+ /* This should use download(), but that doesn't throw errors */
|
|
|
+ downloadFile (uri, indexFname);
|
|
|
+
|
|
|
+ break;
|
|
|
+ } catch (CurlException ex) {
|
|
|
+ logDebug ("Couldn't download: %s", ex.msg);
|
|
|
+ indexFname = null;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ indexFname = buildPath (binDistsPath, "Packages.gz");
|
|
|
+ if (!std.file.exists (indexFname))
|
|
|
+ indexFname = buildPath (binDistsPath, "Packages.xz");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (indexFname.empty)
|
|
|
+ throw new Exception (format ("Couldn't download index file for %s/%s/%s", suite, section, arch));
|
|
|
+
|
|
|
return indexFname;
|
|
|
}
|
|
|
|
|
|
|
You can omit the "auto" here -
immutable x = 5;works fine as a shortcut toimmutable auto x = 5;.