Skip to content

Commit 7d90681

Browse files
committed
Added infrastructure for RC builds
Added a `RC_build` property in the build script to make RC builds for testing purposes. The RC build use a different package_index file called package_index_staging.json. When the IDE detects the presence of the staging index in his dist/ folder then this file is used instead of the main public index to allow testing of new AVR-bundled cores. Updates are also downloaded from a different URL and the original package_index is ignored and left untouched.
1 parent d754c0b commit 7d90681

File tree

7 files changed

+79
-76
lines changed

7 files changed

+79
-76
lines changed

arduino-core/src/cc/arduino/Constants.java

+19-2
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,22 @@
2929

3030
package cc.arduino;
3131

32+
import java.io.File;
3233
import java.util.Arrays;
3334
import java.util.List;
3435

36+
import processing.app.BaseNoGui;
37+
3538
public class Constants {
3639

3740
public static final String PREF_REMOVE_PLACEHOLDER = "___REMOVE___";
3841
public static final String PREF_BOARDS_MANAGER_ADDITIONAL_URLS = "boardsmanager.additional.urls";
3942
public static final String PREF_CONTRIBUTIONS_TRUST_ALL = "contributions.trust.all";
4043

41-
public static final String DEFAULT_INDEX_FILE_NAME = "package_index.json";
44+
public static final String RC_INDEX_FILE_NAME = "package_index_staging.json";
45+
public static final String INDEX_FILE_NAME = "package_index.json";
46+
public static final String DEFAULT_INDEX_FILE_NAME;
47+
public static final boolean IS_RC;
4248
public static final List<String> PROTECTED_PACKAGE_NAMES = Arrays.asList("arduino", "Intel");
4349

4450
public static final String LIBRARY_DEVELOPMENT_FLAG_FILE = ".development";
@@ -69,11 +75,22 @@ public class Constants {
6975
public static final List<String> LIBRARY_MANDATORY_PROPERTIES = Arrays.asList("name", "version", "author", "maintainer", "sentence", "paragraph", "url");
7076

7177
static {
78+
// Check for RC release
79+
File distFolder = BaseNoGui.getContentFile("dist");
80+
File rcPackageJsonFile = new File(distFolder, RC_INDEX_FILE_NAME);
81+
if (rcPackageJsonFile.exists()) {
82+
DEFAULT_INDEX_FILE_NAME = RC_INDEX_FILE_NAME;
83+
IS_RC = true;
84+
} else {
85+
DEFAULT_INDEX_FILE_NAME = INDEX_FILE_NAME;
86+
IS_RC = false;
87+
}
88+
7289
String extenalPackageIndexUrl = System.getProperty("PACKAGE_INDEX_URL");
7390
if (extenalPackageIndexUrl != null && !"".equals(extenalPackageIndexUrl)) {
7491
PACKAGE_INDEX_URL = extenalPackageIndexUrl;
7592
} else {
76-
PACKAGE_INDEX_URL = "http://downloads.arduino.cc/packages/package_index.json";
93+
PACKAGE_INDEX_URL = "http://downloads.arduino.cc/packages/" + Constants.DEFAULT_INDEX_FILE_NAME;
7794
}
7895

7996
String externalLibraryIndexUrl = System.getProperty("LIBRARY_INDEX_URL");

arduino-core/src/cc/arduino/contributions/packages/ContributionInstaller.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private File download(MultiStepProgress progress, String packageIndexUrl, Progre
337337

338338
public synchronized void deleteUnknownFiles(List<String> downloadedPackageIndexFiles) throws IOException {
339339
File preferencesFolder = BaseNoGui.indexer.getIndexFile(".").getParentFile();
340-
File[] additionalPackageIndexFiles = preferencesFolder.listFiles(new PackageIndexFilenameFilter(Constants.DEFAULT_INDEX_FILE_NAME));
340+
File[] additionalPackageIndexFiles = preferencesFolder.listFiles(new PackageIndexFilenameFilter());
341341
if (additionalPackageIndexFiles == null) {
342342
return;
343343
}

arduino-core/src/cc/arduino/contributions/packages/ContributionsIndexer.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void parseIndex() throws Exception {
8686
index = parseIndex(defaultIndexFile);
8787
index.setTrusted();
8888

89-
File[] indexFiles = preferencesFolder.listFiles(new TestPackageIndexFilenameFilter(new PackageIndexFilenameFilter(Constants.DEFAULT_INDEX_FILE_NAME)));
89+
File[] indexFiles = preferencesFolder.listFiles(new PackageIndexFilenameFilter(true));
9090

9191
for (File indexFile : indexFiles) {
9292
try {

arduino-core/src/cc/arduino/contributions/packages/PackageIndexFilenameFilter.java

+20-4
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,32 @@
3232
import java.io.File;
3333
import java.io.FilenameFilter;
3434

35+
import cc.arduino.Constants;
36+
3537
public class PackageIndexFilenameFilter implements FilenameFilter {
3638

37-
private final String defaultPackageIndexFileName;
39+
boolean acceptTestPackages = false;
40+
41+
public PackageIndexFilenameFilter() {
42+
}
3843

39-
public PackageIndexFilenameFilter(String defaultPackageIndexFileName) {
40-
this.defaultPackageIndexFileName = defaultPackageIndexFileName;
44+
public PackageIndexFilenameFilter(boolean acceptTest) {
45+
acceptTestPackages = acceptTest;
4146
}
4247

4348
@Override
4449
public boolean accept(File file, String name) {
45-
return new File(file, name).isFile() && !defaultPackageIndexFileName.equals(name) && name.startsWith("package_") && name.endsWith("_index.json");
50+
if (Constants.INDEX_FILE_NAME.equals(name) || Constants.RC_INDEX_FILE_NAME.equals(name))
51+
return false;
52+
if (acceptTestPackages) {
53+
if (!name.startsWith("package_") && !name.startsWith("test_package_"))
54+
return false;
55+
} else {
56+
if (!name.startsWith("package_"))
57+
return false;
58+
}
59+
if (!name.endsWith("_index.json"))
60+
return false;
61+
return new File(file, name).isFile();
4662
}
4763
}

arduino-core/src/cc/arduino/contributions/packages/TestPackageIndexFilenameFilter.java

-56
This file was deleted.

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

+6-4
Original file line numberDiff line numberDiff line change
@@ -608,9 +608,11 @@ static public void initLogger() {
608608
}
609609

610610
static public void initPackages() throws Exception {
611+
if (Constants.IS_RC)
612+
System.out.println("WARNING: This is is a TEST release of the Arduino IDE");
611613
indexer = new ContributionsIndexer(BaseNoGui.getSettingsFolder(), BaseNoGui.getPlatform(), new GPGDetachedSignatureVerifier());
612-
File indexFile = indexer.getIndexFile("package_index.json");
613-
File defaultPackageJsonFile = new File(getContentFile("dist"), "package_index.json");
614+
File indexFile = indexer.getIndexFile(Constants.DEFAULT_INDEX_FILE_NAME);
615+
File defaultPackageJsonFile = new File(getContentFile("dist"), Constants.DEFAULT_INDEX_FILE_NAME);
614616
if (!indexFile.isFile() || (defaultPackageJsonFile.isFile() && defaultPackageJsonFile.lastModified() > indexFile.lastModified())) {
615617
FileUtils.copyFile(defaultPackageJsonFile, indexFile);
616618
} else if (!indexFile.isFile()) {
@@ -624,8 +626,8 @@ static public void initPackages() throws Exception {
624626
}
625627
}
626628

627-
File indexSignatureFile = indexer.getIndexFile("package_index.json.sig");
628-
File defaultPackageJsonSignatureFile = new File(getContentFile("dist"), "package_index.json.sig");
629+
File indexSignatureFile = indexer.getIndexFile(Constants.DEFAULT_INDEX_FILE_NAME + ".sig");
630+
File defaultPackageJsonSignatureFile = new File(getContentFile("dist"), Constants.DEFAULT_INDEX_FILE_NAME + ".sig");
629631
if (!indexSignatureFile.isFile() || (defaultPackageJsonSignatureFile.isFile() && defaultPackageJsonSignatureFile.lastModified() > indexSignatureFile.lastModified())) {
630632
FileUtils.copyFile(defaultPackageJsonSignatureFile, indexSignatureFile);
631633
}

build/build.xml

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

11+
<!-- Set for RC releases -->
12+
<!--
13+
When this property is set the build script will make a Release Canditate for testing purposes.
14+
15+
The RC build use a different package_index file called package_index_staging.json.
16+
17+
When the IDE detects the presence of the staging index in his dist/ folder then this
18+
file is used instead of the main public index to allow testing of new AVR-bundled
19+
cores. Updates are also downloaded from a different URL and the original package_index
20+
is ignored.
21+
-->
22+
<!--<property name="RC_build" value="true" />-->
23+
1124
<!-- Main url for boards and libraries repository -->
1225
<property name="library_index_url" value="http://downloads.arduino.cc/libraries/library_index.json" />
13-
<property name="package_index_url" value="http://downloads.arduino.cc/packages/package_index.json" />
26+
<condition property="package_index_filename"
27+
value="package_index_staging.json"
28+
else="package_index.json">
29+
<isset property="RC_build"/>
30+
</condition>
31+
<property name="package_index_url" value="http://downloads.arduino.cc/packages/${package_index_filename}" />
1432

1533
<!-- Sets properties for macosx/windows/linux depending on current system -->
1634
<condition property="platform" value="macosx-old">
@@ -274,7 +292,7 @@
274292
</loadfile>
275293

276294
<!-- figure out the latest AVR core version number in package_index.json -->
277-
<loadfile srcfile="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index.json" property="revision.avr.index">
295+
<loadfile srcfile="${staging_folder}/work/${staging_hardware_folder}/../dist/${package_index_filename}" property="revision.avr.index">
278296
<filterchain>
279297
<tokenfilter>
280298
<linetokenizer />
@@ -295,8 +313,8 @@
295313
</or>
296314
</condition>
297315
<fail unless="revision.avr.ok">
298-
Mismatching versions for bundled AVR core and package_index.json.
299-
Please check your platform.txt and package_index.json.
316+
Mismatching versions for bundled AVR core and ${package_index_filename}.
317+
Please check your platform.txt and ${package_index_filename}.
300318
</fail>
301319

302320
<!-- figure out the IDE version number -->
@@ -1170,15 +1188,21 @@
11701188
<target name="package-library-index-json-bundle">
11711189
<mkdir dir="${staging_folder}/work/${staging_hardware_folder}/../dist/"/>
11721190

1191+
<!-- Remove all package_index_staging leftovers -->
1192+
<delete file="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index.json" />
1193+
<delete file="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index.json.sig" />
1194+
<delete file="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index_staging.json" />
1195+
<delete file="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index_staging.json.sig" />
1196+
11731197
<get src="${package_index_url}.gz"
1174-
dest="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index.json.gz"
1198+
dest="${staging_folder}/work/${staging_hardware_folder}/../dist/${package_index_filename}.gz"
11751199
verbose="true" skipexisting="false" />
1176-
<gunzip src ="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index.json.gz"
1200+
<gunzip src ="${staging_folder}/work/${staging_hardware_folder}/../dist/${package_index_filename}.gz"
11771201
dest="${staging_folder}/work/${staging_hardware_folder}/../dist/"/>
1178-
<delete file="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index.json.gz"/>
1202+
<delete file="${staging_folder}/work/${staging_hardware_folder}/../dist/${package_index_filename}.gz"/>
11791203

11801204
<get src="${package_index_url}.sig"
1181-
dest="${staging_folder}/work/${staging_hardware_folder}/../dist/package_index.json.sig"
1205+
dest="${staging_folder}/work/${staging_hardware_folder}/../dist/${package_index_filename}.sig"
11821206
verbose="true" skipexisting="false" />
11831207

11841208
<get src="${library_index_url}.gz"

0 commit comments

Comments
 (0)