-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
334 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Move all cross-compiling steps into a single sourced script | ||
# | ||
|
||
set -e | ||
|
||
printenv | ||
|
||
if [ "${TARGETARCH}" = "arm64" ] ; then | ||
platform_env=aarch64 | ||
export BUILD_TARGET="${platform_env}-unknown-linux-gnu/" | ||
export RUST_TARGET="--target=${platform_env}-unknown-linux-gnu" | ||
#export ARCH=${ARCH:-generic} | ||
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=${platform_env}-linux-gnu-gcc | ||
export CC_aarch64_unknown_linux_gnu=${platform_env}-linux-gnu-gcc | ||
export CXX_aarch64_unknown_linux_gnu=${platform_env}-linux-gnu-g++ | ||
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot /usr/${platform_env}-linux-gnu/include/" | ||
#export RUSTFLAGS="-C target_cpu=$ARCH" | ||
#export ROARING_ARCH=$ARCH | ||
rustup target add ${platform_env}-unknown-linux-gnu | ||
rustup toolchain install stable-${platform_env}-unknown-linux-gnu --force-non-host | ||
|
||
# Check for Debian | ||
if [ -f "/etc/debian_version" ] ; then | ||
dpkg --add-architecture ${TARGETARCH} | ||
apt-get update || true | ||
apt-get install -y pkg-config libssl-dev:${TARGETARCH} gcc-${platform_env}-linux-gnu g++-${platform_env}-linux-gnu | ||
export AARCH64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR=/usr/include/${platform_env}-linux-gnu/openssl/ | ||
export PKG_CONFIG_ALLOW_CROSS=1 | ||
fi | ||
|
||
elif [ "${TARGETARCH}" = "amd64" ] ; then | ||
platform_env=x86_64 | ||
platform_env_alt=x86-64 | ||
export BUILD_TARGET="${platform_env}-unknown-linux-gnu/" | ||
export RUST_TARGET="--target=${platform_env}-unknown-linux-gnu" | ||
# https://gcc.gnu.org/onlinedocs/gcc/x86-Options.html | ||
#export ARCH=${ARCH:-x86-64} | ||
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=${platform_env}-linux-gnu-gcc | ||
export CC_x86_64_unknown_linux_gnu=${platform_env_alt}-linux-gnu-gcc | ||
export CXX_x86_64_unknown_linux_gnu=${platform_env_alt}-linux-gnu-g++ | ||
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot /usr/${platform_env}-linux-gnu/include/" | ||
rustup target add ${platform_env}-unknown-linux-gnu | ||
rustup toolchain install stable-${platform_env}-unknown-linux-gnu --force-non-host | ||
|
||
# Check for Debian | ||
if [ -f "/etc/debian_version" ] ; then | ||
dpkg --add-architecture ${TARGETARCH} | ||
apt-get update | ||
apt-get install -y pkg-config libssl-dev:${TARGETARCH} gcc-${platform_env_alt}-linux-gnu g++-${platform_env_alt}-linux-gnu | ||
export X86_64_UNKNOWN_LINUX_GNU_OPENSSL_INCLUDE_DIR=/usr/include/${platform_env}-linux-gnu/openssl/ | ||
export PKG_CONFIG_ALLOW_CROSS=1 | ||
fi | ||
|
||
else | ||
echo "Need to source [ ${0##*/} ] with env TARGETARCH set to either arm64 or amd64" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,167 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Single script for Ubuntu 18.04 package setup, mostly used for cross-compiling | ||
# | ||
|
||
set -e | ||
|
||
USAGE="Usage: $0 target build ie: x86_64-unknown-linux-gnu or aarch64-unknown-linux-gnu" | ||
|
||
if [ "$#" == "0" ]; then | ||
echo "$USAGE" | ||
exit 1 | ||
fi | ||
|
||
if [ -z "${CROSS_DEB_ARCH}" ]; then | ||
echo "Should be run from cross, which sets the env CROSS_DEB_ARCH" | ||
exit 1 | ||
fi | ||
|
||
targetBuild="${1}" | ||
nativeRunTime=$(uname -m) | ||
echo "Native RunTime is ${nativeRunTime}" | ||
|
||
if [ "${nativeRunTime}" == "x86_64" ]; then | ||
nativeArch=amd64 | ||
if [ "${targetBuild}" == "aarch64-unknown-linux-gnu" ]; then | ||
targetArch=arm64 | ||
targetPlatform=aarch64 | ||
else | ||
targetArch=amd64 | ||
targetPlatform=x86-64 | ||
fi | ||
elif [ "${nativeRunTime}" == "aarch64" ]; then | ||
nativeArch=arm64 | ||
if [ "${targetBuild}" == "x86_64-unknown-linux-gnu" ]; then | ||
targetArch=amd64 | ||
targetPlatform=x86-64 | ||
fi | ||
elif [ "${nativeRunTime}" == "riscv64" ]; then | ||
nativeArch=riscv64 | ||
echo "ToDo!" | ||
else | ||
echo "!!Unsupport platform!!" | ||
exit 1 | ||
fi | ||
|
||
crossArch=${CROSS_DEB_ARCH} | ||
apt-get update | ||
|
||
# Base install packages | ||
# scripts/install_ubuntu_dependencies.sh | ||
apt-get install --no-install-recommends --assume-yes \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gpg \ | ||
bash \ | ||
less \ | ||
openssl \ | ||
libssl-dev \ | ||
pkg-config \ | ||
libsqlite3-dev \ | ||
libsqlite3-0 \ | ||
libreadline-dev \ | ||
git \ | ||
cmake \ | ||
dh-autoreconf \ | ||
clang \ | ||
g++ \ | ||
libc++-dev \ | ||
libc++abi-dev \ | ||
libprotobuf-dev \ | ||
protobuf-compiler \ | ||
libncurses5-dev \ | ||
libncursesw5-dev \ | ||
libudev-dev \ | ||
libhidapi-dev \ | ||
zip | ||
|
||
echo "Installing rust ..." | ||
mkdir -p "$HOME/.cargo/bin/" | ||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
export PATH="$HOME/.cargo/bin:$PATH" | ||
. "$HOME/.cargo/env" | ||
|
||
# Cross-CPU compile setup | ||
if [ "${CROSS_DEB_ARCH}" != "${nativeArch}" ]; then | ||
echo "Setup Cross CPU Compile ..." | ||
sed -i.save -e "s/^deb\ http/deb [arch="${nativeArch}"] http/g" /etc/apt/sources.list | ||
|
||
. /etc/lsb-release | ||
ubuntu_tag=${DISTRIB_CODENAME} | ||
|
||
if [ "${crossArch}" == "arm64" ]; then | ||
cat << EoF > /etc/apt/sources.list.d/${ubuntu_tag}-${crossArch}.list | ||
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag} main restricted universe multiverse | ||
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag} main restricted universe multiverse | ||
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-updates main restricted universe multiverse | ||
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-updates main restricted universe multiverse | ||
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-backports main restricted universe multiverse | ||
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-backports main restricted universe multiverse | ||
deb [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-security main restricted universe multiverse | ||
# deb-src [arch=${crossArch}] http://ports.ubuntu.com/ubuntu-ports ${ubuntu_tag}-security main restricted universe multiverse | ||
deb [arch=${crossArch}] http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
# deb-src [arch=${crossArch}] http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
EoF | ||
fi | ||
|
||
if [ "${crossArch}" == "amd64" ]; then | ||
cat << EoF > /etc/apt/sources.list.d/${ubuntu_tag}-${crossArch}.list | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} main restricted | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} main restricted | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates main restricted | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates main restricted | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} universe | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} universe | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates universe | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates universe | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} multiverse | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag} multiverse | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates multiverse | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-updates multiverse | ||
deb [arch=amd64] http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-backports main restricted universe multiverse | ||
# deb-src http://archive.ubuntu.com/ubuntu/ ${ubuntu_tag}-backports main restricted universe multiverse | ||
# deb http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
# deb-src http://archive.canonical.com/ubuntu ${ubuntu_tag} partner | ||
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security main restricted | ||
# deb-src http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security main restricted | ||
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security universe | ||
# deb-src http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security universe | ||
deb [arch=amd64] http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security multiverse | ||
# deb-src http://security.ubuntu.com/ubuntu/ ${ubuntu_tag}-security multiverse | ||
EoF | ||
fi | ||
|
||
dpkg --add-architecture ${CROSS_DEB_ARCH} | ||
apt-get update | ||
|
||
# scripts/install_ubuntu_dependencies-cross_compile.sh x86-64 | ||
apt-get --assume-yes install \ | ||
pkg-config-${targetPlatform}-linux-gnu \ | ||
gcc-${targetPlatform}-linux-gnu \ | ||
g++-${targetPlatform}-linux-gnu | ||
|
||
# packages needed for Ledger and hidapi | ||
apt-get --assume-yes install \ | ||
libsqlite3-dev:${CROSS_DEB_ARCH} \ | ||
libudev-dev:${CROSS_DEB_ARCH} \ | ||
libhidapi-dev:${CROSS_DEB_ARCH} | ||
|
||
fi | ||
|
||
rustup target add ${targetBuild} | ||
rustup toolchain install stable-${targetBuild} --force-non-host | ||
|
||
rustup target list --installed | ||
rustup toolchain list |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Must be run from the repo root | ||
# | ||
|
||
set -e | ||
|
||
# rg -i "Copyright.*The Tari Project" --files-without-match \ | ||
# -g '!*.{Dockerfile,asc,bat,config,config.js,css,csv,drawio,env,gitkeep,hbs,html,ini,iss,json,lock,md,min.js,ps1,py,rc,scss,sh,sql,svg,toml,txt,yml,vue}' . \ | ||
# | sort > /tmp/rgtemp | ||
|
||
# Exclude files without extensions as well as those with extensions that are not in the list | ||
# | ||
rgTemp=$(mktemp) | ||
rg -i "Copyright.*The Tari Project" --files-without-match \ | ||
-g '!*.{Dockerfile,asc,bat,config,config.js,css,csv,drawio,env,gitkeep,hbs,html,ini,iss,json,lock,md,min.js,ps1,py,rc,scss,sh,sql,svg,toml,txt,yml,vue}' . \ | ||
| while IFS= read -r file; do | ||
if [[ -n $(basename "$file" | grep -E '\.') ]]; then | ||
echo "$file" | ||
fi | ||
done | sort > ${rgTemp} | ||
|
||
# Sort the .license.ignore file as sorting seems to behave differently on different platforms | ||
licenseIgnoreTemp=$(mktemp) | ||
cat .license.ignore | sort > ${licenseIgnoreTemp} | ||
|
||
DIFFS=$(diff -u --strip-trailing-cr ${licenseIgnoreTemp} ${rgTemp}) | ||
|
||
# clean up | ||
rm -vf ${rgTemp} | ||
rm -vf ${licenseIgnoreTemp} | ||
|
||
if [ -n "$DIFFS" ]; then | ||
echo "New files detected that either need copyright/license identifiers added, or they need to be added to .license.ignore" | ||
echo "NB: The ignore file must be sorted alphabetically!" | ||
|
||
echo "Diff:" | ||
echo "$DIFFS" | ||
exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env sh | ||
# | ||
# Install Ubuntu aarch64(arm64)/riscv64 deb dev/tool packages on x86_64 | ||
# | ||
|
||
set -e | ||
|
||
USAGE="Usage: $0 ISA_ARCH other packages, ie aarch64" | ||
|
||
if [ "$#" == "0" ]; then | ||
echo "$USAGE" | ||
exit 1 | ||
fi | ||
|
||
isa_arch=${1} | ||
shift | ||
|
||
apt-get --assume-yes install $* \ | ||
pkg-config-${isa_arch}-linux-gnu \ | ||
gcc-${isa_arch}-linux-gnu \ | ||
g++-${isa_arch}-linux-gnu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env sh | ||
# | ||
# Install rust target/toolchain for aarch64/arm64 | ||
# | ||
|
||
set -e | ||
|
||
export PATH="$HOME/.cargo/bin:$PATH" | ||
rustup target add aarch64-unknown-linux-gnu | ||
rustup toolchain install stable-aarch64-unknown-linux-gnu --force-non-host |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#!/usr/bin/env sh | ||
# | ||
# Install rust unattended - https://www.rust-lang.org/tools/install | ||
# | ||
|
||
set -e | ||
|
||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y | ||
export PATH="$HOME/.cargo/bin:$PATH" | ||
. "$HOME/.cargo/env" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
apt-get install --no-install-recommends --assume-yes \ | ||
apt-transport-https \ | ||
ca-certificates \ | ||
curl \ | ||
gpg \ | ||
bash \ | ||
less \ | ||
openssl \ | ||
libssl-dev \ | ||
pkg-config \ | ||
libsqlite3-dev \ | ||
libsqlite3-0 \ | ||
libreadline-dev \ | ||
git \ | ||
cmake \ | ||
dh-autoreconf \ | ||
clang \ | ||
g++ \ | ||
libc++-dev \ | ||
libc++abi-dev \ | ||
libprotobuf-dev \ | ||
protobuf-compiler \ | ||
libncurses5-dev \ | ||
libncursesw5-dev \ | ||
libudev-dev \ | ||
libhidapi-dev \ | ||
zip |