update device build dependencies

Added support for building the current version of the python
cryptography library which now requires rust. Also included the ability
to build panctl.
This commit is contained in:
Morgan McMillian 2021-09-05 13:28:17 -07:00
parent 808fefb4be
commit b0c720d079

View file

@ -3,8 +3,6 @@
PROJECT_DIR=~/pantalaimon-build PROJECT_DIR=~/pantalaimon-build
TMP_DIR="${PROJECT_DIR}/tmp" TMP_DIR="${PROJECT_DIR}/tmp"
VIRTENV_DIR="${PROJECT_DIR}/virtenv"
OLM_DIR="${PROJECT_DIR}/olm" OLM_DIR="${PROJECT_DIR}/olm"
PANTALAIMON_DIR="${PROJECT_DIR}/pantalaimon" PANTALAIMON_DIR="${PROJECT_DIR}/pantalaimon"
@ -14,11 +12,12 @@ PYTHON_VERSION="${PYTHON_VERSION_MINOR}.${PYTHON_VERSION_PATCH}"
PYTHON_DIR="${PROJECT_DIR}/python" PYTHON_DIR="${PROJECT_DIR}/python"
PYTHON_SRC_DIR="${TMP_DIR}/Python-${PYTHON_VERSION}" PYTHON_SRC_DIR="${TMP_DIR}/Python-${PYTHON_VERSION}"
PYTHON="${PYTHON_DIR}/bin/python${PYTHON_VERSION_MINOR}" PYTHON="${PYTHON_DIR}/bin/python${PYTHON_VERSION_MINOR}"
PIP="${PYTHON_DIR}/bin/pip3"
mkdir -p "${PROJECT_DIR}" mkdir -p "${PROJECT_DIR}"
mkdir -p "${TMP_DIR}" mkdir -p "${TMP_DIR}"
PACKAGES="make cmake build-essential zlibc python3-venv libffi-dev ppa-purge libssl-dev libsqlite3-dev" 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"
PANTALAIMON_PATCH_CONTENT=" PANTALAIMON_PATCH_CONTENT="
diff --git a/pantalaimon/main.py b/pantalaimon/main.py diff --git a/pantalaimon/main.py b/pantalaimon/main.py
@ -42,56 +41,67 @@ echo "Installing dependencies..."
sudo apt update sudo apt update
sudo apt install -y ${PACKAGES} sudo apt install -y ${PACKAGES}
if [ ! -e "${OLM_DIR}/usr/local/lib/libolm.so" ]; then OLMCK=${OLM_DIR}/usr/local/lib/libolm.so
if test -f ${OLMCK}; then
echo "olm found, skipping..."
else
cd "${TMP_DIR}" cd "${TMP_DIR}"
echo "Downloading Olm..." echo "Downloading Olm..."
wget -qO- "https://gitlab.matrix.org/matrix-org/olm/-/archive/master/olm-master.tar.gz" | tar -xz wget -qO- "https://gitlab.matrix.org/matrix-org/olm/-/archive/master/olm-master.tar.gz" | tar -xz
echo "Building Olm..." echo "Building olm..."
cd olm-master cd olm-master
cmake . -Bbuild cmake . -Bbuild
cmake --build build cmake --build build
echo "Installing Olm..."
cd build cd build
make install DESTDIR="${OLM_DIR}" make install DESTDIR="${OLM_DIR}"
else
echo "Olm found. Skipping Olm Install..."
fi fi
if [ ! -e "${PYTHON}" ]; then if test -f ${PYTHON}; then
echo "python found, skipping..."
else
echo "Downloading Python..." echo "Downloading Python..."
cd "${TMP_DIR}" cd "${TMP_DIR}"
wget -qO- "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | tar -xz wget -qO- "https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz" | tar -xz
echo "Installing Python..." echo "Installing python..."
cd "${PYTHON_SRC_DIR}" cd "${PYTHON_SRC_DIR}"
#./configure --prefix="${PYTHON_DIR}" --with-openssl=${OPENSSL_DIR} --enable-shared
./configure --prefix="${PYTHON_DIR}" --enable-shared ./configure --prefix="${PYTHON_DIR}" --enable-shared
make make
make install make install
else
echo "Python found. Skipping Python Install..."
fi fi
LD_LIBRARY_PATH=${PYTHON_DIR}/lib:${OLM_DIR}/usr/local/lib:${LD_LIBRARY_PATH} LD_LIBRARY_PATH=${PYTHON_DIR}/lib:${OLM_DIR}/usr/local/lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH export LD_LIBRARY_PATH
echo "Installing PyInstaller..." echo "Updating setuptools..."
${PYTHON} -m pip install --upgrade pyinstaller ${PIP} install --upgrade setuptools
${PIP} install --upgrade pip
${PIP} install --upgrade wheel
echo "Installing cryptography 3.2.1" echo "Installing PyInstaller..."
${PYTHON} -m pip install cryptography==3.2.1 ${PIP} install --upgrade pyinstaller
echo "Installing cryptography..."
CRYPTOGRAPHY_ALLOW_OPENSSL_102="yes" ${PIP} install cryptography
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..." echo "Installing Pantalaimon..."
CFLAGS=-I"${OLM_DIR}/usr/local/include -I${OLM_DIR}/usr/local/include" LDFLAGS="-L${OLM_DIR}/usr/local/lib" ${PYTHON} -m pip install --upgrade pantalaimon CFLAGS=-I${OLM_DIR}/usr/local/include LDFLAGS=-L${OLM_DIR}/usr/local/lib ${PIP} install --upgrade pantalaimon[ui]
echo "Bundling Pantalaimon..." echo "Bundling Pantalaimon..."
cd ${PROJECT_DIR} cd ${PROJECT_DIR}
echo "${PANTALAIMON_PATCH_CONTENT}" > main.patch echo "${PANTALAIMON_PATCH_CONTENT}" > main.patch
patch ${PYTHON_DIR}/lib/python${PYTHON_VERSION_MINOR}/site-packages/pantalaimon/main.py main.patch patch ${PYTHON_DIR}/lib/python${PYTHON_VERSION_MINOR}/site-packages/pantalaimon/main.py main.patch
${PYTHON_DIR}/bin/pyinstaller --onefile ${PYTHON_DIR}/bin/pantalaimon ${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..." echo "Cleaning up, reverting changes to RootFS..."
sudo apt autoremove -y ${PACKAGES} sudo apt autoremove -y ${PACKAGES}
sudo apt clean sudo apt clean