1
1
package io .github .fvarrui .javapackager .packagers ;
2
2
3
3
import static org .apache .commons .lang3 .StringUtils .defaultIfBlank ;
4
+ import static io .github .fvarrui .javapackager .utils .CommandUtils .execute ;
4
5
5
6
import java .io .File ;
6
7
import java .util .Arrays ;
7
8
8
9
import org .apache .commons .lang3 .StringUtils ;
9
10
10
11
import io .github .fvarrui .javapackager .model .MacConfig ;
11
- import io .github .fvarrui .javapackager .utils .CommandUtils ;
12
12
import io .github .fvarrui .javapackager .utils .FileUtils ;
13
13
import io .github .fvarrui .javapackager .utils .Logger ;
14
14
import io .github .fvarrui .javapackager .utils .ThreadUtils ;
@@ -81,11 +81,14 @@ public File apply(Packager packager) throws Exception {
81
81
82
82
// creates image
83
83
Logger .info ("Creating image: " + tempDmgFile .getAbsolutePath ());
84
- CommandUtils .execute ("hdiutil" , "create" , "-srcfolder" , appFolder , "-volname" , volumeName , "-ov" , "-fs" , "HFS+" , "-format" , "UDRW" , tempDmgFile );
84
+ execute ("hdiutil" , "create" , "-srcfolder" , appFolder , "-volname" , volumeName , "-ov" , "-fs" , "HFS+" , "-format" , "UDRW" , tempDmgFile );
85
+
86
+ Logger .info ("Unmounting disk image (if mounted)..." );
87
+ execute ("hdiutil" , "detach" , volumeName );
85
88
86
89
// mounts image
87
90
Logger .info ("Mounting image: " + tempDmgFile .getAbsolutePath ());
88
- String result = CommandUtils . execute ("hdiutil" , "attach" , "-readwrite" , "-noverify" , "-noautoopen" , tempDmgFile );
91
+ String result = execute ("hdiutil" , "attach" , "-readwrite" , "-noverify" , "-noautoopen" , tempDmgFile );
89
92
String deviceName = Arrays .asList (result .split ("\n " ))
90
93
.stream ()
91
94
.filter (s -> s .contains (mountFolder .getAbsolutePath ()))
@@ -106,26 +109,26 @@ public File apply(Packager packager) throws Exception {
106
109
107
110
// runs applescript
108
111
Logger .info ("Running applescript" );
109
- CommandUtils . execute ("/usr/bin/osascript" , applescriptFile , volumeName );
112
+ execute ("/usr/bin/osascript" , applescriptFile , volumeName );
110
113
111
114
// makes sure it's not world writeable and user readable
112
115
Logger .info ("Fixing permissions..." );
113
- CommandUtils . execute ("chmod" , "-Rf" , "u+r,go-w" , mountFolder );
116
+ execute ("chmod" , "-Rf" , "u+r,go-w" , mountFolder );
114
117
115
118
// makes the top window open itself on mount:
116
119
Logger .info ("Blessing ..." );
117
- CommandUtils . execute ("bless" , "--folder" , mountFolder , "--openfolder" , mountFolder );
120
+ execute ("bless" , "--folder" , mountFolder , "--openfolder" , mountFolder );
118
121
119
122
// tells the volume that it has a special file attribute
120
- CommandUtils . execute ("SetFile" , "-a" , "C" , mountFolder );
123
+ execute ("SetFile" , "-a" , "C" , mountFolder );
121
124
122
125
// unmounts
123
126
Logger .info ("Unmounting disk image..." );
124
- CommandUtils . execute ("hdiutil" , "detach" , deviceName );
127
+ execute ("hdiutil" , "detach" , volumeName );
125
128
126
129
// compress image
127
130
Logger .info ("Compressing disk image..." );
128
- CommandUtils . execute ("hdiutil" , "convert" , tempDmgFile , "-format" , "UDZO" , "-imagekey" , "zlib-level=9" , "-o" , dmgFile );
131
+ execute ("hdiutil" , "convert" , tempDmgFile , "-format" , "UDZO" , "-imagekey" , "zlib-level=9" , "-o" , dmgFile );
129
132
tempDmgFile .delete ();
130
133
131
134
// checks if dmg file was created
0 commit comments