Merge pull request #16150 from MattHardcastle/add-signing-2.0-rebase

Add signing 2.0 rebase
This commit is contained in:
Matt Hardcastle 2019-09-07 09:09:11 -07:00 committed by GitHub
commit 3074ff96e0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 74 additions and 19 deletions

View file

@ -38,7 +38,7 @@ macro(SET_PACKAGING_PARAMETERS)
set(BUILD_ORGANIZATION "High Fidelity")
set(HIGH_FIDELITY_PROTOCOL "hifi")
set(HIGH_FIDELITY_APP_PROTOCOL "hifiapp")
set(INTERFACE_BUNDLE_NAME "Interface")
set(INTERFACE_BUNDLE_NAME "interface")
set(INTERFACE_ICON_PREFIX "interface")
# add definition for this release type
@ -61,7 +61,7 @@ macro(SET_PACKAGING_PARAMETERS)
set(PR_BUILD 1)
set(BUILD_VERSION "PR${RELEASE_NUMBER}")
set(BUILD_ORGANIZATION "High Fidelity - PR${RELEASE_NUMBER}")
set(INTERFACE_BUNDLE_NAME "Interface")
set(INTERFACE_BUNDLE_NAME "interface")
set(INTERFACE_ICON_PREFIX "interface-beta")
# add definition for this release type
@ -70,7 +70,7 @@ macro(SET_PACKAGING_PARAMETERS)
set(DEV_BUILD 1)
set(BUILD_VERSION "dev")
set(BUILD_ORGANIZATION "High Fidelity - ${BUILD_VERSION}")
set(INTERFACE_BUNDLE_NAME "Interface")
set(INTERFACE_BUNDLE_NAME "interface")
set(INTERFACE_ICON_PREFIX "interface-beta")
# add definition for this release type

View file

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>high-fidelity.hifi</string>
</array>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
<key>com.apple.security.network.server</key>
<true/>
</dict>
</plist>

View file

@ -14,6 +14,7 @@
#include <QtCore/QProcess>
#include <QDebug>
#include <QDir>
#include <QFileInfo>
#include <QLocalSocket>
#include <QLocalServer>
#include <QSharedMemory>
@ -117,21 +118,27 @@ int main(int argc, const char* argv[]) {
}
QString applicationPath;
// A temporary application instance is needed to get the location of the running executable
// Tests using high_resolution_clock show that this takes about 30-50 microseconds (on my machine, YMMV)
// If we wanted to avoid the QCoreApplication, we would need to write our own
// cross-platform implementation.
{
// A temporary application instance is needed to get the location of the running executable
// Tests using high_resolution_clock show that this takes about 30-50 microseconds (on my machine, YMMV)
// If we wanted to avoid the QCoreApplication, we would need to write our own
// cross-platform implementation.
QCoreApplication tempApp(argc, const_cast<char**>(argv));
#ifdef Q_OS_OSX
if (QFileInfo::exists(QCoreApplication::applicationDirPath() + "/../../../config.json")) {
applicationPath = QCoreApplication::applicationDirPath() + "/../../../";
} else {
applicationPath = QCoreApplication::applicationDirPath();
}
#else
applicationPath = QCoreApplication::applicationDirPath();
#endif
}
static const QString APPLICATION_CONFIG_FILENAME = "config.json";
QDir applicationDir(applicationPath);
QString configFileName = applicationDir.filePath(APPLICATION_CONFIG_FILENAME);
QFile configFile(configFileName);
QString launcherPath;
if (configFile.exists()) {
if (!configFile.open(QIODevice::ReadOnly)) {
qWarning() << "Found application config, but could not open it";

View file

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>high-fidelity.hifi</string>
</array>
</dict>
</plist>

View file

@ -50,6 +50,8 @@
repeats: YES];
NSError *error = nil;
NSFileManager *fileManager = [NSFileManager defaultManager];
Launcher* sharedLauncher = [Launcher sharedLauncher];
NSString* appPath = [sharedLauncher getAppPath];
NSString *destinationFileName = downloadTask.originalRequest.URL.lastPathComponent;
NSString* finalFilePath = [[[Launcher sharedLauncher] getAppPath] stringByAppendingPathComponent:destinationFileName];
NSURL *destinationURL = [NSURL URLWithString: [finalFilePath stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]];
@ -59,7 +61,12 @@
}
[fileManager moveItemAtURL:location toURL:destinationURL error:&error];
Launcher* sharedLauncher = [Launcher sharedLauncher];
NSURL *oldInterfaceURL = [NSURL URLWithString: [[appPath stringByAppendingString:@"interface.app"] stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]] relativeToURL: [NSURL URLWithString:@"file://"]];
if([fileManager fileExistsAtPath:[oldInterfaceURL path]])
{
[fileManager removeItemAtURL:oldInterfaceURL error:nil];
}
if (error) {
NSLog(@"Download Interface: failed to move file to destination -> error: %@", error);
@ -68,7 +75,6 @@
return;
}
[sharedLauncher setDownloadFilename:destinationFileName];
NSString* appPath = [sharedLauncher getAppPath];
NSString* downloadFileName = [sharedLauncher getDownloadFilename];
NSLog(@"extract interface zip");

View file

@ -14,19 +14,32 @@
return sharedSettings;
}
- (NSString*) getOldFilePath {
Launcher* sharedLauncher = [Launcher sharedLauncher];
NSString* appPath = [sharedLauncher getAppPath];
NSString* filePath = [appPath stringByAppendingString:@"interface.app/Contents/MacOS/"];
return filePath;
}
- (NSString*) getFilePath
{
Launcher* sharedLauncher = [Launcher sharedLauncher];
NSString* appPath = [sharedLauncher getAppPath];
NSString* filePath = [appPath stringByAppendingString:@"interface.app/Contents/MacOS/"];
return filePath;
return appPath;
}
- (void) readDataFromJsonFile
{
NSString* oldPath = [self getOldFilePath];
NSString* fileAtOldPath = [oldPath stringByAppendingString:@"config.json"];
NSString* filePath = [self getFilePath];
NSString* fileAtPath = [filePath stringByAppendingString:@"config.json"];
if ([[NSFileManager defaultManager] fileExistsAtPath:fileAtOldPath] && ![[NSFileManager defaultManager] fileExistsAtPath:fileAtPath]) {
BOOL success = [[NSFileManager defaultManager] moveItemAtPath:fileAtOldPath toPath:fileAtPath error:nil];
NSLog(@"move config to new location -> status: %@", success ? @"SUCCESS" : @"FAILED");
}
if ([[NSFileManager defaultManager] fileExistsAtPath:fileAtPath]) {
NSString* jsonString = [[NSString alloc] initWithData:[NSData dataWithContentsOfFile:fileAtPath] encoding:NSUTF8StringEncoding];
NSError * err;
@ -34,7 +47,6 @@
NSDictionary * json;
if (data != nil) {
json = (NSDictionary *)[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers error:&err];
self.loggedIn = [[json valueForKey:@"loggedIn"] boolValue];
self.build = [[json valueForKey:@"build_version"] integerValue];
self.launcher = [json valueForKey:@"luancherPath"];
@ -64,18 +76,18 @@
NSError * err;
NSData * jsonData = [NSJSONSerialization dataWithJSONObject:json options:0 error:&err];
NSString * jsonString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding];
NSString* filePath = [self getFilePath];
NSString* fileAtPath = [filePath stringByAppendingString:@"config.json"];
if (![[NSFileManager defaultManager] fileExistsAtPath:fileAtPath]) {
NSError * error = nil;
[[NSFileManager defaultManager] createDirectoryAtPath:filePath withIntermediateDirectories:FALSE attributes:nil error:&error];
[[NSFileManager defaultManager] createFileAtPath:fileAtPath contents:nil attributes:nil];
}
[[jsonString dataUsingEncoding:NSUTF8StringEncoding] writeToFile:fileAtPath atomically:NO];
}
-(id)init