aboutsummaryrefslogtreecommitdiffstats
path: root/community/cargo/APKBUILD
blob: 4d0e0524f7efbecf55056332b8321b77b2c24a6a (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
# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=cargo
pkgver=0.22.0
pkgrel=3
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!
_bootstrap_cargo_ver=0.17.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-alpine-linux-musl.tar.gz
	tests-fix-build-auth-http_auth_offered.patch
	tests-ignore-ssh_something_happens.patch
	cargo.lock-use-openssl-0.9.20.patch"
builddir="$srcdir/$pkgname-$pkgver"

export CARGO_HOME="$srcdir/.cargo"

_bootstrap_cargo="$srcdir/$pkgname-$_bootstrap_cargo_ver-$CHOST/bin/cargo"
_cargo_opts="--release --locked --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/
}

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"

	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="31764df0462fcd0e7ddd29aee63ed0916b0d05e44d72aa815b3b823256e90f85e582c468a517d048e4451dfc1a3b22434abf25d825d3d926ab7a95f7bb44ad40  cargo-0.22.0.tar.gz
b78a03942344852fd1a8c0ac893580c589757d4946150e5959e1df08b163b94ce5319236a48506c18f987cf3500a2c7cfe808eef13092c45d271e169946a18d1  cargo-0.17.0-x86_64-alpine-linux-musl.tar.gz
4e9a0d409951a72b5c1d3578cb310c0efc5d98a5b963432ec4f485f1d58d2354f0050c31574d6bd9090b7247468ef1a13b04b133deabe6daed91032764468f97  tests-fix-build-auth-http_auth_offered.patch
17c669a71443e21cc5e5cc6eb99933c20562b7df9d859c493ff25252167eb1aea6dd7322a06207776eab1c769464f95a432d1520a949512a52592b1eb115a4be  tests-ignore-ssh_something_happens.patch
901e949d7b60ffa3f44a120b61a46885b5d0f9e8eae8bcf2ece847cef339c433a9217249e92416f5fa5aa775c6734d58ccb47346daf6034d7031ff30fdfb9aef  cargo.lock-use-openssl-0.9.20.patch"