Skip to content

Commit b88b08a

Browse files
authored
fix(build): switch to pkg based installer (#92)
Change-Id: Ie3ef4fe53faa0af947493e58b81c523c040400a5 Signed-off-by: Thomas Kosiewski <[email protected]>
1 parent 2dee620 commit b88b08a

File tree

15 files changed

+184
-9655
lines changed

15 files changed

+184
-9655
lines changed

Diff for: .env

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Build a release locally using: op run --env-file="./.env" -- make release
2-
APPLE_CERT="op://Apple/Apple DeveloperID PKCS12 base64/notesPlain"
3-
CERT_PASSWORD="op://Apple/DeveloperID p12 password/password"
2+
APPLE_CERT="op://Apple/Apple DeveloperID Application PKCS12 base64/notesPlain"
3+
CERT_PASSWORD="op://Apple/DeveloperID Application p12 password/password"
4+
5+
APPLE_INSTALLER_CERT="op://Apple/Developer ID Installer PKCS12 base64/notesPlain"
6+
INSTALLER_CERT_PASSWORD="op://Apple/DeveloperID Installer Password/password"
47

58
APPLE_ID="op://Apple/3apcadvvcojjbpxnd7m5fgh5wm/username"
69
APPLE_ID_PASSWORD="op://Apple/3apcadvvcojjbpxnd7m5fgh5wm/password"

Diff for: .ignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
!.github
2+
!.ignore

Diff for: Coder Desktop/Coder Desktop/NetworkExtension.swift

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ extension CoderVPNService {
5656
logger.debug("saving new tunnel")
5757
do {
5858
try await tm.saveToPreferences()
59+
neState = .disabled
5960
} catch {
6061
logger.error("save tunnel failed: \(error)")
6162
neState = .failed(error.localizedDescription)
6263
}
63-
neState = .disabled
6464
}
6565

6666
func removeNetworkExtension() async throws(VPNServiceError) {
@@ -105,6 +105,7 @@ extension CoderVPNService {
105105
var tunnels: [NETunnelProviderManager] = []
106106
do {
107107
tunnels = try await NETunnelProviderManager.loadAllFromPreferences()
108+
logger.debug("loaded \(tunnels.count) tunnel(s)")
108109
} catch {
109110
throw .internalError("couldn't load tunnels: \(error)")
110111
}

Diff for: Coder Desktop/Coder Desktop/SystemExtension.swift

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ protocol SystemExtensionAsyncRecorder: Sendable {
2929
extension CoderVPNService: SystemExtensionAsyncRecorder {
3030
func recordSystemExtensionState(_ state: SystemExtensionState) async {
3131
sysExtnState = state
32+
logger.info("system extension state: \(state.description)")
3233
if state == .installed {
3334
// system extension was successfully installed, so we don't need the delegate any more
3435
systemExtnDelegate = nil

Diff for: Coder Desktop/Coder Desktop/VPNService.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,9 @@ enum VPNServiceError: Error, Equatable {
3030
case let .internalError(description):
3131
"Internal Error: \(description)"
3232
case let .systemExtensionError(state):
33-
state.description
33+
"SystemExtensionError: \(state.description)"
3434
case let .networkExtensionError(state):
35-
state.description
35+
"NetworkExtensionError: \(state.description)"
3636
}
3737
}
3838

Diff for: Coder Desktop/Coder Desktop/XPCInterface.swift

+6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ import VPNLib
1414
}
1515

1616
func connect() {
17+
logger.debug("xpc connect called")
1718
guard xpc == nil else {
19+
logger.debug("xpc already exists")
1820
return
1921
}
2022
let networkExtDict = Bundle.main.object(forInfoDictionaryKey: "NetworkExtension") as? [String: Any]
@@ -27,17 +29,21 @@ import VPNLib
2729
}
2830
xpc = proxy
2931

32+
logger.debug("connecting to machServiceName: \(machServiceName!)")
33+
3034
xpcConn.exportedObject = self
3135
xpcConn.invalidationHandler = { [logger] in
3236
Task { @MainActor in
3337
logger.error("XPC connection invalidated.")
3438
self.xpc = nil
39+
self.connect()
3540
}
3641
}
3742
xpcConn.interruptionHandler = { [logger] in
3843
Task { @MainActor in
3944
logger.error("XPC connection interrupted.")
4045
self.xpc = nil
46+
self.connect()
4147
}
4248
}
4349
xpcConn.resume()

Diff for: Coder Desktop/VPN/Info.plist

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
33
<plist version="1.0">
44
<dict>
5-
<key>NSSystemExtensionUsageDescription</key>
6-
<string></string>
5+
<key>NSSystemExtensionUsageDescription</key>
6+
<string>Extends the networking capabilities of macOS to connect this Mac to your workspaces.</string>
7+
<key>CFBundleDisplayName</key>
8+
<string>Coder Desktop Network Extension</string>
79
<key>NetworkExtension</key>
810
<dict>
911
<key>NEMachServiceName</key>

Diff for: Coder Desktop/VPN/main.swift

+10-4
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ final class XPCListenerDelegate: NSObject, NSXPCListenerDelegate, @unchecked Sen
3232
logger.info("active connection dead")
3333
self?.setActiveConnection(nil)
3434
}
35+
newConnection.interruptionHandler = { [weak self] in
36+
logger.debug("connection interrupted")
37+
self?.setActiveConnection(nil)
38+
}
3539
logger.info("new active connection")
3640
setActiveConnection(newConnection)
3741

@@ -47,13 +51,15 @@ else {
4751
fatalError("Missing NEMachServiceName in Info.plist")
4852
}
4953

50-
let globalXPCListenerDelegate = XPCListenerDelegate()
51-
let xpcListener = NSXPCListener(machServiceName: serviceName)
52-
xpcListener.delegate = globalXPCListenerDelegate
53-
xpcListener.resume()
54+
logger.debug("listening on machServiceName: \(serviceName)")
5455

5556
autoreleasepool {
5657
NEProvider.startSystemExtensionMode()
5758
}
5859

60+
let globalXPCListenerDelegate = XPCListenerDelegate()
61+
let xpcListener = NSXPCListener(machServiceName: serviceName)
62+
xpcListener.delegate = globalXPCListenerDelegate
63+
xpcListener.resume()
64+
5965
dispatchMain()

Diff for: Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ $(KEYCHAIN_FILE):
5656
echo "$$APPLE_CERT" | base64 -d > $$tempfile; \
5757
security import $$tempfile -P '$(CERT_PASSWORD)' -A -t cert -f pkcs12 -k "$(APP_SIGNING_KEYCHAIN)"; \
5858
rm $$tempfile
59+
@tempfile=$$(mktemp); \
60+
echo "$$APPLE_INSTALLER_CERT" | base64 -d > $$tempfile; \
61+
security import $$tempfile -P '$(INSTALLER_CERT_PASSWORD)' -A -t cert -f pkcs12 -k "$(APP_SIGNING_KEYCHAIN)"; \
62+
rm $$tempfile
5963
security list-keychains -d user -s $$(security list-keychains -d user | tr -d '\"') "$(APP_SIGNING_KEYCHAIN)"
6064

6165
.PHONY: release
@@ -67,6 +71,7 @@ release: $(KEYCHAIN_FILE) ## Create a release build of Coder Desktop
6771
./scripts/build.sh \
6872
--app-prof-path "$$APP_PROF_PATH" \
6973
--ext-prof-path "$$EXT_PROF_PATH" \
74+
--version $(MARKETING_VERSION) \
7075
--keychain "$(APP_SIGNING_KEYCHAIN)"; \
7176
rm "$$APP_PROF_PATH" "$$EXT_PROF_PATH"
7277

Diff for: flake.nix

-25
Original file line numberDiff line numberDiff line change
@@ -25,30 +25,6 @@
2525
};
2626

2727
formatter = pkgs.nixfmt-rfc-style;
28-
29-
create-dmg = pkgs.buildNpmPackage rec {
30-
pname = "create-dmg";
31-
version = "7.0.0";
32-
33-
src = pkgs.fetchFromGitHub {
34-
owner = "sindresorhus";
35-
repo = pname;
36-
rev = "v${version}";
37-
hash = "sha256-+GxKfhVDmtgEh9NOAzGexgfj1qAb0raC8AmrrnJ2vNA=";
38-
};
39-
40-
npmDepsHash = "sha256-48r9v0sTlHbyH4RjynClfC/QsFAlgMTtXCbleuMSM80=";
41-
42-
# create-dmg author does not want to include a lockfile in their releases,
43-
# thus we need to vendor it in ourselves.
44-
postPatch = ''
45-
cp ${./nix/create-dmg/package-lock.json} package-lock.json
46-
'';
47-
48-
# Plain JS, so nothing to build
49-
dontNpmBuild = true;
50-
dontNpmPrune = true;
51-
};
5228
in
5329
{
5430
inherit formatter;
@@ -60,7 +36,6 @@
6036
actionlint
6137
clang
6238
coreutils
63-
create-dmg
6439
gh
6540
git
6641
gnumake

0 commit comments

Comments
 (0)