Skip to content

Commit d5dc479

Browse files
committed
library_index.json is no more bundled.
There is no reason to bundle this file. If the index file is not available an empty index is returned by the parser. Fix #5143 (together with e80c08: Use a specific hardware/package_index_bundled.json)
1 parent b695e7f commit d5dc479

File tree

4 files changed

+55
-56
lines changed

4 files changed

+55
-56
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* This file is part of Arduino.
3+
*
4+
* Copyright 2016 Arduino LLC (http://www.arduino.cc/)
5+
*
6+
* Arduino is free software; you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation; either version 2 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19+
*
20+
* As a special exception, you may use this file as part of a free software
21+
* library without restriction. Specifically, if other files instantiate
22+
* templates or use macros or inline functions from this file, or you compile
23+
* this file and link it with other files to produce an executable, this
24+
* file does not by itself cause the resulting executable to be covered by
25+
* the GNU General Public License. This exception does not however
26+
* invalidate any other reasons why the executable file might be covered by
27+
* the GNU General Public License.
28+
*/
29+
30+
package cc.arduino.contributions.libraries;
31+
32+
import java.util.ArrayList;
33+
import java.util.List;
34+
35+
public class EmptyLibrariesIndex extends LibrariesIndex {
36+
37+
private List<ContributedLibrary> list = new ArrayList<>();
38+
39+
@Override
40+
public List<ContributedLibrary> getLibraries() {
41+
return list;
42+
}
43+
44+
}

arduino-core/src/cc/arduino/contributions/libraries/LibrariesIndexer.java

+7-3
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,16 @@ public class LibrariesIndexer {
6868
private final List<String> badLibNotified = new ArrayList<>();
6969

7070
public LibrariesIndexer(File preferencesFolder) {
71-
this.indexFile = new File(preferencesFolder, "library_index.json");
72-
this.stagingFolder = new File(new File(preferencesFolder, "staging"), "libraries");
71+
indexFile = new File(preferencesFolder, "library_index.json");
72+
stagingFolder = new File(new File(preferencesFolder, "staging"), "libraries");
7373
}
7474

7575
public void parseIndex() throws IOException {
76-
parseIndex(indexFile);
76+
if (!indexFile.exists()) {
77+
index = new EmptyLibrariesIndex();
78+
} else {
79+
parseIndex(indexFile);
80+
}
7781
// TODO: resolve libraries inner references
7882
}
7983

arduino-core/src/processing/app/BaseNoGui.java

+2-25
Original file line numberDiff line numberDiff line change
@@ -628,35 +628,12 @@ static public void initPackages() throws Exception {
628628
loadHardware(getSketchbookHardwareFolder());
629629
createToolPreferences(indexer.getInstalledTools(), true);
630630

631-
librariesIndexer = new LibrariesIndexer(BaseNoGui.getSettingsFolder());
632-
File librariesIndexFile = librariesIndexer.getIndexFile();
633-
copyStockLibraryIndexIfUpstreamIsMissing(librariesIndexFile);
631+
librariesIndexer = new LibrariesIndexer(getSettingsFolder());
634632
try {
635633
librariesIndexer.parseIndex();
636634
} catch (JsonProcessingException e) {
635+
File librariesIndexFile = librariesIndexer.getIndexFile();
637636
FileUtils.deleteIfExists(librariesIndexFile);
638-
copyStockLibraryIndexIfUpstreamIsMissing(librariesIndexFile);
639-
librariesIndexer.parseIndex();
640-
}
641-
}
642-
643-
private static void copyStockLibraryIndexIfUpstreamIsMissing(File librariesIndexFile) throws IOException {
644-
File defaultLibraryJsonFile = new File(getContentFile("dist"), "library_index.json");
645-
if (!librariesIndexFile.isFile() || (defaultLibraryJsonFile.isFile() && defaultLibraryJsonFile.lastModified() > librariesIndexFile.lastModified())) {
646-
if (defaultLibraryJsonFile.isFile()) {
647-
FileUtils.copyFile(defaultLibraryJsonFile, librariesIndexFile);
648-
} else {
649-
FileOutputStream out = null;
650-
try {
651-
// Otherwise create an empty packages index
652-
out = new FileOutputStream(librariesIndexFile);
653-
out.write("{ \"libraries\" : [ ] }".getBytes());
654-
} catch (IOException e) {
655-
e.printStackTrace();
656-
} finally {
657-
IOUtils.closeQuietly(out);
658-
}
659-
}
660637
}
661638
}
662639

build/build.xml

+2-28
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
<format property="BUILD_DATE" pattern="yyyy/MM/dd hh:mm"/>
99
</tstamp>
1010

11-
<!-- Main url for boards and libraries repository -->
12-
<property name="library_index_url" value="http://downloads.arduino.cc/libraries/library_index.json" />
13-
1411
<!-- Sets properties for macosx/windows/linux depending on current system -->
1512
<condition property="platform" value="macosx-old">
1613
<and>
@@ -259,7 +256,7 @@
259256
<!-- - - - - - - - - -->
260257
<!-- Revision check -->
261258
<!-- - - - - - - - - -->
262-
<target name="revision-check" depends="package-library-index-json-bundle">
259+
<target name="revision-check">
263260

264261
<!-- figure out the AVR core version number in platform.txt -->
265262
<loadfile srcfile="../hardware/arduino/avr/platform.txt" property="revision.avr.platform">
@@ -273,7 +270,7 @@
273270
</loadfile>
274271

275272
<!-- figure out the latest AVR core version number in package_index.json -->
276-
<loadfile srcfile="${staging_folder}/work/${staging_hardware_folder}/package_index_bundled.json" property="revision.avr.index">
273+
<loadfile srcfile="../hardware/package_index_bundled.json" property="revision.avr.index">
277274
<filterchain>
278275
<tokenfilter>
279276
<linetokenizer />
@@ -439,8 +436,6 @@
439436

440437
<antcall target="macosx-build-avr-toolchain" />
441438

442-
<antcall target="package-library-index-json-bundle"/>
443-
444439
<antcall target="assemble">
445440
<param name="target.path" value="${staging_folder}/work/${staging_hardware_folder}/.." />
446441
</antcall>
@@ -720,8 +715,6 @@
720715
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino5-armhf-pc-linux-gnu-glibc2.13.tar.bz2"/>
721716
<param name="avrdude_version" value="6.0.1-arduino5"/>
722717
</antcall>
723-
724-
<antcall target="package-library-index-json-bundle"/>
725718
</target>
726719

727720
<target name="linux32-build" depends="linux-libastyle-x86" description="Build linux (32-bit) version">
@@ -752,8 +745,6 @@
752745
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino5-i686-pc-linux-gnu.tar.bz2"/>
753746
<param name="avrdude_version" value="6.0.1-arduino5"/>
754747
</antcall>
755-
756-
<antcall target="package-library-index-json-bundle"/>
757748
</target>
758749

759750
<target name="linux64-build" depends="linux-libastyle-x86" description="Build linux (64-bit) version">
@@ -784,8 +775,6 @@
784775
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino5-x86_64-pc-linux-gnu.tar.bz2"/>
785776
<param name="avrdude_version" value="6.0.1-arduino5"/>
786777
</antcall>
787-
788-
<antcall target="package-library-index-json-bundle"/>
789778
</target>
790779

791780
<target name="linux-jvm-noop"/>
@@ -1072,8 +1061,6 @@
10721061
<param name="avrdude_archive_file" value="avrdude-6.0.1-arduino5-i686-mingw32.zip"/>
10731062
<param name="avrdude_version" value="6.0.1-arduino5"/>
10741063
</antcall>
1075-
1076-
<antcall target="package-library-index-json-bundle"/>
10771064
</target>
10781065

10791066
<target name="windows-run" depends="build,start"/>
@@ -1164,19 +1151,6 @@
11641151

11651152
<echo append="true" file="${staging_folder}/work/${staging_hardware_folder}/tools/avr/builtin_tools_versions.txt" message="arduino.avrdude=${avrdude_version}${line.separator}"/>
11661153
<echo append="true" file="${staging_folder}/work/${staging_hardware_folder}/tools/avr/builtin_tools_versions.txt" message="arduino.avr-gcc=${gcc_version}${line.separator}"/>
1167-
</target>
1168-
1169-
<target name="package-library-index-json-bundle">
1170-
<mkdir dir="${staging_folder}/work/${staging_hardware_folder}"/>
1171-
<copy file="../hardware/package_index_bundled.json" tofile="${staging_folder}/work/${staging_hardware_folder}/package_index_bundled.json"/>
1172-
1173-
<mkdir dir="${staging_folder}/work/${staging_hardware_folder}/../dist/"/>
1174-
<get src="${library_index_url}.gz"
1175-
dest="${staging_folder}/work/${staging_hardware_folder}/../dist/library_index.json.gz"
1176-
verbose="true" skipexisting="false" />
1177-
<gunzip src ="${staging_folder}/work/${staging_hardware_folder}/../dist/library_index.json.gz"
1178-
dest="${staging_folder}/work/${staging_hardware_folder}/../dist/"/>
1179-
<delete file="${staging_folder}/work/${staging_hardware_folder}/../dist/library_index.json.gz"/>
11801154

11811155
<delete dir="${staging_folder}/work/${staging_hardware_folder}/tmp"/>
11821156
</target>

0 commit comments

Comments
 (0)