Skip to content

Improved install routine #11

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ Please consider giving this repo a star if you found it helpful.
If you encounter any errors, please report it in the issues tab.

## Where is the executable?
The executable is stored in ~/Applications/aseprite. Have fun!
The executable is stored in $XDG_DATA_HOME/aseprite. Have fun!

## Integrating with your desktop environment
Download the aseprite.desktop file from this GitHub repository and move it to ~/.local/share/applications.
Then, it should appear in your application menu!
## How do I run Aseprite?
This script should automatically add aseprite to your application menu and to your path.
You should be able to launch it as you would any other software.

## Credits
I condensed https://github.com/aseprite/aseprite/blob/main/INSTALL.md into this script.
9 changes: 0 additions & 9 deletions aseprite.desktop

This file was deleted.

121 changes: 83 additions & 38 deletions compile.sh
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,22 +1,48 @@
#!/bin/bash

# Check distro
os_name=$(grep 'NAME=' /etc/os-release | head -n 1 | sed 's/NAME=//' | tr -d '"')
[[ -z "${XDG_DATA_HOME}" ]] && XDG_DATA_HOME="${HOME}/.local/share"

INSTALL_DIR="${XDG_DATA_HOME}/aseprite"
BINARY_DIR="${HOME}/.local/bin"
LAUNCHER_DIR="${XDG_DATA_HOME}/applications"
ICON_DIR="${XDG_DATA_HOME}/icons"

# Return to home directory
cd
SIGNATURE_FILE="${INSTALL_DIR}/compile-aseprite-linux"
BINARY_FILE="${BINARY_DIR}/aseprite"
LAUNCHER_FILE="${LAUNCHER_DIR}/aseprite.desktop"
ICON_FILE="${ICON_DIR}/aseprite.png"

# Download skia
wget https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Linux-Release-x64-libc++.zip
mkdir -p ~/deps/skia
unzip Skia-Linux-Release-x64-libc++.zip -d ~/deps/skia
# Clean up zip file
rm Skia-Linux-Release-x64-libc++.zip
if [[ -f "${SIGNATURE_FILE}" ]] ; then
read -e -p "aseprite already installed. update? (y/n): " choice
[[ "${choice}" == [Yy]* ]] \
|| exit 0
else
[[ -d "${INSTALL_DIR}" ]] \
&& { echo "aseprite already installed to '${INSTALL_DIR}'. aborting" >&2 ; exit 1 ; }
{ [[ -f "${LAUNCHER_FILE}" ]] || [[ -f "${BINARY_FILE}" ]] || [[ -f "${ICON_FILE}" ]] ; } \
&& { echo "other aseprite data already installed to home directory. aborting" >&2 ; exit 1 ; }
fi

WORK_DIR=$(mktemp -d -t 'compile-aseprite-linux-XXXXX') \
|| { echo "unable to create temp folder" >&2 ; exit 1 ; }

echo "Enter sudo password to install dependencies. This is also a good time to plug in your computer, since compiling will take a long time."
cleanup() {
code=$?
echo "cleaning up"
pushd -0 >/dev/null
dirs -c
rm -rf "${WORK_DIR}"
exit "${code}"
}

trap "cleanup" EXIT

pushd "${WORK_DIR}"

# Check distro
os_name=$(grep 'NAME=' /etc/os-release | head -n 1 | sed 's/NAME=//' | tr -d '"')

echo "Enter sudo password to install dependencies. This is also a good time to plug in your computer, since compiling will take a long time."

# Assign package manager to a variable
if [[ "$os_name" == *"Fedora"* ]]; then
Expand All @@ -31,41 +57,60 @@ fi

# Install dependencies
if [[ $package_man == "dnf" ]]; then
sudo dnf install -y gcc-c++ clang libcxx-devel cmake ninja-build libX11-devel libXcursor-devel libXi-devel mesa-libGL-devel fontconfig-devel git
sudo dnf install -y gcc-c++ clang libcxx-devel cmake ninja-build libX11-devel libXcursor-devel libXi-devel mesa-libGL-devel fontconfig-devel git
elif [[ $package_man == "apt" ]]; then
sudo apt-get install -y g++ clang libc++-dev libc++abi-dev cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev git
sudo apt-get install -y g++ clang libc++-dev libc++abi-dev cmake ninja-build libx11-dev libxcursor-dev libxi-dev libgl1-mesa-dev libfontconfig1-dev git
fi

[[ $? == 0 ]] \
|| { echo "failed to install dependencies" >&2 ; exit 1 ; }

# Clone aseprite
git clone --recursive https://github.com/aseprite/aseprite.git --depth=1
git clone --recursive https://github.com/aseprite/aseprite.git --depth=1 \
|| { echo "unable to clone code base" >&2 ; exit 1 ; }

# Download skia
wget https://github.com/aseprite/skia/releases/download/m102-861e4743af/Skia-Linux-Release-x64-libc++.zip \
|| { echo "failed to download skia" >&2 ; exit 1 ; }
mkdir ./skia && unzip Skia-Linux-Release-x64-libc++.zip -d ./skia \
|| { echo "failed to extract skia" >&2 ; exit 1 ; }

echo "Finished downloading! Time to compile."

cd aseprite
mkdir build
cd build
mkdir aseprite/build \
|| { echo "failed create build folder" >&2 ; exit 1 ; }
pushd aseprite/build

export CC=clang
export CXX=clang++
cmake \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS:STRING=-stdlib=libc++ \
-DCMAKE_EXE_LINKER_FLAGS:STRING=-stdlib=libc++ \
-DLAF_BACKEND=skia \
-DSKIA_DIR=$HOME/deps/skia \
-DSKIA_LIBRARY_DIR=$HOME/deps/skia/out/Release-x64 \
-DSKIA_LIBRARY=$HOME/deps/skia/out/Release-x64/libskia.a \
-G Ninja \
..
ninja aseprite

# Cleanup
cd
rm -rf deps

mkdir -p Applications/aseprite

mv aseprite/build/bin aseprite/build/aseprite
mv aseprite/build/aseprite ~/Applications/aseprite
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_CXX_FLAGS:STRING=-stdlib=libc++ \
-DCMAKE_EXE_LINKER_FLAGS:STRING=-stdlib=libc++ \
-DLAF_BACKEND=skia \
-DSKIA_DIR="${WORK_DIR}/skia" \
-DSKIA_LIBRARY_DIR="${WORK_DIR}/skia/out/Release-x64" \
-DSKIA_LIBRARY="${WORK_DIR}/skia/out/Release-x64/libskia.a" \
-G Ninja \
.. \
|| { echo "configuration failed" >&2 ; exit 1 ; }

ninja aseprite \
|| { echo "compilation failed" >&2 ; exit 1 ; }

popd

rm -rf "${INSTALL_DIR}" \
|| { echo "unable to clean up old install" >&2 ; exit 1 ; }
mkdir -p "${INSTALL_DIR}" "${BINARY_DIR}" "${LAUNCHER_DIR}" "${ICON_DIR}" \
|| { echo "unable to create install folder" >&2 ; exit 1 ; }

{ mv aseprite/build/bin/* "${INSTALL_DIR}" \
&& touch "${SIGNATURE_FILE}" \
&& ln -sf "${INSTALL_DIR}/aseprite" "${BINARY_FILE}" \
&& ln -sf "${INSTALL_DIR}/data/icons/ase256.png" "${ICON_FILE}" \
&& cp -f "${WORK_DIR}/aseprite/src/desktop/linux/aseprite.desktop" "${LAUNCHER_FILE}" \
; } || { echo "failed to complete install" >&2 ; exit 1 ; }

echo "Done compiling!"
echo "The executable is stored in ~/Applications/aseprite. Have fun!"
echo "You can move this folder anywhere."
echo "The executable is stored in '${INSTALL_DIR}'. Have fun!"