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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
|
# Maintainer: pingplug <pingplug@foxmail.com>
_pkgname=rust
pkgname=mingw-w64-rust-bin
pkgver=1.27.1
pkgrel=1
pkgdesc="Systems programming language focused on safety, speed and concurrency (official build, mingw-w64)"
arch=('x86_64')
url="https://www.rust-lang.org"
license=('MIT' 'Apache' 'custom')
depends=('gcc-libs'
'curl'
'mingw-w64-crt<5.0.4.20180112'
'libgit2'
'mingw-w64-gcc')
optdepends=('mingw-w64-wine: for cargo test support')
provides=("mingw-w64-rust=${pkgver}")
conflicts=('mingw-w64-rust')
options=('!strip' 'staticlibs' '!buildflags')
source=("https://static.rust-lang.org/dist/rust-${pkgver}-x86_64-unknown-linux-gnu.tar.xz"{,.asc}
"https://static.rust-lang.org/dist/rust-std-${pkgver}-i686-pc-windows-gnu.tar.xz"{,.asc}
"https://static.rust-lang.org/dist/rust-std-${pkgver}-x86_64-pc-windows-gnu.tar.xz"{,.asc})
sha256sums=('bae52484fe3cd50b4670487709e77ee5c0412ea55432f6036225e5c5557d43ae'
'SKIP'
'ceb42d78427e7469bde30c4e86fd8c7929ed27379566c064b8c9d7d7eb7bd7b5'
'SKIP'
'd22bfcfa53c5015fd429c735e88ad1997b81f883ffe0e8a9839e4ebab1591430'
'SKIP')
validpgpkeys=('108F66205EAEB0AAA8DD5E1C85AB96E6FA1BE5FE') # Rust Language (Tag and Release Signing Key) <rust-key@rust-lang.org>
backup=("opt/${_pkgname}/cargo/config")
PKGEXT=".pkg.tar.gz"
prepare() {
cd ${srcdir}
rm -rf "rust-${pkgver}-x86_64-unknown-linux-gnu/rust-std-i686-pc-windows-gnu"
mv "rust-std-${pkgver}-i686-pc-windows-gnu/rust-std-i686-pc-windows-gnu" "rust-${pkgver}-x86_64-unknown-linux-gnu"
cat "rust-std-${pkgver}-i686-pc-windows-gnu/components" >> "rust-${pkgver}-x86_64-unknown-linux-gnu/components"
rm -rf "rust-${pkgver}-x86_64-unknown-linux-gnu/rust-std-x86_64-pc-windows-gnu"
mv "rust-std-${pkgver}-x86_64-pc-windows-gnu/rust-std-x86_64-pc-windows-gnu" "rust-${pkgver}-x86_64-unknown-linux-gnu"
cat "rust-std-${pkgver}-x86_64-pc-windows-gnu/components" >> "rust-${pkgver}-x86_64-unknown-linux-gnu/components"
}
package() {
cd "${srcdir}/rust-${pkgver}-x86_64-unknown-linux-gnu"
# rustc, cargo, and libs.
./install.sh \
--disable-ldconfig \
--destdir="${pkgdir}" \
--components=rustc,cargo,rust-std-x86_64-unknown-linux-gnu,rust-std-i686-pc-windows-gnu,rust-std-x86_64-pc-windows-gnu \
--prefix=/opt/${_pkgname}
# license
install -dm755 "${pkgdir}/usr/share/licenses/${pkgname}/"{rust,cargo}
mv "${pkgdir}/opt/${_pkgname}/share/doc/cargo/"LICENSE-* "${pkgdir}/usr/share/licenses/${pkgname}/cargo/"
mv "${pkgdir}/opt/${_pkgname}/share/doc/rust/"{LICENSE-*,COPYRIGHT} "${pkgdir}/usr/share/licenses/${pkgname}/rust/"
# remove unused files
rm -r "${pkgdir}/opt/${_pkgname}/"{etc,share}
rm "${pkgdir}/opt/${_pkgname}/lib/rustlib/"{manifest-*,install.log,uninstall.sh,components,rust-installer-version}
rm "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/librustc_trans-emscripten.so"
rm "${pkgdir}/opt/${_pkgname}/lib/rustlib/i686-pc-windows-gnu/lib/"{arena,fmt_macros,graphviz,proc_macro,rustc,serialize,syntax}*.dll
rm "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-pc-windows-gnu/lib/"{arena,fmt_macros,graphviz,proc_macro,rustc,serialize,syntax}*.dll
# link shared libraries
pushd "${pkgdir}/opt/${_pkgname}/lib"
ln -sf "rustlib/x86_64-unknown-linux-gnu/lib/"*.so .
popd
install -dm755 "${pkgdir}/usr/i686-w64-mingw32/bin" && pushd "${pkgdir}/usr/i686-w64-mingw32/bin"
ln -sf "../../../opt/${_pkgname}/lib/rustlib/i686-pc-windows-gnu/lib/"*.dll .
popd
install -dm755 "${pkgdir}/usr/x86_64-w64-mingw32/bin" && pushd "${pkgdir}/usr/x86_64-w64-mingw32/bin"
ln -sf "../../../opt/${_pkgname}/lib/rustlib/x86_64-pc-windows-gnu/lib/"*.dll .
popd
# strip
strip --strip-all "${pkgdir}/opt/${_pkgname}/bin/"{cargo,rustc,rustdoc}
strip --strip-all "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-unknown-linux-gnu/bin/"lld
strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-unknown-linux-gnu/lib/"*.so
strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-unknown-linux-gnu/codegen-backends/"*.so
i686-w64-mingw32-strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/i686-pc-windows-gnu/lib/"*.dll
x86_64-w64-mingw32-strip --strip-unneeded "${pkgdir}/opt/${_pkgname}/lib/rustlib/x86_64-pc-windows-gnu/lib/"*.dll
# config
install -dm777 "${pkgdir}/opt/${_pkgname}/cargo"
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
[target.i686-pc-windows-gnu]
linker = "/usr/bin/i686-w64-mingw32-gcc"
ar = "/usr/i686-w64-mingw32/bin/ar"
EOF
if pacman -T "mingw-w64-wine" ; then
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
runner = "/usr/bin/i686-w64-mingw32-wine"
EOF
fi
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
rustflags = [
EOF
if [[ ! -f "/usr/i686-w64-mingw32/bin/libgcc_s_dw2-1.dll" ]] ; then
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
"-C", "panic=abort",
EOF
fi
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
]
EOF
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
[target.x86_64-pc-windows-gnu]
linker = "/usr/bin/x86_64-w64-mingw32-gcc"
ar = "/usr/x86_64-w64-mingw32/bin/ar"
EOF
if pacman -T "mingw-w64-wine" ; then
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
runner = "/usr/bin/x86_64-w64-mingw32-wine"
EOF
fi
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
rustflags = [
EOF
if [[ ! -f "/usr/x86_64-w64-mingw32/bin/libgcc_s_seh-1.dll" ]] ; then
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
"-C", "panic=abort",
EOF
fi
if pacman -T "mingw-w64-crt-git>5.0.4.20171219" ; then
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
"-C", "link-arg=-lmsvcrt",
EOF
fi
cat << EOF >> "${pkgdir}/opt/${_pkgname}/cargo/config"
]
EOF
}
# vim:set ts=2 sw=2 et:
|