#!/bin/bash
export DEBIAN_FRONTEND=noninteractive
. /etc/os-release
apt update
apt install -y less wget git
apt install -y appstream-util bison build-essential cmake desktop-file-utils flex gjs libaa1-dev libappstream-glib-dev libarchive-dev libatk1.0-dev libcairo2-dev libcfitsio-dev libexiv2-dev libfontconfig-dev libfreetype-dev libgdk-pixbuf-2.0-dev libgexiv2-dev libglib2.0-dev libgs-dev libgtk-3-dev libgudev-1.0-dev libharfbuzz-dev libheif-dev libjpeg-dev libjson-glib-dev liblcms2-dev libmng-dev libmypaint-dev libopenexr-dev libopenjp2-7-dev libpango1.0-dev libpng-dev libpoppler-dev libpoppler-glib-dev librsvg2-dev libtiff-dev libunwind-dev libwebp-dev libwmf-dev libx11-dev libxcursor-dev libxext-dev libxfixes-dev libxmu-dev libxpm-dev libzstd-dev luajit meson mypaint-brushes ninja-build poppler-data python3-gi libxml2-utils xsltproc gobject-introspection libgirepository1.0-dev libbz2-dev gettext

git config --global --add safe.directory /pika-build/
git config --global --add safe.directory /pika-build/pika

pushd gegl
meson --prefix=/usr/local _build_$HOSTNAME
pushd _build_$HOSTNAME
ninja
ninja install
popd
popd

pushd babl
cp git-version.h.in git-version.h
meson --prefix=/usr/local _build_$HOSTNAME
pushd _build_$HOSTNAME
ninja
ninja install
popd
popd

pushd pika
meson _build_$HOSTNAME --prefix=/usr/local --buildtype=release -Dpython=enabled -Dvala=disabled
pushd _build_$HOSTNAME
ninja
# about dialog fail
ninja install

popd
popd
tar -cf pika-$HOSTNAME-$(date -I)-$VERSION_CODENAME.tar.gz /usr/local/
