Installing tools from packager (eg: arduino) in packager folder, thus avoiding

tools duplication and disk space wasting. Fixes #4193
This commit is contained in:
Federico Fissore 2015-11-20 16:42:09 +01:00
parent a1e223ad62
commit d5a0476948
24 changed files with 55 additions and 45 deletions

View File

@ -21,10 +21,10 @@
<classpathentry kind="lib" path="app/lib/jssc-2.8.0.jar"/>
<classpathentry kind="lib" path="app/lib/bcpg-jdk15on-152.jar"/>
<classpathentry kind="lib" path="app/lib/bcprov-jdk15on-152.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-core-2.2.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-databind-2.2.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-module-mrbean-2.2.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-annotations-2.2.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-core-2.6.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-databind-2.6.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-module-mrbean-2.6.3.jar"/>
<classpathentry kind="lib" path="app/lib/jackson-annotations-2.6.3.jar"/>
<classpathentry kind="lib" path="app/lib/commons-compress-1.8.jar"/>
<classpathentry combineaccessrules="false" kind="src" path="/arduino-core"/>
<classpathentry kind="output" path="app/bin"/>

View File

@ -12,10 +12,10 @@
<classpathentry kind="lib" path="lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="lib/commons-logging-1.0.4.jar"/>
<classpathentry kind="lib" path="lib/commons-net-3.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-databind-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-databind-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/jmdns-3.4.1.jar"/>
<classpathentry kind="lib" path="lib/jsch-0.1.50.jar"/>
<classpathentry kind="lib" path="lib/jssc-2.8.0.jar"/>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -13,10 +13,10 @@
<classpathentry kind="lib" path="../app/lib/commons-compress-1.8.jar"/>
<classpathentry kind="lib" path="../app/lib/commons-exec-1.1.jar"/>
<classpathentry kind="lib" path="../app/lib/commons-httpclient-3.1.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-annotations-2.2.3.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-core-2.2.3.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-databind-2.2.3.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-module-mrbean-2.2.3.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-annotations-2.6.3.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-core-2.6.3.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-databind-2.6.3.jar"/>
<classpathentry kind="lib" path="../app/lib/jackson-module-mrbean-2.6.3.jar"/>
<classpathentry kind="lib" path="../app/lib/bcpg-jdk15on-152.jar"/>
<classpathentry kind="lib" path="../app/lib/bcprov-jdk15on-152.jar"/>
<classpathentry kind="lib" path="lib/bcpg-jdk15on-152.jar"/>
@ -24,10 +24,10 @@
<classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.8.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.3.2.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-databind-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-databind-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-module-mrbean-2.6.3.jar"/>
<classpathentry kind="lib" path="lib/java-semver-0.8.0.jar"/>
<classpathentry kind="lib" path="lib/jna-4.1.0.jar"/>
<classpathentry kind="lib" path="lib/jna-platform-4.1.0.jar"/>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -30,11 +30,9 @@
package cc.arduino.contributions.packages;
import cc.arduino.contributions.DownloadableContribution;
import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
import java.util.*;
public abstract class ContributedPlatform extends DownloadableContribution {
@ -54,18 +52,21 @@ public abstract class ContributedPlatform extends DownloadableContribution {
public abstract ContributedHelp getHelp();
private List<ContributedTool> resolvedTools;
private Map<ContributedToolReference, ContributedTool> resolvedToolReferences;
private ContributedPackage parentPackage;
public List<ContributedTool> getResolvedTools() {
if (resolvedTools == null) {
return null;
}
return new LinkedList<>(resolvedTools);
return new LinkedList<>(resolvedToolReferences.values());
}
@JsonIgnore
public Map<ContributedToolReference, ContributedTool> getResolvedToolReferences() {
return resolvedToolReferences;
}
public void resolveToolsDependencies(Collection<ContributedPackage> packages) {
resolvedTools = new ArrayList<>();
resolvedToolReferences = new HashMap<>();
// If there are no dependencies return empty list
if (getToolsDependencies() == null) {
@ -79,7 +80,7 @@ public abstract class ContributedPlatform extends DownloadableContribution {
if (tool == null) {
System.err.println("Index error: could not find referenced tool " + dep);
} else {
resolvedTools.add(tool);
resolvedToolReferences.put(dep, tool);
}
}
}

View File

@ -52,6 +52,8 @@ import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.*;
import java.util.stream.Collectors;
@ -122,26 +124,31 @@ public class ContributionInstaller {
// once everything is successfully unpacked. If the operation fails remove
// all the temporary folders and abort installation.
// Unzip tools on the correct location
File toolsFolder = new File(packageFolder, "tools");
List<Map.Entry<ContributedToolReference, ContributedTool>> resolvedToolReferences = contributedPlatform.getResolvedToolReferences().entrySet()
.stream()
.filter((entry) -> !entry.getValue().getDownloadableContribution(platform).isInstalled())
.collect(Collectors.toList());
int i = 1;
for (ContributedTool tool : tools) {
progress.setStatus(format(tr("Installing tools ({0}/{1})..."), i, tools.size()));
for (Map.Entry<ContributedToolReference, ContributedTool> entry : resolvedToolReferences) {
progress.setStatus(format(tr("Installing tools ({0}/{1})..."), i, resolvedToolReferences.size()));
progressListener.onProgress(progress);
i++;
ContributedTool tool = entry.getValue();
DownloadableContribution toolContrib = tool.getDownloadableContribution(platform);
File destFolder = new File(toolsFolder, tool.getName() + File.separator + tool.getVersion());
Path destFolder = Paths.get(indexer.getPackagesFolder().getAbsolutePath(), entry.getKey().getPackager(), "tools", tool.getName(), tool.getVersion());
Files.createDirectories(destFolder.toPath());
Files.createDirectories(destFolder);
assert toolContrib.getDownloadedFile() != null;
new ArchiveExtractor(platform).extract(toolContrib.getDownloadedFile(), destFolder, 1);
new ArchiveExtractor(platform).extract(toolContrib.getDownloadedFile(), destFolder.toFile(), 1);
try {
findAndExecutePostInstallScriptIfAny(destFolder, contributedPlatform.getParentPackage().isTrusted(), PreferencesData.getBoolean(Constants.PREF_CONTRIBUTIONS_TRUST_ALL));
findAndExecutePostInstallScriptIfAny(destFolder.toFile(), contributedPlatform.getParentPackage().isTrusted(), PreferencesData.getBoolean(Constants.PREF_CONTRIBUTIONS_TRUST_ALL));
} catch (IOException e) {
errors.add(tr("Error running post install script"));
}
toolContrib.setInstalled(true);
toolContrib.setInstalledFolder(destFolder);
toolContrib.setInstalledFolder(destFolder.toFile());
progress.stepDone();
}

View File

@ -92,7 +92,9 @@ public class ContributionsIndexer {
}
List<ContributedPackage> packages = index.getPackages();
Collection<ContributedPackage> packagesWithTools = packages.stream().filter(input -> input.getTools() != null).collect(Collectors.toList());
Collection<ContributedPackage> packagesWithTools = packages.stream()
.filter(input -> input.getTools() != null && !input.getTools().isEmpty())
.collect(Collectors.toList());
for (ContributedPackage pack : packages) {
for (ContributedPlatform platform : pack.getPlatforms()) {

View File

@ -19,10 +19,10 @@
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
<cp>%EXEDIR%/lib/commons-net-3.3.jar</cp>
<cp>%EXEDIR%/lib/ecj.jar</cp>
<cp>%EXEDIR%/lib/jackson-annotations-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-core-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-databind-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-annotations-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-core-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-databind-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/java-semver-0.8.0.jar</cp>
<cp>%EXEDIR%/lib/jmdns-3.4.1.jar</cp>
<cp>%EXEDIR%/lib/jna-4.1.0.jar</cp>

View File

@ -19,10 +19,10 @@
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
<cp>%EXEDIR%/lib/commons-net-3.3.jar</cp>
<cp>%EXEDIR%/lib/ecj.jar</cp>
<cp>%EXEDIR%/lib/jackson-annotations-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-core-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-databind-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-annotations-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-core-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-databind-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-module-mrbean-2.6.3.jar</cp>
<cp>%EXEDIR%/lib/java-semver-0.8.0.jar</cp>
<cp>%EXEDIR%/lib/jmdns-3.4.1.jar</cp>
<cp>%EXEDIR%/lib/jna-4.1.0.jar</cp>