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 81 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
2bf7514
initialize menuinst crate
wolfv Aug 31, 2024
8ff1dca
implement the rendering
wolfv Sep 17, 2024
c1911a5
continue menuinst
wolfv Sep 20, 2024
f48d5da
try more implementation
wolfv Sep 20, 2024
afc6802
first prototype version
wolfv Sep 20, 2024
65da47e
..
wolfv Sep 21, 2024
dbf3bb1
add windows stuff
wolfv Sep 27, 2024
f24ddb3
more work on menuinst
wolfv Nov 9, 2024
77093b6
refactor: split merging\
baszalmstra Nov 9, 2024
a92ee71
use real data
wolfv Nov 9, 2024
a6f6fd6
update test
wolfv Nov 9, 2024
f91f136
refactor: resolve later
baszalmstra Nov 9, 2024
e1810d0
some fixes
wolfv Nov 9, 2024
033f6de
..
wolfv Nov 10, 2024
737aba6
more placeholders, remove macos old
wolfv Nov 10, 2024
245dbdc
implement more for macos
wolfv Nov 10, 2024
5862b56
make linux compile as well
wolfv Nov 10, 2024
5d62f49
linux
wolfv Nov 10, 2024
af78720
improve and clean linux implementation
wolfv Nov 11, 2024
7f58f3d
write the rest of the items to linux desktop file
wolfv Nov 11, 2024
81753ff
remove comment
wolfv Nov 11, 2024
c451652
re-add missing function
wolfv Nov 11, 2024
a373081
Improve Linux support
Hofer-Julian Nov 11, 2024
6f53787
Fix clippy warnings
Hofer-Julian Nov 11, 2024
e7e92b9
Another clippy warning
Hofer-Julian Nov 11, 2024
cfcceea
Run commands with bash
Hofer-Julian Nov 11, 2024
057d090
continue xml writing for mimetypes
wolfv Nov 11, 2024
44b399a
some clippy
wolfv Nov 11, 2024
f4527d8
Run update-desktop-database
Hofer-Julian Nov 11, 2024
6bd38e3
write xml file
wolfv Nov 11, 2024
3f560eb
properly implement the `paths` function
wolfv Nov 11, 2024
2b08c01
implement more macOS
wolfv Nov 11, 2024
78155e4
register mime types on linux
wolfv Nov 11, 2024
ee65b4e
write out the entire plist file
wolfv Nov 11, 2024
3dae1f1
fix tests
wolfv Nov 11, 2024
fa3aa18
fix some clippy warnings
wolfv Nov 11, 2024
45b3a87
add pre-create
wolfv Nov 12, 2024
17fd7f3
improve linux code some more
wolfv Nov 12, 2024
8d6ca29
add directory entry functions
wolfv Nov 12, 2024
400d75f
some improvements
wolfv Nov 24, 2024
fe7003b
work on mr. windows
wolfv Nov 25, 2024
2e234b4
continue windows implementation
wolfv Nov 26, 2024
4534a5d
make compile on unix
wolfv Dec 10, 2024
0167f08
pre-process transaction and remove menu items
wolfv Dec 10, 2024
2596988
add simple menu test recipe
wolfv Dec 10, 2024
5b418ea
add example menu
wolfv Dec 10, 2024
ae1988d
update linux menu xml modifications
wolfv Dec 11, 2024
3adfc2b
make the test recipe noarch: generic
wolfv Dec 11, 2024
e80376d
correct test and add create_shortcut functions
wolfv Dec 11, 2024
f81f567
fmt clippy
wolfv Dec 11, 2024
ad9b63e
add tests for registry
wolfv Dec 11, 2024
c05edb8
fmt
wolfv Dec 11, 2024
f2e1303
create a first shortcut on Windows
wolfv Dec 11, 2024
7025fe4
improve
wolfv Dec 11, 2024
3ba4a8c
add SingleMainWindow
wolfv Dec 12, 2024
676d121
add macos testing of the whole menu installation
wolfv Dec 12, 2024
3fb3fd2
add snapshot test for linux desktop file
wolfv Dec 12, 2024
d716d31
a little clean up
wolfv Dec 12, 2024
6e73eee
clean
wolfv Dec 12, 2024
0020e83
use correct defaults
wolfv Dec 12, 2024
7f7975a
remove $id, add nsautomaticgraphicsswitching, update snapshots
wolfv Dec 13, 2024
6a1ac81
clippy
wolfv Dec 13, 2024
f7f23c4
small improvement
wolfv Dec 13, 2024
2eb6e57
..
wolfv Dec 16, 2024
69b4e76
fix things up
wolfv Dec 16, 2024
c74aa84
add handler for mime config
wolfv Dec 16, 2024
c9e7d15
..
wolfv Dec 16, 2024
0541cd1
some clippy
wolfv Dec 16, 2024
1dbbd19
more placeholders
wolfv Dec 17, 2024
4f0f6c6
[skip ci] ..
wolfv Dec 17, 2024
874d565
run pre-create
wolfv Dec 16, 2024
b900394
implement more
wolfv Dec 16, 2024
f6e94be
wire up more on Windows
wolfv Dec 18, 2024
829e12d
fix location
wolfv Dec 18, 2024
574d3f0
merge main
wolfv Dec 18, 2024
bb230a2
use the mime config things
wolfv Dec 18, 2024
3ba079e
remove warnings, fix test
wolfv Dec 18, 2024
0c533b8
make things work
wolfv Dec 18, 2024
e2dacc2
more menuinst changes
wolfv Dec 20, 2024
d3f06dd
add missing files
wolfv Dec 20, 2024
d4a5b24
fix tests, add a new error
wolfv Dec 20, 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 @@ -157,6 +157,7 @@ trybuild = { version = "1.0.101" }
typed-path = { version = "0.10.0" }
url = { version = "2.5.4" }
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.2", 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 @@ -32,6 +32,7 @@ memchr = { workspace = true }
memmap2 = { workspace = true }
once_cell = { workspace = true }
parking_lot = { workspace = true }
rattler_menuinst = { path = "../rattler_menuinst", version = "0.1.0", default-features = false }
rattler_cache = { path = "../rattler_cache", version = "0.3.0", default-features = false }
rattler_conda_types = { path = "../rattler_conda_types", version = "0.29.6", default-features = false }
rattler_digest = { path = "../rattler_digest", version = "1.0.4", default-features = false }
Expand Down
49 changes: 46 additions & 3 deletions crates/rattler/src/install/driver.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
use std::{
borrow::Borrow,
collections::{HashMap, HashSet},
ffi::OsStr,
path::{Path, PathBuf},
sync::{Arc, Mutex, MutexGuard},
};

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 @@ -155,18 +156,41 @@ impl InstallDriver {
transaction: &Transaction<Old, New>,
target_prefix: &Path,
) -> Result<Option<PrePostLinkResult>, PrePostLinkError> {
let mut result = None;
if self.execute_link_scripts {
match self.run_pre_unlink_scripts(transaction, target_prefix) {
Ok(res) => {
return Ok(Some(res));
result = Some(res);
}
Err(e) => {
tracing::error!("Error running pre-unlink scripts: {:?}", e);
}
}
}

Ok(None)
// For all packages that are removed, we need to remove menuinst entries as well
for record in transaction.removed_packages().map(Borrow::borrow) {
for path in record.paths_data.paths.iter() {
if path.relative_path.starts_with("Menu")
&& path.relative_path.extension() == Some(OsStr::new("json"))
{
match rattler_menuinst::remove_menu_items(
&target_prefix.join(&path.relative_path),
target_prefix,
target_prefix,
Platform::current(),
rattler_menuinst::MenuMode::User,
) {
Ok(_) => {}
Err(e) => {
tracing::warn!("Failed to remove menu item: {}", e);
}
}
}
}
}

Ok(result)
}

/// Runs a blocking task that will execute on a separate thread. The task is
Expand Down Expand Up @@ -222,6 +246,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);
}
}
46 changes: 46 additions & 0 deletions crates/rattler_menuinst/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[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"
quick-xml = "0.37.1"
chrono = { workspace = true, features = ["clock"] }
configparser = { version = "3.1.0", features = ["indexmap"] }

[target.'cfg(target_os = "windows")'.dependencies]
windows = { version = "0.58", features = [
"Win32_System_Com",
"Win32_UI_Shell",
"Win32_System_Com_StructuredStorage",
"Win32_UI_Shell_PropertiesSystem",
"Win32_Storage_EnhancedStorage",
"Win32_Foundation",
"implement"
]}
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
Loading