Skip to content

Commit 7c3a212

Browse files
committed
Merge branch 'issue-316' into devel
2 parents 6644e68 + 883931a commit 7c3a212

File tree

1 file changed

+24
-12
lines changed

1 file changed

+24
-12
lines changed

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

Lines changed: 24 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -68,21 +68,21 @@ protected File doApply(LinuxPackager packager) throws Exception {
6868
executionPermissions.add(new File(appFolder, jreDirectoryName + "/bin/java"));
6969
executionPermissions.add(new File(appFolder, jreDirectoryName + "/lib/jspawnhelper"));
7070

71-
// add all app files
72-
addDirectoryTree(builder, "/opt", appFolder, executionPermissions);
73-
7471
// link to desktop file
75-
builder.addLink("/usr/share/applications/" + desktopFile.getName(), "/opt/" + name + "/" + desktopFile.getName());
72+
addLink(builder, "/usr/share/applications/" + desktopFile.getName(), "/opt/" + name + "/" + desktopFile.getName());
7673

7774
// copy and link to mime.xml file
7875
if (mimeXmlFile != null) {
7976
FileUtils.copyFileToFolder(mimeXmlFile, appFolder);
80-
builder.addLink("/usr/share/mime/packages/" + mimeXmlFile.getName(), "/opt/" + name + "/" + mimeXmlFile.getName());
77+
addLink(builder, "/usr/share/mime/packages/" + mimeXmlFile.getName(), "/opt/" + name + "/" + mimeXmlFile.getName());
8178
}
8279

8380
// link to binary
84-
builder.addLink("/usr/local/bin/" + executable.getName(), "/opt/" + name + "/" + executable.getName());
81+
addLink(builder, "/usr/local/bin/" + executable.getName(), "/opt/" + name + "/" + executable.getName());
8582

83+
// add all app files
84+
addDirectory(builder, "/opt", appFolder, executionPermissions);
85+
8686
// build RPM file
8787
builder.build(outputDirectory);
8888

@@ -98,15 +98,27 @@ protected File doApply(LinuxPackager packager) throws Exception {
9898

9999
return rpm;
100100
}
101+
102+
private void addLink(Builder builder, String path, String target) throws NoSuchAlgorithmException, IOException {
103+
Logger.info("Adding link '" + path + "' to RPM builder targeting '" + target + "'");
104+
builder.addLink(path, target);
105+
}
106+
107+
private void addFile(Builder builder, String rootPath, File file, int mode) throws NoSuchAlgorithmException, IOException {
108+
String filePath = rootPath + "/" + file.getName();
109+
Logger.info("Adding file '" + file + "' to RPM builder as '" + filePath + "'");
110+
builder.addFile(filePath, file, mode);
111+
}
101112

102-
private void addDirectoryTree(Builder builder, String parentPath, File root, List<File> executionPermissions) throws NoSuchAlgorithmException, IOException {
103-
String rootPath = parentPath + "/" + root.getName();
104-
builder.addDirectory(rootPath);
105-
for (File f : root.listFiles()) {
113+
private void addDirectory(Builder builder, String parentPath, File directory, List<File> executionPermissions) throws NoSuchAlgorithmException, IOException {
114+
String dirPath = parentPath + "/" + directory.getName();
115+
Logger.info("Adding directory '" + directory + "' to RPM builder as '" + dirPath + "'");
116+
builder.addDirectory(dirPath);
117+
for (File f : directory.listFiles()) {
106118
if (f.isDirectory())
107-
addDirectoryTree(builder, parentPath + "/" + root.getName(), f, executionPermissions);
119+
addDirectory(builder, dirPath, f, executionPermissions);
108120
else {
109-
builder.addFile(rootPath + "/" + f.getName(), f, executionPermissions.contains(f) ? 0755 : 0644);
121+
addFile(builder, dirPath, f, executionPermissions.contains(f) ? 0755 : 0644);
110122
}
111123
}
112124
}

0 commit comments

Comments
 (0)