mirror of
https://github.com/arduino/Arduino.git
synced 2025-02-19 13:54:23 +01:00
Showing post install script errors AFTER the installation is completed
This commit is contained in:
parent
a40415a7df
commit
d94e279fdf
@ -344,9 +344,9 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
|
||||
String desc = "<html><body>";
|
||||
|
||||
// Library name...
|
||||
desc += format("<b>{0}</b> ", name);
|
||||
desc += format("<b>{0}</b>", name);
|
||||
if (installed != null && installed.isReadOnly()) {
|
||||
desc += "Built-In ";
|
||||
desc += " Built-In ";
|
||||
}
|
||||
|
||||
// ...author...
|
||||
|
@ -348,8 +348,11 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
|
||||
String desc = "<html><body>";
|
||||
desc += "<b>" + selected.getName() + "</b>";
|
||||
if (installed != null && installed.isReadOnly()) {
|
||||
desc += " Built-In ";
|
||||
}
|
||||
|
||||
String author = selected.getParentPackage().getMaintainer();
|
||||
String url = selected.getParentPackage().getWebsiteURL();
|
||||
if (author != null && !author.isEmpty()) {
|
||||
desc += " " + format("by <b>{0}</b>", author);
|
||||
}
|
||||
@ -364,6 +367,7 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
|
||||
}
|
||||
desc = desc.substring(0, desc.lastIndexOf(',')) + ".<br />";
|
||||
|
||||
String url = selected.getParentPackage().getWebsiteURL();
|
||||
if (url != null && !url.isEmpty()) {
|
||||
desc += " " + format("<a href=\"{0}\">More info</a>", url);
|
||||
}
|
||||
|
@ -40,6 +40,8 @@ import processing.app.I18n;
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static processing.app.I18n._;
|
||||
|
||||
@ -158,17 +160,21 @@ public class ContributionManagerUI extends InstallerJDialog {
|
||||
installerThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> errors = new LinkedList<String>();
|
||||
try {
|
||||
setProgressVisible(true, _("Installing..."));
|
||||
installer.install(platformToInstall);
|
||||
errors.addAll(installer.install(platformToInstall));
|
||||
if (platformToRemove != null && !platformToRemove.isReadOnly()) {
|
||||
installer.remove(platformToRemove);
|
||||
errors.addAll(installer.remove(platformToRemove));
|
||||
}
|
||||
onIndexesUpdated();
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
} finally {
|
||||
setProgressVisible(false, "");
|
||||
if (!errors.isEmpty()) {
|
||||
setErrorMessage(errors.get(0));
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -79,7 +79,8 @@ public class ContributionInstaller {
|
||||
};
|
||||
}
|
||||
|
||||
public void install(ContributedPlatform platform) throws Exception {
|
||||
public List<String> install(ContributedPlatform platform) throws Exception {
|
||||
List<String> errors = new LinkedList<String>();
|
||||
if (platform.isInstalled()) {
|
||||
throw new Exception("Platform is already installed!");
|
||||
}
|
||||
@ -117,7 +118,7 @@ public class ContributionInstaller {
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
// Download interrupted... just exit
|
||||
return;
|
||||
return errors;
|
||||
}
|
||||
|
||||
ContributedPackage pack = platform.getParentPackage();
|
||||
@ -140,7 +141,11 @@ public class ContributionInstaller {
|
||||
destFolder.mkdirs();
|
||||
assert toolContrib.getDownloadedFile() != null;
|
||||
new ArchiveExtractor(BaseNoGui.getPlatform()).extract(toolContrib.getDownloadedFile(), destFolder, 1);
|
||||
executePostInstallScriptIfAny(destFolder);
|
||||
try {
|
||||
executePostInstallScriptIfAny(destFolder);
|
||||
} catch (IOException e) {
|
||||
errors.add(_("Error running post install script"));
|
||||
}
|
||||
toolContrib.setInstalled(true);
|
||||
toolContrib.setInstalledFolder(destFolder);
|
||||
progress.stepDone();
|
||||
@ -159,6 +164,8 @@ public class ContributionInstaller {
|
||||
|
||||
progress.setStatus(_("Installation completed!"));
|
||||
onProgress(progress);
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
private void executePostInstallScriptIfAny(File folder) throws IOException {
|
||||
@ -184,14 +191,15 @@ public class ContributionInstaller {
|
||||
ByteArrayOutputStream stdout = new ByteArrayOutputStream();
|
||||
ByteArrayOutputStream stderr = new ByteArrayOutputStream();
|
||||
Executor executor = new CollectStdOutStdErrExecutor(stdout, stderr);
|
||||
|
||||
executor.setWorkingDirectory(folder);
|
||||
executor.execute(new CommandLine(postInstallScript));
|
||||
|
||||
System.out.write(stdout.toByteArray());
|
||||
System.err.write(stderr.toByteArray());
|
||||
}
|
||||
|
||||
public void remove(ContributedPlatform platform) {
|
||||
public List<String> remove(ContributedPlatform platform) {
|
||||
List<String> errors = new LinkedList<String>();
|
||||
FileUtils.recursiveDelete(platform.getInstalledFolder());
|
||||
platform.setInstalled(false);
|
||||
platform.setInstalledFolder(null);
|
||||
@ -217,11 +225,14 @@ public class ContributionInstaller {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
|
||||
return errors;
|
||||
}
|
||||
|
||||
public void updateIndex() throws Exception {
|
||||
final MultiStepProgress progress = new MultiStepProgress(1);
|
||||
final String statusText = _("Downloading platforms index...");
|
||||
public List<String> updateIndex() throws Exception {
|
||||
List<String> errors = new LinkedList<String>();
|
||||
MultiStepProgress progress = new MultiStepProgress(1);
|
||||
String statusText = _("Downloading platforms index...");
|
||||
|
||||
URL url = new URL(PACKAGE_INDEX_URL);
|
||||
File outputFile = indexer.getIndexFile();
|
||||
@ -232,10 +243,13 @@ public class ContributionInstaller {
|
||||
// TODO: Check downloaded index
|
||||
|
||||
// Replace old index with the updated one
|
||||
if (outputFile.exists())
|
||||
if (outputFile.exists()) {
|
||||
outputFile.delete();
|
||||
if (!tmpFile.renameTo(outputFile))
|
||||
}
|
||||
if (!tmpFile.renameTo(outputFile)) {
|
||||
throw new Exception("An error occurred while updating platforms index!");
|
||||
}
|
||||
return errors;
|
||||
}
|
||||
|
||||
protected void onProgress(Progress progress) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user