opt/rust/Pkgfile

138 lines
3.5 KiB
Plaintext
Raw Normal View History

2018-12-26 09:59:18 +01:00
# Description: The Rust language with Cargo included.
# URL: https://www.rust-lang.org/
2018-12-26 09:59:18 +01:00
# Maintainer: Danny Rawlins, crux at romster dot me
2019-12-28 15:07:59 +01:00
# Depends on: llvm
2019-05-18 13:19:04 +02:00
# Optional: sccache llvm-32
2018-12-26 09:59:18 +01:00
name=rust
2020-08-07 12:19:01 +02:00
version=1.45.2
2018-12-26 09:59:18 +01:00
##cat src/stage0.txt
2020-07-18 05:51:01 +02:00
_date=2020-06-04
_rustc=1.44.0
_cargo=0.45.0
2018-12-26 09:59:18 +01:00
##
2020-04-28 16:40:21 +02:00
release=1
2018-12-26 09:59:18 +01:00
source=(
https://static.rust-lang.org/dist/${name}c-$version-src.tar.xz
https://static.rust-lang.org/dist/$_date/rust-std-$_rustc-x86_64-unknown-linux-gnu.tar.xz
https://static.rust-lang.org/dist/$_date/rustc-$_rustc-x86_64-unknown-linux-gnu.tar.xz
https://static.rust-lang.org/dist/$_date/cargo-$_cargo-x86_64-unknown-linux-gnu.tar.xz
2018-12-26 09:59:18 +01:00
)
unpack_source() {
for file in ${source[@]}; do
case ${file##*/} in
rustc-${version}-src.tar.xz)
echo "Unpacking $(get_filename $file)";
bsdtar -p -o -C $SRC -xf $(get_filename $file) ;;
*.tar.xz)
echo "Copying $(get_filename $file)";
mkdir -p $SRC/${name}c-$version-src/build/cache/$_date || true
cp $(get_filename $file) $SRC/${name}c-$version-src/build/cache/$_date ;;
*)
cp $(get_filename $file) $SRC ;;
esac
done
}
2018-12-26 09:59:18 +01:00
build() {
cd "${name}c-$version-src"
2019-10-11 11:37:45 +02:00
local ERROR
local DATE="$(awk '/^date: / { print $2 }' src/stage0.txt)"
local RUSTC="$(awk '/^rustc: / { print $2 }' src/stage0.txt)"
local CARGO="$(awk '/^cargo: / { print $2 }' src/stage0.txt)"
if [ "$DATE" != "$_date" ]; then
printf "\e[031mError: _date $_date != $DATE\033[0m\n"
ERROR=1
fi
if [ "$RUSTC" != "$_rustc" ]; then
printf "\e[031mError: _rustc $_rustc != $RUSTC\033[0m\n"
ERROR=1
fi
if [ "$CARGO" != "$_cargo" ]; then
printf "\e[031mError: _cargo $_cargo != $CARGO\033[0m\n"
ERROR=1
fi
[ $ERROR ] && exit 1
unset DATE RUSTC CARGO ERROR
2019-06-03 16:20:39 +02:00
prt-get isinst sccache && export RUSTC_WRAPPER=/usr/bin/sccache
2018-12-26 09:59:18 +01:00
cat <<- EOF > $SRC/config.toml
[llvm]
2019-02-15 11:00:35 +01:00
ninja = true
2018-12-26 09:59:18 +01:00
targets = "X86"
2019-02-15 11:00:35 +01:00
experimental-targets = ""
2019-04-16 17:24:08 +02:00
link-shared = true
2018-12-26 09:59:18 +01:00
[install]
prefix = "/usr"
[rust]
channel = "stable"
rpath = false
codegen-tests = false
2019-02-15 11:00:35 +01:00
backtrace-on-ice = true
2018-12-26 09:59:18 +01:00
[build]
2019-02-15 11:00:35 +01:00
docs = false
2018-12-26 09:59:18 +01:00
extended = true
python = "python3"
EOF
2019-05-18 13:19:04 +02:00
# part of [build] options
if [ -e '/usr/bin/rustc' ]; then
if [ -z "$(/usr/bin/ldd /usr/bin/rustc | egrep '.*libLLVM.*.so => not found')" ]; then
2019-05-18 13:19:04 +02:00
cat <<- EOF >> $SRC/config.toml
2019-06-03 16:20:39 +02:00
cargo = "/usr/bin/cargo"
rustc = "/usr/bin/rustc"
2019-05-18 13:19:04 +02:00
EOF
2019-06-03 16:20:39 +02:00
else
2019-10-11 11:37:45 +02:00
printf "\e[031mllvm broken symlink detected, not using system rust to bootstrap\033[0m\n"
2019-06-03 16:20:39 +02:00
fi
2020-05-09 12:21:23 +02:00
fi
2019-05-18 13:19:04 +02:00
cat <<- EOF >> $SRC/config.toml
[target.x86_64-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config"
EOF
2018-12-26 09:59:18 +01:00
2019-05-18 13:19:04 +02:00
if [ -e '/usr/bin/llvm-config-32' ]; then
2018-12-26 09:59:18 +01:00
cat <<- EOF >> $SRC/config.toml
2019-05-18 13:19:04 +02:00
[target.i686-unknown-linux-gnu]
llvm-config = "/usr/bin/llvm-config-32"
2018-12-26 09:59:18 +01:00
EOF
fi
cat $SRC/config.toml
2019-05-18 13:19:04 +02:00
mkdir "$PKGMK_SOURCE_DIR/rust" || true
export CARGO_HOME="$PKGMK_SOURCE_DIR/rust"
2018-12-26 09:59:18 +01:00
export RUSTFLAGS="$RUSTFLAGS -C link-args=-lffi"
2019-02-15 11:00:35 +01:00
/usr/bin/python3 ./x.py build --config="${SRC}"/config.toml --exclude src/tools/miri -j ${JOBS-1}
export LIBSSH2_SYS_USE_PKG_CONFIG=1
2018-12-26 09:59:18 +01:00
DESTDIR=$PKG /usr/bin/python3 ./x.py --config="${SRC}"/config.toml install
2019-02-15 11:00:35 +01:00
unset LIBSSH2_SYS_USE_PKG_CONFIG
2018-12-26 09:59:18 +01:00
[ -e '/usr/bin/zsh' ] || rm -r $PKG/usr/share/zsh
# cleanup
2018-12-26 09:59:18 +01:00
rm -r $PKG/usr/share/doc
rm -r $PKG/etc
rm $PKG/usr/lib/rustlib/{components,manifest-rustc,rust-installer-version,uninstall.sh}
2020-06-20 09:33:25 +02:00
# Remove analysis data for libs that weren't installed
local file lib
while read -rd '' file; do
lib="${file%.json}.rlib"
lib="${lib/\/analysis\///lib/}"
if [[ ! -e $lib ]]; then
echo "missing '$lib'"
rm -v "$file"
fi
done < <(find "$PKG/usr/lib/rustlib" -path '*/analysis/*.json' -print0)
2018-12-26 09:59:18 +01:00
}