Skip to content

Commit 79b2626

Browse files
feat: Add updating for Linux AppImage (#410)
1 parent 921c861 commit 79b2626

File tree

30 files changed

+878
-125
lines changed

30 files changed

+878
-125
lines changed

Cargo.lock

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,10 @@ fig_request = { path = "crates/fig_request" }
7171
fig_settings = { path = "crates/fig_settings" }
7272
fig_telemetry = { path = "crates/fig_telemetry" }
7373
fig_telemetry_core = { path = "crates/fig_telemetry_core" }
74+
fig_test_utils = { path = "crates/fig_test_utils" }
7475
fig_util = { path = "crates/fig_util" }
7576
hex = "0.4.3"
77+
http = "1.2.0"
7678
indoc = "2.0.5"
7779
insta = "1.38.0"
7880
libc = "0.2.167"
@@ -108,6 +110,7 @@ reqwest = { version = "0.12.5", default-features = false, features = [
108110
"socks",
109111
"cookies",
110112
] }
113+
ring = "0.17.8"
111114
shell-color = { path = "crates/shell-color" }
112115
semver = { version = "1.0.16", features = ["serde"] }
113116
serde = { version = "1.0.216", features = ["derive", "rc"] }
@@ -125,6 +128,7 @@ time = { version = "0.3.34", features = [
125128
"serde",
126129
] }
127130
tokio = { version = "1.42.0", features = ["full"] }
131+
tokio-util = { version = "0.7.13", features = ["compat"] }
128132
toml = "0.8.12"
129133
tracing = { version = "0.1.40", features = ["log"] }
130134
tracing-subscriber = { version = "0.3.19", features = [

build-scripts/build.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
import shutil
88
from typing import Dict, List, Mapping, Sequence
99
from util import (
10+
Package,
1011
Variant,
12+
enum_encoder,
1113
get_variants,
1214
isDarwin,
1315
isLinux,
@@ -471,6 +473,7 @@ def linux_tauri_config(
471473
themes_path: pathlib.Path,
472474
legacy_extension_dir_path: pathlib.Path,
473475
modern_extension_dir_path: pathlib.Path,
476+
bundle_metadata_path: pathlib.Path,
474477
target: str,
475478
) -> str:
476479
config = {
@@ -490,6 +493,7 @@ def linux_tauri_config(
490493
themes_path.absolute().as_posix(): "themes",
491494
legacy_extension_dir_path.absolute().as_posix(): LINUX_LEGACY_GNOME_EXTENSION_UUID,
492495
modern_extension_dir_path.absolute().as_posix(): LINUX_MODERN_GNOME_EXTENSION_UUID,
496+
bundle_metadata_path.absolute().as_posix(): "bundle-metadata",
493497
},
494498
},
495499
}
@@ -509,6 +513,24 @@ def linux_desktop_entry() -> str:
509513
)
510514

511515

516+
@dataclass
517+
class BundleMetadata:
518+
packaged_as: Package
519+
520+
521+
def make_linux_bundle_metadata(packaged_as: Package) -> pathlib.Path:
522+
"""
523+
Creates the bundle metadata json file under a new directory, returning the path to the directory.
524+
"""
525+
metadata_dir_path = BUILD_DIR / f"{packaged_as.value}-metadata"
526+
shutil.rmtree(metadata_dir_path, ignore_errors=True)
527+
metadata_dir_path.mkdir(parents=True)
528+
(metadata_dir_path / "metadata.json").write_text(
529+
json.dumps(BundleMetadata(packaged_as=packaged_as), default=enum_encoder)
530+
)
531+
return metadata_dir_path
532+
533+
512534
@dataclass
513535
class LinuxDebResources:
514536
cli_path: pathlib.Path
@@ -517,6 +539,7 @@ class LinuxDebResources:
517539
themes_path: pathlib.Path
518540
legacy_extension_dir_path: pathlib.Path
519541
modern_extension_dir_path: pathlib.Path
542+
bundle_metadata_path: pathlib.Path
520543
npm_packages: NpmBuildOutput
521544

522545

@@ -651,6 +674,7 @@ def copy_extension(extension_uuid, extension_dir_name):
651674
themes_path=themes_path,
652675
legacy_extension_dir_path=legacy_extension_dir_path,
653676
modern_extension_dir_path=modern_extension_dir_path,
677+
bundle_metadata_path=make_linux_bundle_metadata(Package.APPIMAGE),
654678
target=target,
655679
)
656680
)
@@ -683,6 +707,7 @@ def copy_extension(extension_uuid, extension_dir_name):
683707
themes_path=themes_path,
684708
legacy_extension_dir_path=legacy_extension_dir_path,
685709
modern_extension_dir_path=modern_extension_dir_path,
710+
bundle_metadata_path=make_linux_bundle_metadata(Package.DEB),
686711
npm_packages=npm_packages,
687712
)
688713
deb_output = build_linux_deb(

build-scripts/util.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,14 @@ def get_variants() -> List[Variant]:
136136
return [Variant.MINIMAL]
137137
case other:
138138
raise ValueError(f"Unsupported platform {other}")
139+
140+
141+
class Package(Enum):
142+
DEB = "deb"
143+
APPIMAGE = "appImage"
144+
145+
146+
def enum_encoder(obj):
147+
if isinstance(obj, Enum):
148+
return obj.value
149+
return obj.__dict__

crates/dbus/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ serde.workspace = true
1818
serde_json.workspace = true
1919
thiserror.workspace = true
2020
tokio.workspace = true
21-
tokio-util = { version = "0.7.12", features = ["compat"] }
21+
tokio-util.workspace = true
2222
tracing.workspace = true
2323
zbus = { path = "../zbus" }
2424

crates/fig_api_client/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fig_aws_common.workspace = true
3131
fig_request.workspace = true
3232
fig_settings.workspace = true
3333
fig_util.workspace = true
34-
http = "1.1.0"
34+
http.workspace = true
3535
regex.workspace = true
3636
serde.workspace = true
3737
serde_json.workspace = true

crates/fig_desktop/src/event.rs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,7 @@ pub enum Event {
3434
is_logged_in: bool,
3535
},
3636

37-
ShowMessageNotification {
38-
title: Cow<'static, str>,
39-
body: Cow<'static, str>,
40-
parent: Option<WindowId>,
41-
},
37+
ShowMessageNotification(ShowMessageNotification),
4238
}
4339

4440
impl From<PlatformBoundEvent> for Event {
@@ -47,6 +43,21 @@ impl From<PlatformBoundEvent> for Event {
4743
}
4844
}
4945

46+
impl From<ShowMessageNotification> for Event {
47+
fn from(event: ShowMessageNotification) -> Self {
48+
Self::ShowMessageNotification(event)
49+
}
50+
}
51+
52+
#[derive(Debug, Default)]
53+
pub struct ShowMessageNotification {
54+
pub title: Cow<'static, str>,
55+
pub body: Cow<'static, str>,
56+
pub parent: Option<WindowId>,
57+
pub buttons: Option<rfd::MessageButtons>,
58+
pub buttons_result: Option<tokio::sync::mpsc::Sender<rfd::MessageDialogResult>>,
59+
}
60+
5061
#[derive(Debug, Clone)]
5162
pub enum EmitEventName {
5263
Notification,

crates/fig_desktop/src/local_ipc/commands.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
use std::sync::Mutex;
22

33
use fig_os_shim::{
4+
Context,
45
ContextArcProvider,
56
ContextProvider,
67
};
78
use fig_proto::local::command_response::Response as CommandResponseTypes;
89
use fig_proto::local::dump_state_command::Type as DumpStateType;
910
use fig_proto::local::{
11+
BundleMetadataResponse,
1012
DebugModeCommand,
1113
DiagnosticsCommand,
1214
DiagnosticsResponse,
@@ -295,3 +297,15 @@ pub async fn connect_to_ibus(proxy: EventLoopProxy, platform_state: &PlatformSta
295297
}
296298
}
297299
}
300+
301+
pub async fn bundle_metadata(ctx: &Context) -> LocalResult {
302+
match fig_util::manifest::bundle_metadata_json(ctx).await {
303+
Ok(json) => Ok(LocalResponse::Message(Box::new(CommandResponseTypes::BundleMetadata(
304+
BundleMetadataResponse { json },
305+
)))),
306+
Err(err) => Err(LocalResponse::Error {
307+
code: None,
308+
message: Some(format!("Failed to get the bundled metadata: {:?}", err)),
309+
}),
310+
}
311+
}

crates/fig_desktop/src/local_ipc/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ async fn handle_local_ipc<Ctx>(
164164
},
165165
Some(command) => {
166166
use fig_proto::local::command::Command::{
167+
BundleMetadata,
167168
ConnectToIbus,
168169
DebugMode,
169170
Devtools,
@@ -204,6 +205,7 @@ async fn handle_local_ipc<Ctx>(
204205
&platform_state,
205206
),
206207
ConnectToIbus(_) => commands::connect_to_ibus(proxy.clone(), &platform_state).await,
208+
BundleMetadata(_) => commands::bundle_metadata(&ctx.context_arc()).await,
207209
Update(_) => fig_install::update(
208210
ctx.context_arc(),
209211
Some(Box::new(move |_| {
@@ -215,7 +217,7 @@ async fn handle_local_ipc<Ctx>(
215217
.map(|_| LocalResponse::Success(None))
216218
.map_err(|err| LocalResponse::Error {
217219
code: None,
218-
message: Some(format!("Failed to check for updates: {err}")),
220+
message: Some(format!("Failed to update: {err}")),
219221
}),
220222
Devtools(command) => {
221223
let window_id = match command.window() {

0 commit comments

Comments
 (0)