Skip to content

Commit df4a131

Browse files
authored
Merge pull request #110 from imagej/update-jaunch
Add support for updating Jaunch files
2 parents 7465c0e + afbd5c3 commit df4a131

File tree

2 files changed

+41
-11
lines changed

2 files changed

+41
-11
lines changed

src/main/java/net/imagej/updater/Checksummer.java

+1
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ else if (file.filename.startsWith("mm/")) {
438438

439439
public static final String[][] directories = {
440440
{ "jars", "retro", "misc" }, { ".jar", ".class" },
441+
{ "jaunch" }, { ".toml", ".class", ".java", ".py", ".txt" },
441442
{ "plugins" }, { ".jar", ".class", ".txt", ".ijm", ".py", ".rb", ".clj", ".js", ".bsh", ".groovy", ".gvy" },
442443
{ "scripts" }, { ".m", ".ijm", ".py", ".rb", ".clj", ".js", ".bsh", ".groovy", ".gvy" },
443444
{ "macros" }, { ".txt", ".ijm", ".png" },

src/main/java/net/imagej/updater/util/UpdaterUtil.java

+40-11
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,46 @@ public class UpdaterUtil {
104104
public UpdaterUtil(final File imagejRoot) {
105105
platform = getPlatform();
106106

107+
108+
// These platform names determine what can be supported in the updater
107109
platforms =
108-
new String[] { "linux32", "linux64", "macosx", "tiger", "win32", "win64" };
110+
new String[] { "linux32", "linux64", "linux-arm64", "macosx", "tiger",
111+
"macos-arm64", "win32", "win64" };
112+
113+
List<String> launcherNames = new ArrayList<>();
114+
115+
// Derive the old-style ImageJ launcher names
116+
final String[] ijLaunchers =
117+
{ "linux32", "linux64", "macosx", "tiger", "win32", "win64" };
109118
final int macIndex = 2;
110-
Arrays.sort(platforms);
111119

112-
launchers = platforms.clone();
113-
for (int i = 0; i < launchers.length; i++)
114-
launchers[i] =
115-
(i == macIndex || i == macIndex + 1 ? macPrefix : "") + "ImageJ-" +
116-
platforms[i] + (platforms[i].startsWith("win") ? ".exe" : "");
117-
Arrays.sort(launchers);
120+
for (int i = 0; i < ijLaunchers.length; i++)
121+
launcherNames.add((i == macIndex || i == macIndex + 1 ? macPrefix
122+
: "") + "ImageJ-" + ijLaunchers[i] + (ijLaunchers[i].startsWith("win")
123+
? ".exe" : ""));
124+
125+
// Derive the new-style Jaunch launcher names
126+
final String[] jaunchers = { "linux-x64", "linux-arm64", "macos-x64",
127+
"macos-arm64", "macos-universal", "windows-x64" };
128+
129+
for (int i=0; i<jaunchers.length; i++) {
130+
String launcherDir = "";
131+
String jaunchDir = "";
132+
String extension = "";
133+
if (jaunchers[i].startsWith("macos")) {
134+
launcherDir = macPrefix;
135+
jaunchDir = macPrefix;
136+
} else if (jaunchers[i].startsWith("windows")) {
137+
jaunchDir = "jaunch/";
138+
extension = ".exe";
139+
} else if (jaunchers[i].startsWith("linux")) {
140+
jaunchDir = "jaunch/";
141+
}
142+
launcherNames.add(launcherDir + "fiji-" + jaunchers[i] + extension);
143+
launcherNames.add(jaunchDir + "jaunch-" + jaunchers[i] + extension);
144+
}
145+
146+
launchers = launcherNames.toArray(new String[launcherNames.size()]);
118147

119148
updateablePlatforms = new HashSet<>();
120149
updateablePlatforms.add(platform);
@@ -151,11 +180,11 @@ public static String stripPrefix(final String string, final String prefix) {
151180
}
152181

153182
public static String getPlatform() {
154-
final boolean is64bit =
155-
System.getProperty("os.arch", "").indexOf("64") >= 0;
183+
final String osArch = System.getProperty("os.arch", "");
184+
final boolean is64bit = osArch.indexOf("64") >= 0;
156185
final String osName = System.getProperty("os.name", "<unknown>");
157186
if (osName.equals("Linux")) return "linux" + (is64bit ? "64" : "32");
158-
if (osName.equals("Mac OS X")) return "macosx";
187+
if (osName.equals("Mac OS X")) return osArch.equals("aarch64") ? "macos-arm64" : "macosx";
159188
if (osName.startsWith("Windows")) return "win" + (is64bit ? "64" : "32");
160189
// System.err.println("Unknown platform: " + osName);
161190
return osName.toLowerCase();

0 commit comments

Comments
 (0)