# Contributor: Jakub Jirutka # Maintainer: Jakub Jirutka pkgname=cargo pkgver=0.25.0 pkgrel=1 pkgdesc="The Rust package manager" url="https://crates.io" arch="x86_64" # limited by rust pkg license="MIT Apache-2.0" depends="rust" makedepends="cmake curl-dev libgit2-dev libssh2-dev libressl-dev python2 zlib-dev" subpackages="$pkgname-doc $pkgname-bash-completion:bashcomp:noarch $pkgname-zsh-completion:zshcomp:noarch" # NOTE: Cargo is self-hosted, so you need cargo to build cargo (ugh). # The bootstrap static cargo has been cross-compiled on GNU system using # prebuilt cargo downloaded from the upstream. # XXX: Cargo depends on many crates (Rust packages) and currently downloads # them itself in the build phase. This quite violates our policy. However, # unlike some other package managers, Cargo does not download arbitrary # packages from the Internet without any verification. The source tarball # includes file Cargo.lock that contains complete dependency tree with exact # version and checksum for each crate . With --locked we force cargo to # adhere to this file and verify checksums. So it provides the same # guarantees as abuild. That said, for now it's exception only for cargo # package and should not be applied to other rust packages! # FIXME: There's no Cargo.lock in the cargo's repository anymore! According to # the upstream, Cargo should be always built together with Rust... For now we # at least include Cargo.lock generated locally as a side effect of running # `cargo build` for particular $pkgver to ensure basic reproducibility. _bootstrap_cargo_ver=0.25.0 source="$pkgname-$pkgver.tar.gz::https://github.com/rust-lang/$pkgname/archive/$pkgver.tar.gz https://dev.alpinelinux.org/archive/$pkgname/$pkgname-$_bootstrap_cargo_ver-x86_64-unknown-linux-musl.tar.gz Cargo.lock update-git2-to-0.7.0.patch tests-fix-build-auth-http_auth_offered.patch tests-ignore-ssh_something_happens.patch tests-ignore-rustdoc.patch tests-ignore-wasm32_final_outputs.patch " builddir="$srcdir/$pkgname-$pkgver" export CARGO_HOME="$srcdir/.cargo" _bootstrap_cargo="$srcdir/$pkgname-$_bootstrap_cargo_ver-${CHOST/alpine/unknown}/bin/cargo" _cargo_opts="--locked --release --verbose ${JOBS:+--jobs $JOBS}" # Uploaded cargo binary from the built package to dev.a.o, so it can be used # for building cargo next time (needed for bootstrapping). # TODO: Build statically linked binary for bootstrapping! snapshot() { local apkfile="$REPODEST/$repo/$CARCH/$pkgname-$pkgver-r$pkgrel.apk" local tarname="$pkgname-$pkgver-$CHOST" [ -f "$apkfile" ] || die "$apkfile does not exist, run abuild -r" mkdir -p "$srcdir/$tarname" cd "$srcdir" tar -C "$tarname" -x --strip-components 1 -f "$apkfile" usr/bin/cargo tar -czf "$tarname.tar.gz" "$tarname" msg "Uploading $tarname.tar.gz to dev.alpinelinux.org" scp "$tarname.tar.gz" dev.alpinelinux.org:/archive/$pkgname/ } prepare() { default_prepare cp "$srcdir"/Cargo.lock "$builddir"/ } build() { cd "$builddir" # Convince libgit2-sys to use the distro libgit2. export LIBGIT2_SYS_USE_PKG_CONFIG=1 "$_bootstrap_cargo" build $_cargo_opts "$_bootstrap_cargo" test $_cargo_opts --no-run } check() { cd "$builddir" ./target/release/cargo --version CFG_DISABLE_CROSS_TESTS=1 RUST_BACKTRACE=1 \ "$_bootstrap_cargo" test $_cargo_opts --no-fail-fast } package() { cd "$builddir" install -D -m 755 target/release/cargo "$pkgdir"/usr/bin/cargo mkdir -p "$pkgdir"/usr/share/man/man1 install -m 644 -t "$pkgdir"/usr/share/man/man1/ src/etc/man/*.1 mkdir -p "$pkgdir"/usr/share/licenses/$pkgname install -m 644 -t "$pkgdir"/usr/share/licenses/$pkgname/ LICENSE* } bashcomp() { pkgdesc="Bash completions for $pkgname" depends="" install_if="$pkgname=$pkgver-r$pkgrel bash-completion" cd "$builddir" install -D -m 644 -D src/etc/cargo.bashcomp.sh \ "$subpkgdir"/usr/share/bash-completion/completions/cargo } zshcomp() { pkgdesc="ZSH completions for $pkgname" depends="" install_if="$pkgname=$pkgver-r$pkgrel zsh" cd "$builddir" install -D -m 644 src/etc/_cargo \ "$subpkgdir"/usr/share/zsh/site-functions/_cargo } sha512sums="959277eaf993b455ced93581dd04358507d91390dbc4413ca5e30f5548221e8d321b8983c195025b73a193107410429b33b9692298733c201c98ab62da99dfad cargo-0.25.0.tar.gz 67d6d353d26232aa9e7c8d5b0eacc7cacb455fafa42b1932e6ebc832cbc9f948e723e5c5a9209ad504b34313e8a861236691e9bfefc12ef22afcd23f8859e918 cargo-0.25.0-x86_64-unknown-linux-musl.tar.gz 5de09259c2d469206eb91ed2cef15528713d650995705cfb158c4d1aa277cb1f811fb25f0ab8ded3cddee6bb69c65536cb15330f5f02b1a5e90cb6eab78f4e89 Cargo.lock 9aadf8f9c7be05d62976857611051113dc5b47fe25231edb7a147d8c09cb44f6af5a196460568dbeff9e8ee201b79a09de1f6c9fc18626036dff50d043089179 update-git2-to-0.7.0.patch 8f9ce1c7c17693a92b8f5f1e7718bf6045910240326cd06346adbf66049dd62a4ea5a2e7a60d2793e532d2b406d5ed673d05068058abb5ca8e8df85273625024 tests-fix-build-auth-http_auth_offered.patch 17c669a71443e21cc5e5cc6eb99933c20562b7df9d859c493ff25252167eb1aea6dd7322a06207776eab1c769464f95a432d1520a949512a52592b1eb115a4be tests-ignore-ssh_something_happens.patch cf2c55d71cb376fdaac7efedfd9bb7a1d8b8709c7cd98aa7e74e574885e8dfa17fbb61050335d7fc63932c5b45ac1ca33cf516d4340e1ba9fe5f41fd6983078e tests-ignore-rustdoc.patch 9319350e31dc661131bc6c3cc4609a221d70e8d9f22faa8bea12cdbe87c989872b8b69c181e6c701bc38682b26c49a8133f93be316271995856f6ead1df296b5 tests-ignore-wasm32_final_outputs.patch"