#!/usr/bin/env bash

# Maintainer: Hugo Sales <hugo <at> hsal <dot> es>
pkgname=gnu-social-git
pkgver=3.0.0dev.293c6fe
pkgrel=1
pkgdesc="GNU social is a social communication software used in federated social networks. It is widely supported and has a large user base. It is already used by the Free Software Foundation"
arch=(any)
url="https://www.gnusocial.rocks/"
license=('AGPL')
groups=()
depends=(php nginx)
makedepends=(git)
provides=("${pkgname%-git}")
conflicts=("${pkgname%-git}")
replaces=()
backup=()
options=()
install=gnu-social.install
source=()
noextract=()
md5sums=()

prepare() {
    if [ ! -d "${srcdir}/${pkgname%-git}" ]; then
        git clone --depth 1 'https://codeberg.org/GNUsocial/gnu-social.git' "${srcdir}/${pkgname%-git}"
    else
        git pull
    fi
}

pkgver() {
    cd "$srcdir/${pkgname%-git}"
    printf "3.0.0dev.%s" "$(git rev-parse --short HEAD)"
}

package() {
    cd "$srcdir/${pkgname%-git}"
    mkdir -p "${pkgdir}/var/www/gnu-social"
    mkdir -p "${pkgdir}/etc/nginx/conf.d"
    cp -r components config extlib plugins public src social.yaml templates translations "${pkgdir}/var/www/gnu-social"
    cp docker/nginx/nginx.conf "${pkgdir}/etc/nginx/conf.d/gnu-social.conf"
}
