diff --git a/source/dub/commandline.d b/source/dub/commandline.d index a3a6444..98e657d 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -194,7 +194,7 @@ } else { // initialize DUB auto package_suppliers = options.registry_urls.map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))).array; - dub = new Dub(package_suppliers, options.root_path); + dub = new Dub(package_suppliers, options.root_path, options.skipRegistry); dub.dryRun = options.annotate; // make the CWD package available so that for example sub packages can reference their @@ -231,12 +231,19 @@ bool help, annotate, bare; string[] registry_urls; string root_path; + SkipRegistry skipRegistry = SkipRegistry.none; void prepare(CommandArgs args) { args.getopt("h|help", &help, ["Display general or command specific help"]); args.getopt("root", &root_path, ["Path to operate in instead of the current working dir"]); args.getopt("registry", ®istry_urls, ["Search the given DUB registry URL first when resolving dependencies. Can be specified multiple times."]); + args.getopt("skip-registry", &skipRegistry, [ + "Skips searching certain package registries for dependencies:", + " none: Search all configured registries (default)", + " standard: Don't search on "~defaultRegistryURL, + " all: Search none of the configured registries", + ]); args.getopt("annotate", &annotate, ["Do not perform any action, just print what would be done"]); args.getopt("bare", &bare, ["Read only packages contained in the current directory"]); args.getopt("v|verbose", &verbose, ["Print diagnostic output"]); diff --git a/source/dub/dub.d b/source/dub/dub.d index 6992d4d..82927ec 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -39,14 +39,14 @@ // Workaround for libcurl liker errors when building with LDC version (LDC) pragma(lib, "curl"); +enum defaultRegistryURL = "http://code.dlang.org/"; /// The default supplier for packages, which is the registry /// hosted by code.dlang.org. PackageSupplier[] defaultPackageSuppliers() { - URL url = URL.parse("http://code.dlang.org/"); - logDiagnostic("Using dub registry url '%s'", url); - return [new RegistryPackageSupplier(url)]; + logDiagnostic("Using dub registry url '%s'", defaultRegistryURL); + return [new RegistryPackageSupplier(URL(defaultRegistryURL))]; } /// Option flags for fetch @@ -77,7 +77,7 @@ /// Initiales the package manager for the vibe application /// under root. - this(PackageSupplier[] additional_package_suppliers = null, string root_path = ".") + this(PackageSupplier[] additional_package_suppliers = null, string root_path = ".", SkipRegistry skip_registry = SkipRegistry.none) { m_rootPath = Path(root_path); if (!m_rootPath.absolute) m_rootPath = Path(getcwd()) ~ m_rootPath; @@ -98,15 +98,23 @@ 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 => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))) - .array; - if (auto pp = "registryUrls" in m_systemConfig) - ps ~= deserializeJson!(string[])(*pp) - .map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))) - .array; - ps ~= defaultPackageSuppliers(); + + if (skip_registry < SkipRegistry.all) { + if (auto pp = "registryUrls" in m_userConfig) + ps ~= deserializeJson!(string[])(*pp) + .map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))) + .array; + } + + if (skip_registry < SkipRegistry.all) { + if (auto pp = "registryUrls" in m_systemConfig) + ps ~= deserializeJson!(string[])(*pp) + .map!(url => cast(PackageSupplier)new RegistryPackageSupplier(URL(url))) + .array; + } + + if (skip_registry < SkipRegistry.standard) + ps ~= defaultPackageSuppliers(); auto cacheDir = m_userDubPath ~ "cache/"; foreach (p; ps) @@ -873,6 +881,12 @@ useCachedResult = 1<<6, /// Use cached information stored with the package to determine upgrades } +enum SkipRegistry { + none, + standard, + all +} + class DependencyVersionResolver : DependencyResolver!(Dependency, Dependency) { protected { Dub m_dub;