Skip to content

Commit 38d114d

Browse files
committed
Update GenerateAppImage.java
1 parent dc16776 commit 38d114d

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

src/main/java/io/github/fvarrui/javapackager/packagers/GenerateAppImage.java

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
public class GenerateAppImage extends ArtifactGenerator<LinuxPackager> {
1414

1515
private static final int IMAGETOOL_VERSION = 13;
16-
private static final String IMAGETOOL_URL = "https://github.com/AppImage/AppImageKit/releases/download/" + IMAGETOOL_VERSION + "/appimagetool-" + SystemUtils.OS_ARCH + ".AppImage";
16+
private static final String IMAGETOOL_URL = "https://github.com/AppImage/AppImageKit/releases/download/" + IMAGETOOL_VERSION + "/appimagetool-%s.AppImage";
1717

1818
public GenerateAppImage() {
1919
super("AppImage");
@@ -72,14 +72,30 @@ protected File doApply(LinuxPackager packager) throws Exception {
7272
return appImage;
7373
}
7474

75-
private File getAppImageTool(LinuxPackager packager) throws IOException {
75+
private File getAppImageTool(LinuxPackager packager) throws Exception {
7676
File assetsFolder = packager.getAssetsFolder();
7777
File appImageTool = new File(assetsFolder, "appimagetool");
7878
if (!appImageTool.exists()) {
79-
FileUtils.downloadFromUrl(IMAGETOOL_URL, appImageTool);
79+
String imageToolUrl = IMAGETOOL_URL.formatted(getOSArch());
80+
try {
81+
FileUtils.downloadFromUrl(imageToolUrl, appImageTool);
82+
} catch (IOException e) {
83+
throw new Exception(imageToolUrl + "not found! ... Unsupported OS architecture " + getOSArch() + "?");
84+
}
8085
appImageTool.setExecutable(true);
8186
}
8287
return appImageTool;
8388
}
84-
89+
90+
private String getOSArch() {
91+
switch (SystemUtils.OS_ARCH) {
92+
case "amd64":
93+
return "x86_64";
94+
case "x86":
95+
case "i386":
96+
return "i686";
97+
}
98+
return SystemUtils.OS_ARCH;
99+
}
100+
85101
}

0 commit comments

Comments
 (0)