5
5
import java .security .NoSuchAlgorithmException ;
6
6
import java .util .ArrayList ;
7
7
import java .util .List ;
8
+ import java .util .Objects ;
8
9
9
10
import org .redline_rpm .Builder ;
10
11
import org .redline_rpm .header .Architecture ;
@@ -44,9 +45,9 @@ protected File doApply(LinuxPackager packager) throws Exception {
44
45
String jreDirectoryName = packager .getJreDirectoryName ();
45
46
Architecture arch = packager .getArch ().toRpmArchitecture ();
46
47
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
+
50
51
// generates desktop file from velocity template
51
52
File desktopFile = new File (assetsFolder , name + ".desktop" );
52
53
VelocityUtils .render ("linux/desktop.vtl" , desktopFile , packager );
@@ -62,7 +63,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
62
63
builder .setPackage (name , version , "1" );
63
64
builder .setPackager (organizationName );
64
65
builder .setDescription (description );
65
- builder .setPrefixes ("opt" );
66
+ builder .setPrefixes (installationPath );
66
67
67
68
// list of files which needs execution permissions
68
69
List <File > executionPermissions = new ArrayList <>();
@@ -71,7 +72,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
71
72
executionPermissions .add (new File (appFolder , jreDirectoryName + "/lib/jspawnhelper" ));
72
73
73
74
// add all app files
74
- addDirectory (builder , installationPath . getAbsolutePath () , appFolder , executionPermissions );
75
+ addDirectory (builder , installationPath , appFolder , executionPermissions );
75
76
76
77
// link to desktop file
77
78
addLink (builder , "/usr/share/applications/" + desktopFile .getName (), appPath + "/" + desktopFile .getName ());
@@ -86,13 +87,13 @@ protected File doApply(LinuxPackager packager) throws Exception {
86
87
addLink (builder , "/usr/local/bin/" + executable .getName (), appPath + "/" + executable .getName ());
87
88
88
89
// add all app files
89
- addDirectory (builder , "/opt" , appFolder , executionPermissions );
90
+ addDirectory (builder , installationPath , appFolder , executionPermissions );
90
91
91
92
// build RPM file
92
93
builder .build (outputDirectory );
93
94
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" ;
96
97
File originalRpm = new File (outputDirectory , name + "-" + version + suffix );
97
98
File rpm = null ;
98
99
if (originalRpm .exists ()) {
@@ -119,7 +120,7 @@ private void addDirectory(Builder builder, String parentPath, File directory, Li
119
120
String dirPath = parentPath + "/" + directory .getName ();
120
121
Logger .info ("Adding directory '" + directory + "' to RPM builder as '" + dirPath + "'" );
121
122
builder .addDirectory (dirPath );
122
- for (File f : directory .listFiles ()) {
123
+ for (File f : Objects . requireNonNull ( directory .listFiles () )) {
123
124
if (f .isDirectory ())
124
125
addDirectory (builder , dirPath , f , executionPermissions );
125
126
else {
0 commit comments