Commit graph

142 commits

Author SHA1 Message Date
Jiahao XU
065f62a625
Use VersionReq for Options::version_req and update usage of
`CrateName` in `binstall::install`

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:59 +10:00
Jiahao XU
34f714c64f
Pass --force to cargo-install
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:58 +10:00
Jiahao XU
4b79abeedc
Refactor: Run TempDir creation in block_in_place
Since it could also issues blocking operations.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:58 +10:00
Jiahao XU
b8c44839c1
Detect install_path & load metadata in block_in_place
since they involves blocking fs io.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:58 +10:00
Jiahao XU
b4c6db7cda
Refactor & Optimize: Launch target detection as soon as possible
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:58 +10:00
Jiahao XU
4dae214af3
Use block_in_place for loading metadata
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:57 +10:00
Jiahao XU
6716d75607
Minor Refactor: Gather code related to crate_names
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:57 +10:00
Jiahao XU
ac085533cc
Skip crates that are already installed.
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:57 +10:00
Jiahao XU
04fee49c22
Add new option Options::force
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-08 18:05:57 +10:00
Jiahao XU
132c5dfaa9
Merge pull request #280 from cargo-bins/signal-handling
Add Signal handling
2022-08-06 20:13:03 +10:00
Jiahao XU
c352eb00d1
Add missing doc for trace for Options::log_level
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-05 15:24:39 +10:00
Jiahao XU
7a90d4d6c6
Improve help page for Options::log_level
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-05 15:09:40 +10:00
Jiahao XU
8d5f555373
Add new option -q for compatibility with cargo-install
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-05 15:02:38 +10:00
Jiahao XU
b6a539735d
Pass -q to cargo-install if log_level is set to off
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-04 23:21:29 +10:00
Jiahao XU
6685d5a610
Add new option Options::quiet
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-04 23:16:45 +10:00
Jiahao XU
62bce2f52f
Improve doc for Options::log_level
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-04 23:15:05 +10:00
Jiahao XU
b921e9dfc8
Use cancel_on_user_sig_term in main
to cancel the execution if users requested termination via signal.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-04 19:42:47 +10:00
Jiahao XU
e8301839a9
Use AutoAbortJoinHandle in main::entry
so that the tasks will be cancelled if future returned by
`entry()` is cancelled.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-04 18:39:17 +10:00
Jiahao XU
28aeae938e
fs::create_dir_all(&install_path) in main.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-04 14:00:44 +10:00
Jiahao XU
f7625fcefc
Merge pull request #264 from NobodyXu/fix-repeated-crates-on-batch-installation
Fix repeated crates on batch installation: Dedup them and only keep the last one
2022-08-03 21:32:09 +10:00
Jiahao XU
f72eafb049
Use PathBuf for field Options::install_path
Since it does not require a utf-8 string.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-02 22:28:44 +10:00
Jiahao XU
a52ac3fc7a
Use CompactString for Options::version_req
which is unlikely to be larger than 24 bytes.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-02 22:26:44 +10:00
Jiahao XU
caeb49ce33
Rm duplicate crate_names specified on cmdline
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-02 22:15:09 +10:00
Jiahao XU
9391d22fa2
Apply clippy suggestion
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-08-02 19:54:01 +10:00
Félix Saparelli
47fd7c14a6
Add -V, clean up errors and help text (#259)
Co-authored-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-30 17:26:52 +12:00
Jiahao XU
6c6d0fe9c2
Update logging for binstall_v1::append
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-28 23:15:26 +10:00
Jiahao XU
2490c08840
Write to .binstall-crates.toml in entry
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-27 23:15:54 +10:00
Jiahao XU
2f27a5fd93
Refactor: Use binstall_v1::MetaData in mod binstall
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-27 19:44:16 +10:00
Jiahao XU
48f1825c98
Print out help when crate_names is empty
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-24 19:03:55 +10:00
Félix Saparelli
e93f0beb4b
Remove support for .crates2.json (#235) 2022-07-24 03:33:31 +12:00
Jiahao XU
1768392413
Merge pull request #228 from NobodyXu/fix/skip-on-custom-install
Fix updating metafiles: Skip on custom install path
2022-07-23 19:57:58 +10:00
Jiahao XU
5ea66574c3
Mod get_install_path to ret Arc<Path> instead of PathBuf
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 18:37:59 +10:00
Jiahao XU
79476e490b
Fix custom_install_path detection
Installing to `CARGO_INSTALL_ROOT` or the local executable dir should be
considered a custom installation path.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-23 18:33:30 +10:00
Jiahao XU
7bdc720a9a
Fix updating metafiles: Skip on custom install path
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 22:59:02 +10:00
Jiahao XU
95c30122e9
Rm unused import tempfile::TempDir in main.rs
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 19:17:23 +10:00
Jiahao XU
fb35863faa
Create temp_dir in install_path
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 19:17:09 +10:00
Jiahao XU
92f4d0af95
Fix metafile updating: Update them in entry only
to avoid race condition.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-22 17:58:29 +10:00
Jiahao XU
6964eee5d1
Merge pull request #223 from NobodyXu/fix/join-err
Fix: join err handling, unify it using `BinstallError`
2022-07-22 11:29:21 +10:00
Jiahao XU
adc0a22a50
Rm unused variant MainExit::JoinErr
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 20:44:13 +10:00
Jiahao XU
d39bc0acab
Construct BinstallError from JoinError in main
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 20:43:47 +10:00
Jiahao XU
6a95bb07e0
Add field desired_targets to binstall::Options
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:05:12 +10:00
Jiahao XU
aa88dce215
Add field cli_overrides to binstall::Options
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 15:00:01 +10:00
Jiahao XU
f09004b5b7
Optimize: Share crates_io_api::AsyncClient
So that the connection pool and the rate limit will be shared.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 14:50:51 +10:00
Jiahao XU
c418c2dbbe
Optimize arg parsing: Avoid O(n) Vec::remove
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-21 12:44:54 +10:00
Jiahao XU
cfe7703af9
Forbid --manifest-path to used with batch installation
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 19:11:02 +10:00
Jiahao XU
3981400ebb
Create new type LazyJobserverClient
and use it to replace `jobserver::Client`.

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:54:17 +10:00
Jiahao XU
921774b8f9
Refactor: Extract new mod binstall
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:26:24 +10:00
Jiahao XU
3b82e9e375
Rm unnecessary clone in install_from_package
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 17:04:26 +10:00
Jiahao XU
1eedae1ee2
Rm unused param temp_dir from install_from_package
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 16:59:23 +10:00
Jiahao XU
1ebd4bdb75
Refactor: Reduce params of install_from_package
Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
2022-07-20 16:58:12 +10:00