Skip to content

Instantly share code, notes, and snippets.

@ilobmirt
Last active January 17, 2022 04:01
Show Gist options
  • Save ilobmirt/e0a2e3cc182bb6aa0c492809d79eefc5 to your computer and use it in GitHub Desktop.
Save ilobmirt/e0a2e3cc182bb6aa0c492809d79eefc5 to your computer and use it in GitHub Desktop.
Downloads, compiles, and sets up box64 targeted towards the arm64 raspberry pi 4 running raspbian
#!/bin/bash
#=================================================================================================#
#install_box64.sh
#----------
#by: ilobmirt @ 2022_JAN_16
#
#Downloads, compiles, and sets up box64 targeted towards the arm64 raspberry pi 4 running raspbian
#Learn more about box64 at the project's github page - https://github.com/ptitSeb/box64
#=================================================================================================#
install_architecture="amd64"
install_target="$HOME/box64"
verify_architecture(){
if [ -z $(dpkg --print-foreign-architectures | grep $install_architecture) ]; then
echo "Adding $install_architecture to system's package lists"
dpkg --add-architecture $install_architecture
sudo apt-get update
fi
}
verify_environment(){
local search_target="<<x64_LIB_SEARCH_TARGET>>"
local library_path="$HOME/x64_lib"
local env_file="$HOME/.bashrc"
local env_addendum="
#$search_target
#Setup Box64 emulated libraries to include local directory
# include x64_lib if it exists
if [ -d \"$library_path\" ]; then
if [ -n \"\$BOX64_LD_LIBRARY_PATH\" ]; then
BOX64_LD_LIBRARY_PATH=\"$library_path:\$BOX64_LD_LIBRARY_PATH\"
else
BOX64_LD_LIBRARY_PATH=\"$library_path:./:lib/:lib64/:x86_64/:bin64/:libs64/\"
fi
fi
"
if [ -z $(grep -F "$search_target" $env_file) ]; then
#We haven't set up the x64 environment yet
echo "Updating $env_file to reference x64 libraries"
echo "$env_addendum" >> $env_file
fi
}
verify_lib_path(){
local library_path="$HOME/x64_lib"
if [ ! -d "$library_path" ]; then
#We haven't set up any custom x64 libraries yet
echo "setting up x64 libraries directory"
mkdir $library_path
fi
}
#Ensure we have the tools
echo "Making sure system is up to date"
sudo apt update 1> /dev/null
sudo apt full-upgrade -y 1> /dev/null
echo "Making sure we have the tools to get and build box64"
sudo apt install git build-essential cmake -y 1> /dev/null
#Clone the repository
if [ -d "$install_target" ]; then
#Erase old installs
echo "Removing old install of Box64"
rm -rf $install_target
fi
cd $HOME
echo "Cloning github repository"
git clone https://github.com/ptitSeb/box64 $install_target 1> /dev/null
#Build the code
cd $install_target
mkdir build
cd build
cmake .. -DRPI4ARM64=1 -DCMAKE_BUILD_TYPE=RelWithDebInfo
make -j$(nproc)
sudo make install
sudo systemctl restart systemd-binfmt
#Verify if x64 libraries are set up
echo "Verifying x64 architecture is set up for this computer"
verify_architecture
verify_lib_path
verify_environment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment