Skip to content

Commit 9ae5842

Browse files
loutskiyloutskiy
authored andcommitted
new
1 parent d70d772 commit 9ae5842

10 files changed

Lines changed: 91 additions & 113 deletions

File tree

.DS_Store

-2 KB
Binary file not shown.

Installer.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@
2020
A757F2BB2100C1420049AE99 /* fileS.sig in Resources */ = {isa = PBXBuildFile; fileRef = A757F2BA2100C1420049AE99 /* fileS.sig */; };
2121
A757F2BE2100D6350049AE99 /* VerifySigning.m in Sources */ = {isa = PBXBuildFile; fileRef = A757F2BD2100D6350049AE99 /* VerifySigning.m */; };
2222
A757F2C021022D0E0049AE99 /* License.html in Resources */ = {isa = PBXBuildFile; fileRef = A757F2BF21022D0D0049AE99 /* License.html */; };
23-
A7AE17D82105E58F0086343D /* Shell.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7AE17D72105E58F0086343D /* Shell.swift */; };
2423
A7AE17DA2105EADA0086343D /* Script.sh in Resources */ = {isa = PBXBuildFile; fileRef = A7AE17D92105EADA0086343D /* Script.sh */; };
2524
A7AE17FC210B50DE0086343D /* LanguageManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7AE17FB210B50DE0086343D /* LanguageManager.swift */; };
2625
A7DE66B220F8D25200746EE0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE66B120F8D25200746EE0 /* AppDelegate.swift */; };
2726
A7DE66B620F8D25400746EE0 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = A7DE66B520F8D25400746EE0 /* Assets.xcassets */; };
2827
A7DE66B920F8D25400746EE0 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = A7DE66B720F8D25400746EE0 /* Main.storyboard */; };
2928
A7DE66C220F8DCC800746EE0 /* ContainerVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7DE66C120F8DCC800746EE0 /* ContainerVC.swift */; };
29+
A7F96ED421186DCD002D9078 /* NameStorage.swift in Sources */ = {isa = PBXBuildFile; fileRef = A7F96ED321186DCD002D9078 /* NameStorage.swift */; };
3030
/* End PBXBuildFile section */
3131

3232
/* Begin PBXFileReference section */
@@ -48,7 +48,6 @@
4848
A757F2BC2100D6340049AE99 /* VerifySigning.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VerifySigning.h; sourceTree = "<group>"; };
4949
A757F2BD2100D6350049AE99 /* VerifySigning.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VerifySigning.m; sourceTree = "<group>"; };
5050
A757F2BF21022D0D0049AE99 /* License.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = License.html; sourceTree = "<group>"; };
51-
A7AE17D72105E58F0086343D /* Shell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Shell.swift; sourceTree = "<group>"; };
5251
A7AE17D92105EADA0086343D /* Script.sh */ = {isa = PBXFileReference; lastKnownFileType = text.script.sh; path = Script.sh; sourceTree = "<group>"; };
5352
A7AE17FB210B50DE0086343D /* LanguageManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = LanguageManager.swift; sourceTree = "<group>"; };
5453
A7DE66AE20F8D25200746EE0 /* Installer.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Installer.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -58,6 +57,7 @@
5857
A7DE66BA20F8D25400746EE0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
5958
A7DE66BB20F8D25400746EE0 /* Installer.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Installer.entitlements; sourceTree = "<group>"; };
6059
A7DE66C120F8DCC800746EE0 /* ContainerVC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContainerVC.swift; sourceTree = "<group>"; };
60+
A7F96ED321186DCD002D9078 /* NameStorage.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NameStorage.swift; sourceTree = "<group>"; };
6161
C8DC292E1F969C59552384F9 /* Pods_Installer.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Installer.framework; sourceTree = BUILT_PRODUCTS_DIR; };
6262
CB42D04924269F4F63C525E9 /* Pods-Installer.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Installer.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Installer/Pods-Installer.debug.xcconfig"; sourceTree = "<group>"; };
6363
EAEA76E138AB54C28504BDCD /* Pods-Installer.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Installer.release.xcconfig"; path = "Pods/Target Support Files/Pods-Installer/Pods-Installer.release.xcconfig"; sourceTree = "<group>"; };
@@ -111,12 +111,12 @@
111111
A7DE66B120F8D25200746EE0 /* AppDelegate.swift */,
112112
A716D12220FCA641001998D7 /* WindowController.swift */,
113113
A716D12420FCA68D001998D7 /* Loader.swift */,
114+
A7F96ED321186DCD002D9078 /* NameStorage.swift */,
114115
A716D10A20FC9C41001998D7 /* LicenseVC.swift */,
115116
A716D11420FCA0C7001998D7 /* ProgressVC.swift */,
116117
A716D11E20FCA22F001998D7 /* Config.swift */,
117118
A716D12020FCA434001998D7 /* l18n.swift */,
118119
A757F2B2210092F60049AE99 /* Array+Extension.swift */,
119-
A7AE17D72105E58F0086343D /* Shell.swift */,
120120
A7AE17FB210B50DE0086343D /* LanguageManager.swift */,
121121
A757F2BF21022D0D0049AE99 /* License.html */,
122122
A716D10E20FC9E8F001998D7 /* config.json */,
@@ -278,11 +278,11 @@
278278
A7DE66C220F8DCC800746EE0 /* ContainerVC.swift in Sources */,
279279
A716D10B20FC9C41001998D7 /* LicenseVC.swift in Sources */,
280280
A7AE17FC210B50DE0086343D /* LanguageManager.swift in Sources */,
281+
A7F96ED421186DCD002D9078 /* NameStorage.swift in Sources */,
281282
A7DE66B220F8D25200746EE0 /* AppDelegate.swift in Sources */,
282283
A757F2B3210092F60049AE99 /* Array+Extension.swift in Sources */,
283284
A716D12320FCA641001998D7 /* WindowController.swift in Sources */,
284285
A716D11520FCA0C7001998D7 /* ProgressVC.swift in Sources */,
285-
A7AE17D82105E58F0086343D /* Shell.swift in Sources */,
286286
A716D11F20FCA22F001998D7 /* Config.swift in Sources */,
287287
A716D12520FCA68D001998D7 /* Loader.swift in Sources */,
288288
A716D12120FCA434001998D7 /* l18n.swift in Sources */,

Installer/Base.lproj/Main.storyboard

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@
5353
</menuItem>
5454
</items>
5555
</menu>
56+
<connections>
57+
<binding destination="lxa-J1-8Ch" name="font" keyPath="values" id="OVL-Dg-fe5"/>
58+
</connections>
5659
</menuItem>
5760
<menuItem title="Edit" id="5QF-Oa-p0T">
5861
<modifierMask key="keyEquivalentModifierMask"/>
@@ -307,6 +310,7 @@
307310
<customObject id="Voe-Tx-rLC" customClass="AppDelegate" customModule="Installer" customModuleProvider="target"/>
308311
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
309312
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
313+
<userDefaultsController representsSharedInstance="YES" id="lxa-J1-8Ch"/>
310314
</objects>
311315
<point key="canvasLocation" x="757" y="-208"/>
312316
</scene>

Installer/ContainerVC.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,12 @@ class ContainerVC: NSPageController, NSPageControllerDelegate {
2323
self.licenseViewButtons.isHidden = true
2424
}
2525

26+
override func viewDidAppear() {
27+
super.viewDidAppear()
28+
Loader.shared.loadConfig()
29+
self.view.window?.title = (Loader.shared.config.title?.en)!
30+
}
31+
2632
func pageController(_ pageController: NSPageController, viewControllerForIdentifier identifier: NSPageController.ObjectIdentifier) -> NSViewController {
2733
print(identifier.rawValue)
2834
switch identifier.rawValue {

Installer/NameStorage.swift

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//
2+
// NameStorage.swift
3+
// Installer
4+
//
5+
// Created by Mikhail Lutskiy on 06.08.2018.
6+
// Copyright © 2018 Mikhail Lutskii. All rights reserved.
7+
//
8+
9+
import Foundation
10+
11+
class NameStorage {
12+
static let shared = NameStorage()
13+
14+
var data = [String]()
15+
}

Installer/ProgressVC.swift

Lines changed: 60 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,32 +25,32 @@ class ProgressVC: NSViewController {
2525
override func viewDidLoad() {
2626
super.viewDidLoad()
2727
Loader.shared.loadConfig()
28-
let myContext = LAContext()
29-
let myLocalizedReasonString = "unlock itself"
30-
31-
var authError: NSError? = nil
32-
if #available(iOS 8.0, OSX 10.12, *) {
33-
if myContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthentication, error: &authError) {
34-
myContext.evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: myLocalizedReasonString) { (success, evaluateError) in
35-
if (success) {
36-
// User authenticated successfully, take appropriate action
37-
print("Success")
28+
// let myContext = LAContext()
29+
// let myLocalizedReasonString = "unlock itself"
30+
//
31+
// var authError: NSError? = nil
32+
// if #available(iOS 8.0, OSX 10.12, *) {
33+
// if myContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthentication, error: &authError) {
34+
// myContext.evaluatePolicy(LAPolicy.deviceOwnerAuthentication, localizedReason: myLocalizedReasonString) { (success, evaluateError) in
35+
// if (success) {
36+
// // User authenticated successfully, take appropriate action
37+
// print("Success")
3838
self.primaryLink = self.generateLink()
3939
self.loadSignature()
40-
} else {
41-
// User did not authenticate successfully, look at error and take appropriate action
42-
print("Failure")
43-
}
44-
}
45-
} else {
46-
// Could not evaluate policy; look at authError and present an appropriate message to user
47-
print("Evaluation")
48-
print(authError)
49-
}
50-
} else {
51-
// Fallback on earlier versions
52-
print("Fallback")
53-
}
40+
// } else {
41+
// // User did not authenticate successfully, look at error and take appropriate action
42+
// print("Failure")
43+
// }
44+
// }
45+
// } else {
46+
// // Could not evaluate policy; look at authError and present an appropriate message to user
47+
// print("Evaluation")
48+
// print(authError)
49+
// }
50+
// } else {
51+
// // Fallback on earlier versions
52+
// print("Fallback")
53+
// }
5454
}
5555

5656
func downloadFileDestination(fileName: String) -> DownloadRequest.DownloadFileDestination {
@@ -66,17 +66,21 @@ class ProgressVC: NSViewController {
6666

6767
func untar () {
6868
let documentsPath = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0]
69-
let dataPath = documentsPath.appending("/\(Loader.shared.config.name ?? "installer")/file.tar.gz")
69+
let dataPath = documentsPath.appending("/\(Loader.shared.config.name ?? "installer")")
70+
let filePath = dataPath.appending("/file.tar.gz")
7071
let toPath = documentsPath.appending("/\(Loader.shared.config.name ?? "installer")/application")
7172
print(toPath)
7273
print(dataPath)
73-
do {
74-
try DCTar.decompressFile(atPath: dataPath, toPath: toPath)
75-
self.progressIndicator.doubleValue += 20
76-
} catch (let error) {
77-
print(error)
78-
self.errorReadingResults(question: "Ошибка", text: error.localizedDescription)
74+
75+
76+
let script = NSAppleScript(source: "do shell script \"cd '" + dataPath + "' && tar -xzvf '" + filePath + "'\"")
77+
var errorInfo: NSDictionary?
78+
script?.executeAndReturnError(&errorInfo)
79+
if let error = errorInfo {
80+
print("ERROR: \(error)")
81+
self.errorReadingResults(question: "Ошибка", text: "Ошибка при разархивировании")
7982
}
83+
self.progressIndicator.doubleValue += 20
8084
}
8185

8286
func loadSignature() {
@@ -168,9 +172,10 @@ class ProgressVC: NSViewController {
168172
func copyAppToApplication () {
169173
let documentsPath = NSSearchPathForDirectoriesInDomains(.applicationSupportDirectory, .userDomainMask, true)[0]
170174
let documentsURL = URL(fileURLWithPath: documentsPath, isDirectory: true)
171-
let fileURL = documentsURL.appendingPathComponent("\(Loader.shared.config.name ?? "installer")/application")
172-
173-
let destURL = URL(fileURLWithPath: "/Applications/", isDirectory: true)
175+
let fileURL = documentsURL.appendingPathComponent("\(Loader.shared.config.name ?? "installer")")
176+
177+
let applicationsPath = NSSearchPathForDirectoriesInDomains(.applicationDirectory, .userDomainMask, true)[0]
178+
let destURL = URL(fileURLWithPath: applicationsPath, isDirectory: true)
174179
let completelyDestURL = destURL.appendingPathComponent(Loader.shared.config.name ?? "Application", isDirectory: true)
175180
print(completelyDestURL)
176181

@@ -189,10 +194,10 @@ class ProgressVC: NSViewController {
189194
let appFilePaths = filePaths.filter{$0.contains(kEXTENSION)}
190195
for appFilePath in appFilePaths{
191196
if String(appFilePath.suffix(4)) == kEXTENSION {
192-
193197
var fullNameArr = appFilePath.components(separatedBy: "/")
194198
let appFilePathNew = fullNameArr[fullNameArr.count-1]
195-
199+
NameStorage.shared.data.append(appFilePathNew)
200+
196201
if !fileManager.fileExists(atPath: completelyDestURL.appendingPathComponent(appFilePathNew).path) {
197202
do {
198203
try fileManager.copyItem(at: fileURL.appendingPathComponent(appFilePath, isDirectory: false), to: completelyDestURL.appendingPathComponent(appFilePathNew))
@@ -213,9 +218,18 @@ class ProgressVC: NSViewController {
213218
print(destURL)
214219
}
215220
}
216-
DispatchQueue.main.async {
217-
self.statusLabel.stringValue = "Копирование завершено"
218-
self.progressIndicator.increment(by: 20)
221+
self.changeProgress(withText: "Копирование завершено", toProgress: 20)
222+
223+
}
224+
225+
func deleteFileAtPath (_ file: String) {
226+
let fileManager = FileManager.default
227+
if fileManager.fileExists(atPath: file) {
228+
do {
229+
try fileManager.removeItem(atPath: file)
230+
} catch let error as NSError {
231+
print(error)
232+
}
219233
}
220234
}
221235

@@ -236,4 +250,11 @@ class ProgressVC: NSViewController {
236250
}
237251
}
238252
}
253+
254+
func changeProgress (withText: String, toProgress: Double) {
255+
DispatchQueue.main.async {
256+
self.statusLabel.stringValue = withText
257+
self.progressIndicator.increment(by: toProgress)
258+
}
259+
}
239260
}

Installer/Shell.swift

Lines changed: 0 additions & 62 deletions
This file was deleted.

Installer/VerifySigning.m

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@ @implementation VerifySigning
1313
+ (BOOL)isVerifyFile:(NSData *)fileData withSignatureData:(NSData *)signatureData withKeys:(NSArray<PGPKey *> *)keys {
1414
NSError *error = nil;
1515
BOOL isVerify = [ObjectivePGP verify:fileData withSignature:signatureData usingKeys:keys passphraseForKey:nil error:&error];
16-
NSLog(@"is verify %i %@", isVerify, error);
17-
if (error == nil) {
18-
return true;
19-
} else {
20-
return false;
21-
}
16+
return isVerify;
2217
}
2318

2419
@end

Installer/WindowController.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@ class WindowController: NSWindowController {
1414
super.windowDidLoad()
1515
// Implement this method to handle any initialization after your window controller's window has been loaded from its nib file.
1616
}
17-
1817
}

Installer/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@
88
"licenseFile": {"en": "License.html"},
99
"script": "postinstall.js",
1010
"gpgKey": "./array.gpg",
11-
"downloadLinks": ["https://github.com/rumkin/bake/archive/v0.15.1.tar.gz"]
11+
"downloadLinks": ["https://github.com/arrayio/macos-installer/releases/download/v0.1/hello_world.tar.gz"]
1212
}

0 commit comments

Comments
 (0)