-
Notifications
You must be signed in to change notification settings - Fork 87
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use anyhow::{Context, Result}; | ||
use clap::Parser; | ||
use rattler_conda_types::{menuinst::MenuMode, PackageName, Platform, PrefixRecord}; | ||
use std::{fs, path::PathBuf}; | ||
|
||
#[derive(Debug, Parser)] | ||
pub s 10000 truct InstallOpt { | ||
/// Target prefix to look for the package (defaults to `.prefix`) | ||
#[clap(long, short, default_value = ".prefix")] | ||
target_prefix: PathBuf, | ||
|
||
/// Name of the package for which to install menu items | ||
package_name: PackageName, | ||
} | ||
|
||
pub async fn install_menu(opts: InstallOpt) -> Result<()> { | ||
// Find the prefix record in the target_prefix and call `install_menu` on it | ||
let records: Vec<PrefixRecord> = PrefixRecord::collect_from_prefix(&opts.target_prefix)?; | ||
|
||
let record = records | ||
.iter() | ||
.find(|r| r.repodata_record.package_record.name == opts.package_name) | ||
.with_context(|| { | ||
format!( | ||
"Package {} not found in prefix {:?}", | ||
opts.package_name.as_normalized(), | ||
opts.target_prefix | ||
) | ||
})?; | ||
let prefix = fs::canonicalize(&opts.target_prefix)?; | ||
rattler_menuinst::install_menuitems_for_record( | ||
&prefix, | ||
record, | ||
Platform::current(), | ||
MenuMode::User, | ||
)?; | ||
|
||
Ok(()) | ||
} | ||
|
||
pub async fn remove_menu(opts: InstallOpt) -> Result<()> { | ||
// Find the prefix record in the target_prefix and call `remove_menu` on it | ||
let records: Vec<PrefixRecord> = PrefixRecord::collect_from_prefix(&opts.target_prefix)?; | ||
|
||
let record = records | ||
.iter() | ||
.find(|r| r.repodata_record.package_record.name == opts.package_name) | ||
.with_context(|| { | ||
format!( | ||
"Package {} not found in prefix {:?}", | ||
opts.package_name.as_normalized(), | ||
opts.target_prefix | ||
) | ||
})?; | ||
|
||
rattler_menuinst::remove_menu_items(&record.installed_system_menus)?; | ||
|
||
Ok(()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
pub mod create; | ||
pub mod menu; | ||
pub mod virtual_packages; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
//! Define types that can be serialized into a `PrefixRecord` to track | ||
//! menu entries installed into the system. | ||
use serde::{Deserialize, Serialize}; | ||
use std::path::PathBuf; | ||
|
||
/// Menu mode that was used to install the menu entries | ||
#[derive(Default, Debug, Clone, Copy, Serialize, Deserialize, PartialEq, Eq)] | ||
pub enum MenuMode { | ||
/// System-wide installation | ||
System, | ||
|
||
/// User installation | ||
#[default] | ||
User, | ||
} | ||
|
||
/// Tracker for menu entries installed into the system | ||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
#[serde(tag = "type", rename_all = "snake_case")] | ||
pub enum Tracker { | ||
/// Linux tracker | ||
Linux(LinuxTracker), | ||
/// Windows tracker | ||
Windows(WindowsTracker), | ||
/// macOS tracker | ||
MacOs(MacOsTracker), | ||
} | ||
|
||
/// Registered MIME file on the system | ||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct LinuxRegisteredMimeFile { | ||
/// The application that was registered | ||
pub application: String, | ||
/// Path to use when calling `update-mime-database` | ||
pub database_path: PathBuf, | ||
/// The location of the config file that was edited | ||
pub config_file: PathBuf, | ||
/// The MIME types that were associated to the application | ||
pub mime_types: Vec<String>, | ||
} | ||
|
||
/// Tracker for Linux installations | ||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct LinuxTracker { | ||
/// The menu mode that was used to install the menu entries | ||
pub install_mode: MenuMode, | ||
|
||
/// List of desktop files that were installed | ||
pub paths: Vec<PathBuf>, | ||
|
||
/// MIME types that were installed | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub mime_types: Option<LinuxRegisteredMimeFile>, | ||
|
||
/// MIME type glob files that were registered on the system | ||
#[serde(default, skip_serializing_if = "Vec::is_empty")] | ||
pub registered_mime_files: Vec<PathBuf>, | ||
} | ||
|
||
/// File extension that was installed | ||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct WindowsFileExtension { | ||
/// The file extension that was installed | ||
pub extension: String, | ||
/// The identifier of the file extension | ||
pub identifier: String, | ||
} | ||
|
||
/// URL protocol that was installed | ||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct WindowsUrlProtocol { | ||
/// The URL protocol that was installed | ||
pub protocol: String, | ||
/// The identifier of the URL protocol | ||
pub identifier: String, | ||
} | ||
|
||
/// Terminal profile that was installed | ||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct WindowsTerminalProfile { | ||
/// The name of the terminal profile | ||
pub configuration_file: PathBuf, | ||
/// The identifier of the terminal profile | ||
pub identifier: String, | ||
} | ||
|
||
/// Tracker for Windows installations | ||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct WindowsTracker { | ||
/// The menu mode that was used to install the menu entries | ||
pub menu_mode: MenuMode, | ||
|
||
/// List of shortcuts that were installed | ||
#[serde(default, skip_serializing_if = "Vec::is_empty")] | ||
pub shortcuts: Vec<PathBuf>, | ||
|
||
/// List of file extensions that were installed | ||
#[serde(default, skip_serializing_if = "Vec::is_empty")] | ||
pub file_extensions: Vec<WindowsFileExtension>, | ||
|
||
/// List of URL protocols that were installed | ||
#[serde(default, skip_serializing_if = "Vec::is_empty")] | ||
pub url_protocols: Vec<WindowsUrlProtocol>, | ||
|
||
/// List of terminal profiles that were installed | ||
#[serde(default, skip_serializing_if = "Vec::is_empty")] | ||
pub terminal_profiles: Vec<WindowsTerminalProfile>, | ||
} | ||
|
||
impl WindowsTracker { | ||
/// Create a new Windows tracker | ||
pub fn new(menu_mode: MenuMode) -> Self { | ||
Self { | ||
menu_mode, | ||
shortcuts: Vec::new(), | ||
file_extensions: Vec::new(), | ||
url_protocols: Vec::new(), | ||
terminal_profiles: Vec::new(), | ||
} | ||
} | ||
} | ||
|
||
/// Tracker for macOS installations | ||
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] | ||
pub struct MacOsTracker { | ||
/// The app folder that was installed, e.g. ~/Applications/foobar.app | ||
pub app_folder: PathBuf, | ||
/// Argument that was used to call `lsregister` and that we need to | ||
/// call to unregister the app | ||
#[serde(default, skip_serializing_if = "Option::is_none")] | ||
pub lsregister: Option<PathBuf>, | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
[package] | ||
name = "rattler_menuinst" | ||
version = "0.1.0" | ||
edition.workspace = true | ||
authors = ["Wolf Vollprecht <w.vollprecht@gmail.com>"] | ||
description = "Install menu entries for a Conda package" | ||
categories.workspace = true | ||
homepage.workspace = true | ||
repository.workspace = true | ||
license.workspace = true | ||
readme.workspace = true | ||
|
||
[dependencies] | ||
dirs = { workspace = true } | ||
serde = { workspace = true, features = ["derive"] } | ||
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 = { workspace = true } | ||
chrono = { workspace = true, features = ["clock"] } | ||
once_cell = {workspace = true} | ||
|
||
[target.'cfg(target_os = "macos")'.dependencies] | ||
plist = { workspace = true } | ||
sha2 = { workspace = true } | ||
|
||
[target.'cfg(target_os = "linux")'.dependencies] | ||
quick-xml = "0.37.2" | ||
configparser = { version = "3.1.0" } | ||
shlex = { workspace = true } | ||
|
||
[target.'cfg(target_os = "windows")'.dependencies] | ||
known-folders = "1.2.0" | ||
windows = { version = "0.60.0", features = [ | ||
"Win32_System_Com_StructuredStorage", | ||
"Win32_UI_Shell_PropertiesSystem", | ||
"Win32_Storage_EnhancedStorage", | ||
"Win32_System_Variant", | ||
]} | ||
windows-registry = "0.5.0" | ||
|
||
[dev-dependencies] | ||
insta = { workspace = true, features = ["json"] } | ||
configparser = { version = "3.1.0", features = ["indexmap"] } |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
feat: add
rattler_menuinst
crate #840New 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
Uh oh!
There was an error while loading. Please reload this page.
feat: add
rattler_menuinst
crate #840Changes from all commits
204b40b
4867340
1e103d1
5f1a6d8
a31d54d
9f598bc
d8ebe0d
f6b136f
82234b6
278a8cc
db9513a
ba32e08
1bfeccf
4046c32
791a8f0
9f474e7
ef53370
37b3f70
< 8000 div class="text-emphasized css-truncate css-truncate-target"> linuxff23eed
100f977
30e7842
b402d1b
3002b56
0f09559
5f081b5
26150ea
08654d8
2972e17
e53e561
02c8b0b
61326ff
d6fce2a
f830f2d
4a8d70d
d2e16d2
7e88b6b
bfdd26d
bb18d71
dcf1011
9592a89
9b214c9
3eb2cc2
5835828
1239522
1e9447c
639874c
6b3f88e
ead7c27
e2e136f
22f130a
582b1cd
b18ccc7
0169a41
d48686b
8de5021
8b298dd
c446acb
141b1e8
f9e59e0
3cd2c19
e73d516
390a7b7
c565f54
b51b59e
4a708a4
6004fc7
a14792e
cfcb718
5cd9bb4
b7a34bd
374807e
1271afc
9afee15
a458d96
40d2be4
6df5eb8
aaaa567
ecbbe8d
144abb1
99cefa4
116e505
d8e5cf6
c7b69c1
6f7cedd
8d3e66a
61fefc5
46f2f0f
b5b121e
3aabb34
4318724
1bc887f
1f5713c
3d94672
38906b8
b6e190b
2645838
0310c46
ccaf57b
8f6702a
5fc3195
800d642
075e242
ee82081
55f9b31
806faa6
f0555d7
fba4833
56c8171
1e78cde
ba4e8f4
eafca67
1f0185e
9c4f43a
ac855fd
86515a3
636c71a
08683b3
7a38f0e
223bba0
b303b3d
7df5c6f
edbdd22
faa76d9
9babf90
8d84e8c
4ee5a34
1ad46b3
2dfed77
4716453
c6e7b7a
3e436ee
4557f24
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.