diff --git a/source/dub/commandline.d b/source/dub/commandline.d index 738f30c..a0e16c6 100644 --- a/source/dub/commandline.d +++ b/source/dub/commandline.d @@ -902,8 +902,9 @@ return 0; // search for the package and filter versions for exact matches - auto search = dub.searchPackages(packageParts.name) - .map!(tup => tup[1].find!(p => p.name == packageParts.name)) + auto basePackageName = getBasePackageName(packageParts.name); + auto search = dub.searchPackages(basePackageName) + .map!(tup => tup[1].find!(p => p.name == basePackageName)) .filter!(ps => !ps.empty); if (search.empty) { logWarn("Package '%s' was neither found locally nor online.", packageParts.name); diff --git a/source/dub/dub.d b/source/dub/dub.d index c8d4845..028066e 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -798,11 +798,12 @@ /// Fetches the package matching the dependency and places it in the specified location. Package fetch(string packageId, const Dependency dep, PlacementLocation location, FetchOptions options, string reason = "") { + auto basePackageName = getBasePackageName(packageId); Json pinfo; PackageSupplier supplier; foreach(ps; m_packageSuppliers){ try { - pinfo = ps.fetchPackageRecipe(packageId, dep, (options & FetchOptions.usePrerelease) != 0); + pinfo = ps.fetchPackageRecipe(basePackageName, dep, (options & FetchOptions.usePrerelease) != 0); if (pinfo.type == Json.Type.null_) continue; supplier = ps; @@ -859,14 +860,14 @@ clean_package_version = clean_package_version.replace("+", "_"); // + has special meaning for Optlink if (!placement.existsFile()) mkdirRecurse(placement.toNativeString()); - NativePath dstpath = placement ~ (packageId ~ "-" ~ clean_package_version); + NativePath dstpath = placement ~ (basePackageName ~ "-" ~ clean_package_version); if (!dstpath.existsFile()) mkdirRecurse(dstpath.toNativeString()); // Support libraries typically used with git submodules like ae. // Such libraries need to have ".." as import path but this can create // import path leakage. - dstpath = dstpath ~ packageId; + dstpath = dstpath ~ basePackageName; import std.datetime : seconds; auto lock = lockFile(dstpath.toNativeString() ~ ".lock", 30.seconds); // possibly wait for other dub instance @@ -881,13 +882,14 @@ { import std.zip : ZipException; - auto path = getTempFile(packageId, ".zip"); - supplier.fetchPackage(path, packageId, dep, (options & FetchOptions.usePrerelease) != 0); // Q: continue on fail? + auto path = getTempFile(basePackageName, ".zip"); + supplier.fetchPackage(path, basePackageName, dep, (options & FetchOptions.usePrerelease) != 0); // Q: continue on fail? scope(exit) std.file.remove(path.toNativeString()); logDiagnostic("Placing to %s...", placement.toNativeString()); try { - return m_packageManager.storeFetchedPackage(path, pinfo, dstpath); + m_packageManager.storeFetchedPackage(path, pinfo, dstpath); + return m_packageManager.getPackage(packageId, ver, dstpath); } catch (ZipException e) { logInfo("Failed to extract zip archive for %s %s...", packageId, ver); // rethrow the exception at the end of the loop @@ -1126,8 +1128,9 @@ Version[] listPackageVersions(string name) { Version[] versions; + auto basePackageName = getBasePackageName(name); foreach (ps; this.m_packageSuppliers) { - try versions ~= ps.getVersions(name); + try versions ~= ps.getVersions(basePackageName); catch (Exception e) { logWarn("Failed to get versions for package %s on provider %s: %s", name, ps.description, e.msg); } diff --git a/test/issue1567-fetch-sub-package.sh b/test/issue1567-fetch-sub-package.sh new file mode 100755 index 0000000..98ec125 --- /dev/null +++ b/test/issue1567-fetch-sub-package.sh @@ -0,0 +1,12 @@ +#!/usr/bin/env bash +. $(dirname "${BASH_SOURCE[0]}")/common.sh +DIR=$(dirname "${BASH_SOURCE[0]}") +packname="fetch-sub-package-dubpackage" +sub_packagename="my-sub-package" + +$DUB remove $packname --non-interactive --version=* 2>/dev/null || true +$DUB fetch "$packname:$sub_packagename" --skip-registry=all --registry=file://"$DIR"/issue1567-fetch-sub-package + +if ! dub remove $packname --non-interactive --version=1.0.1 2>/dev/null; then + die 'DUB did not install package $packname:$sub_packagename.' +fi \ No newline at end of file diff --git a/test/issue1567-fetch-sub-package/.no_build b/test/issue1567-fetch-sub-package/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1567-fetch-sub-package/.no_build diff --git a/test/issue1567-fetch-sub-package/.no_run b/test/issue1567-fetch-sub-package/.no_run new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1567-fetch-sub-package/.no_run diff --git a/test/issue1567-fetch-sub-package/.no_test b/test/issue1567-fetch-sub-package/.no_test new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1567-fetch-sub-package/.no_test diff --git a/test/issue1567-fetch-sub-package/fetch-sub-package-dubpackage-1.0.1.zip b/test/issue1567-fetch-sub-package/fetch-sub-package-dubpackage-1.0.1.zip new file mode 100644 index 0000000..1b4f72b --- /dev/null +++ b/test/issue1567-fetch-sub-package/fetch-sub-package-dubpackage-1.0.1.zip Binary files differ