Write script to install blender in proot-distro Alpine running on termux, proot distro…
- User
Write script to install blender in proot-distro Alpine running on termux, proot distro is already installed but install all dependencies too
- Assistant
Write script to install blender in proot-distro Alpine running on termux, proot distro is already installed but install all dependencies too
Certainly! Below is a comprehensive shell script that automates the installation of Blender on an Alpine Linux proot-distro running within Termux. This script updates the package repositories, installs all necessary dependencies, downloads the latest Blender release, extracts it, and sets it up for easy access.
Save the following script as install_blender.sh and execute it within your Alpine proot-distro environment.
#!/bin/sh
# Exit immediately if a command exits with a non-zero status
set -e
# Function to display messages
echo_info() {
echo "\033[1;34m[INFO]\033[0m $1"
}
echo_success() {
echo "\033[1;32m[SUCCESS]\033[0m $1"
}
echo_error() {
echo "\033[1;31m[ERROR]\033[0m $1"
}
# Update the package list
echo_info "Updating package repositories..."
apk update
# Upgrade existing packages
echo_info "Upgrading existing packages..."
apk upgrade
# Install required dependencies for Blender
echo_info "Installing Blender dependencies..."
apk add --no-cache \
bash \
wget \
tar \
mesa-gl \
libxi \
libxrandr \
libxxf86vm \
libxinerama \
libxcursor \
libx11 \
python3 \
libpng \
freetype \
openal-soft \
libjpeg-turbo \
glfw \
glew \
ttf-dejavu \
libglvnd \
libtiff \
libopenal \
&& echo_success "Dependencies installed successfully."
# Navigate to the /opt directory or create it if it doesn't exist
echo_info "Setting up /opt directory..."
mkdir -p /opt/blender
cd /opt/blender
# Fetch the latest Blender version number from the official Blender website
echo_info "Fetching the latest Blender version..."
LATEST_VERSION=$(wget -qO- https://www.blender.org/download/ | grep -oP 'blender-\K[0-9]+\.[0-9]+\.[0-9]+(?=-linux-x64\.tar\.xz)' | head -1)
if [ -z "$LATEST_VERSION" ]; then
echo_error "Failed to fetch the latest Blender version."
exit 1
fi
echo_info "Latest Blender version is $LATEST_VERSION"
# Define the Blender download URL
BLENDER_TARBALL="blender-${LATEST_VERSION}-linux-x64.tar.xz"
BLENDER_DOWNLOAD_URL="https://download.blender.org/release/Blender${LATEST_VERSION}/$BLENDER_TARBALL"
# Download Blender
echo_info "Downloading Blender from $BLENDER_DOWNLOAD_URL..."
wget -c "$BLENDER_DOWNLOAD_URL" -O "$BLENDER_TARBALL"
# Verify the download (optional: you can add checksum verification if available)
# Extract the Blender tarball
echo_info "Extracting Blender..."
tar -xf "$BLENDER_TARBALL" --strip-components=1
# Clean up the tarball to save space
echo_info "Cleaning up..."
rm "$BLENDER_TARBALL"
# Create a symbolic link to make Blender easily accessible
echo_info "Creating symbolic link for Blender..."
ln -sf /opt/blender/blender /usr/local/bin/blender
# Verify Blender installation
echo_info "Verifying Blender installation..."
if command -v blender >/dev/null 2>&1; then
echo_success "Blender installed successfully! Version: $(blender --version | head -n1)"
else
echo_error "Blender installation failed."
exit 1
fi
# Optional: Create a desktop entry or launcher script if using a graphical environment
echo_success "Blender installation completed successfully."
Transfer the Script to Alpine:
scp, wget, or simply create the script directly using a text editor like nano or vi inside Alpine.Make the Script Executable:
chmod +x install_blender.sh
Execute the Script:
./install_blender.sh
Function Definitions: The script defines helper functions (echo_info, echo_success, echo_error) to display colored and formatted messages for better readability.
Package Update and Upgrade:
apk update: Updates the list of available packages and their versions.apk upgrade: Upgrades the installed packages to the latest versions.Installing Dependencies:
apk add. This includes graphics libraries (mesa-gl, libxi, etc.), Python (if needed), and other utilities.Downloading Blender:
wget to download the Blender tarball.Extraction and Setup:
/opt/blender./usr/local/bin to allow running Blender from any terminal by simply typing blender.Verification:
Running Blender in Termux:
Performance Considerations:
Updating Blender:
Permission Issues:
/usr/local/bin directory is writable. If not, you might need to adjust permissions or choose an alternative directory that's in your PATH.Checksum Verification:
Missing Dependencies:
apk add <library-name>.Permission Denied:
GUI Issues:
This script should streamline the process of installing Blender on your Alpine proot-distro within Termux. Ensure you follow the prerequisites and adapt the script as needed based on updates or specific requirements of your environment.
Not yet included in a published release.