55import java .security .NoSuchAlgorithmException ;
66import java .util .ArrayList ;
77import java .util .List ;
8+ import java .util .Objects ;
89
910import org .redline_rpm .Builder ;
1011import 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- String appPath = new File ( installationPath , name ). toPath (). normalize (). toString () ;
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 {
0 commit comments