diff --git a/source/dub/packagemanager.d b/source/dub/packagemanager.d index 6d20401..bc3a737 100644 --- a/source/dub/packagemanager.d +++ b/source/dub/packagemanager.d @@ -168,16 +168,17 @@ { auto package_name = package_info.name.get!string(); auto package_version = package_info["version"].get!string(); + auto clean_package_version = package_version[package_version.startsWith("~") ? 1 : 0 .. $]; - logDebug("Installing package '%s' version '%s' to location '%s' from file '%s'", - package_name, package_version, to!string(location), zip_file_path.toNativeString()); - + logDebug("Installing package '%s' version '%s' to location '%s' from file '%s'", + package_name, package_version, to!string(location), zip_file_path.toNativeString()); + Path destination; final switch( location ){ case InstallLocation.local: destination = Path(package_name); break; case InstallLocation.projectLocal: enforce(!m_projectPackagePath.empty, "no project path set."); destination = m_projectPackagePath ~ package_name; break; - case InstallLocation.userWide: destination = m_userPackagePath ~ (package_name ~ "/" ~ package_version); break; - case InstallLocation.systemWide: destination = m_systemPackagePath ~ (package_name ~ "/" ~ package_version); break; + case InstallLocation.userWide: destination = m_userPackagePath ~ (package_name ~ "/" ~ clean_package_version); break; + case InstallLocation.systemWide: destination = m_systemPackagePath ~ (package_name ~ "/" ~ clean_package_version); break; } if( existsFile(destination) ){ @@ -187,13 +188,13 @@ // open zip file ZipArchive archive; { - logTrace("Opening file %s", zip_file_path); + logTrace("Opening file %s", zip_file_path); auto f = openFile(zip_file_path, FileMode.Read); scope(exit) f.close(); archive = new ZipArchive(f.readAll()); } - logTrace("Installing from zip."); + logTrace("Installing from zip."); // In a github zip, the actual contents are in a subfolder Path zip_prefix; @@ -211,7 +212,7 @@ zip_prefix = Path(am.name); } - logTrace("zip root folder: %s", zip_prefix); + logTrace("zip root folder: %s", zip_prefix); Path getCleanedPath(string fileName) { auto path = Path(fileName); @@ -222,14 +223,14 @@ // install mkdirRecurse(destination.toNativeString()); auto journal = new Journal; - logDebug("Copying all files..."); - int countFiles = 0; + logDebug("Copying all files..."); + int countFiles = 0; foreach(ArchiveMember a; archive.directory) { auto cleanedPath = getCleanedPath(a.name); if(cleanedPath.empty) continue; auto dst_path = destination~cleanedPath; - logTrace("Creating %s", cleanedPath); + logTrace("Creating %s", cleanedPath); if( dst_path.endsWithSlash ){ if( !existsDirectory(dst_path) ) mkdirRecurse(dst_path.toNativeString()); @@ -241,10 +242,10 @@ scope(exit) dstFile.close(); dstFile.put(archive.expand(a)); journal.add(Journal.Entry(Journal.Type.RegularFile, cleanedPath)); - ++countFiles; + ++countFiles; } } - logDebug("%s file(s) copied.", to!string(countFiles)); + logDebug("%s file(s) copied.", to!string(countFiles)); // overwrite package.json (this one includes a version field) Json pi = jsonFromFile(destination~PackageJsonFilename); @@ -260,14 +261,14 @@ logInfo("%s has been installed with version %s", package_name, package_version); auto pack = new Package(location, destination); - + final switch( location ){ case InstallLocation.local: break; case InstallLocation.projectLocal: m_projectPackages[package_name] = pack; break; case InstallLocation.userWide: m_userPackages[package_name] ~= pack; break; case InstallLocation.systemWide: m_systemPackages[package_name] ~= pack; break; } - + return pack; }