|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +if [ -z "$DEBUG" ] || [ "$DEBUG" -eq "0" ]; then |
| 4 | + set -e |
| 5 | +else |
| 6 | + set -ex |
| 7 | +fi |
| 8 | + |
| 9 | + |
| 10 | +REPO_ROOT=$(readlink -f $(dirname "$0")"/..") |
| 11 | + |
| 12 | + |
| 13 | +if [ -z "$1" ]; then |
| 14 | + echo "no recipe specified. Aborting..." |
| 15 | + exit 1 |
| 16 | +fi |
| 17 | +if [ -f "$1" ]; then |
| 18 | + source "$1" |
| 19 | + filename=$(basename "$1") |
| 20 | + name="${filename%.*}" |
| 21 | +else |
| 22 | + source "${REPO_ROOT}/appimage/recipes/${1}.sh" |
| 23 | + name="$1" |
| 24 | +fi |
| 25 | + |
| 26 | +export PYTHON_SOURCE="${PYTHON_SOURCE:-https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz}" |
| 27 | +export PIP_REQUIREMENTS |
| 28 | + |
| 29 | + |
| 30 | +ARCH="${ARCH:-$(arch)}" |
| 31 | +export ARCH="${ARCH}" |
| 32 | + |
| 33 | + |
| 34 | +# Setup a temporary work space |
| 35 | +if [ -z "${BUILD_DIR}" ]; then |
| 36 | + BUILD_DIR=$(mktemp -d) |
| 37 | + |
| 38 | + _cleanup() { |
| 39 | + rm -rf "${BUILD_DIR}" |
| 40 | + } |
| 41 | + |
| 42 | + trap _cleanup EXIT |
| 43 | +else |
| 44 | + BUILD_DIR=$(readlink -m "${BUILD_DIR}") |
| 45 | + mkdir -p "${BUILD_DIR}" |
| 46 | +fi |
| 47 | + |
| 48 | +pushd $BUILD_DIR |
| 49 | + |
| 50 | + |
| 51 | +# Build the AppImage |
| 52 | +linuxdeploy="linuxdeploy-${ARCH}.AppImage" |
| 53 | +plugin="linuxdeploy-plugin-python-${ARCH}.AppImage" |
| 54 | + |
| 55 | +if [ ! -f "${linuxdeploy}" ]; then |
| 56 | + url="https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous" |
| 57 | + wget --no-check-certificate -q "${url}/${linuxdeploy}" |
| 58 | + chmod u+x "${linuxdeploy}" |
| 59 | +fi |
| 60 | + |
| 61 | +if [ ! -f "${REPO_ROOT}/appimage/${plugin}" ]; then |
| 62 | + ${REPO_ROOT}/appimage/build-plugin.sh |
| 63 | +fi |
| 64 | +cp "${REPO_ROOT}/appimage/${plugin}" "." |
| 65 | + |
| 66 | +exe="python${PYTHON_VERSION::3}" |
| 67 | + |
| 68 | +cp "${REPO_ROOT}/appimage/resources/python.desktop" "${name}.desktop" |
| 69 | +sed -i "s|[{][{]exe[}][}]|${exe}|g" "${name}.desktop" |
| 70 | +sed -i "s|[{][{]name[}][}]|${name}|g" "${name}.desktop" |
| 71 | + |
| 72 | +./"${linuxdeploy}" --appdir AppDir \ |
| 73 | + --plugin python |
| 74 | +./"${linuxdeploy}" --appdir AppDir \ |
| 75 | + -i "${REPO_ROOT}/appimage/resources/python.png" \ |
| 76 | + -d "${name}.desktop" \ |
| 77 | + -e "AppDir/usr/bin/.${exe}" \ |
| 78 | + --custom-apprun "AppDir/usr/bin/${exe}" \ |
| 79 | + --output "appimage" |
| 80 | + |
| 81 | +popd |
| 82 | +mv "${BUILD_DIR}/${name}-${ARCH}.AppImage" "${REPO_ROOT}/appimage" |
0 commit comments