mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-19 08:52:15 +01:00
Allow empty bundle hardware folder
This commit is contained in:
parent
61cccc0151
commit
a044f59634
@ -69,13 +69,14 @@ public class ContributionsIndexer {
|
||||
private final File builtInHardwareFolder;
|
||||
private final Platform platform;
|
||||
private final SignatureVerifier signatureVerifier;
|
||||
private ContributionsIndex index;
|
||||
private final ContributionsIndex index;
|
||||
|
||||
public ContributionsIndexer(File preferencesFolder, File builtInHardwareFolder, Platform platform, SignatureVerifier signatureVerifier) {
|
||||
this.preferencesFolder = preferencesFolder;
|
||||
this.builtInHardwareFolder = builtInHardwareFolder;
|
||||
this.platform = platform;
|
||||
this.signatureVerifier = signatureVerifier;
|
||||
index = new EmptyContributionIndex();
|
||||
packagesFolder = new File(preferencesFolder, "packages");
|
||||
stagingFolder = new File(preferencesFolder, "staging" + File.separator + "packages");
|
||||
}
|
||||
@ -83,7 +84,7 @@ public class ContributionsIndexer {
|
||||
public void parseIndex() throws Exception {
|
||||
// Read bundled index...
|
||||
File bundledIndexFile = new File(builtInHardwareFolder, Constants.BUNDLED_INDEX_FILE_NAME);
|
||||
index = parseIndex(bundledIndexFile);
|
||||
mergeContributions(bundledIndexFile);
|
||||
|
||||
// ...and overlay the default index if present
|
||||
File defaultIndexFile = getIndexFile(Constants.DEFAULT_INDEX_FILE_NAME);
|
||||
@ -93,7 +94,7 @@ public class ContributionsIndexer {
|
||||
throw new SignatureVerificationFailedException(Constants.DEFAULT_INDEX_FILE_NAME);
|
||||
}
|
||||
|
||||
mergeContributions(parseIndex(defaultIndexFile), defaultIndexFile);
|
||||
mergeContributions(defaultIndexFile);
|
||||
}
|
||||
|
||||
// Set main and bundled indexes as trusted
|
||||
@ -104,8 +105,7 @@ public class ContributionsIndexer {
|
||||
|
||||
for (File indexFile : indexFiles) {
|
||||
try {
|
||||
ContributionsIndex contributionsIndex = parseIndex(indexFile);
|
||||
mergeContributions(contributionsIndex, indexFile);
|
||||
mergeContributions(indexFile);
|
||||
} catch (JsonProcessingException e) {
|
||||
System.err.println(I18n.format(tr("Skipping contributed index file {0}, parsing error occured:"), indexFile));
|
||||
System.err.println(e);
|
||||
@ -136,7 +136,11 @@ public class ContributionsIndexer {
|
||||
index.fillCategories();
|
||||
}
|
||||
|
||||
private void mergeContributions(ContributionsIndex contributionsIndex, File indexFile) {
|
||||
private void mergeContributions(File indexFile) throws IOException {
|
||||
if (!indexFile.exists())
|
||||
return;
|
||||
|
||||
ContributionsIndex contributionsIndex = parseIndex(indexFile);
|
||||
boolean signed = signatureVerifier.isSigned(indexFile);
|
||||
boolean trustall = PreferencesData.getBoolean(Constants.PREF_CONTRIBUTIONS_TRUST_ALL);
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* This file is part of Arduino.
|
||||
*
|
||||
* Copyright 2014 Arduino LLC (http://www.arduino.cc/)
|
||||
*
|
||||
* Arduino is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*
|
||||
* As a special exception, you may use this file as part of a free software
|
||||
* library without restriction. Specifically, if other files instantiate
|
||||
* templates or use macros or inline functions from this file, or you compile
|
||||
* this file and link it with other files to produce an executable, this
|
||||
* file does not by itself cause the resulting executable to be covered by
|
||||
* the GNU General Public License. This exception does not however
|
||||
* invalidate any other reasons why the executable file might be covered by
|
||||
* the GNU General Public License.
|
||||
*/
|
||||
|
||||
package cc.arduino.contributions.packages;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
class EmptyContributionIndex extends ContributionsIndex {
|
||||
List<ContributedPackage> packs = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
public List<ContributedPackage> getPackages() {
|
||||
return packs;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user