[ENG-430] *Nix setup script improvements (#602)

* add `protobuf` deps to arch and fedora

* update webkit2gtk package name for fedora >= 37

* revert last change as fedora 37/38 can still use the old name

This reverts commit cc9b2d705307cbbf2e18aaa7b1b9d1694c3add49.

* shfmt

* re-introduce webkit changes (and fix my bad bash)

* remove duplicate webkit dep

* update mac setup logic

* remove ffmpeg versioning (we don't use it on any other system)

* check that RPMFusion is enabled

* more verbose protobuf variable names

* add comments/todos and remove unnecessary 64 bit declaration

* fix incorrect command & use latest ffmpeg on macos

* update deps & remove comments
This commit is contained in:
jake 2023-03-15 16:11:15 +00:00 committed by GitHub
parent f487db254b
commit 1e86d24c96
2 changed files with 82 additions and 51 deletions

View File

@ -2,13 +2,13 @@
set -e
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
function log_err {
function log_err() {
echo "$@" >&2
}
function script_failure {
function script_failure() {
log_err "An error occurred$([ -z "$1" ] && " on line $1" || " (unknown)")."
log_err "Setup failed."
}
@ -63,8 +63,7 @@ if [ "$1" == "mobile" ]; then
fi
# Android requires python
if ! command -v python3 >/dev/null
then
if ! command -v python3 >/dev/null; then
log_err "python3 command could not be found. This is required for Android mobile development."
log_err "Ensure python3 is available in your \$PATH and try again."
exit 1
@ -73,15 +72,15 @@ if [ "$1" == "mobile" ]; then
# Android targets
echo "Setting up Android targets for Rust..."
rustup target add armv7-linux-androideabi # for arm
rustup target add aarch64-linux-android # for arm64
rustup target add i686-linux-android # for x86
rustup target add x86_64-linux-android # for x86_64
rustup target add x86_64-unknown-linux-gnu # for linux-x86-64
rustup target add aarch64-apple-darwin # for darwin arm64 (if you have an M1 Mac)
rustup target add x86_64-apple-darwin # for darwin x86_64 (if you have an Intel Mac)
rustup target add x86_64-pc-windows-gnu # for win32-x86-64-gnu
rustup target add x86_64-pc-windows-msvc # for win32-x86-64-msvc
rustup target add armv7-linux-androideabi # for arm
rustup target add aarch64-linux-android # for arm64
rustup target add i686-linux-android # for x86
rustup target add x86_64-linux-android # for x86_64
rustup target add x86_64-unknown-linux-gnu # for linux-x86-64
rustup target add aarch64-apple-darwin # for darwin arm64 (if you have an M1 Mac)
rustup target add x86_64-apple-darwin # for darwin x86_64 (if you have an Intel Mac)
rustup target add x86_64-pc-windows-gnu # for win32-x86-64-gnu
rustup target add x86_64-pc-windows-msvc # for win32-x86-64-msvc
echo "Done setting up mobile targets."
echo
@ -91,65 +90,96 @@ if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if command -v apt-get >/dev/null; then
echo "Detected apt!"
echo "Installing dependencies with apt..."
DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev" # Tauri dependencies
DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg" # FFmpeg dependencies
DEBIAN_BINDGEN_DEPS="pkg-config clang" # Bindgen dependencies - it's used by a dependency of Spacedrive
PROTOBUF="protobuf-compiler" # Protobuf compiler
# Tauri dependencies
DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev"
# FFmpeg dependencies
DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg"
# Bindgen dependencies - it's used by a dependency of Spacedrive
DEBIAN_BINDGEN_DEPS="pkg-config clang"
# Protobuf compiler
DEBIAN_LIBP2P_DEPS="protobuf-compiler"
sudo apt-get -y update
sudo apt-get -y install ${SPACEDRIVE_CUSTOM_APT_FLAGS:-} $DEBIAN_TAURI_DEPS $DEBIAN_FFMPEG_DEPS $DEBIAN_BINDGEN_DEPS $PROTOBUF
sudo apt-get -y install ${SPACEDRIVE_CUSTOM_APT_FLAGS:-} $DEBIAN_TAURI_DEPS $DEBIAN_FFMPEG_DEPS $DEBIAN_BINDGEN_DEPS $DEBIAN_LIBP2P_DEPS
elif command -v pacman >/dev/null; then
echo "Detected pacman!"
echo "Installing dependencies with pacman..."
ARCH_TAURI_DEPS="webkit2gtk base-devel curl wget openssl appmenu-gtk-module gtk3 libappindicator-gtk3 librsvg libvips" # Tauri deps https://tauri.studio/guides/getting-started/setup/linux#1-system-dependencies
ARCH_FFMPEG_DEPS="ffmpeg" # FFmpeg dependencies
ARCH_BINDGEN_DEPS="clang" # Bindgen dependencies - it's used by a dependency of Spacedrive
# Tauri deps https://tauri.studio/guides/getting-started/setup/linux#1-system-dependencies
ARCH_TAURI_DEPS="webkit2gtk base-devel curl wget openssl appmenu-gtk-module gtk3 libappindicator-gtk3 librsvg libvips"
# FFmpeg dependencies
ARCH_FFMPEG_DEPS="ffmpeg"
# Bindgen dependencies - it's used by a dependency of Spacedrive
ARCH_BINDGEN_DEPS="clang"
# Protobuf compiler - https://github.com/archlinux/svntogit-packages/blob/packages/protobuf/trunk/PKGBUILD provides `libprotoc`
ARCH_LIBP2P_DEPS="protobuf"
sudo pacman -Syu
sudo pacman -S --needed $ARCH_TAURI_DEPS $ARCH_FFMPEG_DEPS $ARCH_BINDGEN_DEPS
sudo pacman -S --needed $ARCH_TAURI_DEPS $ARCH_FFMPEG_DEPS $ARCH_BINDGEN_DEPS $ARCH_LIBP2P_DEPS
elif command -v dnf >/dev/null; then
echo "Detected dnf!"
echo "Installing dependencies with dnf..."
FEDORA_TAURI_DEPS="webkit2gtk3-devel.x86_64 openssl-devel curl wget libappindicator-gtk3 librsvg2-devel" # Tauri dependencies
FEDORA_FFMPEG_DEPS="ffmpeg ffmpeg-devel" # FFmpeg dependencies
FEDORA_BINDGEN_DEPS="clang" # Bindgen dependencies - it's used by a dependency of Spacedrive
# `webkit2gtk4.0-devel` also provides `webkit2gtk3-devel`, it's just under a different package in fedora versions >= 37.
# https://koji.fedoraproject.org/koji/packageinfo?tagOrder=-blocked&packageID=26162#taglist
# https://packages.fedoraproject.org/pkgs/webkitgtk/webkit2gtk4.0-devel/fedora-38.html#provides
FEDORA_37_TAURI_WEBKIT="webkit2gtk4.0-devel"
FEDORA_36_TAURI_WEBKIT="webkit2gtk3-devel"
sudo dnf check-update
sudo dnf install $FEDORA_TAURI_DEPS $FEDORA_FFMPEG_DEPS $FEDORA_BINDGEN_DEPS
# Tauri dependencies
# openssl is manually declared here as i don't think openssl and openssl-devel are actually dependant on eachother
# openssl also has a habit of being missing from some of my fresh Fedora installs - i've had to install it at least twice
FEDORA_TAURI_DEPS="openssl-devel curl wget libappindicator-gtk3 librsvg2-devel"
# required for building the openssl-sys crate
FEDORA_OPENSSL_SYS_DEPS="perl-FindBin perl-File-Compare perl-IPC-Cmd perl-File-Copy"
# FFmpeg dependencies
FEDORA_FFMPEG_DEPS="ffmpeg ffmpeg-devel"
# Bindgen dependencies - it's used by a dependency of Spacedrive
FEDORA_BINDGEN_DEPS="clang"
# Protobuf compiler
FEDORA_LIBP2P_DEPS="protobuf-compiler"
sudo dnf update
if ! sudo dnf install $FEDORA_37_TAURI_WEBKIT && ! sudo dnf install $FEDORA_36_TAURI_WEBKIT; then
log_err "We were unable to install the webkit2gtk4.0-devel/webkit2gtk3-devel package. Please open an issue if you feel that this is incorrect. https://github.com/spacedriveapp/spacedrive/issues"
exit 1
fi
if ! sudo dnf install $FEDORA_FFMPEG_DEPS; then
log_err "We were unable to install the FFmpeg and FFmpeg-devel packages. This is likely because the RPM Fusion free repository is not enabled. https://docs.fedoraproject.org/en-US/quick-docs/setup_rpmfusion/"
exit 1
fi
sudo dnf install $FEDORA_TAURI_DEPS $FEDORA_BINDGEN_DEPS $FEDORA_LIBP2P_DEPS
sudo dnf group install "C Development Tools and Libraries"
else
log_err "Your Linux distro '$(lsb_release -s -d)' is not supported by this script. We would welcome a PR or some help adding your OS to this script. https://github.com/spacedriveapp/spacedrive/issues"
exit 1
fi
elif [[ "$OSTYPE" == "darwin"* ]]; then
if ! command -v brew >/dev/null; then
log_err "Homebrew was not found. Please install it using the instructions at https://brew.sh and try again."
exit 1
fi
if ! command -v brew >/dev/null; then
log_err "Homebrew was not found. Please install it using the instructions at https://brew.sh and try again."
exit 1
fi
echo "Installing Homebrew dependencies..."
echo "Installing Homebrew dependencies..."
if ! brew tap -q | grep -qx "spacedriveapp/deps" >/dev/null; then
echo "Creating Homebrew tap \`spacedriveapp/deps\`..."
brew tap-new spacedriveapp/deps
fi
BREW_DEPS="ffmpeg"
BREW_LIBP2P_DEPS="protobuf"
FFMPEG_VERSION="5.0.1"
if ! brew list --full-name -1 | grep -x "spacedriveapp/deps/ffmpeg@$FFMPEG_VERSION" >/dev/null; then
echo "Extracting FFmpeg version $FFMPEG_VERSION..."
brew extract -q --force --version $FFMPEG_VERSION ffmpeg spacedriveapp/deps
brew unlink -q ffmpeg || true
brew install -q "spacedriveapp/deps/ffmpeg@$FFMPEG_VERSION"
brew install protobuf
echo "FFmpeg version $FFMPEG_VERSION has been installed and is now being used on your system."
fi
brew install -q $BREW_DEPS $BREW_LIBP2P_DEPS
else
log_err "Your OS ($OSTYPE) is not supported by this script. We would welcome a PR or some help adding your OS to this script. https://github.com/spacedriveapp/spacedrive/issues"
exit 1

View File

@ -13,6 +13,7 @@ resolver = "2"
[dependencies]
ffmpeg-sys-next = "5.1.1"
thiserror = "1.0.37"
webp = "0.2.2"
tokio = { workspace = true, features = ["fs", "rt"] }