1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
//! Add installer functionality to standalone binaries.
//!
//! This crate enables CLI applications to be distributed as standalone
//! binaries that can install and uninstall themselves.
//!
//! ## Overview
//!
//! To get started:
//!
//! 1. Create a unique ID for your application using [`AppId`].
//! 2. Create the listing of input files using [`PackageManifest`].
//! 3. Based on context, run [`install_interactive()`] or [`uninstall_interactive()`], or continue normally in your binary.
//! 4. If you need a included data file in a installation, use [`manifest()`] to get a [`DiskManifest`].
//!
//! ## Example
//!
//! ```
//! # use std::error::Error;
//! # use takecrate::manifest::AppId;
//! # use takecrate::inst::PackageManifest;
//! # fn main() -> Result<(), Box<dyn Error>> {
//! # let exe_name = "";
//! let app_id = AppId::new("com.example.my-app")?;
//! let manifest = PackageManifest::new(&app_id).with_self_exe()?;
//!
//! if exe_name.ends_with("_installer") {
//! takecrate::install_interactive(&manifest)?;
//! }
//! # Ok(())
//! # }
//! ```
//!
//! ## Further reading
//!
//! [More information](crate::lib_doc)
use InstallerError;
use ;
use ;
use Uninstaller;
compile_error!;
/// Starts the installer with a interactive interface.
///
/// A terminal user interface (TUI) will guide the user with installation
/// options and perform the installation.
///
/// If the user cancels the guide, the error kind [`InterruptedByUser`](crate::error::InstallerErrorKind::InterruptedByUser)
/// will be returned. If an error occurs, an appropriate error kind will be
/// returned.
/// Installs the binary to the device with the given configuration.
///
/// This function is intended for "quiet" installs where the installation
/// occurs automatically, such as, a shell script.
/// Starts the uninstaller with a interactive interface.
///
/// A terminal user interface (TUI) will prompt for a confirmation before
/// the uninstallation proceeds.
///
/// If there is both a User and System installation, the uninstaller will
/// uninstall the User version.
/// Uninstalls the binary from the device with the given application ID.
///
/// This function is intended for "quiet" uninstalls where the uninstallation
/// occurs automatically, such as, a shell script.
///
/// If there is both a User and System installation, the uninstaller will
/// uninstall the User version.
/// Returns the disk manifest when the binary is installed.
///
/// If there is both a User and System installation, the User version will
/// be returned.