diff --git a/source/dub/dub.d b/source/dub/dub.d index 5cbe3af..97d87fc 100644 --- a/source/dub/dub.d +++ b/source/dub/dub.d @@ -168,7 +168,7 @@ else m_packageSuppliers = getPackageSuppliers(additional_package_suppliers, skip_registry); - m_packageManager = new PackageManager(m_dirs.localRepository, m_dirs.systemSettings); + m_packageManager = new PackageManager(m_rootPath, m_dirs.localRepository, m_dirs.systemSettings); auto ccps = m_config.customCachePaths; if (ccps.length) @@ -260,7 +260,7 @@ { init(NativePath()); m_overrideSearchPath = override_path; - m_packageManager = new PackageManager(NativePath(), NativePath(), false); + m_packageManager = new PackageManager(NativePath(), NativePath(), NativePath(), false); updatePackageSearchPath(); } @@ -862,7 +862,7 @@ NativePath placement; final switch (location) { - case PlacementLocation.local: placement = m_rootPath; break; + case PlacementLocation.local: placement = m_rootPath ~ ".dub/packages/"; break; case PlacementLocation.user: placement = m_dirs.localRepository ~ "packages/"; break; case PlacementLocation.system: placement = m_dirs.systemSettings ~ "packages/"; break; } diff --git a/source/dub/generators/build.d b/source/dub/generators/build.d index 5a92dbf..5f54d4a 100644 --- a/source/dub/generators/build.d +++ b/source/dub/generators/build.d @@ -623,7 +623,7 @@ auto desc = parseJsonString(`{"name": "test", "targetType": "library", "sourceFiles": ["foo.d", "`~libfile~`"]}`); auto pack = new Package(desc, NativePath("/tmp/fooproject")); - auto pman = new PackageManager(NativePath("/tmp/foo/"), NativePath("/tmp/foo/"), false); + auto pman = new PackageManager(pack.path, NativePath("/tmp/foo/"), NativePath("/tmp/foo/"), false); auto prj = new Project(pman, pack); final static class TestCompiler : GDCCompiler { diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index c06da9c..ae03dbf 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -39,9 +39,20 @@ this(NativePath user_path, NativePath system_path, bool refresh_packages = true) { - m_repositories.length = LocalPackageType.max+1; - m_repositories[LocalPackageType.user] = Repository(user_path ~ "packages/"); - m_repositories[LocalPackageType.system] = Repository(system_path ~ "packages/"); + m_repositories = [ + Repository(user_path ~ "packages/"), + Repository(system_path ~ "packages/")]; + + if (refresh_packages) refresh(true); + } + + this(NativePath package_path, NativePath user_path, NativePath system_path, bool refresh_packages = true) + { + m_repositories = [ + Repository(package_path ~ ".dub/packages/"), + Repository(user_path ~ "packages/"), + Repository(system_path ~ "packages/")]; + if (refresh_packages) refresh(true); } @@ -615,6 +626,7 @@ } scanLocalPackages(LocalPackageType.system); scanLocalPackages(LocalPackageType.user); + scanLocalPackages(LocalPackageType.package_); auto old_packages = m_packages; @@ -681,6 +693,7 @@ } } } + loadOverrides(LocalPackageType.package_); loadOverrides(LocalPackageType.user); loadOverrides(LocalPackageType.system); } @@ -813,6 +826,7 @@ } enum LocalPackageType { + package_, user, system } diff --git a/test/issue1180-local-cache-broken.sh b/test/issue1180-local-cache-broken.sh new file mode 100755 index 0000000..e46970a --- /dev/null +++ b/test/issue1180-local-cache-broken.sh @@ -0,0 +1,20 @@ +#!/usr/bin/env bash +DIR=$(dirname "${BASH_SOURCE[0]}") + +. "$DIR"/common.sh + +PORT=$(($$ + 1024)) # PID + 1024 +"$DUB" remove maven-dubpackage --root="$DIR/issue1180-local-cache-broken" --non-interactive --version=* 2>/dev/null || true + +"$DUB" build --single "$DIR"/test_registry.d +"$DIR"/test_registry --folder="$DIR/issue1416-maven-repo-pkg-supplier" --port=$PORT & +PID=$! +sleep 1 +trap 'kill $PID 2>/dev/null || true' exit + +echo "Trying to download maven-dubpackage (1.0.5)" +"$DUB" upgrade --root="$DIR/issue1180-local-cache-broken" --cache=local --skip-registry=all --registry=mvn+http://localhost:$PORT/maven/release/dubpackages + +if ! "$DUB" remove maven-dubpackage --root="$DIR/issue1180-local-cache-broken" --non-interactive --version=1.0.5 2>/dev/null; then + die 'DUB did not install package from maven registry.' +fi diff --git a/test/issue1180-local-cache-broken.sh.min_frontend b/test/issue1180-local-cache-broken.sh.min_frontend new file mode 100644 index 0000000..bb0a2e1 --- /dev/null +++ b/test/issue1180-local-cache-broken.sh.min_frontend @@ -0,0 +1 @@ +2.076 diff --git a/test/issue1180-local-cache-broken/.gitignore b/test/issue1180-local-cache-broken/.gitignore new file mode 100644 index 0000000..0fd9d37 --- /dev/null +++ b/test/issue1180-local-cache-broken/.gitignore @@ -0,0 +1,4 @@ +test +*.o +*.exe +.dub \ No newline at end of file diff --git a/test/issue1180-local-cache-broken/.no_build b/test/issue1180-local-cache-broken/.no_build new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/test/issue1180-local-cache-broken/.no_build diff --git a/test/issue1180-local-cache-broken/dub.json b/test/issue1180-local-cache-broken/dub.json new file mode 100644 index 0000000..495617d --- /dev/null +++ b/test/issue1180-local-cache-broken/dub.json @@ -0,0 +1,7 @@ +{ + "name": "test", + "dependencies": { + "maven-dubpackage": "1.0.5" + } + +} \ No newline at end of file diff --git a/test/issue1180-local-cache-broken/source/app.d b/test/issue1180-local-cache-broken/source/app.d new file mode 100644 index 0000000..ef93217 --- /dev/null +++ b/test/issue1180-local-cache-broken/source/app.d @@ -0,0 +1 @@ +void main(){} \ No newline at end of file diff --git a/test/issue674-concurrent-dub.sh b/test/issue674-concurrent-dub.sh index d49bdd3..8f59ab7 100755 --- a/test/issue674-concurrent-dub.sh +++ b/test/issue674-concurrent-dub.sh @@ -16,4 +16,4 @@ pid2=$! wait $pid1 wait $pid2 -[ -d ${TMPDIR}/bloom* ] +[ -d ${TMPDIR}/.dub/packages/bloom* ] \ No newline at end of file