sigh 1.3.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/bin/sigh +1 -0
- data/lib/assets/resign.sh +221 -200
- data/lib/sigh/resign.rb +9 -6
- data/lib/sigh/version.rb +1 -1
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e49ced620631a80f353f66ce2aaec2eb7623fe89
|
4
|
+
data.tar.gz: 44753e2b434bf48330d3222265371d999b527535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ce2f1fecf07da5caa9b196081bd5a9363b87d6b69c3bd614dd9a8526584b38dfa8b518f6e5ecaf7b33eef2526ebd04ae6a6e07334b348aa702e7d420779b1248
|
7
|
+
data.tar.gz: b9a69234e758c2128ca442cc117f5259c6a7cd544bc3d937da5f73ef2ffc134b6f52a4f2e2425e925a2c9fdd5a768579de7127e02a5c52f5f14549173e2c42ec
|
data/bin/sigh
CHANGED
@@ -61,6 +61,7 @@ class SighApplication
|
|
61
61
|
c.syntax = 'sigh resign'
|
62
62
|
c.description = 'Resigns an existing ipa file with the given provisioning profile'
|
63
63
|
c.option '-i', '--signing_identity STRING', String, 'The signing identity to use. Must match the one defined in the provisioning profile.'
|
64
|
+
c.option '-x', '--version_number STRING', String, 'Version number to force binary to use'
|
64
65
|
c.option '-p', '--provisioning_profile PATH', String, '(or BUNDLE_ID=PATH) The path to the provisioning profile which should be used.'\
|
65
66
|
'Can be provided multiple times if the application contains nested applications and app extensions, which need their own provisioning profile.'\
|
66
67
|
'The path may be prefixed with a identifier in order to determine which provisioning profile should be used on which app.',
|
data/lib/assets/resign.sh
CHANGED
@@ -51,7 +51,7 @@
|
|
51
51
|
# 3. fixed bug in packaging if -e flag is used
|
52
52
|
# 4. renamed 'temp' directory and made it a variable so it can be easily modified
|
53
53
|
# 5. various code formatting and logging adjustments
|
54
|
-
#
|
54
|
+
#
|
55
55
|
# new features October 2015
|
56
56
|
# 1. now re-signs nested applications and app extensions, if present, prior to re-signing the application itself
|
57
57
|
# 2. enables the -p option to be used more than once
|
@@ -63,11 +63,11 @@
|
|
63
63
|
|
64
64
|
function checkStatus {
|
65
65
|
|
66
|
-
if [ $? -ne 0 ];
|
67
|
-
then
|
68
|
-
|
69
|
-
|
70
|
-
fi
|
66
|
+
if [ $? -ne 0 ];
|
67
|
+
then
|
68
|
+
echo "Encountered an error, aborting!" >&2
|
69
|
+
exit 1
|
70
|
+
fi
|
71
71
|
}
|
72
72
|
|
73
73
|
if [ $# -lt 3 ]; then
|
@@ -87,6 +87,8 @@ RAW_PROVISIONS=()
|
|
87
87
|
PROVISIONS_BY_ID=()
|
88
88
|
DEFAULT_PROVISION=""
|
89
89
|
TEMP_DIR="_floatsignTemp"
|
90
|
+
# List of plist keys used for reference to and from nested apps and extensions
|
91
|
+
NESTED_APP_REFERENCE_KEYS=(":WKCompanionAppBundleIdentifier" ":NSExtension:NSExtensionAttributes:WKAppBundleIdentifier")
|
90
92
|
|
91
93
|
# options start index
|
92
94
|
OPTIND=3
|
@@ -134,7 +136,7 @@ done
|
|
134
136
|
shift $((OPTIND-1))
|
135
137
|
|
136
138
|
NEW_FILE="$1"
|
137
|
-
if [ -z "$NEW_FILE" ];
|
139
|
+
if [ -z "$NEW_FILE" ];
|
138
140
|
then
|
139
141
|
echo "Output file name required" >&2
|
140
142
|
exit 1
|
@@ -146,7 +148,7 @@ if [[ "${#RAW_PROVISIONS[*]}" == "0" ]]; then
|
|
146
148
|
fi
|
147
149
|
|
148
150
|
# Check for and remove the temporary directory if it already exists
|
149
|
-
if [ -d "$TEMP_DIR" ];
|
151
|
+
if [ -d "$TEMP_DIR" ];
|
150
152
|
then
|
151
153
|
echo "Removing previous temporary directory: '$TEMP_DIR'" >&2
|
152
154
|
rm -Rf "$TEMP_DIR"
|
@@ -192,73 +194,73 @@ export PATH=$PATH:/usr/libexec
|
|
192
194
|
# The first one may contain the wildcard character '*', in which case pattern matching will be used unless the third parameter is "STRICT"
|
193
195
|
function does_bundle_id_match {
|
194
196
|
|
195
|
-
if [[ "$1" == "$2" ]]; then
|
196
|
-
return 0
|
197
|
-
elif [[ "$3" != STRICT && "$1" =~ \* ]]; then
|
198
|
-
local PATTERN0="${1//\./\\.}" # com.example.* -> com\.example\.*
|
199
|
-
local PATTERN1="${PATTERN0//\*/.*}" # com\.example\.* -> com\.example\..*
|
200
|
-
if [[ "$2" =~ ^$PATTERN1$ ]]; then
|
197
|
+
if [[ "$1" == "$2" ]]; then
|
201
198
|
return 0
|
199
|
+
elif [[ "$3" != STRICT && "$1" =~ \* ]]; then
|
200
|
+
local PATTERN0="${1//\./\\.}" # com.example.* -> com\.example\.*
|
201
|
+
local PATTERN1="${PATTERN0//\*/.*}" # com\.example\.* -> com\.example\..*
|
202
|
+
if [[ "$2" =~ ^$PATTERN1$ ]]; then
|
203
|
+
return 0
|
204
|
+
fi
|
202
205
|
fi
|
203
|
-
fi
|
204
206
|
|
205
|
-
return 1
|
207
|
+
return 1
|
206
208
|
}
|
207
209
|
|
208
210
|
# Find the provisioning profile for a given bundle identifier
|
209
211
|
function provision_for_bundle_id {
|
210
212
|
|
211
|
-
for ARG in "${PROVISIONS_BY_ID[@]}"; do
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
done
|
213
|
+
for ARG in "${PROVISIONS_BY_ID[@]}"; do
|
214
|
+
if does_bundle_id_match "${ARG%%=*}" "$1" "$2"; then
|
215
|
+
echo "${ARG#*=}"
|
216
|
+
break
|
217
|
+
fi
|
218
|
+
done
|
217
219
|
}
|
218
220
|
|
219
221
|
# Find the bundle identifier contained inside a provisioning profile
|
220
222
|
function bundle_id_for_provison {
|
221
223
|
|
222
|
-
local FULL_BUNDLE_ID=`PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< $(security cms -D -i "$1")`
|
223
|
-
checkStatus
|
224
|
-
echo "${FULL_BUNDLE_ID#*.}"
|
224
|
+
local FULL_BUNDLE_ID=`PlistBuddy -c 'Print :Entitlements:application-identifier' /dev/stdin <<< $(security cms -D -i "$1")`
|
225
|
+
checkStatus
|
226
|
+
echo "${FULL_BUNDLE_ID#*.}"
|
225
227
|
}
|
226
228
|
|
227
229
|
# Add given provisioning profile and bundle identifier to the search list
|
228
230
|
function add_provision_for_bundle_id {
|
229
231
|
|
230
|
-
local PROVISION="$1"
|
231
|
-
local BUNDLE_ID="$2"
|
232
|
+
local PROVISION="$1"
|
233
|
+
local BUNDLE_ID="$2"
|
232
234
|
|
233
|
-
local CURRENT_PROVISION=`provision_for_bundle_id "$BUNDLE_ID" STRICT`
|
235
|
+
local CURRENT_PROVISION=`provision_for_bundle_id "$BUNDLE_ID" STRICT`
|
234
236
|
|
235
|
-
if [[ "$CURRENT_PROVISION" != "" && "$CURRENT_PROVISION" != "$PROVISION" ]]; then
|
236
|
-
|
237
|
-
|
238
|
-
fi
|
237
|
+
if [[ "$CURRENT_PROVISION" != "" && "$CURRENT_PROVISION" != "$PROVISION" ]]; then
|
238
|
+
echo "Conflicting provisioning profiles '$PROVISION' and '$CURRENT_PROVISION' for bundle identifier '$BUNDLE_ID'." >&2
|
239
|
+
exit 1
|
240
|
+
fi
|
239
241
|
|
240
|
-
PROVISIONS_BY_ID+=("$BUNDLE_ID=$PROVISION")
|
242
|
+
PROVISIONS_BY_ID+=("$BUNDLE_ID=$PROVISION")
|
241
243
|
}
|
242
244
|
|
243
245
|
# Add given provisioning profile to the search list
|
244
246
|
function add_provision {
|
245
247
|
|
246
|
-
local PROVISION="$1"
|
248
|
+
local PROVISION="$1"
|
247
249
|
|
248
|
-
if [[ "$1" =~ .+=.+ ]]; then
|
249
|
-
|
250
|
-
|
251
|
-
elif [[ "$DEFAULT_PROVISION" == "" ]]; then
|
252
|
-
|
253
|
-
fi
|
250
|
+
if [[ "$1" =~ .+=.+ ]]; then
|
251
|
+
PROVISION="${1#*=}"
|
252
|
+
add_provision_for_bundle_id "$PROVISION" "${1%%=*}"
|
253
|
+
elif [[ "$DEFAULT_PROVISION" == "" ]]; then
|
254
|
+
DEFAULT_PROVISION="$PROVISION"
|
255
|
+
fi
|
254
256
|
|
255
|
-
if [[ ! -e "$PROVISION" ]]; then
|
256
|
-
|
257
|
-
|
258
|
-
fi
|
257
|
+
if [[ ! -e "$PROVISION" ]]; then
|
258
|
+
echo "Provisioning profile '$PROVISION' file does not exist" >&2
|
259
|
+
exit 1;
|
260
|
+
fi
|
259
261
|
|
260
|
-
local BUNDLE_ID=`bundle_id_for_provison "$PROVISION"`
|
261
|
-
add_provision_for_bundle_id "$PROVISION" "$BUNDLE_ID"
|
262
|
+
local BUNDLE_ID=`bundle_id_for_provison "$PROVISION"`
|
263
|
+
add_provision_for_bundle_id "$PROVISION" "$BUNDLE_ID"
|
262
264
|
}
|
263
265
|
|
264
266
|
# Load bundle identifiers from provisioning profiles
|
@@ -269,206 +271,225 @@ done
|
|
269
271
|
# Resign the given application
|
270
272
|
function resign {
|
271
273
|
|
272
|
-
local APP_PATH="$1"
|
273
|
-
local NESTED="$2"
|
274
|
-
local BUNDLE_IDENTIFIER="$BUNDLE_IDENTIFIER"
|
275
|
-
local NEW_PROVISION="$NEW_PROVISION"
|
276
|
-
local APP_IDENTIFER_PREFIX=""
|
277
|
-
local TEAM_IDENTIFIER=""
|
274
|
+
local APP_PATH="$1"
|
275
|
+
local NESTED="$2"
|
276
|
+
local BUNDLE_IDENTIFIER="$BUNDLE_IDENTIFIER"
|
277
|
+
local NEW_PROVISION="$NEW_PROVISION"
|
278
|
+
local APP_IDENTIFER_PREFIX=""
|
279
|
+
local TEAM_IDENTIFIER=""
|
278
280
|
|
279
|
-
if [[ "$NESTED" == NESTED ]]; then
|
280
|
-
|
281
|
-
|
282
|
-
fi
|
281
|
+
if [[ "$NESTED" == NESTED ]]; then
|
282
|
+
# Ignore bundle identifier for nested applications
|
283
|
+
BUNDLE_IDENTIFIER=""
|
284
|
+
fi
|
283
285
|
|
284
|
-
# Make sure that the Info.plist file is where we expect it
|
285
|
-
if [ ! -e "$APP_PATH/Info.plist" ];
|
286
|
-
then
|
287
|
-
|
288
|
-
|
289
|
-
fi
|
286
|
+
# Make sure that the Info.plist file is where we expect it
|
287
|
+
if [ ! -e "$APP_PATH/Info.plist" ];
|
288
|
+
then
|
289
|
+
echo "Expected file does not exist: '$APP_PATH/Info.plist'" >&2
|
290
|
+
exit 1;
|
291
|
+
fi
|
290
292
|
|
291
|
-
# Read in current values from the app
|
292
|
-
local CURRENT_NAME=`PlistBuddy -c "Print :CFBundleDisplayName" "$APP_PATH/Info.plist"`
|
293
|
-
local CURRENT_BUNDLE_IDENTIFIER=`PlistBuddy -c "Print :CFBundleIdentifier" "$APP_PATH/Info.plist"`
|
294
|
-
local NEW_PROVISION=`provision_for_bundle_id "${BUNDLE_IDENTIFIER:-$CURRENT_BUNDLE_IDENTIFIER}"`
|
293
|
+
# Read in current values from the app
|
294
|
+
local CURRENT_NAME=`PlistBuddy -c "Print :CFBundleDisplayName" "$APP_PATH/Info.plist"`
|
295
|
+
local CURRENT_BUNDLE_IDENTIFIER=`PlistBuddy -c "Print :CFBundleIdentifier" "$APP_PATH/Info.plist"`
|
296
|
+
local NEW_PROVISION=`provision_for_bundle_id "${BUNDLE_IDENTIFIER:-$CURRENT_BUNDLE_IDENTIFIER}"`
|
295
297
|
|
296
|
-
if [[ "$NEW_PROVISION" == "" && "$NESTED" != NESTED ]]; then
|
297
|
-
|
298
|
-
fi
|
298
|
+
if [[ "$NEW_PROVISION" == "" && "$NESTED" != NESTED ]]; then
|
299
|
+
NEW_PROVISION="$DEFAULT_PROVISION"
|
300
|
+
fi
|
299
301
|
|
300
|
-
if [[ "$NEW_PROVISION" == "" ]]; then
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
302
|
+
if [[ "$NEW_PROVISION" == "" ]]; then
|
303
|
+
if [[ "$NESTED" == NESTED ]]; then
|
304
|
+
echo "No provisioning profile for nested application: '$APP_PATH' with bundle identifier '${BUNDLE_IDENTIFIER:-$CURRENT_BUNDLE_IDENTIFIER}'" >&2
|
305
|
+
else
|
306
|
+
echo "No provisioning profile for application: '$APP_PATH' with bundle identifier '${BUNDLE_IDENTIFIER:-$CURRENT_BUNDLE_IDENTIFIER}'" >&2
|
307
|
+
fi
|
308
|
+
echo "Use the -p option (example: -p com.example.app=xxxx.mobileprovision)" >&2
|
309
|
+
exit 1;
|
305
310
|
fi
|
306
|
-
echo "Use the -p option (example: -p com.example.app=xxxx.mobileprovision)" >&2
|
307
|
-
exit 1;
|
308
|
-
fi
|
309
311
|
|
310
|
-
local PROVISION_BUNDLE_IDENTIFIER=`bundle_id_for_provison "$NEW_PROVISION"`
|
312
|
+
local PROVISION_BUNDLE_IDENTIFIER=`bundle_id_for_provison "$NEW_PROVISION"`
|
311
313
|
|
312
|
-
# Use provisioning profile's bundle identifier
|
313
|
-
if [ "$BUNDLE_IDENTIFIER" == "" ]; then
|
314
|
-
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
|
314
|
+
# Use provisioning profile's bundle identifier
|
315
|
+
if [ "$BUNDLE_IDENTIFIER" == "" ]; then
|
316
|
+
if [[ "$PROVISION_BUNDLE_IDENTIFIER" =~ \* ]]; then
|
317
|
+
echo "Bundle Identifier contains a *, using the current bundle identifier" >&2
|
318
|
+
BUNDLE_IDENTIFIER="$CURRENT_BUNDLE_IDENTIFIER"
|
319
|
+
else
|
320
|
+
BUNDLE_IDENTIFIER="$PROVISION_BUNDLE_IDENTIFIER"
|
321
|
+
fi
|
319
322
|
fi
|
320
|
-
fi
|
321
323
|
|
322
|
-
if ! does_bundle_id_match "$PROVISION_BUNDLE_IDENTIFIER" "$BUNDLE_IDENTIFIER"; then
|
323
|
-
|
324
|
-
|
325
|
-
fi
|
324
|
+
if ! does_bundle_id_match "$PROVISION_BUNDLE_IDENTIFIER" "$BUNDLE_IDENTIFIER"; then
|
325
|
+
echo "Bundle Identifier '$PROVISION_BUNDLE_IDENTIFIER' in provisioning profile '$NEW_PROVISION' does not match the Bundle Identifier '$BUNDLE_IDENTIFIER' for application '$APP_PATH'." >&2
|
326
|
+
exit 1
|
327
|
+
fi
|
326
328
|
|
327
|
-
echo "Current bundle identifier is: '$CURRENT_BUNDLE_IDENTIFIER'" >&2
|
328
|
-
echo "New bundle identifier will be: '$BUNDLE_IDENTIFIER'" >&2
|
329
|
+
echo "Current bundle identifier is: '$CURRENT_BUNDLE_IDENTIFIER'" >&2
|
330
|
+
echo "New bundle identifier will be: '$BUNDLE_IDENTIFIER'" >&2
|
329
331
|
|
330
|
-
# Update the CFBundleDisplayName property in the Info.plist if a new name has been provided
|
331
|
-
if [ "${DISPLAY_NAME}" != "" ];
|
332
|
-
then
|
333
|
-
if [ "${DISPLAY_NAME}" != "${CURRENT_NAME}" ];
|
332
|
+
# Update the CFBundleDisplayName property in the Info.plist if a new name has been provided
|
333
|
+
if [ "${DISPLAY_NAME}" != "" ];
|
334
334
|
then
|
335
|
-
|
336
|
-
|
335
|
+
if [ "${DISPLAY_NAME}" != "${CURRENT_NAME}" ];
|
336
|
+
then
|
337
|
+
echo "Changing display name from '$CURRENT_NAME' to '$DISPLAY_NAME'" >&2
|
338
|
+
`PlistBuddy -c "Set :CFBundleDisplayName $DISPLAY_NAME" "$APP_PATH/Info.plist"`
|
339
|
+
fi
|
337
340
|
fi
|
338
|
-
fi
|
339
341
|
|
340
|
-
# Replace the embedded mobile provisioning profile
|
341
|
-
echo "Validating the new provisioning profile: $NEW_PROVISION" >&2
|
342
|
-
security cms -D -i "$NEW_PROVISION" > "$TEMP_DIR/profile.plist"
|
343
|
-
checkStatus
|
342
|
+
# Replace the embedded mobile provisioning profile
|
343
|
+
echo "Validating the new provisioning profile: $NEW_PROVISION" >&2
|
344
|
+
security cms -D -i "$NEW_PROVISION" > "$TEMP_DIR/profile.plist"
|
345
|
+
checkStatus
|
344
346
|
|
345
|
-
APP_IDENTIFER_PREFIX=`PlistBuddy -c "Print :Entitlements:application-identifier" "$TEMP_DIR/profile.plist" | grep -E '^[A-Z0-9]*' -o | tr -d '\n'`
|
346
|
-
if [ "$APP_IDENTIFER_PREFIX" == "" ];
|
347
|
-
then
|
348
|
-
APP_IDENTIFER_PREFIX=`PlistBuddy -c "Print :ApplicationIdentifierPrefix:0" "$TEMP_DIR/profile.plist"`
|
347
|
+
APP_IDENTIFER_PREFIX=`PlistBuddy -c "Print :Entitlements:application-identifier" "$TEMP_DIR/profile.plist" | grep -E '^[A-Z0-9]*' -o | tr -d '\n'`
|
349
348
|
if [ "$APP_IDENTIFER_PREFIX" == "" ];
|
350
349
|
then
|
351
|
-
|
352
|
-
|
350
|
+
APP_IDENTIFER_PREFIX=`PlistBuddy -c "Print :ApplicationIdentifierPrefix:0" "$TEMP_DIR/profile.plist"`
|
351
|
+
if [ "$APP_IDENTIFER_PREFIX" == "" ];
|
352
|
+
then
|
353
|
+
echo "Failed to extract any app identifier prefix from '$NEW_PROVISION'" >&2
|
354
|
+
exit 1;
|
355
|
+
else
|
356
|
+
echo "WARNING: extracted an app identifier prefix '$APP_IDENTIFER_PREFIX' from '$NEW_PROVISION', but it was not found in the profile's entitlements" >&2
|
357
|
+
fi
|
353
358
|
else
|
354
|
-
echo "
|
359
|
+
echo "Profile app identifier prefix is '$APP_IDENTIFER_PREFIX'" >&2
|
355
360
|
fi
|
356
|
-
else
|
357
|
-
echo "Profile app identifier prefix is '$APP_IDENTIFER_PREFIX'" >&2
|
358
|
-
fi
|
359
361
|
|
360
|
-
TEAM_IDENTIFIER=`PlistBuddy -c "Print :Entitlements:com.apple.developer.team-identifier" "$TEMP_DIR/profile.plist" | tr -d '\n'`
|
361
|
-
if [ "$TEAM_IDENTIFIER" == "" ];
|
362
|
-
then
|
363
|
-
TEAM_IDENTIFIER=`PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/profile.plist"`
|
362
|
+
TEAM_IDENTIFIER=`PlistBuddy -c "Print :Entitlements:com.apple.developer.team-identifier" "$TEMP_DIR/profile.plist" | tr -d '\n'`
|
364
363
|
if [ "$TEAM_IDENTIFIER" == "" ];
|
365
364
|
then
|
366
|
-
|
365
|
+
TEAM_IDENTIFIER=`PlistBuddy -c "Print :TeamIdentifier:0" "$TEMP_DIR/profile.plist"`
|
366
|
+
if [ "$TEAM_IDENTIFIER" == "" ];
|
367
|
+
then
|
368
|
+
echo "Failed to extract team identifier from '$NEW_PROVISION', resigned ipa may fail on iOS 8 and higher" >&2
|
369
|
+
else
|
370
|
+
echo "WARNING: extracted a team identifier '$TEAM_IDENTIFIER' from '$NEW_PROVISION', but it was not found in the profile's entitlements, resigned ipa may fail on iOS 8 and higher" >&2
|
371
|
+
fi
|
367
372
|
else
|
368
|
-
echo "
|
373
|
+
echo "Profile team identifier is '$TEAM_IDENTIFIER'" >&2
|
369
374
|
fi
|
370
|
-
else
|
371
|
-
echo "Profile team identifier is '$TEAM_IDENTIFIER'" >&2
|
372
|
-
fi
|
373
375
|
|
374
|
-
cp "$NEW_PROVISION" "$APP_PATH/embedded.mobileprovision"
|
376
|
+
cp "$NEW_PROVISION" "$APP_PATH/embedded.mobileprovision"
|
375
377
|
|
376
378
|
|
377
|
-
#if the current bundle identifier is different from the new one in the provisioning profile, then change it.
|
378
|
-
if [ "$CURRENT_BUNDLE_IDENTIFIER" != "$BUNDLE_IDENTIFIER" ];
|
379
|
-
then
|
380
|
-
echo "Updating the bundle identifier from '$CURRENT_BUNDLE_IDENTIFIER' to '$BUNDLE_IDENTIFIER'" >&2
|
381
|
-
`PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_IDENTIFIER" "$APP_PATH/Info.plist"`
|
382
|
-
checkStatus
|
383
|
-
fi
|
384
|
-
|
385
|
-
# Update the version number properties in the Info.plist if a version number has been provided
|
386
|
-
if [ "$VERSION_NUMBER" != "" ];
|
387
|
-
then
|
388
|
-
CURRENT_VERSION_NUMBER=`PlistBuddy -c "Print :CFBundleVersion" "$APP_PATH/Info.plist"`
|
389
|
-
if [ "$VERSION_NUMBER" != "$CURRENT_VERSION_NUMBER" ];
|
379
|
+
#if the current bundle identifier is different from the new one in the provisioning profile, then change it.
|
380
|
+
if [ "$CURRENT_BUNDLE_IDENTIFIER" != "$BUNDLE_IDENTIFIER" ];
|
390
381
|
then
|
391
|
-
echo "Updating the
|
392
|
-
`PlistBuddy -c "Set :
|
393
|
-
|
382
|
+
echo "Updating the bundle identifier from '$CURRENT_BUNDLE_IDENTIFIER' to '$BUNDLE_IDENTIFIER'" >&2
|
383
|
+
`PlistBuddy -c "Set :CFBundleIdentifier $BUNDLE_IDENTIFIER" "$APP_PATH/Info.plist"`
|
384
|
+
checkStatus
|
394
385
|
fi
|
395
|
-
fi
|
396
386
|
|
397
|
-
#
|
398
|
-
|
399
|
-
if [ -d "$FRAMEWORKS_DIR" ];
|
400
|
-
then
|
401
|
-
if [ "$TEAM_IDENTIFIER" == "" ];
|
387
|
+
# Update the version number properties in the Info.plist if a version number has been provided
|
388
|
+
if [ "$VERSION_NUMBER" != "" ];
|
402
389
|
then
|
403
|
-
|
404
|
-
|
405
|
-
fi
|
406
|
-
|
407
|
-
echo "Resigning embedded frameworks using certificate: '$CERTIFICATE'" >&2
|
408
|
-
for framework in "$FRAMEWORKS_DIR"/*
|
409
|
-
do
|
410
|
-
if [[ "$framework" == *.framework || "$framework" == *.dylib ]]
|
390
|
+
CURRENT_VERSION_NUMBER=`PlistBuddy -c "Print :CFBundleVersion" "$APP_PATH/Info.plist"`
|
391
|
+
if [ "$VERSION_NUMBER" != "$CURRENT_VERSION_NUMBER" ];
|
411
392
|
then
|
412
|
-
|
413
|
-
|
414
|
-
|
415
|
-
echo "Ignoring non-framework: $framework" >&2
|
393
|
+
echo "Updating the version from '$CURRENT_VERSION_NUMBER' to '$VERSION_NUMBER'" >&2
|
394
|
+
`PlistBuddy -c "Set :CFBundleVersion $VERSION_NUMBER" "$APP_PATH/Info.plist"`
|
395
|
+
`PlistBuddy -c "Set :CFBundleShortVersionString $VERSION_NUMBER" "$APP_PATH/Info.plist"`
|
416
396
|
fi
|
417
|
-
|
418
|
-
fi
|
419
|
-
|
397
|
+
fi
|
420
398
|
|
421
|
-
|
422
|
-
|
423
|
-
if [ -
|
399
|
+
# Check for and resign any embedded frameworks (new feature for iOS 8 and above apps)
|
400
|
+
FRAMEWORKS_DIR="$APP_PATH/Frameworks"
|
401
|
+
if [ -d "$FRAMEWORKS_DIR" ];
|
424
402
|
then
|
425
|
-
|
426
|
-
ENTITLEMENTS_APP_ID_PREFIX=`PlistBuddy -c "Print :application-identifier" "$ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n'`
|
427
|
-
if [ "$ENTITLEMENTS_APP_ID_PREFIX" == "" ];
|
428
|
-
then
|
429
|
-
echo "Provided entitlements file is missing a value for the required 'application-identifier' key" >&2
|
430
|
-
exit 1;
|
431
|
-
elif [ "$ENTITLEMENTS_APP_ID_PREFIX" != "$APP_IDENTIFER_PREFIX" ];
|
403
|
+
if [ "$TEAM_IDENTIFIER" == "" ];
|
432
404
|
then
|
433
|
-
echo "
|
405
|
+
echo "ERROR: embedded frameworks detected, re-signing iOS 8 (or higher) applications wihout a team identifier in the certificate/profile does not work" >&2
|
434
406
|
exit 1;
|
435
407
|
fi
|
408
|
+
|
409
|
+
echo "Resigning embedded frameworks using certificate: '$CERTIFICATE'" >&2
|
410
|
+
for framework in "$FRAMEWORKS_DIR"/*
|
411
|
+
do
|
412
|
+
if [[ "$framework" == *.framework || "$framework" == *.dylib ]]
|
413
|
+
then
|
414
|
+
/usr/bin/codesign -f -s "$CERTIFICATE" "$framework"
|
415
|
+
checkStatus
|
416
|
+
else
|
417
|
+
echo "Ignoring non-framework: $framework" >&2
|
418
|
+
fi
|
419
|
+
done
|
436
420
|
fi
|
437
421
|
|
438
|
-
|
422
|
+
# Check for and update bundle identifiers for extensions and associated nested apps
|
423
|
+
echo "Fixing nested app and extension references"
|
424
|
+
for key in ${NESTED_APP_REFERENCE_KEYS[@]}; do
|
425
|
+
# Check if Info.plist has a reference to another app or extension
|
426
|
+
REF_BUNDLE_ID=`PlistBuddy -c "Print ${key}" "$APP_PATH/Info.plist" 2>/dev/null`
|
427
|
+
if [ -n "$REF_BUNDLE_ID" ];
|
428
|
+
then
|
429
|
+
# Found a reference bundle id, now get the corresponding provisioning profile for this bundle id
|
430
|
+
REF_PROVISION=`provision_for_bundle_id $REF_BUNDLE_ID`
|
431
|
+
# Map to the new bundle id
|
432
|
+
NEW_REF_BUNDLE_ID=`bundle_id_for_provison "$REF_PROVISION"`
|
433
|
+
# Change if not the same
|
434
|
+
if [ "$REF_BUNDLE_ID" != "$NEW_REF_BUNDLE_ID" ];
|
435
|
+
then
|
436
|
+
echo "Updating nested app or extension reference for ${key} key from ${REF_BUNDLE_ID} to ${NEW_REF_BUNDLE_ID}" >&2
|
437
|
+
`PlistBuddy -c "Set ${key} $NEW_REF_BUNDLE_ID" "$APP_PATH/Info.plist"`
|
438
|
+
fi
|
439
|
+
fi
|
440
|
+
done
|
441
|
+
|
442
|
+
if [ "$ENTITLEMENTS" != "" ];
|
439
443
|
then
|
440
|
-
|
441
|
-
ENTITLEMENTS_TEAM_IDENTIFIER=`PlistBuddy -c "Print :com.apple.developer.team-identifier" "$ENTITLEMENTS" | tr -d '\n'`
|
442
|
-
if [ "$ENTITLEMENTS_TEAM_IDENTIFIER" == "" ];
|
444
|
+
if [ -n "$APP_IDENTIFER_PREFIX" ];
|
443
445
|
then
|
444
|
-
|
445
|
-
|
446
|
-
|
446
|
+
# sanity check the 'application-identifier' is present in the provided entitlements and matches the provisioning profile value
|
447
|
+
ENTITLEMENTS_APP_ID_PREFIX=`PlistBuddy -c "Print :application-identifier" "$ENTITLEMENTS" | grep -E '^[A-Z0-9]*' -o | tr -d '\n'`
|
448
|
+
if [ "$ENTITLEMENTS_APP_ID_PREFIX" == "" ];
|
449
|
+
then
|
450
|
+
echo "Provided entitlements file is missing a value for the required 'application-identifier' key" >&2
|
451
|
+
exit 1;
|
452
|
+
elif [ "$ENTITLEMENTS_APP_ID_PREFIX" != "$APP_IDENTIFER_PREFIX" ];
|
453
|
+
then
|
454
|
+
echo "Provided entitlements file's app identifier prefix value '$ENTITLEMENTS_APP_ID_PREFIX' does not match the provided provisioning profile's value '$APP_IDENTIFER_PREFIX'" >&2
|
455
|
+
exit 1;
|
456
|
+
fi
|
457
|
+
fi
|
458
|
+
|
459
|
+
if [ -n "$TEAM_IDENTIFIER" ];
|
447
460
|
then
|
448
|
-
|
449
|
-
|
461
|
+
# sanity check the 'com.apple.developer.team-identifier' is present in the provided entitlements and matches the provisioning profile value
|
462
|
+
ENTITLEMENTS_TEAM_IDENTIFIER=`PlistBuddy -c "Print :com.apple.developer.team-identifier" "$ENTITLEMENTS" | tr -d '\n'`
|
463
|
+
if [ "$ENTITLEMENTS_TEAM_IDENTIFIER" == "" ];
|
464
|
+
then
|
465
|
+
echo "Provided entitlements file is missing a value for the required 'com.apple.developer.team-identifier' key" >&2
|
466
|
+
exit 1;
|
467
|
+
elif [ "$ENTITLEMENTS_TEAM_IDENTIFIER" != "$TEAM_IDENTIFIER" ];
|
468
|
+
then
|
469
|
+
echo "Provided entitlements file's 'com.apple.developer.team-identifier' '$ENTITLEMENTS_TEAM_IDENTIFIER' does not match the provided provisioning profile's value '$TEAM_IDENTIFIER'" >&2
|
470
|
+
exit 1;
|
471
|
+
fi
|
450
472
|
fi
|
451
|
-
fi
|
452
473
|
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
else
|
459
|
-
|
460
|
-
|
461
|
-
|
462
|
-
|
463
|
-
|
464
|
-
|
465
|
-
|
466
|
-
|
467
|
-
fi
|
474
|
+
echo "Resigning application using certificate: '$CERTIFICATE'" >&2
|
475
|
+
echo "and entitlements: $ENTITLEMENTS" >&2
|
476
|
+
cp -- "$ENTITLEMENTS" "$APP_PATH/archived-expanded-entitlements.xcent"
|
477
|
+
/usr/bin/codesign -f -s "$CERTIFICATE" --entitlements="$ENTITLEMENTS" "$APP_PATH"
|
478
|
+
checkStatus
|
479
|
+
else
|
480
|
+
echo "Extracting entitlements from provisioning profile" >&2
|
481
|
+
PlistBuddy -x -c "Print Entitlements" "$TEMP_DIR/profile.plist" > "$TEMP_DIR/newEntitlements"
|
482
|
+
checkStatus
|
483
|
+
echo "Resigning application using certificate: '$CERTIFICATE'" >&2
|
484
|
+
echo "and entitlements from provisioning profile: $NEW_PROVISION" >&2
|
485
|
+
cp -- "$TEMP_DIR/newEntitlements" "$APP_PATH/archived-expanded-entitlements.xcent"
|
486
|
+
/usr/bin/codesign -f -s "$CERTIFICATE" --entitlements="$TEMP_DIR/newEntitlements" "$APP_PATH"
|
487
|
+
checkStatus
|
488
|
+
fi
|
468
489
|
|
469
|
-
# Remove the temporary files if they were created before generating ipa
|
470
|
-
rm -f "$TEMP_DIR/newEntitlements"
|
471
|
-
rm -f "$TEMP_DIR/profile.plist"
|
490
|
+
# Remove the temporary files if they were created before generating ipa
|
491
|
+
rm -f "$TEMP_DIR/newEntitlements"
|
492
|
+
rm -f "$TEMP_DIR/profile.plist"
|
472
493
|
|
473
494
|
}
|
474
495
|
|
@@ -499,4 +520,4 @@ mv "$TEMP_DIR.ipa" "$NEW_FILE"
|
|
499
520
|
# Remove the temp directory
|
500
521
|
rm -rf "$TEMP_DIR"
|
501
522
|
|
502
|
-
echo "Process complete" >&2
|
523
|
+
echo "Process complete" >&2
|
data/lib/sigh/resign.rb
CHANGED
@@ -6,16 +6,16 @@ module Sigh
|
|
6
6
|
def run(options, args)
|
7
7
|
# get the command line inputs and parse those into the vars we need...
|
8
8
|
|
9
|
-
ipa, signing_identity, provisioning_profiles, entitlements = get_inputs(options, args)
|
9
|
+
ipa, signing_identity, provisioning_profiles, entitlements, version = get_inputs(options, args)
|
10
10
|
# ... then invoke our programmatic interface with these vars
|
11
|
-
resign(ipa, signing_identity, provisioning_profiles, entitlements)
|
11
|
+
resign(ipa, signing_identity, provisioning_profiles, entitlements, version)
|
12
12
|
end
|
13
13
|
|
14
|
-
def self.resign(ipa, signing_identity, provisioning_profiles, entitlements)
|
15
|
-
self.new.resign(ipa, signing_identity, provisioning_profiles, entitlements)
|
14
|
+
def self.resign(ipa, signing_identity, provisioning_profiles, entitlements, version)
|
15
|
+
self.new.resign(ipa, signing_identity, provisioning_profiles, entitlements, version)
|
16
16
|
end
|
17
17
|
|
18
|
-
def resign(ipa, signing_identity, provisioning_profiles, entitlements)
|
18
|
+
def resign(ipa, signing_identity, provisioning_profiles, entitlements, version)
|
19
19
|
resign_path = find_resign_path
|
20
20
|
signing_identity = find_signing_identity(signing_identity)
|
21
21
|
|
@@ -27,6 +27,7 @@ module Sigh
|
|
27
27
|
validate_params(resign_path, ipa, provisioning_profiles)
|
28
28
|
entitlements = "-e #{entitlements}" if entitlements
|
29
29
|
provisioning_options = provisioning_profiles.map { |fst, snd| "-p #{[fst, snd].compact.map(&:shellescape).join('=')}" }.join(' ')
|
30
|
+
version = "-n #{version}" if version
|
30
31
|
|
31
32
|
command = [
|
32
33
|
resign_path.shellescape,
|
@@ -34,6 +35,7 @@ module Sigh
|
|
34
35
|
signing_identity.shellescape,
|
35
36
|
provisioning_options, # we are aleady shellescaping this above, when we create the provisioning_options from the provisioning_profiles
|
36
37
|
entitlements,
|
38
|
+
version,
|
37
39
|
ipa.shellescape
|
38
40
|
].join(' ')
|
39
41
|
|
@@ -54,8 +56,9 @@ module Sigh
|
|
54
56
|
signing_identity = options.signing_identity || ask_for_signing_identity
|
55
57
|
provisioning_profiles = options.provisioning_profile || find_provisioning_profile || ask('Path to provisioning file: ')
|
56
58
|
entitlements = options.entitlements || find_entitlements
|
59
|
+
version = options.version_number || nil
|
57
60
|
|
58
|
-
return ipa, signing_identity, provisioning_profiles, entitlements
|
61
|
+
return ipa, signing_identity, provisioning_profiles, entitlements, version
|
59
62
|
end
|
60
63
|
|
61
64
|
def find_resign_path
|
data/lib/sigh/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sigh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Krause
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane_core
|
@@ -50,14 +50,20 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - ">="
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 0.
|
53
|
+
version: 0.22.0
|
54
|
+
- - "<"
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 1.0.0
|
54
57
|
type: :runtime
|
55
58
|
prerelease: false
|
56
59
|
version_requirements: !ruby/object:Gem::Requirement
|
57
60
|
requirements:
|
58
61
|
- - ">="
|
59
62
|
- !ruby/object:Gem::Version
|
60
|
-
version: 0.
|
63
|
+
version: 0.22.0
|
64
|
+
- - "<"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 1.0.0
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: bundler
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -226,7 +232,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
232
|
version: '0'
|
227
233
|
requirements: []
|
228
234
|
rubyforge_project:
|
229
|
-
rubygems_version: 2.4.
|
235
|
+
rubygems_version: 2.4.5.1
|
230
236
|
signing_key:
|
231
237
|
specification_version: 4
|
232
238
|
summary: Because you would rather spend your time building stuff than fighting provisioning
|