116 String.class, |
116 String.class, |
117 params -> "-MacAppStore", |
117 params -> "-MacAppStore", |
118 (s, p) -> s); |
118 (s, p) -> s); |
119 |
119 |
120 //@Override |
120 //@Override |
121 public File bundle(Map<String, ? super Object> p, |
121 public File bundle(Map<String, ? super Object> params, |
122 File outdir) throws PackagerException { |
122 File outdir) throws PackagerException { |
123 Log.verbose(MessageFormat.format(I18N.getString( |
123 Log.verbose(MessageFormat.format(I18N.getString( |
124 "message.building-bundle"), APP_NAME.fetchFrom(p))); |
124 "message.building-bundle"), APP_NAME.fetchFrom(params))); |
125 if (!outdir.isDirectory() && !outdir.mkdirs()) { |
125 if (!outdir.isDirectory() && !outdir.mkdirs()) { |
126 throw new PackagerException( |
126 throw new PackagerException( |
127 "error.cannot-create-output-dir", |
127 "error.cannot-create-output-dir", |
128 outdir.getAbsolutePath()); |
128 outdir.getAbsolutePath()); |
129 } |
129 } |
133 outdir.getAbsolutePath()); |
133 outdir.getAbsolutePath()); |
134 } |
134 } |
135 |
135 |
136 // first, load in some overrides |
136 // first, load in some overrides |
137 // icns needs @2 versions, so load in the @2 default |
137 // icns needs @2 versions, so load in the @2 default |
138 p.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI); |
138 params.put(DEFAULT_ICNS_ICON.getID(), TEMPLATE_BUNDLE_ICON_HIDPI); |
139 |
139 |
140 // now we create the app |
140 // now we create the app |
141 File appImageDir = APP_IMAGE_TEMP_ROOT.fetchFrom(p); |
141 File appImageDir = APP_IMAGE_TEMP_ROOT.fetchFrom(params); |
142 try { |
142 try { |
143 appImageDir.mkdirs(); |
143 appImageDir.mkdirs(); |
144 |
144 |
145 try { |
145 try { |
146 MacAppImageBuilder.addNewKeychain(p); |
146 MacAppImageBuilder.addNewKeychain(params); |
147 } catch (InterruptedException e) { |
147 } catch (InterruptedException e) { |
148 Log.error(e.getMessage()); |
148 Log.error(e.getMessage()); |
149 } |
149 } |
150 // first, make sure we don't use the local signing key |
150 // first, make sure we don't use the local signing key |
151 p.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null); |
151 params.put(DEVELOPER_ID_APP_SIGNING_KEY.getID(), null); |
152 File appLocation = prepareAppBundle(p, false); |
152 File appLocation = prepareAppBundle(params, false); |
153 |
153 |
154 prepareEntitlements(p); |
154 prepareEntitlements(params); |
155 |
155 |
156 String signingIdentity = MAC_APP_STORE_APP_SIGNING_KEY.fetchFrom(p); |
156 String signingIdentity = |
157 String identifierPrefix = BUNDLE_ID_SIGNING_PREFIX.fetchFrom(p); |
157 MAC_APP_STORE_APP_SIGNING_KEY.fetchFrom(params); |
158 String entitlementsFile = getConfig_Entitlements(p).toString(); |
158 String identifierPrefix = |
|
159 BUNDLE_ID_SIGNING_PREFIX.fetchFrom(params); |
|
160 String entitlementsFile = |
|
161 getConfig_Entitlements(params).toString(); |
159 String inheritEntitlements = |
162 String inheritEntitlements = |
160 getConfig_Inherit_Entitlements(p).toString(); |
163 getConfig_Inherit_Entitlements(params).toString(); |
161 |
164 |
162 MacAppImageBuilder.signAppBundle(p, appLocation.toPath(), |
165 MacAppImageBuilder.signAppBundle(params, appLocation.toPath(), |
163 signingIdentity, identifierPrefix, |
166 signingIdentity, identifierPrefix, |
164 entitlementsFile, inheritEntitlements); |
167 entitlementsFile, inheritEntitlements); |
165 MacAppImageBuilder.restoreKeychainList(p); |
168 MacAppImageBuilder.restoreKeychainList(params); |
166 |
169 |
167 ProcessBuilder pb; |
170 ProcessBuilder pb; |
168 |
171 |
169 // create the final pkg file |
172 // create the final pkg file |
170 File finalPKG = new File(outdir, INSTALLER_NAME.fetchFrom(p) |
173 File finalPKG = new File(outdir, INSTALLER_NAME.fetchFrom(params) |
171 + INSTALLER_SUFFIX.fetchFrom(p) |
174 + INSTALLER_SUFFIX.fetchFrom(params) |
172 + ".pkg"); |
175 + ".pkg"); |
173 outdir.mkdirs(); |
176 outdir.mkdirs(); |
174 |
177 |
175 String installIdentify = |
178 String installIdentify = |
176 MAC_APP_STORE_PKG_SIGNING_KEY.fetchFrom(p); |
179 MAC_APP_STORE_PKG_SIGNING_KEY.fetchFrom(params); |
177 |
180 |
178 List<String> buildOptions = new ArrayList<>(); |
181 List<String> buildOptions = new ArrayList<>(); |
179 buildOptions.add("productbuild"); |
182 buildOptions.add("productbuild"); |
180 buildOptions.add("--component"); |
183 buildOptions.add("--component"); |
181 buildOptions.add(appLocation.toString()); |
184 buildOptions.add(appLocation.toString()); |
182 buildOptions.add("/Applications"); |
185 buildOptions.add("/Applications"); |
183 buildOptions.add("--sign"); |
186 buildOptions.add("--sign"); |
184 buildOptions.add(installIdentify); |
187 buildOptions.add(installIdentify); |
185 buildOptions.add("--product"); |
188 buildOptions.add("--product"); |
186 buildOptions.add(appLocation + "/Contents/Info.plist"); |
189 buildOptions.add(appLocation + "/Contents/Info.plist"); |
187 String keychainName = SIGNING_KEYCHAIN.fetchFrom(p); |
190 String keychainName = SIGNING_KEYCHAIN.fetchFrom(params); |
188 if (keychainName != null && !keychainName.isEmpty()) { |
191 if (keychainName != null && !keychainName.isEmpty()) { |
189 buildOptions.add("--keychain"); |
192 buildOptions.add("--keychain"); |
190 buildOptions.add(keychainName); |
193 buildOptions.add(keychainName); |
191 } |
194 } |
192 buildOptions.add(finalPKG.getAbsolutePath()); |
195 buildOptions.add(finalPKG.getAbsolutePath()); |