Skip to content

Commit

Permalink
Added support for signing python egg files
Browse files Browse the repository at this point in the history
  • Loading branch information
DanTheMan827 committed Dec 23, 2015
1 parent 5eb1f4f commit 82fde2a
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AppSigner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0b13</string>
<string>1.0b14</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
Expand Down
49 changes: 45 additions & 4 deletions AppSigner/MainView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,13 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
}
}

func unzip(inputFile: String, outputPath: String)->AppSignerTaskOutput {
return NSTask().execute(unzipPath, workingDirectory: nil, arguments: ["-q",inputFile,"-d",outputPath])
}
func zip(inputPath: String, outputFile: String)->AppSignerTaskOutput {
return NSTask().execute(zipPath, workingDirectory: inputPath, arguments: ["-qry", outputFile, "."])
}

func cleanup(tempFolder: String){
do {
try fileManager.removeItemAtPath(tempFolder)
Expand Down Expand Up @@ -366,6 +373,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
let newApplicationID = self.NewApplicationIDTextField.stringValue.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let newDisplayName = self.appDisplayName.stringValue.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let inputStartsWithHTTP = inputFile.lowercaseString.substringToIndex(inputFile.startIndex.advancedBy(4)) == "http"
var eggCount: Int = 0

//MARK: Sanity checks

Expand Down Expand Up @@ -395,13 +403,23 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
}
let tempFolder = tempTask.output.stringByTrimmingCharactersInSet(NSCharacterSet.whitespaceAndNewlineCharacterSet())
let workingDirectory = tempFolder.stringByAppendingPathComponent("out")
let eggDirectory = tempFolder.stringByAppendingPathComponent("eggs")
let payloadDirectory = workingDirectory.stringByAppendingPathComponent("Payload/")
let entitlementsPlist = tempFolder.stringByAppendingPathComponent("entitlements.plist")

Log.write("Temp folder: \(tempFolder)")
Log.write("Working directory: \(workingDirectory)")
Log.write("Payload directory: \(payloadDirectory)")

//MARK: Create Egg Temp Directory
do {
try fileManager.createDirectoryAtPath(eggDirectory, withIntermediateDirectories: true, attributes: nil)
} catch let error as NSError {
setStatus("Error creating egg temp directory")
Log.write(error.localizedDescription)
cleanup(tempFolder); return
}

//MARK: Download file
downloading = false
downloadError = nil
Expand Down Expand Up @@ -479,7 +497,8 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
do {
try fileManager.createDirectoryAtPath(workingDirectory, withIntermediateDirectories: true, attributes: nil)
setStatus("Extracting ipa file")
let unzipTask = NSTask().execute(unzipPath, workingDirectory: nil, arguments: ["-q",inputFile,"-d",workingDirectory])

let unzipTask = self.unzip(inputFile, outputPath: workingDirectory)
if unzipTask.status != 0 {
setStatus("Error extracting ipa file")
cleanup(tempFolder); return
Expand Down Expand Up @@ -645,10 +664,32 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
}
}

//MARK: Codesigning
let signingFunction = generateFileSignFunc(payloadDirectory, entitlementsPath: entitlementsPlist, signingCertificate: signingCertificate!)
//MARK: Codesigning - General
let signableExtensions = ["dylib","so","0","vis","pvr","framework"]

//MARK: Codesigning - Eggs
let eggSigningFunction = generateFileSignFunc(eggDirectory, entitlementsPath: entitlementsPlist, signingCertificate: signingCertificate!)
func signEgg(eggFile: String){
eggCount++

let currentEggPath = eggDirectory.stringByAppendingPathComponent("egg\(eggCount)")
let shortName = eggFile.substringFromIndex(payloadDirectory.endIndex)
setStatus("Extracting \(shortName)")
if self.unzip(eggFile, outputPath: currentEggPath).status != 0 {
Log.write("Error extracting \(shortName)")
return
}
recursiveDirectorySearch(currentEggPath, extensions: ["egg"], found: signEgg)
recursiveDirectorySearch(currentEggPath, extensions: signableExtensions, found: eggSigningFunction)
setStatus("Compressing \(shortName)")
self.zip(currentEggPath, outputFile: eggFile)
}
recursiveDirectorySearch(appBundlePath, extensions: ["egg"], found: signEgg)

//MARK: Codesigning - App
let signingFunction = generateFileSignFunc(payloadDirectory, entitlementsPath: entitlementsPlist, signingCertificate: signingCertificate!)


recursiveDirectorySearch(appBundlePath, extensions: signableExtensions, found: signingFunction)
signingFunction(file: appBundlePath)
}
Expand All @@ -670,7 +711,7 @@ class MainView: NSView, NSURLSessionDataDelegate, NSURLSessionDelegate, NSURLSes
}
}
setStatus("Packaging IPA")
let zipTask = NSTask().execute(zipPath, workingDirectory: workingDirectory, arguments: ["-qry", outputFile!, "."])
let zipTask = self.zip(workingDirectory, outputFile: outputFile!)
if zipTask.status != 0 {
setStatus("Error packaging IPA")
}
Expand Down
4 changes: 0 additions & 4 deletions iOS App Signer.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
objects = {

/* Begin PBXBuildFile section */
6514F9CD1BF6F3020060EC17 /* app-sign.sh in Resources */ = {isa = PBXBuildFile; fileRef = 6514F9CC1BF6F3020060EC17 /* app-sign.sh */; };
652408CC1BE743D4006FA4C6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652408CB1BE743D4006FA4C6 /* AppDelegate.swift */; };
652408CE1BE743D4006FA4C6 /* MainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 652408CD1BE743D4006FA4C6 /* MainView.swift */; };
652408D01BE743D4006FA4C6 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 652408CF1BE743D4006FA4C6 /* Assets.xcassets */; };
Expand Down Expand Up @@ -39,7 +38,6 @@
/* End PBXContainerItemProxy section */

/* Begin PBXFileReference section */
6514F9CC1BF6F3020060EC17 /* app-sign.sh */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; name = "app-sign.sh"; path = "../app-sign.sh"; sourceTree = "<group>"; };
652408C81BE743D4006FA4C6 /* iOS App Signer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS App Signer.app"; sourceTree = BUILT_PRODUCTS_DIR; };
652408CB1BE743D4006FA4C6 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
652408CD1BE743D4006FA4C6 /* MainView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainView.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -108,7 +106,6 @@
652408CA1BE743D4006FA4C6 /* AppSigner */ = {
isa = PBXGroup;
children = (
6514F9CC1BF6F3020060EC17 /* app-sign.sh */,
655FFFDF1BEB270200D43AD8 /* Extensions */,
655FFFA01BEAD90800D43AD8 /* Classes */,
65311EB51BF88EB800516EFD /* Application.xib */,
Expand Down Expand Up @@ -271,7 +268,6 @@
files = (
65311EB61BF88EB800516EFD /* Application.xib in Resources */,
652408D01BE743D4006FA4C6 /* Assets.xcassets in Resources */,
6514F9CD1BF6F3020060EC17 /* app-sign.sh in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 82fde2a

Please sign in to comment.