Skip to content
New 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

rustup: new, 1.27.1 #20989

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions mingw-w64-rustup/PKGBUILD
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
_realname=rustup
pkgbase=mingw-w64-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}")
pkgver=1.27.1
pkgrel=1
pkgdesc="The Rust toolchain installer (mingw-w64)"
arch=('x86_64')
mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64')
url="https://github.com/rust-lang/rustup"
license=('spdx:Apache-2.0 AND MIT')
msys2_references=(
'archlinux: rustup'
)
depends=(
"${MINGW_PACKAGE_PREFIX}-curl"
"${MINGW_PACKAGE_PREFIX}-xz"
"${MINGW_PACKAGE_PREFIX}-zstd"
)
makedepends=("${MINGW_PACKAGE_PREFIX}-rust")
optdepends=(
"${MINGW_PACKAGE_PREFIX}-gdb: rust-gdb script"
"${MINGW_PACKAGE_PREFIX}-lldb: rust-lldb script"
)
provides=("${MINGW_PACKAGE_PREFIX}-rust")
conflicts=("${MINGW_PACKAGE_PREFIX}-rust")
install='post.install'
options=("!lto")
source=(
"rustup-${pkgver}.tar.gz::${url}/archive/${pkgver}.tar.gz"
"rustup-profile.sh"
)
sha256sums=('f5ba37f2ba68efec101198dca1585e6e7dd7640ca9c526441b729a79062d3b77'
'c90eac939a9166240697ed5772f7b6f944d3b16bdaab7071dd9ac81ce5b07b1c')
_binlinks=('cargo' 'rustc' 'rustdoc' 'rust-gdb' 'rust-lldb' 'rustfmt' 'cargo-fmt' 'cargo-clippy' 'clippy-driver' 'cargo-miri')

build() {
cd "${_realname}-${pkgver}"
cargo build --release --features no-self-update --bin rustup-init
}

package() {
cd "${_realname}-${pkgver}"
install -d "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin"
install -Dm755 "target/release/rustup-init" "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe"
for link in "${_binlinks[@]}"; do
MSYS=winsymlinks:native ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/bin/${link}.exe"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do native symlinks in packages, as Windows does not support them by default.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware, which is why this is a hard link - it's supported on a fresh install since Win8+. Without it, the package size bloats from 8mb (same as Arch, which uses symlinks) to 80mb (copying a multicall binary loses a lot of the benefits of it being a multicall binary).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

zst packages are compressed files, so hardlinks symlinks get erased into just being files...
maybe we can get away with a script instead?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The underlying tar file being compressed knows whether the files in it are regular files, symlinks, or hardlinks. I imagine that's how pacman -Qip can tell that the copied version is 80mb while the hardlinked version is 8mb, even though in both cases the zst file is 2mb.

Not sure what a script would do better than the tar file containing a hardlink, which is supported on all versions of Windows that the MSYS2 project currently supports (Win8+).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't do native symlinks in packages, as Windows does not support them by default.

Can we precreate these symlinks, and upload them into Github?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could, but end users still won't be able to use them - tar (and consequently pacman) will simply fail extracting.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unless you fork tar for msys2 which supports it, but then why not do it for upstream cygwin

done

# Special treatment to allow for rust-analyzer to still allow the separate package version to be used.
MSYS=winsymlinks:native ln "${pkgdir}/${MINGW_PREFIX}/bin/rustup.exe" "${pkgdir}/${MINGW_PREFIX}/lib/${_realname}/bin/rust-analyzer.exe"

install -Dm644 "${srcdir}/rustup-profile.sh" "${pkgdir}/etc/profile.d/rustup.sh"

# Generate completion files.
mkdir -p "${pkgdir}/${MINGW_PREFIX}/share/bash-completion/completions"
"${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions bash > "${pkgdir}/${MINGW_PREFIX}/share/bash-completion/completions/rustup"
"${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions bash cargo > "${pkgdir}/${MINGW_PREFIX}/share/bash-completion/completions/cargo"
mkdir -p "${pkgdir}/${MINGW_PREFIX}/share/fish/vendor_completions.d"
"${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions fish > "${pkgdir}/${MINGW_PREFIX}/share/fish/vendor_completions.d/rustup.fish"
mkdir -p "${pkgdir}/${MINGW_PREFIX}/share/zsh/site-functions"
"${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions zsh > "${pkgdir}/${MINGW_PREFIX}/share/zsh/site-functions/_rustup"
"${pkgdir}/${MINGW_PREFIX}/bin/rustup" completions zsh cargo > "${pkgdir}/${MINGW_PREFIX}/share/zsh/site-functions/_cargo"

install -Dm644 LICENSE-MIT "${pkgdir}/${MINGW_PREFIX}/share/licenses/${pkgname}/LICENSE-MIT"
install -Dm644 LICENSE-APACHE "${pkgdir}/${MINGW_PREFIX}/share/licenses/${pkgname}/LICENSE-APACHE"
}
8 changes: 8 additions & 0 deletions mingw-w64-rustup/post.install
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
post_install() {
echo "You may need to run rustup update stable"
echo "and possibly also rustup self upgrade-data"
}

post_upgrade() {
echo "You may need to run rustup self upgrade-data"
}
2 changes: 2 additions & 0 deletions mingw-w64-rustup/rustup-profile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
append_path "${MINGW_PREFIX}/lib/rustup/bin"
500-internal-server-error marked this conversation as resolved.
Show resolved Hide resolved
export PATH
Loading