mirror of
https://github.com/sparkle-project/Sparkle
synced 2026-11-24 04:38:16 +00:00
Backport flat package support from #1745
This commit is contained in:
1 parent
3b78c78702
commit
a841415046
6 files changed
+123
-10
No files matched your search
@@ -223,6 +223,9 @@
|
||||
721BC2111D1DFF05002BC71E /* SUFileOperationConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = 722954C31D04E66F00ECF9CA /* SUFileOperationConstants.m */; };
|
||||
721CF1AA1AD7647000D9AC09 /* libxar.1.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D1AF5890FD7678C0065DB48 /* libxar.1.dylib */; };
|
||||
721CF1AB1AD764EB00D9AC09 /* libbz2.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 5D06E8FB0FD68D61005AE3F6 /* libbz2.dylib */; };
|
||||
721D5B5A25C6940400D23BEA /* SUFlatPackageUnarchiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 721D5B5825C6940400D23BEA /* SUFlatPackageUnarchiver.m */; };
|
||||
721D5B5B25C6940400D23BEA /* SUFlatPackageUnarchiver.h in Headers */ = {isa = PBXBuildFile; fileRef = 721D5B5925C6940400D23BEA /* SUFlatPackageUnarchiver.h */; };
|
||||
721D5B6925C69A6900D23BEA /* test.sparkle_interactive.pkg in Resources */ = {isa = PBXBuildFile; fileRef = 721D5B6825C69A6900D23BEA /* test.sparkle_interactive.pkg */; };
|
||||
722589D71E0AD86B005EA0B9 /* SUUnarchiverProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = 722589D61E0AD86B005EA0B9 /* SUUnarchiverProtocol.h */; };
|
||||
722589DA1E0B19F4005EA0B9 /* SUUnarchiverNotifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 722589D81E0B19F4005EA0B9 /* SUUnarchiverNotifier.h */; };
|
||||
722589DB1E0B19F4005EA0B9 /* SUUnarchiverNotifier.m in Sources */ = {isa = PBXBuildFile; fileRef = 722589D91E0B19F4005EA0B9 /* SUUnarchiverNotifier.m */; };
|
||||
@@ -837,6 +840,9 @@
|
||||
720B16421C66433D006985FB /* UITests-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = "UITests-Info.plist"; path = "UITests/UITests-Info.plist"; sourceTree = SOURCE_ROOT; };
|
||||
720B16431C66433D006985FB /* SUTestApplicationTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SUTestApplicationTest.swift; path = UITests/SUTestApplicationTest.swift; sourceTree = SOURCE_ROOT; };
|
||||
7210C7671B9A9A1500EB90AC /* SUUnarchiverTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SUUnarchiverTest.swift; sourceTree = "<group>"; };
|
||||
721D5B5825C6940400D23BEA /* SUFlatPackageUnarchiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SUFlatPackageUnarchiver.m; sourceTree = "<group>"; };
|
||||
721D5B5925C6940400D23BEA /* SUFlatPackageUnarchiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUFlatPackageUnarchiver.h; sourceTree = "<group>"; };
|
||||
721D5B6825C69A6900D23BEA /* test.sparkle_interactive.pkg */ = {isa = PBXFileReference; lastKnownFileType = file; path = test.sparkle_interactive.pkg; sourceTree = "<group>"; };
|
||||
7223E7611AD1AEFF008E3161 /* sais.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = sais.c; sourceTree = "<group>"; };
|
||||
7223E7621AD1AEFF008E3161 /* sais.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sais.h; sourceTree = "<group>"; };
|
||||
722589D61E0AD86B005EA0B9 /* SUUnarchiverProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SUUnarchiverProtocol.h; sourceTree = "<group>"; };
|
||||
@@ -1351,6 +1357,7 @@
|
||||
F8761EB21ADC50EB000C9034 /* SparkleTestCodeSignApp.zip */,
|
||||
14958C6C19AEBC610061B14F /* test-pubkey.pem */,
|
||||
5AF6C74E1AEA46D10014A3AB /* test.pkg */,
|
||||
721D5B6825C69A6900D23BEA /* test.sparkle_interactive.pkg */,
|
||||
5AD0FA7E1C73F2E2004BCEFF /* testappcast.xml */,
|
||||
5F1510A11C96E591006E1629 /* testnamespaces.xml */,
|
||||
4444E78E237B047B00CBB3CF /* testlocalizedreleasenotesappcast.xml */,
|
||||
@@ -1480,6 +1487,8 @@
|
||||
6102FE490E07803800F85D09 /* SUDiskImageUnarchiver.m */,
|
||||
6102FE440E077FCE00F85D09 /* SUPipedUnarchiver.h */,
|
||||
6129C0B90E0B79810062CE76 /* SUPipedUnarchiver.m */,
|
||||
721D5B5925C6940400D23BEA /* SUFlatPackageUnarchiver.h */,
|
||||
721D5B5825C6940400D23BEA /* SUFlatPackageUnarchiver.m */,
|
||||
61299A8B09CA790200B7442F /* SUUnarchiver.h */,
|
||||
61299A8C09CA790200B7442F /* SUUnarchiver.m */,
|
||||
722589D81E0B19F4005EA0B9 /* SUUnarchiverNotifier.h */,
|
||||
@@ -1763,6 +1772,7 @@
|
||||
72E1D7DE25A3E3AD0001BA6D /* SUWebViewCommon.h in Headers */,
|
||||
5AB8F187214D564C00A1187F /* precomp_data.h in Headers */,
|
||||
5AB8F18F214D564C00A1187F /* sc.h in Headers */,
|
||||
721D5B5B25C6940400D23BEA /* SUFlatPackageUnarchiver.h in Headers */,
|
||||
5AB8F181214D564C00A1187F /* sha512.h in Headers */,
|
||||
61299B3609CB04E000B7442F /* Sparkle.h in Headers */,
|
||||
34074B9F1FEABD5A001CB3A5 /* SPUDownloadData.h in Headers */,
|
||||
@@ -2220,6 +2230,7 @@
|
||||
C23E885B1BE7B24F0050BB73 /* SparkleTestCodeSignApp.enc.dmg in Resources */,
|
||||
4444E790237B057900CBB3CF /* testlocalizedreleasenotesappcast.xml in Resources */,
|
||||
72AC6B281B9AAD6700F62325 /* SparkleTestCodeSignApp.tar in Resources */,
|
||||
721D5B6925C69A6900D23BEA /* test.sparkle_interactive.pkg in Resources */,
|
||||
72AC6B2A1B9AAF3A00F62325 /* SparkleTestCodeSignApp.tar.bz2 in Resources */,
|
||||
72AC6B261B9AAC8800F62325 /* SparkleTestCodeSignApp.tar.gz in Resources */,
|
||||
72AC6B2C1B9AB0EE00F62325 /* SparkleTestCodeSignApp.tar.xz in Resources */,
|
||||
@@ -2514,6 +2525,7 @@
|
||||
6196CFFA09C72149000DC222 /* SUStatusController.m in Sources */,
|
||||
61A2279D0D1CEE7600430CCD /* SUSystemProfiler.m in Sources */,
|
||||
72316BE41E0E1C7F0039EFD9 /* SUSystemUpdateInfo.m in Sources */,
|
||||
721D5B5A25C6940400D23BEA /* SUFlatPackageUnarchiver.m in Sources */,
|
||||
A3AD648C24D283F400058938 /* SUGlobalUpdateLock.m in Sources */,
|
||||
E1545EC61E1D7E0200FAECE8 /* SUTouchBarButtonGroup.m in Sources */,
|
||||
61B93A3D0DD02D7000DCD2F8 /* SUUIBasedUpdateDriver.m in Sources */,
|
||||
|
||||
Vendored
+21
@@ -0,0 +1,21 @@
|
||||
//
|
||||
// SUFlatPackageUnarchiver.h
|
||||
// Autoupdate
|
||||
//
|
||||
// Created by Mayur Pawashe on 1/30/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
#import "SUUnarchiverProtocol.h"
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
// An unarchiver for flat packages that doesn't really do any unarchiving
|
||||
@interface SUFlatPackageUnarchiver : NSObject <SUUnarchiverProtocol>
|
||||
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath;
|
||||
|
||||
@end
|
||||
|
||||
NS_ASSUME_NONNULL_END
|
||||
Vendored
+64
@@ -0,0 +1,64 @@
|
||||
//
|
||||
// SUFlatPackageUnarchiver.m
|
||||
// Autoupdate
|
||||
//
|
||||
// Created by Mayur Pawashe on 1/30/21.
|
||||
// Copyright © 2021 Sparkle Project. All rights reserved.
|
||||
//
|
||||
|
||||
#import "SUFlatPackageUnarchiver.h"
|
||||
#import "SUUnarchiverNotifier.h"
|
||||
#import "SUErrors.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
|
||||
@interface SUFlatPackageUnarchiver ()
|
||||
|
||||
@property (nonatomic, readonly) NSString *flatPackagePath;
|
||||
|
||||
@end
|
||||
|
||||
@implementation SUFlatPackageUnarchiver
|
||||
|
||||
@synthesize flatPackagePath = _flatPackagePath;
|
||||
|
||||
+ (BOOL)canUnarchivePath:(NSString *)path
|
||||
{
|
||||
return [path.pathExtension isEqualToString:@"pkg"];
|
||||
}
|
||||
|
||||
// Note in 2.x this method returns YES, but 1.x does not support pre-validation of pkgs
|
||||
+ (BOOL)mustValidateBeforeExtraction
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
|
||||
- (instancetype)initWithFlatPackagePath:(NSString *)flatPackagePath;
|
||||
{
|
||||
self = [super init];
|
||||
if (self != nil) {
|
||||
_flatPackagePath = [flatPackagePath copy];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)unarchiveWithCompletionBlock:(void (^)(NSError * _Nullable))completionBlock progressBlock:(void (^ _Nullable)(double))progressBlock
|
||||
{
|
||||
SUUnarchiverNotifier *notifier = [[SUUnarchiverNotifier alloc] initWithCompletionBlock:completionBlock progressBlock:progressBlock];
|
||||
|
||||
// Flat packages must use guided package installs, not interactive
|
||||
BOOL isDirectory = NO;
|
||||
if ([[[self.flatPackagePath stringByDeletingPathExtension] pathExtension] isEqualToString:@"sparkle_interactive"]) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat packages can not be installed interactively with 'sparkle_interactive' and must instead be guided"]}]];
|
||||
} else if (![[NSFileManager defaultManager] fileExistsAtPath:self.flatPackagePath isDirectory:&isDirectory] || isDirectory) {
|
||||
[notifier notifyFailureWithError:[NSError errorWithDomain:SUSparkleErrorDomain code:SUUnarchivingError userInfo:@{ NSLocalizedDescriptionKey:[NSString stringWithFormat:@"Flat package does not exist at %@", self.flatPackagePath]}]];
|
||||
} else {
|
||||
[notifier notifyProgress:1.0];
|
||||
[notifier notifySuccess];
|
||||
}
|
||||
}
|
||||
|
||||
- (NSString *)description { return [NSString stringWithFormat:@"%@ <%@>", [self class], self.flatPackagePath]; }
|
||||
|
||||
@end
|
||||
Vendored
+4
@@ -11,6 +11,7 @@
|
||||
#import "SUPipedUnarchiver.h"
|
||||
#import "SUDiskImageUnarchiver.h"
|
||||
#import "SUBinaryDeltaUnarchiver.h"
|
||||
#import "SUFlatPackageUnarchiver.h"
|
||||
|
||||
|
||||
#include "AppKitPrevention.h"
|
||||
@@ -29,6 +30,9 @@
|
||||
assert(hostPath != nil);
|
||||
NSString *nonNullHostPath = hostPath;
|
||||
return [[SUBinaryDeltaUnarchiver alloc] initWithArchivePath:path updateHostBundlePath:nonNullHostPath];
|
||||
|
||||
} else if ([SUFlatPackageUnarchiver canUnarchivePath:path]) {
|
||||
return [[SUFlatPackageUnarchiver alloc] initWithFlatPackagePath:path];
|
||||
}
|
||||
return nil;
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -10,8 +10,8 @@ import XCTest
|
||||
|
||||
class SUUnarchiverTest: XCTestCase
|
||||
{
|
||||
func unarchiveTestAppWithExtension(_ archiveExtension: String, password: String? = nil) {
|
||||
let appName = "SparkleTestCodeSignApp"
|
||||
func unarchiveTestAppWithExtension(_ archiveExtension: String, password: String? = nil, resourceName: String = "SparkleTestCodeSignApp", expectingSuccess: Bool = true) {
|
||||
let appName = resourceName
|
||||
let archiveResourceURL = Bundle(for: type(of: self)).url(forResource: appName, withExtension: archiveExtension)!
|
||||
|
||||
let fileManager = FileManager.default
|
||||
@@ -27,17 +27,18 @@ class SUUnarchiverTest: XCTestCase
|
||||
let tempArchiveURL = tempDirectoryURL.appendingPathComponent(archiveResourceURL.lastPathComponent)
|
||||
let extractedAppURL = tempDirectoryURL.appendingPathComponent(appName).appendingPathExtension("app")
|
||||
|
||||
self.unarchiveTestSuccessAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, testExpectation: unarchivedSuccessExpectation)
|
||||
self.unarchiveTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation)
|
||||
self.unarchiveTestAppWithExtension(archiveExtension, appName: appName, tempDirectoryURL: tempDirectoryURL, tempArchiveURL: tempArchiveURL, archiveResourceURL: archiveResourceURL, password: password, expectingSuccess: expectingSuccess, testExpectation: unarchivedSuccessExpectation)
|
||||
self.unarchiveNonExistentFileTestFailureAppWithExtension(archiveExtension, tempDirectoryURL: tempDirectoryURL, password: password, testExpectation: unarchivedFailureExpectation)
|
||||
|
||||
super.waitForExpectations(timeout: 7.0, handler: nil)
|
||||
|
||||
XCTAssertTrue(fileManager.fileExists(atPath: extractedAppURL.path))
|
||||
|
||||
XCTAssertEqual("6a60ab31430cfca8fb499a884f4a29f73e59b472", hashOfTree(extractedAppURL.path))
|
||||
if !archiveExtension.hasSuffix("pkg") {
|
||||
XCTAssertTrue(fileManager.fileExists(atPath: extractedAppURL.path))
|
||||
XCTAssertEqual("6a60ab31430cfca8fb499a884f4a29f73e59b472", hashOfTree(extractedAppURL.path))
|
||||
}
|
||||
}
|
||||
|
||||
func unarchiveTestFailureAppWithExtension(_ archiveExtension: String, tempDirectoryURL: URL, password: String?, testExpectation: XCTestExpectation) {
|
||||
func unarchiveNonExistentFileTestFailureAppWithExtension(_ archiveExtension: String, tempDirectoryURL: URL, password: String?, testExpectation: XCTestExpectation) {
|
||||
let tempArchiveURL = tempDirectoryURL.appendingPathComponent("error-invalid").appendingPathExtension(archiveExtension)
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
|
||||
@@ -48,7 +49,7 @@ class SUUnarchiverTest: XCTestCase
|
||||
}
|
||||
|
||||
// swiftlint:disable function_parameter_count
|
||||
func unarchiveTestSuccessAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, tempArchiveURL: URL, archiveResourceURL: URL, password: String?, testExpectation: XCTestExpectation) {
|
||||
func unarchiveTestAppWithExtension(_ archiveExtension: String, appName: String, tempDirectoryURL: URL, tempArchiveURL: URL, archiveResourceURL: URL, password: String?, expectingSuccess: Bool, testExpectation: XCTestExpectation) {
|
||||
|
||||
let fileManager = FileManager.default
|
||||
|
||||
@@ -57,7 +58,11 @@ class SUUnarchiverTest: XCTestCase
|
||||
let unarchiver = SUUnarchiver.unarchiver(forPath: tempArchiveURL.path, updatingHostBundlePath: nil, decryptionPassword: password)!
|
||||
|
||||
unarchiver.unarchive(completionBlock: {(error: Error?) -> Void in
|
||||
XCTAssertNil(error)
|
||||
if expectingSuccess {
|
||||
XCTAssertNil(error)
|
||||
} else {
|
||||
XCTAssertNotNil(error)
|
||||
}
|
||||
testExpectation.fulfill()
|
||||
}, progressBlock: nil)
|
||||
}
|
||||
@@ -96,4 +101,11 @@ class SUUnarchiverTest: XCTestCase
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("enc.dmg", password: "testpass")
|
||||
}
|
||||
|
||||
func testUnarchivingFlatPackage()
|
||||
{
|
||||
self.unarchiveTestAppWithExtension("pkg", resourceName: "test")
|
||||
|
||||
self.unarchiveTestAppWithExtension("pkg", resourceName: "test.sparkle_interactive", expectingSuccess: false)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user