~thrrgilag/pantalaimon-ut

ref: a36c12ad5c3610c2650f4e9467551af0787078e8 pantalaimon-ut/dev-build.sh -rwxr-xr-x 3.0 KiB
a36c12ad — Morgan McMillian update python version 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#!/bin/bash

PROJECT_DIR=~/pantalaimon-build
TMP_DIR="${PROJECT_DIR}/tmp"

OLM_DIR="${PROJECT_DIR}/olm"
PANTALAIMON_DIR="${PROJECT_DIR}/pantalaimon"

PYTHON_VERSION_MINOR="3.8"
PYTHON_VERSION_PATCH="12"
PYTHON_VERSION="${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}"
PYTHON_DIR="${PROJECT_DIR}/python"
PYTHON_SRC_DIR="${TMP_DIR}/Python-${PYTHON_VERSION}"
PYTHON="${PYTHON_DIR}/bin/python${PYTHON_VERSION_MINOR}"
PIP="${PYTHON_DIR}/bin/pip3"

mkdir -p "${PROJECT_DIR}"
mkdir -p "${TMP_DIR}"

PACKAGES="make cmake build-essential zlibc python3-venv libffi-dev ppa-purge libssl-dev libsqlite3-dev zlib1g-dev rustc cargo libgirepository1.0-dev libdbus-1-dev libcairo2-dev"

echo "Remounting RootFS writable..."
sudo mount -o remount,rw /

echo "Installing dependencies..."
sudo apt update
sudo apt install -y ${PACKAGES}

OLMCK=${OLM_DIR}/usr/local/lib/libolm.so
if test -f ${OLMCK}; then
    echo "olm found, skipping..."
else
    cd "${TMP_DIR}"
    echo "Downloading Olm..."
    wget -qO- "https://gitlab.matrix.org/matrix-org/olm/-/archive/master/olm-master.tar.gz" | tar -xz

    echo "Building olm..."
    cd olm-master
    cmake . -Bbuild
    cmake --build build
    cd build
    make install DESTDIR="${OLM_DIR}"
fi

if test -f ${PYTHON}; then
    echo "python found, skipping..."
else
    echo "Downloading Python..."
    cd "${TMP_DIR}"
    wget -qO- "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | tar -xz

    echo "Installing python..."
    cd "${PYTHON_SRC_DIR}"
    #./configure --prefix="${PYTHON_DIR}" --with-openssl=${OPENSSL_DIR} --enable-shared
    ./configure --prefix="${PYTHON_DIR}" --enable-shared
    make
    make install
fi

LD_LIBRARY_PATH=${PYTHON_DIR}/lib:${OLM_DIR}/usr/local/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH

echo "Updating setuptools..."
${PIP} install --upgrade setuptools
${PIP} install --upgrade pip
${PIP} install --upgrade wheel

echo "Installing PyInstaller..."
${PIP} install --upgrade pyinstaller
# dirty hack to work around pyinstaller locating the bootloader when building for armhf
ln -s ${PYTHON_DIR}/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-32bit-unknown ${PYTHON_DIR}/lib/python3.7/site-packages/PyInstaller/bootloader/Linux-32bit-arm

# NOTE: Newer versions of cryptography require rustc+cargo to build. While the
# new version builds fine with rust on arm64 it fails on armhf
echo "Installing cryptography..."
export CRYPTOGRAPHY_ALLOW_OPENSSL_102="yes"
${PIP} install cryptography==3.2.1

echo "Installing pycairo..."
${PIP} install pycairo==1.19.1

echo "Installing pygobject..."
PYGOBJECT_WITHOUT_PYCAIRO=1 ${PIP} install --no-build-isolation pygobject==3.38

echo "Installing Pantalaimon..."
CFLAGS=-I${OLM_DIR}/usr/local/include LDFLAGS=-L${OLM_DIR}/usr/local/lib ${PIP} install --upgrade pantalaimon[ui]

echo "Bundling Pantalaimon..."
cd ${PROJECT_DIR}
${PYTHON_DIR}/bin/pyinstaller --onefile ${PYTHON_DIR}/bin/pantalaimon
${PYTHON_DIR}/bin/pyinstaller --onefile ${PYTHON_DIR}/bin/panctl

echo "Cleaning up, reverting changes to RootFS..."
sudo apt autoremove -y ${PACKAGES}
sudo apt clean