Skip to content

Commit 00dee20

Browse files
committed
Merge branch 'issue-419' into devel
2 parents 702aa13 + 45eda4c commit 00dee20

File tree

5 files changed

+34
-23
lines changed

5 files changed

+34
-23
lines changed

Diff for: src/main/java/io/github/fvarrui/javapackager/model/Arch.java

+9
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,15 @@ public static Arch getArch(String archString) {
2929
public static Arch getDefault() {
3030
return getArch(SystemUtils.OS_ARCH);
3131
}
32+
33+
public String toDebArchitecture() {
34+
switch (this) {
35+
case aarch64: return "arm64";
36+
case x64: return "amd64";
37+
case x86: return "i386";
38+
default: return null;
39+
}
40+
}
3241

3342
public Architecture toRpmArchitecture() {
3443
switch (this) {

Diff for: src/main/java/io/github/fvarrui/javapackager/model/LinuxConfig.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.File;
44
import java.io.Serializable;
55
import java.util.Arrays;
6+
import java.util.Collections;
67
import java.util.List;
78

89
import org.apache.commons.lang3.ObjectUtils;
@@ -21,7 +22,7 @@ public class LinuxConfig implements Serializable {
2122
private boolean generateAppImage = true;
2223
private File pngFile;
2324
private boolean wrapJar = true;
24-
private File installationPath;
25+
private String installationPath;
2526

2627
public void setCategories(List<String> categories) {
2728
this.categories = categories;
@@ -71,11 +72,11 @@ public void setWrapJar(boolean wrapJar) {
7172
this.wrapJar = wrapJar;
7273
}
7374

74-
public File getInstallationPath() {
75+
public String getInstallationPath() {
7576
return installationPath;
7677
}
7778

78-
public void setInstallationPath(File installationPath) {
79+
public void setInstallationPath(String installationPath) {
7980
this.installationPath = installationPath;
8081
}
8182

@@ -92,8 +93,8 @@ public String toString() {
9293
* @param packager Packager
9394
*/
9495
public void setDefaults(Packager packager) {
95-
this.setCategories((categories == null || categories.isEmpty()) ? Arrays.asList("Utility") : categories);
96-
this.setInstallationPath(ObjectUtils.defaultIfNull(installationPath, new File("/opt")));
96+
this.setCategories((categories == null || categories.isEmpty()) ? Collections.singletonList("Utility") : categories);
97+
this.setInstallationPath(ObjectUtils.defaultIfNull(installationPath, "/opt"));
9798
}
9899

99100
}

Diff for: src/main/java/io/github/fvarrui/javapackager/packagers/GenerateDeb.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
public class GenerateDeb extends ArtifactGenerator<LinuxPackager> {
2424

25-
private Console console;
25+
private final Console console;
2626

2727
public GenerateDeb() {
2828
super("DEB package");
@@ -64,8 +64,8 @@ protected File doApply(LinuxPackager packager) throws Exception {
6464
File executable = packager.getExecutable();
6565
File javaFile = new File(appFolder, jreDirectoryName + "/bin/java");
6666
File mimeXmlFile = packager.getMimeXmlFile();
67-
File installationPath = packager.getLinuxConfig().getInstallationPath();
68-
File appPath = new File(installationPath, name);
67+
String installationPath = packager.getLinuxConfig().getInstallationPath();
68+
String appPath = installationPath + "/" + name;
6969

7070
// generates desktop file from velocity template
7171
File desktopFile = new File(assetsFolder, name + ".desktop");
@@ -82,14 +82,14 @@ protected File doApply(LinuxPackager packager) throws Exception {
8282

8383
// create data producers collections
8484

85-
List<DataProducer> conffilesProducers = new ArrayList<>();
85+
List<DataProducer> confFilesProducers = new ArrayList<>();
8686
List<DataProducer> dataProducers = new ArrayList<>();
8787

8888
// builds app folder data producer, except executable file and jre/bin/java
8989

9090
Mapper appFolderMapper = new Mapper();
9191
appFolderMapper.setType("perm");
92-
appFolderMapper.setPrefix(appPath.getAbsolutePath());
92+
appFolderMapper.setPrefix(appPath);
9393
appFolderMapper.setFileMode("644");
9494

9595
Data appFolderData = new Data();
@@ -104,7 +104,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
104104

105105
Mapper executableMapper = new Mapper();
106106
executableMapper.setType("perm");
107-
executableMapper.setPrefix(appPath.getAbsolutePath());
107+
executableMapper.setPrefix(appPath);
108108
executableMapper.setFileMode("755");
109109

110110
Data executableData = new Data();
@@ -190,7 +190,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
190190

191191
// builds deb file
192192

193-
DebMaker debMaker = new DebMaker(console, dataProducers, conffilesProducers);
193+
DebMaker debMaker = new DebMaker(console, dataProducers, confFilesProducers);
194194
debMaker.setDeb(debFile);
195195
debMaker.setControl(controlFile.getParentFile());
196196
debMaker.setCompression("gzip");

Diff for: src/main/java/io/github/fvarrui/javapackager/packagers/GenerateRpm.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.security.NoSuchAlgorithmException;
66
import java.util.ArrayList;
77
import java.util.List;
8+
import java.util.Objects;
89

910
import org.redline_rpm.Builder;
1011
import org.redline_rpm.header.Architecture;
@@ -44,9 +45,9 @@ protected File doApply(LinuxPackager packager) throws Exception {
4445
String jreDirectoryName = packager.getJreDirectoryName();
4546
Architecture arch = packager.getArch().toRpmArchitecture();
4647
File mimeXmlFile = packager.getMimeXmlFile();
47-
File installationPath = packager.getLinuxConfig().getInstallationPath();
48-
File appPath = new File(installationPath, name);
49-
48+
String installationPath = packager.getLinuxConfig().getInstallationPath();
49+
String appPath = installationPath + "/" + name;
50+
5051
// generates desktop file from velocity template
5152
File desktopFile = new File(assetsFolder, name + ".desktop");
5253
VelocityUtils.render("linux/desktop.vtl", desktopFile, packager);
@@ -62,7 +63,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
6263
builder.setPackage(name, version, "1");
6364
builder.setPackager(organizationName);
6465
builder.setDescription(description);
65-
builder.setPrefixes("opt");
66+
builder.setPrefixes(installationPath);
6667

6768
// list of files which needs execution permissions
6869
List<File> executionPermissions = new ArrayList<>();
@@ -71,7 +72,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
7172
executionPermissions.add(new File(appFolder, jreDirectoryName + "/lib/jspawnhelper"));
7273

7374
// add all app files
74-
addDirectory(builder, installationPath.getAbsolutePath(), appFolder, executionPermissions);
75+
addDirectory(builder, installationPath, appFolder, executionPermissions);
7576

7677
// link to desktop file
7778
addLink(builder, "/usr/share/applications/" + desktopFile.getName(), appPath + "/" + desktopFile.getName());
@@ -86,13 +87,13 @@ protected File doApply(LinuxPackager packager) throws Exception {
8687
addLink(builder, "/usr/local/bin/" + executable.getName(), appPath + "/" + executable.getName());
8788

8889
// add all app files
89-
addDirectory(builder, "/opt", appFolder, executionPermissions);
90+
addDirectory(builder, installationPath, appFolder, executionPermissions);
9091

9192
// build RPM file
9293
builder.build(outputDirectory);
9394

94-
// renames genewrated RPM file if created
95-
String suffix = "-1." + arch.name().toLowerCase() + ".rpm";
95+
// renames generated RPM file if created
96+
String suffix = "-1." + arch + ".rpm";
9697
File originalRpm = new File(outputDirectory, name + "-" + version + suffix);
9798
File rpm = null;
9899
if (originalRpm.exists()) {
@@ -119,7 +120,7 @@ private void addDirectory(Builder builder, String parentPath, File directory, Li
119120
String dirPath = parentPath + "/" + directory.getName();
120121
Logger.info("Adding directory '" + directory + "' to RPM builder as '" + dirPath + "'");
121122
builder.addDirectory(dirPath);
122-
for (File f : directory.listFiles()) {
123+
for (File f : Objects.requireNonNull(directory.listFiles())) {
123124
if (f.isDirectory())
124125
addDirectory(builder, dirPath, f, executionPermissions);
125126
else {

Diff for: src/main/resources/linux/control.vtl

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ Package: ${info.name}
22
Version: ${info.version}
33
Section: misc
44
Priority: optional
5-
Architecture: ${info.arch.deb}
5+
Architecture: ${info.arch.toDebArchitecture()}
66
Maintainer: ${info.organizationName} <$!{info.organizationEmail}>
77
Description: ${info.description}
8-
Distribution: development
8+
Distribution: stable
99
#if(${info.url})
1010
Homepage: ${info.url}
1111
#end

0 commit comments

Comments
 (0)