aboutsummaryrefslogtreecommitdiffstats
path: root/testing/cargo/APKBUILD
blob: 3089fecd36025b6a1e9719920390cc86e6ad2045 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=cargo
pkgver=0.18.0
# Git revision of prebuilt Cargo to use for bootstrapping.
_bootstrap_gitrev=6e0c18cccc8b0c06fba8a8d76486f81a792fb420  # 0.16.0
# Git revision of rust-installer (submodule in cargo repo).
_installer_gitrev=4f994850808a572e2cc8d43f968893c8e942e9bf
pkgrel=0
pkgdesc="The Rust package manager"
url="https://crates.io"
arch="x86_64"  # limited by rust pkg
license="MIT ASL-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).
# 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!
_cbuild="$CARCH-unknown-linux-musl"
source="$pkgname-$pkgver.tar.gz::https://github.com/rust-lang/$pkgname/archive/$pkgver.tar.gz
	https://github.com/rust-lang/rust-installer/archive/$_installer_gitrev/rust-installer-$_installer_gitrev.tar.gz
	cargo-$_bootstrap_gitrev-$_cbuild.tar.gz::https://s3.amazonaws.com/rust-lang-ci/cargo-builds/$_bootstrap_gitrev/cargo-nightly-$_cbuild.tar.gz
	fix-test-build-auth.patch"
builddir="$srcdir/$pkgname-$pkgver"

_bootstrap_cargo="$srcdir/cargo-nightly-$_cbuild/cargo/bin/cargo"

export CARGOFLAGS="--locked"
export CARGO_HOME="$srcdir/.cargo"

prepare() {
	default_prepare
	cd "$builddir"

	rmdir src/rust-installer
	ln -s "$srcdir"/rust-installer-$_installer_gitrev src/rust-installer
}

build() {
	cd "$builddir"

	./configure \
		--prefix=/usr \
		--release-channel=stable \
		--cargo="$_bootstrap_cargo"

	# LIBGIT2... Convince libgit2-sys to use the distro libgit2.
	make LIBGIT2_SYS_USE_PKG_CONFIG=1 \
		VERBOSE=1
}

check() {
	cd "$builddir"

	./target/$CTARGET/release/cargo --version

	# XXX: ignore test failures for now
	CFG_DISABLE_CROSS_TESTS=1 \
		"$_bootstrap_cargo" test \
			--release \
			--target "$CTARGET" \
			--no-fail-fast \
			--verbose || true
}

package() {
	cd "$builddir"

	make install DESTDIR="$pkgdir"

	# Remove installer artifacts (manifests, uninstall scripts, etc.)
	rm -rv "$pkgdir"/usr/lib
}

bashcomp() {
	pkgdesc="Bash completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel bash"

	_mv "$pkgdir"/usr/etc/bash_completion.d/* \
		"$subpkgdir"/usr/share/bash-completion/completions/

	# Clean directories which are supposed to be empty.
	rmdir -p "$pkgdir"/usr/etc/bash_completion.d 2>/dev/null || true
}

zshcomp() {
	pkgdesc="ZSH completions for $pkgname"
	depends=""
	install_if="$pkgname=$pkgver-r$pkgrel zsh"

	_mv "$pkgdir"/usr/share/zsh "$subpkgdir"/usr/share/
	rmdir "$pkgdir"/usr/share
}

_mv() {
	local dest; for dest; do true; done  # get last argument
	mkdir -p "$dest"
	mv $@
}

sha512sums="561d6817555da802e99964daa74550cc47a285903301da12a245bb62e5857c18069d87a520c5cefb62aecfe5561666352d57dca8f75758f81ea82709565577d2  cargo-0.18.0.tar.gz
9ceb4755890ad3ae68ce141231c5114077261e0279d3a9a6208053f8d3386c9198e6b94d6321b456648dd5baa86dfc3ae81df44b67d41b428d11afd6763f0cff  rust-installer-4f994850808a572e2cc8d43f968893c8e942e9bf.tar.gz
4df33353b6be1af822220ca03f9ec5a3b6421c9b10ec17b864be586ba495c6210bac70d904b0e0b35eff62ef2c9a681ded526e5cbd37e326dc3146742aa659de  cargo-6e0c18cccc8b0c06fba8a8d76486f81a792fb420-x86_64-unknown-linux-musl.tar.gz
6a789fc1bf0eb19dde9267a10f7506787d6a4bb8316b09f4dee5da083c0fb0bad87630b238d92ef3aaf114d9a337a87797c8ac427f71c53ac06106925d459ee0  fix-test-build-auth.patch"