# clone git repository https://github.com/nextcloud/client_theming

DDIR=$( pwd )

PKG=/tmp/nextcloud

cd client_theming
git pull
git submodule update --init --recursive
[ ! -e build-linux ] && mkdir build-linux
cd build-linux
make clean
cmake -D OEM_THEME_DIR=$(realpath ../nextcloudtheme) -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_LIBDIR=/usr/lib64 ../client
make clean
make -j2

[ -e $PKG/ ] && rm -rf $PKG/
DESTDIR=$PKG make DESTDIR=$PKG install

cd $PKG
VER=$( find . -name "libocsync.so.*" -type f | sed -es/^.*\.so\.// )
makepkg -l y -c y /tmp/nextcloud-${VER}-x86_64-1airaghi.txz

cd $DDIR
