Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add rattler_menuinst crate #840

Draft
wants to merge 42 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
0ca5781
initialize menuinst crate
wolfv Aug 31, 2024
a2204ad
implement the rendering
wolfv Sep 17, 2024
64794d3
continue menuinst
wolfv Sep 20, 2024
62a68d9
try more implementation
wolfv Sep 20, 2024
c923ea0
first prototype version
wolfv Sep 20, 2024
dbe4791
..
wolfv Sep 21, 2024
cfa6b74
add windows stuff
wolfv Sep 27, 2024
29390e7
more work on menuinst
wolfv Nov 9, 2024
5da54bb
refactor: split merging\
baszalmstra Nov 9, 2024
9dcb56f
use real data
wolfv Nov 9, 2024
ae11010
update test
wolfv Nov 9, 2024
15c359d
refactor: resolve later
baszalmstra Nov 9, 2024
81a4409
some fixes
wolfv Nov 9, 2024
4636f49
..
wolfv Nov 10, 2024
a03acbd
more placeholders, remove macos old
wolfv Nov 10, 2024
6ce3e6d
implement more for macos
wolfv Nov 10, 2024
ce30ab0
make linux compile as well
wolfv Nov 10, 2024
b030063
linux
wolfv Nov 10, 2024
6c40a7a
improve and clean linux implementation
wolfv Nov 11, 2024
e90a351
write the rest of the items to linux desktop file
wolfv Nov 11, 2024
bb2334a
remove comment
wolfv Nov 11, 2024
6edf779
re-add missing function
wolfv Nov 11, 2024
5ff96c2
Improve Linux support
Hofer-Julian Nov 11, 2024
d20bad2
Fix clippy warnings
Hofer-Julian Nov 11, 2024
75552a0
Another clippy warning
Hofer-Julian Nov 11, 2024
90dd6a1
Run commands with bash
Hofer-Julian Nov 11, 2024
60a55fd
continue xml writing for mimetypes
wolfv Nov 11, 2024
5797adc
some clippy
wolfv Nov 11, 2024
8bfe72a
Run update-desktop-database
Hofer-Julian Nov 11, 2024
903139d
write xml file
wolfv Nov 11, 2024
61fa45e
properly implement the `paths` function
wolfv Nov 11, 2024
2c325e6
implement more macOS
wolfv Nov 11, 2024
6bac179
register mime types on linux
wolfv Nov 11, 2024
272f8f5
write out the entire plist file
wolfv Nov 11, 2024
36235d5
fix tests
wolfv Nov 11, 2024
c548bfb
fix some clippy warnings
wolfv Nov 11, 2024
5c1481b
add pre-create
wolfv Nov 12, 2024
b4912b3
improve linux code some more
wolfv Nov 12, 2024
39d5eaf
add directory entry functions
wolfv Nov 12, 2024
e150020
some improvements
wolfv Nov 24, 2024
7376e18
work on mr. windows
wolfv Nov 25, 2024
3c4ce45
continue windows implementation
wolfv Nov 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ trybuild = { version = "1.0.101" }
typed-path = { version = "0.9.3" }
url = { version = "2.5.2" }
uuid = { version = "1.11.0", default-features = false }
unicode-normalization = { version = "0.1.24" }
walkdir = "2.5.0"
windows-sys = { version = "0.59.0", default-features = false }
zip = { version = "2.2.0", default-features = false }
Expand Down
1 change: 1 addition & 0 deletions crates/rattler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ memmap2 = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true }
rattler_cache = { path = "../rattler_cache", version = "0.2.8", default-features = false }
rattler_menuinst = { path = "../rattler_menuinst", version = "0.1.0", default-features = false }
rattler_conda_types = { path = "../rattler_conda_types", version = "0.29.0", default-features = false }
rattler_digest = { path = "../rattler_digest", version = "1.0.3", default-features = false }
rattler_networking = { path = "../rattler_networking", version = "0.21.5", default-features = false }
Expand Down
21 changes: 20 additions & 1 deletion crates/rattler/src/install/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{

use indexmap::IndexSet;
use itertools::Itertools;
use rattler_conda_types::{prefix_record::PathType, PackageRecord, PrefixRecord};
use rattler_conda_types::{prefix_record::PathType, PackageRecord, Platform, PrefixRecord};
use simple_spawn_blocking::{tokio::run_blocking_task, Cancelled};
use thiserror::Error;
use tokio::sync::{AcquireError, OwnedSemaphorePermit, Semaphore};
Expand Down Expand Up @@ -222,6 +222,25 @@ impl InstallDriver {
None
};

// find all files in `$PREFIX/Menu/*.json` and install them with `menuinst`
if let Ok(read_dir) = target_prefix.join("Menu").read_dir() {
for file in read_dir.flatten() {
let file = file.path();
if file.is_file() && file.extension().map_or(false, |ext| ext == "json") {
rattler_menuinst::install_menuitems(
&file,
target_prefix,
target_prefix,
Platform::current(),
rattler_menuinst::MenuMode::User,
)
.unwrap_or_else(|e| {
tracing::warn!("Failed to install menu item: {} (ignored)", e);
});
}
}
}

Ok(PostProcessResult {
post_link_result,
clobbered_paths,
Expand Down
5 changes: 5 additions & 0 deletions crates/rattler_conda_types/src/match_spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -716,4 +716,9 @@ mod tests {
.collect::<Vec<String>>()
.join("\n"));
}

#[test]
fn test_size_stays_the_same() {
assert_eq!(std::mem::size_of::<MatchSpec>(), 464);
}
}
35 changes: 35 additions & 0 deletions crates/rattler_menuinst/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[package]
name = "rattler_menuinst"
version = "0.1.0"
edition.workspace = true
authors = ["Wolf Vollprecht <[email protected]>"]
description = "Install menu entries for a Conda package"
categories.workspace = true
homepage.workspace = true
repository.workspace = true
license.workspace = true
readme.workspace = true

[dependencies]
plist = { workspace = true }
dirs = { workspace = true }
serde = { workspace = true, features = ["derive"] }
shlex = { workspace = true }
serde_json = { workspace = true }
tracing = { workspace = true }
rattler_conda_types = { path = "../rattler_conda_types", default-features = false }
rattler_shell = { path = "../rattler_shell", default-features = false }
thiserror = { workspace = true }
unicode-normalization = { workspace = true }
regex = { workspace = true }
tempfile = { workspace = true }
fs-err = { workspace = true }
which = "7.0.0"
known-folders = "1.2.0"

[target.'cfg(target_os = "windows")'.dependencies]
winapi = "0.3.9"
winreg = "0.52.0"

[dev-dependencies]
insta = { workspace = true }
Binary file not shown.
Binary file not shown.
68 changes: 68 additions & 0 deletions crates/rattler_menuinst/data/menuinst.default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"id_": "https://schemas.conda.io/menuinst-1.schema.json",
"schema_": "https://json-schema.org/draft-07/schema",
"menu_name": "REQUIRED",
"menu_items": [
{
"name": "REQUIRED",
"description": "REQUIRED",
"command": [
"REQUIRED"
],
"icon": null,
"precommand": null,
"precreate": null,
"working_dir": null,
"activate": true,
"terminal": false,
"platforms": {
"linux": {
"Categories": null,
"DBusActivatable": null,
"GenericName": null,
"Hidden": null,
"Implements": null,
"Keywords": null,
"MimeType": null,
"NoDisplay": null,
"NotShowIn": null,
"OnlyShowIn": null,
"PrefersNonDefaultGPU": null,
"StartupNotify": null,
"StartupWMClass": null,
"TryExec": null,
"glob_patterns": null
},
"osx": {
"CFBundleDisplayName": null,
"CFBundleIdentifier": null,
"CFBundleName": null,
"CFBundleSpokenName": null,
"CFBundleVersion": null,
"CFBundleURLTypes": null,
"CFBundleDocumentTypes": null,
"LSApplicationCategoryType": null,
"LSBackgroundOnly": null,
"LSEnvironment": null,
"LSMinimumSystemVersion": null,
"LSMultipleInstancesProhibited": null,
"LSRequiresNativeExecution": null,
"NSSupportsAutomaticGraphicsSwitching": null,
"UTExportedTypeDeclarations": null,
"UTImportedTypeDeclarations": null,
"entitlements": null,
"link_in_bundle": null,
"event_handler": null
},
"win": {
"desktop": true,
"quicklaunch": true,
"terminal_profile": null,
"url_protocols": null,
"file_extensions": null,
"app_user_model_id": null
}
}
}
]
}
Loading