Skip to content

Instantly share code, notes, and snippets.

@samrocketman
Last active March 27, 2022 21:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save samrocketman/6068b09f46c24370c359b2bae438b7a4 to your computer and use it in GitHub Desktop.
Save samrocketman/6068b09f46c24370c359b2bae438b7a4 to your computer and use it in GitHub Desktop.
How to build the pirates campaign

Background Information

What is Docker?

Docker provides portable development environments (among many other uses but for Endless Sky this is a key feature). It enables you to bring all of your dependencies to compile endless sky into a docker container so that you do not need them to be installed on your main operating system.

Install Docker Engine for Linux

Follow these instructions https://docs.docker.com/engine/install/

What is the final result

You can open the resulting AppImage on any Linux distribution.

Build Endless Sky for Testing

As part of this build the version is substituted with <branch>-<git short hash>".

Clone source code

mkdir -p ~/git/github/
cd ~/git/github/
git clone https://github.com/endless-sky/endless-sky.git
cd endless-sky/
git remote add pirates https://github.com/endless-sky-pirate-campaign/endless-sky
git fetch pirates
git checkout pirates/smuggling -b smuggling

Run script to build AppImage

Assumes you have docker installed, running, and accessible to your user. Also, assumes you're in the Endless Sky source tree.

Launch a new user shell which has access to running docker commands.

sudo su -g docker - $USER
cd ~/git/github/endless-sky/
../build-endless-sky-with-docker.sh

Note: ../build-endless-sky-with-docker.sh is one directory up because if you're checking out and building different commits you should reset the work space (including cleaning the workspace). To reset the workspace run the following commands.

git reset --hard
git clean -xfd

Run the AppImage

Just open ./Endless_Sky-x86_64*.AppImage. It is an executable file.

Download endless-sky-wrapper.sh to $HOME/git/github/endless-sky-wrapper.sh.

Configure steam launch options for endless sky.

$HOME/git/github/endless-sky-wrapper.sh %command%

Play Testing

It is good to manage your save games with git so that you can track differences as you play.

cd ~/.local/share/endless-sky/
git init
git add -A
git commit -m 'initial commit'

I find it useful to configure a cron job to run every 5 minutes while playtesting via crontab -e.

*/5 * * * * /bin/bash -lc 'cd ~/.local/share/endless-sky/; git add -A; git commit -m checkpoint'
#!/bin/bash
# Created by Sam Gleske
# Sat 08 Jan 2022 10:11:35 PM EST
# MIT Licensed
# DESCRIPTION
# Build Endless Sky AppImage from any branch. This is to help with
# playtesting.
# ENVIRONMENT
# Ubuntu 20.04.3 LTS
# Linux 5.11.0-44-generic x86_64
# GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
# Docker version 20.10.12, build e91ed57
function add_docker_file() {
if [ ! -f Dockerfile ]; then
cat > Dockerfile <<'EOF'
FROM ubuntu:20.04
VOLUME /tmp
VOLUME /var/cache/apt/archives
ENV DEBIAN_FRONTEND=noninteractive
# Endless sky requirements
RUN set -ex; \
apt-get update; \
apt-get install -y g++ scons libsdl2-dev libpng-dev libjpeg-dev libgl1-mesa-dev libglew-dev libopenal-dev libmad0-dev uuid-dev
# AppImage requirements
RUN set -ex; \
apt-get update; \
apt-get install -y curl fuse libfuse2
# assumes UID 1000
RUN adduser es-user
USER es-user
WORKDIR /home/es-user
EOF
fi
}
if ! type -P docker &> /dev/null; then
echo 'Docker needs to be installed, running, and accessible.' >&2
exit 1
fi
APPIMAGE_OUTPUT="Endless_Sky-x86_64-$(git rev-parse --short HEAD).AppImage"
if [ -f "${APPIMAGE_OUTPUT}" ]; then
echo "${APPIMAGE_OUTPUT} already exists. Skipping..." >&2
echo 'Remove the file to force a rebuild' >&2
exit
fi
if [ -d AppDir ]; then
# reset appimage build if it was done already
rm -rf AppDir
fi
sed -i 's/^version.*/version '"$(git rev-parse --abbrev-ref HEAD)-$(git rev-parse --short HEAD)"'/' credits.txt
if ! docker images | awk 'BEGIN {found=1};$1 == "pirates" {found=0;exit};END{exit found}'; then
add_docker_file
docker build -t pirates .
fi
docker run --rm -v "$PWD:$PWD" -w "$PWD" --device /dev/fuse --cap-add SYS_ADMIN --security-opt apparmor:unconfined pirates ./utils/build_appimage.sh
# rename the appimage to include the Git short hash
mv Endless_Sky-x86_64.AppImage "${APPIMAGE_OUTPUT}"
#!/bin/bash
# Created by Sam Gleske
# Tue 11 Jan 2022 06:18:25 PM EST
# Ubuntu 20.04.3 LTS
# Linux 5.11.0-44-generic x86_64
# GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
# DESCRIPTION
# Launch Endless sky and store the version being launched in the save file
# git directory.
# Assumes you have endless sky source code cloned to ~/git/github/endless-sky
# STEAM LAUNCH COMMAND (taskset 33 sets process affinity and is safe to remove)
# taskset 33 /path/to/endless-sky-wrapper.sh %command%
saves="${HOME}"/.local/share/endless-sky
src="${HOME}"/git/github/endless-sky
exe="$(\ls -tr "${src}"/Endless_Sky*x86_64*.AppImage | tail -n1)"
echo "${exe##*/}" > "${saves}"/exe_name
# Ignores arguments passed to the script
"${exe}"
#!/bin/bash
# Created by Sam Gleske
# Wed 16 Feb 2022 03:46:36 PM EST
# Ubuntu 20.04.3 LTS
# Linux 5.11.0-44-generic x86_64
# GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
# DESCRIPTION
# Update endless sky and high dpi git repositories. Removes author ships.
# Rebuilds endless sky AppImage.
set -ex
groups | grep docker
cd ~/git/github/endless-sky
git reset --hard
git clean -xfd
git pull
rm -f ./data/persons.txt
../build-endless-sky-with-docker.sh
if [ ! -d ~/.local/share/endless-sky/plugins/endless-sky-high-dpi ]; then
(
mkdir -p ~/.local/share/endless-sky/plugins
cd ~/.local/share/endless-sky/plugins
git clone https://github.com/endless-sky/endless-sky-high-dpi.git
)
else
cd ~/.local/share/endless-sky/plugins/endless-sky-high-dpi/
git pull
fi
@samrocketman
Copy link
Author

samrocketman commented Jan 9, 2022

https://github.com/Endless-Sky-Pirate-Campaign/endless-sky/actions/runs/1672276130 there's a continuous build so you can skip these docker instructions if you want. I still build from source because it's useful for bug hunting and validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment