2023-06-27 03:38:22 +02:00
#!/bin/bash
set -e
if [ " $( whoami) " = = "root" ] ; then
SUDOCMD = ""
else
SUDOCMD = "sudo "
fi
${ SUDOCMD } apt-get update &&
2024-10-26 09:19:13 +02:00
${ SUDOCMD } apt-get install -y \
libpam0g-dev \
libudev-dev \
libssl-dev \
2025-01-17 06:17:58 +01:00
libsystemd-dev \
2024-10-26 09:19:13 +02:00
pkg-config \
curl \
rsync \
git \
cmake \
build-essential \
jq \
tpm-udev
2023-09-27 06:08:20 +02:00
2023-11-02 01:55:32 +01:00
if [ -z " ${ PACKAGING } " ] ; then
PACKAGING = 0
fi
2023-09-27 06:08:20 +02:00
if [ " ${ PACKAGING } " -eq 1 ] ; then
2024-10-15 04:27:48 +02:00
# Install packages needed for cargo-deb to build healthy debs for any supported target
# This works in Debian, but not in Ubuntu because they do multiarch weird.
# It would be too invasive to config a daily driver Ubuntu install for multiarch,
# so instead we don't, and just warn.
2024-10-26 09:19:13 +02:00
# shellcheck disable=SC1091
2024-10-15 04:27:48 +02:00
source /etc/os-release
if [ [ " $ID " = = "ubuntu" ] ] ; then
2024-10-26 09:19:13 +02:00
echo 2>& 1 "You're running Ubuntu, so we're skipping enabling multiarch for you because it would be too invasive. You won't be able to build valid debs for other than your native architecture."
${ SUDOCMD } apt-get install -y \
libpam0g \
libssl3
2024-10-15 04:27:48 +02:00
elif [ [ " $ID " = = "debian" ] ] ; then
2024-10-26 09:19:13 +02:00
${ SUDOCMD } dpkg --add-architecture arm64 && ${ SUDOCMD } apt-get update
${ SUDOCMD } apt-get install -y \
libpam0g:{ amd64,arm64} \
libssl3:{ amd64,arm64}
2024-10-15 04:27:48 +02:00
fi
2023-09-27 06:08:20 +02:00
export INSTALL_RUST = 1
fi
2023-06-27 03:38:22 +02:00
if [ -z " $( which cargo) " ] ; then
if [ -f " $HOME /.cargo/env " ] ; then
#shellcheck disable=SC1091
source " $HOME /.cargo/env "
elif [ " ${ INSTALL_RUST } " = = "1" ] ; then
2023-09-27 06:08:20 +02:00
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
2023-06-27 03:38:22 +02:00
#shellcheck disable=SC1091
source " $HOME /.cargo/env "
2024-07-25 03:10:55 +02:00
else
echo "#############################################################"
echo "Couldn't find rust and you didn't say to install it..."
echo "#############################################################"
2023-06-27 03:38:22 +02:00
fi
fi
ERROR = 0
if [ -z " $( which cargo) " ] ; then
echo "You don't have cargo / rust installed!"
echo "Go to <https://www.rust-lang.org/tools/install> for instructions!"
echo ""
echo "Or run this script with INSTALL_RUST=1 to install it for you."
ERROR = 1
fi
2024-10-15 04:27:48 +02:00
if [ $ERROR -eq 0 ] && [ -z " $( which cross) " ] ; then
echo "You don't have cross installed! Installing it now..."
cargo install -f cross
fi
if [ $ERROR -eq 0 ] && [ -z " $( which cargo-deb) " ] ; then
echo "You don't have cargo-deb installed! Installing it now..."
cargo install -f cargo-deb
fi
2023-06-27 03:38:22 +02:00
if [ $ERROR -eq 1 ] ; then
exit 1
fi
echo "Woo, all ready to go!"
#shellcheck disable=SC2016
echo 'You might need to load the env: source "$HOME/.cargo/env"'