31 lines
1.0 KiB
Bash
31 lines
1.0 KiB
Bash
# !/bin/bash
|
|
SOURCEIPA="$1"
|
|
DEVELOPER="$2"
|
|
MOBILEPROV="$3"
|
|
TARGET="$4"
|
|
|
|
unzip -qo "$SOURCEIPA" -d extracted
|
|
|
|
APPLICATION=$(ls extracted/Payload/)
|
|
|
|
cp "$MOBILEPROV" "extracted/Payload/$APPLICATION/embedded.mobileprovision"
|
|
|
|
echo "Resigning with certificate: $DEVELOPER" >&2
|
|
find -d extracted -type d \( -name "*.app" -o -name "*.appex" -o -name "*.framework" \) > directories.txt
|
|
security cms -D -i "extracted/Payload/$APPLICATION/embedded.mobileprovision" > t_entitlements_full.plist
|
|
/usr/libexec/PlistBuddy -x -c 'Print:Entitlements' t_entitlements_full.plist > t_entitlements.plist
|
|
while IFS='' read -r line || [[ -n "$line" ]]; do
|
|
#/usr/bin/codesign -d --entitlements :- "$line" > t_entitlements.plist //save original entitlements from the app
|
|
/usr/bin/codesign --continue -f -s "$DEVELOPER" --entitlements "t_entitlements.plist" "$line"
|
|
done < directories.txt
|
|
|
|
echo "Creating the Signed IPA"
|
|
cd extracted
|
|
zip -qry ../extracted.ipa *
|
|
cd ..
|
|
mv extracted.ipa "$TARGET"
|
|
|
|
rm -rf "extracted"
|
|
rm directories.txt
|
|
rm t_entitlements.plist
|
|
rm t_entitlements_full.plist |