mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-25 06:40:03 +00:00
Fix self-update on windows (#712)
Fixed #702 * Add new dep windows v0.44.0 for windows only * Add regression test for #702 * Impl `win::replace_file` * Use `ReplaceFileW` on windows if `fs::rename` in `fs::atomic_install` fails * Improve logging and err messages * Add more regression tests * Make `BinFile::install_link` atomic: Do not remove file if dst exists * Fallback to `ReplaceFileW` in `fs::atomic_symlink_file` * Refactor: Extract new fn `fs::persist` * Use `fs::persist` instead of `TempFile::persist` in `fs::atomic_install`, which fallbacks to `ReplaceFileW` on windows Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com> Co-authored-by: Félix Saparelli <felix@passcod.name>
This commit is contained in:
parent
a60ae7ef6c
commit
ab4da7f059
6 changed files with 153 additions and 38 deletions
32
e2e-tests/self-upgrade-no-symlink.sh
Normal file
32
e2e-tests/self-upgrade-no-symlink.sh
Normal file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -euxo pipefail
|
||||
|
||||
unset CARGO_INSTALL_ROOT
|
||||
|
||||
export CARGO_HOME=$(mktemp -d 2>/dev/null || mktemp -d -t 'cargo-home')
|
||||
export PATH="$CARGO_HOME/bin:$PATH"
|
||||
|
||||
# first boostrap-install into the CARGO_HOME
|
||||
mkdir -p "$CARGO_HOME/bin"
|
||||
cp "./$1" "$CARGO_HOME/bin"
|
||||
|
||||
# now we're running the CARGO_HOME/bin/cargo-binstall (via cargo):
|
||||
|
||||
# self update replacing no-symlinks with no-symlinks
|
||||
cargo binstall --no-confirm --no-symlinks --force cargo-binstall
|
||||
|
||||
# self update replacing no-symlinks with symlinks
|
||||
cp "./$1" "$CARGO_HOME/bin"
|
||||
|
||||
cargo binstall --no-confirm --force cargo-binstall
|
||||
|
||||
# self update replacing symlinks with symlinks
|
||||
ln -snf "$(pwd)/cargo-binstall" "$CARGO_HOME/bin/cargo-binstall"
|
||||
|
||||
cargo binstall --no-confirm --force cargo-binstall
|
||||
|
||||
# self update replacing symlinks with no-symlinks
|
||||
ln -snf "$(pwd)/cargo-binstall" "$CARGO_HOME/bin/cargo-binstall"
|
||||
|
||||
cargo binstall --no-confirm --force --no-symlinks cargo-binstall
|
Loading…
Add table
Add a link
Reference in a new issue