Improve setup script (#436)

* Improve bash setup script (less silent!)

* use proper FFmpeg capitalization in relevant docs

* Fix typo in Homebrew error message

Co-authored-by: maxichrome <maxichrome@users.noreply.github.com>
This commit is contained in:
maxichrome 2022-10-25 20:08:50 -05:00 committed by GitHub
parent 9e77b56962
commit 9d72de352b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 129 additions and 90 deletions

View file

@ -2,110 +2,149 @@
set -e
script_failure() {
echo "An error occurred while performing the task on line $1" >&2
echo "Setup for Spacedrive development failed" >&2
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
function log_err {
echo "$@" >&2
}
function script_failure {
log_err "An error occurred$([ -z "$1" ] && " on line $1" || " (unknown)")."
log_err "Setup failed."
}
trap 'script_failure $LINENO' ERR
echo "Setting up your system for Spacedrive development!"
echo "Setting up this system for Spacedrive development."
echo
if ! which cargo &> /dev/null; then
echo "Rust was not detected on your system. Ensure the 'rustc' and 'cargo' binaries are in your \$PATH."
exit 1
if ! command -v cargo >/dev/null; then
log_err "Rust was not found. Ensure the 'rustc' and 'cargo' binaries are in your \$PATH."
exit 1
fi
if [ "${SPACEDRIVE_SKIP_PNPM_CHECK:-}" != "true" ]; then
if ! which pnpm &> /dev/null; then
echo "PNPM was not detected on your system. Ensure the 'pnpm' command is in your \$PATH. You are not able to use Yarn or NPM."
exit 1
fi
if [ "${SPACEDRIVE_SKIP_PNPM_CHECK:-'false'}" != "true" ]; then
echo "Checking for pnpm..."
if ! command -v pnpm >/dev/null; then
log_err "pnpm was not found. Ensure the 'pnpm' command is in your \$PATH."
log_err 'You MUST use pnpm for this project; yarn and npm are not allowed.'
exit 1
else
echo "Found pnpm!"
fi
else
echo "Skipped PNPM check!"
echo "Skipping pnpm check."
fi
echo
if [ "$1" == "mobile" ]; then
echo "Setting up for mobile development!"
echo "Setting up for mobile development."
# IOS targets
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Installing IOS Rust targets..."
# iOS targets
if [[ "$OSTYPE" == "darwin"* ]]; then
echo "Checking for Xcode..."
if ! /usr/bin/xcodebuild -version >/dev/null; then
log_err "Xcode was not detected."
log_err "Please ensure Xcode is installed and try again."
exit 1
fi
if ! /usr/bin/xcodebuild -version; then
echo "Xcode is not installed! Ensure you have it installed!"
exit 1
fi
echo "Installing iOS targets for Rust..."
rustup target add aarch64-apple-ios
rustup target add aarch64-apple-ios-sim
fi
rustup target add aarch64-apple-ios
rustup target add aarch64-apple-ios-sim
fi
# Android requires python
if ! command -v python3 &> /dev/null
then
echo "Python3 could not be found. This is required for Android mobile development!"
exit 1
fi
# Android requires python
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
fi
# Android targets
echo "Installing Android Rust targets..."
rustup target add armv7-linux-androideabi # for arm
rustup target add i686-linux-android # for x86
rustup target add aarch64-linux-android # for arm64
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 x86_64-apple-darwin # for darwin x86_64 (if you have an Intel MacOS)
rustup target add aarch64-apple-darwin # for darwin arm64 (if you have a M1 MacOS)
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
# 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
echo "Done setting up mobile targets."
echo
fi
if [[ "$OSTYPE" == "linux-gnu"* ]]; then
if which apt-get &> /dev/null; then
echo "Detected 'apt' based distro!"
DEBIAN_FFMPEG_DEPS="libavcodec-dev libavdevice-dev libavfilter-dev libavformat-dev libavutil-dev libswscale-dev libswresample-dev ffmpeg" # FFMPEG dependencies
DEBIAN_TAURI_DEPS="libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev" # Tauri dependencies
DEBIAN_BINDGEN_DEPS="pkg-config clang" # Bindgen dependencies - it's used by a dependency of Spacedrive
sudo apt-get -y update
sudo apt-get -y install ${SPACEDRIVE_CUSTOM_APT_FLAGS:-} $DEBIAN_TAURI_DEPS $DEBIAN_FFMPEG_DEPS $DEBIAN_BINDGEN_DEPS
elif which pacman &> /dev/null; then
echo "Detected 'pacman' based distro!"
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
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
sudo pacman -Syu
sudo pacman -S --needed $ARCH_TAURI_DEPS $ARCH_FFMPEG_DEPS $ARCH_BINDGEN_DEPS
elif which dnf &> /dev/null; then
echo "Detected 'dnf' based distro!"
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
sudo apt-get -y update
sudo apt-get -y install ${SPACEDRIVE_CUSTOM_APT_FLAGS:-} $DEBIAN_TAURI_DEPS $DEBIAN_FFMPEG_DEPS $DEBIAN_BINDGEN_DEPS
elif command -v pacman >/dev/null; then
echo "Detected pacman!"
echo "Installing dependencies with pacman..."
sudo dnf check-update
sudo dnf install $FEDORA_TAURI_DEPS $FEDORA_FFMPEG_DEPS $FEDORA_BINDGEN_DEPS
sudo dnf group install "C Development Tools and Libraries"
else
echo "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
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
echo "Your machine has been setup for Spacedrive development!"
sudo pacman -Syu
sudo pacman -S --needed $ARCH_TAURI_DEPS $ARCH_FFMPEG_DEPS $ARCH_BINDGEN_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
sudo dnf check-update
sudo dnf install $FEDORA_TAURI_DEPS $FEDORA_FFMPEG_DEPS $FEDORA_BINDGEN_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 ! brew tap | grep spacedriveapp/deps > /dev/null; then
brew tap-new spacedriveapp/deps > /dev/null
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
brew extract --force --version 5.0.1 ffmpeg spacedriveapp/deps > /dev/null
brew unlink ffmpeg &> /dev/null || true
brew install spacedriveapp/deps/ffmpeg@5.0.1 &> /dev/null
echo "ffmpeg v5.0.1 has been installed and is now being used on your system."
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
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"
echo "FFmpeg version $FFMPEG_VERSION has been installed and is now being used on your system."
fi
else
echo "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
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
fi
echo "Your machine has been successfully set up for Spacedrive development."

View file

@ -40,9 +40,9 @@ This project uses [Cargo](https://doc.rust-lang.org/cargo/getting-started/instal
- `git clone https://github.com/spacedriveapp/spacedrive`
- `cd spacedrive`
- For Linux or MacOS users run: `./.github/scripts/setup-system.sh`
- This will install FFMPEG and any other required dependencies for Spacedrive to build.
- This will install FFmpeg and any other required dependencies for Spacedrive to build.
- For Windows users run using PowerShell: `.\.github\scripts\setup-system.ps1`
- This will install pnpm, LLVM, FFMPEG and any other required dependencies for Spacedrive to build.
- This will install pnpm, LLVM, FFmpeg and any other required dependencies for Spacedrive to build.
- Ensure you run it like documented above as it expects it is executed from the root of the repository.
- `pnpm i`
- `pnpm prep` - Runs all necessary codegen & builds required dependencies.

View file

@ -71,7 +71,7 @@ function Page() {
{
title: 'Media encoder',
description:
'Encode video and audio into various formats, use Tags to automate. Built with FFMPEG.'
'Encode video and audio into various formats, use Tags to automate. Built with FFmpeg.'
},
{
title: 'Cloud integration',

View file

@ -1,6 +1,6 @@
# FFMPEG Thumbnailer RS
# FFmpeg Thumbnailer RS
Rust implementation of a thumbnail generation for video files using ffmpeg.
Rust implementation of a thumbnail generation for video files using FFmpeg.
Based on https://github.com/dirkvdb/ffmpegthumbnailer
For now only implements the minimum API for Spacedrive needs. PRs are welcome

View file

@ -20,9 +20,9 @@ pub enum ThumbnailerError {
Io(#[from] std::io::Error),
#[error("Path conversion error: Path: {0:#?}")]
PathConversion(PathBuf),
#[error("FFMPEG internal error: {0}")]
#[error("FFmpeg internal error: {0}")]
Ffmpeg(#[from] FfmpegError),
#[error("FFMPEG internal error: {0}; Reason: {1}")]
#[error("FFmpeg internal error: {0}; Reason: {1}")]
FfmpegWithReason(FfmpegError, String),
#[error("Failed to decode video frame")]
FrameDecodeError,
@ -38,7 +38,7 @@ pub enum ThumbnailerError {
BackgroundTaskFailed(#[from] JoinError),
}
/// Enum to represent possible errors from FFMPEG library
/// Enum to represent possible errors from FFmpeg library
///
/// Extracted from https://ffmpeg.org/doxygen/trunk/group__lavu__error.html
#[derive(Error, Debug)]

View file

@ -22,7 +22,7 @@ This project uses [Cargo](https://doc.rust-lang.org/cargo/getting-started/instal
./.github/scripts/setup-system.sh
```
This will install FFMPEG and any other required dependencies for Spacedrive to build.
This will install FFmpeg and any other required dependencies for Spacedrive to build.
**...or for Windows users run using PowerShell:**
@ -30,7 +30,7 @@ This project uses [Cargo](https://doc.rust-lang.org/cargo/getting-started/instal
.\.github\scripts\setup-system.ps1
```
_This will install pnpm, LLVM, FFMPEG and any other required dependencies for Spacedrive to build. Ensure you run it like documented above as it expects it is executed from the root of the repository._
_This will install pnpm, LLVM, FFmpeg and any other required dependencies for Spacedrive to build. Ensure you run it like documented above as it expects it is executed from the root of the repository._
3. **Install dependencies**
```shell