Skip to content

Commit

Permalink
Add patches to installer to support transition from cargo-home to `…
Browse files Browse the repository at this point in the history
…flat` install layouts
  • Loading branch information
zanieb committed Nov 8, 2024
1 parent 027da8d commit 0af46c1
Show file tree
Hide file tree
Showing 46 changed files with 1,176 additions and 44 deletions.
16 changes: 16 additions & 0 deletions cargo-dist/templates/installer/installer.ps1.j2
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,22 @@ function Invoke-Installer($artifacts, $platforms) {
$install_layout = "flat"
}

# Check if the install layout should be changed from `flat` to `cargo-home`
# for backwards compatible updates of applications that switched layouts.
if (($force_install_dir) -and ($install_layout -eq "flat")) {
# If the install directory is targeting the Cargo home directory, then
# we assume this application was previously installed that layout
# Note the installer passes the path with `\\` separators, but here they are
# `\` so we normalize for comparison. We don't use `Resolve-Path` because they
# may not exist.
$cargo_home = if ($env:CARGO_HOME) { $env:CARGO_HOME } else {
Join-Path $(if ($env:HOME) { $env:HOME } else { "" }) ".cargo"
}
if ($force_install_dir.Replace('\\', '\') -eq $cargo_home) {
$install_layout = "cargo-home"
}
}

# The actual path we're going to install to
$dest_dir = $null
$dest_dir_lib = $null
Expand Down
12 changes: 12 additions & 0 deletions cargo-dist/templates/installer/installer.sh.j2
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,18 @@ install() {
_install_layout="flat"
fi
# Check if the install layout should be changed from `flat` to `cargo-home`
# for backwards compatible updates of applications that switched layouts.
if [ -n "${_force_install_dir:-}" ]; then
if [ "$_install_layout" = "flat" ]; then
# If the install directory is targeting the Cargo home directory, then
# we assume this application was previously installed that layout
if [ "$_force_install_dir" = "${CARGO_HOME:-${HOME:-}/.cargo}" ]; then
_install_layout="cargo-home"
fi
fi
fi
# Before actually consulting the configured install strategy, see
# if we're overriding it.
if [ -n "${_force_install_dir:-}" ]; then
Expand Down
29 changes: 28 additions & 1 deletion cargo-dist/tests/snapshots/akaikatana_basic.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion cargo-dist/tests/snapshots/akaikatana_musl.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion cargo-dist/tests/snapshots/akaikatana_two_bin_aliases.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion cargo-dist/tests/snapshots/akaikatana_updaters.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion cargo-dist/tests/snapshots/axolotlsay_abyss.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 28 additions & 1 deletion cargo-dist/tests/snapshots/axolotlsay_abyss_only.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 0af46c1

Please sign in to comment.