@@ -68,21 +68,21 @@ protected File doApply(LinuxPackager packager) throws Exception {
68
68
executionPermissions .add (new File (appFolder , jreDirectoryName + "/bin/java" ));
69
69
executionPermissions .add (new File (appFolder , jreDirectoryName + "/lib/jspawnhelper" ));
70
70
71
- // add all app files
72
- addDirectoryTree (builder , "/opt" , appFolder , executionPermissions );
73
-
74
71
// 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 ());
76
73
77
74
// copy and link to mime.xml file
78
75
if (mimeXmlFile != null ) {
79
76
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 ());
81
78
}
82
79
83
80
// 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 ());
85
82
83
+ // add all app files
84
+ addDirectory (builder , "/opt" , appFolder , executionPermissions );
85
+
86
86
// build RPM file
87
87
builder .build (outputDirectory );
88
88
@@ -98,15 +98,27 @@ protected File doApply(LinuxPackager packager) throws Exception {
98
98
99
99
return rpm ;
100
100
}
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
+ }
101
112
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 ()) {
106
118
if (f .isDirectory ())
107
- addDirectoryTree (builder , parentPath + "/" + root . getName () , f , executionPermissions );
119
+ addDirectory (builder , dirPath , f , executionPermissions );
108
120
else {
109
- builder . addFile (rootPath + "/" + f . getName () , f , executionPermissions .contains (f ) ? 0755 : 0644 );
121
+ addFile (builder , dirPath , f , executionPermissions .contains (f ) ? 0755 : 0644 );
110
122
}
111
123
}
112
124
}
0 commit comments