# Build recipe for dejavu-fonts-ttf.
#
# Copyright (c) 2022 Matias Fonzo, <selk@dragora.org>.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Exit immediately on any error
set -e

program=dejavu-fonts-ttf
version=2.37
arch=noarch
release=1

# Define a category for the output of the package name
pkgcategory=xorg_extra

tarname=${program}-${version}.tar.bz2

# Remote source(s)
fetch=https://github.com/dejavu-fonts/dejavu-fonts/releases/download/version_2_37/$tarname

description="
DejaVu (True Type) Fonts.

The DejaVu fonts are a font family based on the Vera Fonts.  Its purpose is
to provide a wider range of characters while maintaining the original look
and feel through the process of collaborative development (see authors),
under a Free license.
"

homepage=https://dejavu-fonts.github.io
license="GPLv2+ | Public domain"

# Source documentation
docs="AUTHORS BUGS LICENSE NEWS README.md *.txt"
docsdir="${docdir}/${program}-${version}"

build()
{
    unpack "${tardir}/$tarname"

    cd "$srcdir"

    # Set sane permissions
    chmod -R u+w,go-w,a+rX-s .

    # Prepare package directories

    mkdir -p "${destdir}/usr/share/fonts/X11/TTF"  \
             "${destdir}/etc/fonts/conf.avail"     \
             "${destdir}/etc/fonts/conf.d"

    # Copy True Type Fonts for package destination

    for file in ttf/*.ttf
    do
        install -p -m 644 "$file" "${destdir}/usr/share/fonts/X11/TTF"
    done

    # Add config files for 'fontconfig'

    for file in fontconfig/*.conf
    do
        install -p -m 644 "$file" "${destdir}/etc/fonts/conf.avail"
        ( cd "${destdir}/etc/fonts/conf.d" && ln -sf "../conf.avail/${file##*/}" . )
    done

    # Copy documentation
    mkdir -p "${destdir}/$docsdir"
    cp -p $docs "${destdir}/$docsdir"
}

