diff --git a/source/app.d b/source/app.d index 9ae9af6..1edf84b 100644 --- a/source/app.d +++ b/source/app.d @@ -16,6 +16,7 @@ import dub.internal.vibecompat.core.log; import dub.internal.vibecompat.inet.url; import dub.package_; +import dub.packagesupplier; import dub.project; import dub.registry; import dub.version_; @@ -52,6 +53,7 @@ bool print_platform, print_builds, print_configs; bool install_system = false, install_local = false; string install_version; + string[] registry_urls; getopt(args, "v|verbose", &verbose, "vverbose", &vverbose, @@ -70,7 +72,8 @@ "print-platform", &print_platform, "system", &install_system, "local", &install_local, - "version", &install_version + "version", &install_version, + "registry", ®istry_urls ); if( vverbose ) loglevel = LogLevel.debug_; @@ -106,7 +109,7 @@ logInfo(""); } - Dub dub = new Dub; + Dub dub = new Dub(registry_urls.map!(url => cast(PackageSupplier)new RegistryPS(Url(url))).array); string def_config; bool loadCwdPackage() @@ -334,6 +337,8 @@ --vverbose Also output trace messages (produces a lot of output) -q --quiet Only output warnings and errors --vquiet No output + --registry=URL Search the given DUB registry URL first when resolving + dependencies. Can be specified multiple times. Build/run options: --build=NAME Specifies the type of build to perform. Note that diff --git a/source/dub/dub.d b/source/dub/dub.d index 5082924..3c55431 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -61,7 +61,7 @@ /// Initiales the package manager for the vibe application /// under root. - this(PackageSupplier[] ps = defaultPackageSuppliers()) + this(PackageSupplier[] additional_package_suppliers = null) { m_cwd = Path(getcwd()); @@ -78,6 +78,11 @@ m_userConfig = jsonFromFile(m_userDubPath ~ "settings.json", true); m_systemConfig = jsonFromFile(m_systemDubPath ~ "settings.json", true); + PackageSupplier[] ps = additional_package_suppliers; + if (auto pp = "registryUrls" in m_userConfig) ps ~= deserializeJson!(string[])(*pp).map!(url => new RegistryPS(Url(url))).array; + if (auto pp = "registryUrls" in m_systemConfig) ps ~= deserializeJson!(string[])(*pp).map!(url => new RegistryPS(Url(url))).array; + ps ~= defaultPackageSuppliers(); + m_packageSuppliers = ps; m_packageManager = new PackageManager(m_userDubPath, m_systemDubPath); updatePackageSearchPath(); diff --git a/source/dub/packagesupplier.d b/source/dub/packagesupplier.d index f6f08e2..e71d0d7 100644 --- a/source/dub/packagesupplier.d +++ b/source/dub/packagesupplier.d @@ -27,11 +27,15 @@ /// returns the metadata for the package Json getPackageDescription(const string packageId, const Dependency dep); + + string toString(); } class FSPackageSupplier : PackageSupplier { private { Path m_path; } this(Path root) { m_path = root; } + + override string toString() { return "file repository at "~m_path.toNativeString(); } void retrievePackage(const Path path, const string packageId, const Dependency dep) { enforce(path.absolute); diff --git a/source/dub/project.d b/source/dub/project.d index aa1b7db..05e1920 100644 --- a/source/dub/project.d +++ b/source/dub/project.d @@ -412,15 +412,15 @@ if( !p ){ try { - logDiagnostic("using package from registry"); - foreach(ps; packageSuppliers){ + logDiagnostic("Fechting package %s (%d suppliers registered)", pkg, packageSuppliers.length); + foreach (ps; packageSuppliers) { try { p = new Package(ps.getPackageDescription(ppath[0], reqDep.dependency)); foreach (spn; ppath[1 .. $]) p = p.getSubPackage(spn); break; - } catch(Exception e) { - logDiagnostic("No metadata for %s: %s", ps.classinfo.name, e.msg); + } catch (Exception e) { + logDiagnostic("No metadata for %s: %s", ps.toString(), e.msg); } } enforce(p !is null, "Could not find package candidate for "~pkg~" "~reqDep.dependency.toString()); diff --git a/source/dub/registry.d b/source/dub/registry.d index 99260c2..5e0d431 100644 --- a/source/dub/registry.d +++ b/source/dub/registry.d Binary files differ