Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for updating Jaunch files #110

Merged
merged 4 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/main/java/net/imagej/updater/Checksummer.java
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ else if (file.filename.startsWith("mm/")) {

public static final String[][] directories = {
{ "jars", "retro", "misc" }, { ".jar", ".class" },
{ "jaunch" }, { ".toml", ".class", ".java", ".py", ".txt" },
{ "plugins" }, { ".jar", ".class", ".txt", ".ijm", ".py", ".rb", ".clj", ".js", ".bsh", ".groovy", ".gvy" },
{ "scripts" }, { ".m", ".ijm", ".py", ".rb", ".clj", ".js", ".bsh", ".groovy", ".gvy" },
{ "macros" }, { ".txt", ".ijm", ".png" },
Expand Down
51 changes: 40 additions & 11 deletions src/main/java/net/imagej/updater/util/UpdaterUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,17 +104,46 @@ public class UpdaterUtil {
public UpdaterUtil(final File imagejRoot) {
platform = getPlatform();


// These platform names determine what can be supported in the updater
platforms =
new String[] { "linux32", "linux64", "macosx", "tiger", "win32", "win64" };
new String[] { "linux32", "linux64", "linux-arm64", "macosx", "tiger",
"macos-arm64", "win32", "win64" };

List<String> launcherNames = new ArrayList<>();

// Derive the old-style ImageJ launcher names
final String[] ijLaunchers =
{ "linux32", "linux64", "macosx", "tiger", "win32", "win64" };
final int macIndex = 2;
Arrays.sort(platforms);

launchers = platforms.clone();
for (int i = 0; i < launchers.length; i++)
launchers[i] =
(i == macIndex || i == macIndex + 1 ? macPrefix : "") + "ImageJ-" +
platforms[i] + (platforms[i].startsWith("win") ? ".exe" : "");
Arrays.sort(launchers);
for (int i = 0; i < ijLaunchers.length; i++)
launcherNames.add((i == macIndex || i == macIndex + 1 ? macPrefix
: "") + "ImageJ-" + ijLaunchers[i] + (ijLaunchers[i].startsWith("win")
? ".exe" : ""));

// Derive the new-style Jaunch launcher names
final String[] jaunchers = { "linux-x64", "linux-arm64", "macos-x64",
"macos-arm64", "macos-universal", "windows-x64" };

for (int i=0; i<jaunchers.length; i++) {
String launcherDir = "";
String jaunchDir = "";
String extension = "";
if (jaunchers[i].startsWith("macos")) {
launcherDir = macPrefix;
jaunchDir = macPrefix;
} else if (jaunchers[i].startsWith("windows")) {
jaunchDir = "jaunch/";
extension = ".exe";
} else if (jaunchers[i].startsWith("linux")) {
jaunchDir = "jaunch/";
}
launcherNames.add(launcherDir + "fiji-" + jaunchers[i] + extension);
launcherNames.add(jaunchDir + "jaunch-" + jaunchers[i] + extension);
}

launchers = launcherNames.toArray(new String[launcherNames.size()]);

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

public static String getPlatform() {
final boolean is64bit =
System.getProperty("os.arch", "").indexOf("64") >= 0;
final String osArch = System.getProperty("os.arch", "");
final boolean is64bit = osArch.indexOf("64") >= 0;
final String osName = System.getProperty("os.name", "<unknown>");
if (osName.equals("Linux")) return "linux" + (is64bit ? "64" : "32");
if (osName.equals("Mac OS X")) return "macosx";
if (osName.equals("Mac OS X")) return osArch.equals("aarch64") ? "macos-arm64" : "macosx";
if (osName.startsWith("Windows")) return "win" + (is64bit ? "64" : "32");
// System.err.println("Unknown platform: " + osName);
return osName.toLowerCase();
Expand Down
Loading