code:
# Build recipe for dbus-tqt.
#
# Copyright (c) 2020-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=dbus-tqt
version=20220503_c2e0347
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
DBUS bindings for TQt.

DBUS is a simple IPC library based on messages.
"

homepage=https://www.trinitydesktop.org/
license="Academic Free License version 2.1 | GPLv2+"

# Source documentation
docs="AUTHORS COPYING ChangeLog HACKING NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DCMAKE_INSTALL_PREFIX=/usr                            \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/dbus-tqt/recipe


code:
# Build recipe for kgtk-qt3.
#
# 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=kgtk-qt3
version=20220503_55dcc5b
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
TDE dialogs in GTK 2.x applications.

KGtk is a quick-n-dirty hack to allow some Gtk2, Qt3, and Qt4
applications to use KDE3 or KDE4 file dialogs.

KGtk is composed of the following pieces:

1. An application called kdialogd. In this archive there are
   two varieties of this - a KDE3 version, and a KDE4 version.
2. LD_PRELOAD libraries that are used to override the Gtk2, Qt3,
   and Qt4 file dialogs.
"

homepage=https://www.trinitydesktop.org/
license=GPLv2+

# Source documentation
docs="AUTHORS COPYING ChangeLog README TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$QICFLAGS"      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DCMAKE_INSTALL_PREFIX=/opt/trinity                    \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DCMAKE_SKIP_RPATH=OFF                                 \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

repo_name: dustdfg/dragora

license: mit


code:
# Build recipe for libart-gpl.
#
# Copyright (c) 2020-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=libart-lgpl
version=20220503_9f2ffb3
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
LGPL version of the libart library.

This is the LGPL'd component of libart.  All functions needed for
running the Gnome canvas, and for printing support, will be going in
here.  The GPL'd component will be getting various enhanced functions
for specific applications.
"

homepage=https://www.trinitydesktop.org/
license=LGPLv2+

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_CXX_FLAGS:STRING="$QICXXFLAGS"                 \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DCMAKE_INSTALL_PREFIX=/usr                            \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DCMAKE_SKIP_RPATH=OFF                                 \
     -DWITH_ALL_OPTIONS=ON                                  \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/libart-lgpl/recipe


code:
# Build recipe for libr.
#
# Copyright (c) 2021-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=libr
version=20220503_0877bf9
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
ELF resource manager library.

This is a simple inter-process messaging system (TQt-based shared library).
"

homepage=https://www.trinitydesktop.org/
license=LGPLv2.1

# Source documentation
docs="AUTHORS COPYING* ChangeLog NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    # We don't have doxygen by the moment, so we avoid calling it
    # for generate the documentation (aka manpage)
    patch -Np1 -i "${worktree}/patches/libr/do-not-call-doxygen-for-doc.diff"

    rm -rf man/

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$QICFLAGS"      \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DCMAKE_INSTALL_PREFIX=/usr                            \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DWITH_BACKEND_LIBBFD=ON                               \
     -DWITH_BACKEND_LIBELF=ON                               \
     -DWITH_BACKEND_READONLY=ON                             \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/libr/recipe


code:
# Build recipe for tde-i18n.
#
# Copyright (c) 2021-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

# This recipe does not produce a main package, but sub-packages
opt_nopkg=opt_nopkg

program=tde-i18n
version=20220504_e67bfc8629
arch=noarch
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="TDE internationalization translations."

homepage=https://www.trinitydesktop.org/
license=GPLv2+

# Source documentation
docs="AUTHORS COPYING* README*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    for langdir in tde-i18n-*
    do
        unset -v pkgname destdir full_pkgname description
        pkgname="$langdir"
        destdir="${TMPDIR}/package-$pkgname"
        full_pkgname="${pkgname}_${pkgversion}_${arch}-${release}${pkgcategory}"

        # Set description for each generated package
        case $langdir in
        tde-i18n-af)
            langdescription="Afrikaans (af)"
            ;;
        tde-i18n-ar)
            langdescription="Arabic (ar)"
            ;;
        tde-i18n-az)
            langdescription="Azerbaijani (az)"
            ;;
        tde-i18n-be)
            langdescription="Belarusian (be)"
            ;;
        tde-i18n-bg)
            langdescription="Bulgarian (bg)"
            ;;
        tde-i18n-bn)
            langdescription="Bengali (bn)"
            ;;
        tde-i18n-br)
            langdescription="Breton (br)"
            ;;
        tde-i18n-bs)
            langdescription="Bosnian (bs)"
            ;;
        tde-i18n-ca)
            langdescription="Catalan (ca)"
            ;;
        tde-i18n-cs)
            langdescription="Czech (cs)"
            ;;
        tde-i18n-csb)
            langdescription="Kashubian (csb)"
            ;;
        tde-i18n-cy)
            langdescription="Welsh (cy)"
            ;;
        tde-i18n-da)
            langdescription="Danish (da)"
            ;;
        tde-i18n-de)
            langdescription="German (de)"
            ;;
        tde-i18n-el)
            langdescription="Greek (el)"
            ;;
        tde-i18n-en_GB)
            langdescription="British English (en_GB)"
            ;;
        tde-i18n-eo)
            langdescription="Esperanto (eo)"
            ;;
        tde-i18n-es)
            langdescription="Spanish (es)"
            ;;
        tde-i18n-es_AR)
            langdescription="Spanish Argentina (es_AR)"
            ;;
        tde-i18n-et)
            langdescription="Estonian (et)"
            ;;
        tde-i18n-eu)
            langdescription="Basque (eu)"
            ;;
        tde-i18n-fa)
            langdescription="Farsi, Persian (fa)"
            ;;
        tde-i18n-fi)
            langdescription="Finnish (fi)"
            ;;
        tde-i18n-fr)
            langdescription="French (fr)"
            ;;
        tde-i18n-fy)
            langdescription="Frisian (fy)"
            ;;
        tde-i18n-ga)
            langdescription="Irish (ga)"
            ;;
        tde-i18n-gl)
            langdescription="Galician (gl)"
            ;;
        tde-i18n-he)
            langdescription="Hebrew (he)"
            ;;
        tde-i18n-hi)
            langdescription="Hindi (hi)"
            ;;
        tde-i18n-hr)
            langdescription="Croatian (hr)"
            ;;
        tde-i18n-hu)
            langdescription="Hungarian (hu)"
            ;;
        tde-i18n-ie)
            # "tde-i18n-ie" lacks a valid CMakeList file
            #langdescription="Occidental (ie)"
            continue;
            ;;
        tde-i18n-is)
            langdescription="Icelandic (is)"
            ;;
        tde-i18n-it)
            langdescription="Italian (it)"
            ;;
        tde-i18n-ja)
            langdescription="Japanese (ja)"
            ;;
        tde-i18n-kk)
            langdescription="Kazakh (kk)"
            ;;
        tde-i18n-km)
            langdescription="Khmer (km)"
            ;;
        tde-i18n-ko)
            langdescription="Korean (ko)"
            ;;
        tde-i18n-lt)
            langdescription="Lithuanian (lt)"
            ;;
        tde-i18n-lv)
            langdescription="Latvian (lv)"
            ;;
        tde-i18n-mk)
            langdescription="Macedonian (mk)"
            ;;
        tde-i18n-mn)
            langdescription="Mongolian (mn)"
            ;;
        tde-i18n-ms)
            langdescription="Malay (ms)"
            ;;
        tde-i18n-nb)
            langdescription="Norwegian Bookmal (nb)"
            ;;
        tde-i18n-nds)
            langdescription="Low Saxon (nds)"
            ;;
        tde-i18n-nl)
            langdescription="Dutch (nl)"
            ;;
        tde-i18n-nn)
            langdescription="Norwegian Nynorsk (nn)"
            ;;
        tde-i18n-pa)
            langdescription="Punjabi (pa)"
            ;;
        tde-i18n-pl)
            langdescription="Polish (pl)"
            ;;
        tde-i18n-pt)
            langdescription="Portuguese (pl)"
            ;;
        tde-i18n-pt_BR)
            langdescription="Brazilian Portuguese (pt_BR)"
            ;;
        tde-i18n-ro)
            langdescription="Romanian (ro)"
            ;;
        tde-i18n-ru)
            langdescription="Russian (ru)"
            ;;
        tde-i18n-rw)
            langdescription="Kinyarwanda (rw)"
            ;;
        tde-i18n-se)
            langdescription="Northern Sami (se)"
            ;;
        tde-i18n-sk)
            langdescription="Slovak (sk)"
            ;;
        tde-i18n-sl)
            langdescription="Slovenian (sl)"
            ;;
        tde-i18n-sr)
            langdescription="Serbian (sr)"
            ;;
        tde-i18n-sr@Latn)
            langdescription="Serbian (sr@Latn)"
            ;;
        tde-i18n-ss)
            langdescription="Swati (ss)"
            ;;
        tde-i18n-sv)
            langdescription="Swedish (sv)"
            ;;
        tde-i18n-ta)
            langdescription="Tamil (ta)"
            ;;
        tde-i18n-te)
            langdescription="Telugu (te)"
            ;;
        tde-i18n-tg)
            langdescription="Tajik (tg)"
            ;;
        tde-i18n-th)
            langdescription="Thai (th)"
            ;;
        tde-i18n-tr)
            langdescription="Turkish (tr)"
            ;;
        tde-i18n-uk)
            langdescription="Ukrainian (uk)"
            ;;
        tde-i18n-uz)
            langdescription="Uzbek (uz)"
            ;;
        tde-i18n-uz@cyrillic)
            langdescription="Uzbek (uz@cyrillic)"
            ;;
        tde-i18n-vi)
            langdescription="Vietnamese (vi)"
            ;;
        tde-i18n-wa)
            langdescription="Walloon (wa)"
            ;;
        tde-i18n-zh_CN)
            langdescription="Chinese Simplified (zh_CN)"
            ;;
        tde-i18n-zh_TW)
            langdescription="Chinese Traditional (zh_TW)"
            ;;
        *)
            langdescription="$langdir"
            ;;
        esac

        description="${langdescription} translation for TDE."

        cd -- "$langdir"
        rm -rf BUILD
        mkdir BUILD
        cd BUILD
        cmake \
         -DCMAKE_INSTALL_PREFIX=/usr                            \
         -DLIB_SUFFIX=${libSuffix}                              \
         -DCMAKE_VERBOSE_MAKEFILE=ON                            \
         -DCMAKE_SKIP_RPATH=OFF                                 \
         -DCMAKE_INSTALL_PREFIX=/opt/trinity                    \
         -DCONFIG_INSTALL_DIR=/etc/trinity                      \
         -DSYSCONF_INSTALL_DIR=/etc/trinity                     \
         -DCMAKE_LIBRARY_PATH=/opt/trinity/lib${libSuffix}      \
         -DCMAKE_INCLUDE_PATH=/opt/trinity/include              \
         -DBUILD_DOC=ON                                         \
         -DBUILD_DATA=ON                                        \
         -DBUILD_MESSAGES=ON                                    \
         -G Ninja ..
         ninja -j${jobs}
         DESTDIR="$destdir" ninja -j${jobs} install

         # Produce the sub-package by invoking the internal Qi function
         do_meta > "${outdir}/${full_pkgname}.tlz.txt"
         mkdir -p -- "${destdir}/var/lib/qi"
         cp -p "${outdir}/${full_pkgname}.tlz.txt" \
               "${destdir}/var/lib/qi/${full_pkgname}.txt"

         cd -- "$destdir" && mode_create "${outdir}/${full_pkgname}.tlz"

         # Install or upgrade the package after build
         if test "$opt_install" = opt_install
         then
             mode_install "${outdir}/${full_pkgname}.tlz"
         elif test "$opt_upgrade" = opt_upgrade
         then
             mode_upgrade "${outdir}/${full_pkgname}.tlz"
         fi

         # Check given options to Qi in order to remove 'destdir' or not
         if test "$opt_keep" != opt_keep && test -z "$keep_destdir"
         then
             cd ..
             rm -r "$destdir"
         fi

         # Switch back to the source directory
         cd -- "${TMPDIR}/$srcdir"
    done

    unset -v pkgname destdir full_pkgname description
}


code:
echo "Updating desktop database: update-desktop-database -q opt/trinity/share/applications/tde"
chroot "$rootdir" /usr/bin/update-desktop-database -q opt/trinity/share/applications/tde 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/locolor"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/locolor 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/mono"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/mono 2> /dev/null


code:
# Build recipe for tdeaccessibility.
#
# Copyright (c) 2021-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=tdeaccessibility
version=20220503_d05857f
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
Accessibility support for TDE.

This package includes a collection of programs to make TDE more
accessible, provided with the official release of TDE.
"

homepage=https://www.trinitydesktop.org/
license="GPLv2+, GFDLv1.2"

# Source documentation
docs="COPYING*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$QICFLAGS"      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DCMAKE_SKIP_RPATH=OFF                                 \
     -DCMAKE_INSTALL_PREFIX=/opt/trinity                    \
     -DCONFIG_INSTALL_DIR=/etc/trinity                      \
     -DSYSCONF_INSTALL_DIR=/etc/trinity                     \
     -DMAN_INSTALL_DIR=$mandir                              \
     -DCMAKE_LIBRARY_PATH=/opt/trinity/lib${libSuffix}      \
     -DCMAKE_INCLUDE_PATH=/opt/trinity/include              \
     -DWITH_GCC_VISIBILITY=ON                               \
     -DBUILD_ALL=ON                                         \
     -DWITH_ALSA=ON                                         \
     -DWITH_GSTREAMER=OFF                                   \
     -DWITH_ARTS=OFF                                        \
     -DBUILD_KTTSD=OFF                                      \
     -DBUILD_KSAYIT=OFF                                     \
     -DBUILD_KSAYIT_FREEVERB=OFF                            \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # To handle dot new config(s)
    touch "${destdir}/etc/trinity/.graft-config"

    # Compress and link man pages (if needed)
    (
        cd "${destdir}/$mandir"
        find . -type f -exec lzip -9 {} +
        find . -type l | while read -r file
        do
            ln -sf "$(readlink -- "$file").lz" "${file}.lz"
            rm -- "$file"
        done
    )

    cd ..

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

path: recipes/tde/tdeaccessibility/recipe


code:
# Build recipe for tdebase.
#
# Copyright (c) 2020-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=tdebase
version=20220502_cbd6a3e28
release=2

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
TDE base libraries and programs.

tdebase is the second mandatory package (besides tdelibs) for the
Trinity Desktop Environment.  Here we have various applications
and infrastructure files and libraries.
"

homepage=https://www.trinitydesktop.org/
license="GPLv2+, GFDLv1.2"

# Source documentation
docs="AUTHORS COPYING* README*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    # https://mirror.git.trinitydesktop.org/gitea/TDE/tdebase/pulls/205
    patch -Np1 -i "${worktree}/patches/tdebase/kicker-clock-FTBFS.patch"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$QICFLAGS"      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DCMAKE_SKIP_RPATH=OFF                                 \
     -DCMAKE_INSTALL_PREFIX=/opt/trinity                    \
     -DCONFIG_INSTALL_DIR=/etc/trinity                      \
     -DSYSCONF_INSTALL_DIR=/etc/trinity                     \
     -DCMAKE_LIBRARY_PATH=/opt/trinity/lib${libSuffix}      \
     -DCMAKE_INCLUDE_PATH=/opt/trinity/include              \
     -DXDG_MENU_INSTALL_DIR=/etc/xdg/menus                  \
     -DHTDIG_SEARCH_BINARY=/usr/bin/hlsearch                \
     -DWITH_GCC_VISIBILITY=ON                               \
     -DBUILD_ALL=ON                                         \
     -DBUILD_TDM_SYSTEMD_UNIT_FILE=OFF                      \
     -DWITH_USBIDS=/usr/share/hwdata/usb.ids                \
     -DWITH_ARTS=OFF                                        \
     -DWITH_PAM=OFF                                         \
     -DWITH_SASL=OFF                                        \
     -DWITH_ELFICON=ON                                      \
     -DWITH_SUDO_TDESU_BACKEND=ON                           \
     -DWITH_SUDO_KONSOLE_SUPER_USER_COMMAND=OFF             \
     -DWITH_LDAP=OFF                                        \
     -DWITH_SAMBA=OFF                                       \
     -DWITH_LIBUSB=ON                                       \
     -DWITH_LIBRAW1394=OFF                                  \
     -DWITH_OPENEXR=ON                                      \
     -DWITH_XCOMPOSITE=ON                                   \
     -DWITH_XCURSOR=ON                                      \
     -DWITH_XFIXES=ON                                       \
     -DWITH_XRANDR=ON                                       \
     -DWITH_XINERAMA=ON                                     \
     -DWITH_SENSORS=ON                                      \
     -DWITH_HAL=OFF                                         \
     -DWITH_TDEHWLIB=OFF                                    \
     -DWITH_XDMCP=ON                                        \
     -DWITH_XRENDER=ON                                      \
     -DWITH_XTEST=ON                                        \
     -DWITH_OPENGL=ON                                       \
     -DWITH_XSCREENSAVER=OFF                                \
     -DWITH_UPOWER=OFF                                      \
     -DWITH_LIBART=ON                                       \
     -DWITH_LIBCONFIG=OFF                                   \
     -DWITH_PCRE=ON                                         \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # To handle (dot) .new files via graft(1)

    find "${destdir}/etc" -type d -print | while read -r directory
    do
        ( cd -- "$directory" && touch .graft-config )
    done

    # Include wallpaper of our team mate "Oswald Kelso"
    install -p -m 644 "${worktree}/archive/tdebase/bluedragora.jpg" \
     "${destdir}"/opt/trinity/share/wallpapers/

    install -p -m 644 "${worktree}/archive/tdebase/bluedragora.jpg.desktop" \
     "${destdir}"/opt/trinity/share/wallpapers/

    # Set or point to our wallpaper location
    sed \
     -e 's|Trinity-lineart.svg.desktop|bluedragora.jpg.desktop|g' \
     -e 's|Wallpaper=Trinity-lineart.svg|Wallpaper=bluedragora.jpg|g' \
     -i "${destdir}"/opt/trinity/bin/starttde

    # Include xinitrc file to start TDE

    mkdir -p "${destdir}/etc/X11/xinit"
    cp -p "${worktree}/archive/tdebase/xinitrc-tde" \
          "${destdir}/etc/X11/xinit/"
    chmod 644 "${destdir}/etc/X11/xinit/xinitrc-tde"

    # Include profile file

    mkdir -p "${destdir}/etc/profile.d"
    cp -p "${worktree}/archive/tdebase/etc/profile.d/trinity.sh" \
           "${destdir}/etc/profile.d/"
    chmod 644 "${destdir}/etc/profile.d/trinity.sh"

    # To handle .new config file(s)
    touch "${destdir}/etc/profile.d/.graft-config" \
          "${destdir}/etc/X11/xinit/.graft-config"

    # Create post-install script

    mkdir -p "${destdir}/var/lib/qi"
    cat << EOF > "${destdir}/var/lib/qi/${full_pkgname}.sh"

# Make symlink for canonical path at /opt/trinity/lib
#
# Link using \$libSuffix
if test -n "$libSuffix" && test ! -e "\${rootdir}/opt/trinity/lib"
then
    ( cd -- "\${rootdir}/opt/trinity" && ln -sf lib${libSuffix} lib )
fi

echo "Updating desktop database: update-desktop-database -q opt/trinity/share/applications/tde"
chroot "\$rootdir" /usr/bin/update-desktop-database -q opt/trinity/share/applications/tde

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor"
chroot "\$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/crystalsvg"
chroot "\$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/crystalsvg

# Set xinitrc as default to start TDE when this package is installed

cd -- "\${rootdir}/etc/X11/xinit" && ln -sf xinitrc-tde xinitrc

EOF

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/tdebase/recipe


code:
echo "Updating desktop database: update-desktop-database -q opt/trinity/share/applications/tde"
chroot "$rootdir" /usr/bin/update-desktop-database -q opt/trinity/share/applications/tde 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/crystalsvg"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/crystalsvg 2> /dev/null

# Re-create default TDE symlink in the final location,
# instead of pointing to the package directory
(
    cd -- "${rootdir}/opt/trinity/share/icons" && \
     ln -sf crystalsvg default.tde
)

path: recipes/tde/tdelibs/post-install


code:
# Build recipe for tdelibs.
#
# Copyright (c) 2020-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=tdelibs
version=20220503_32fc7e3e
release=2

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
The Trinity Desktop Environment (TDE) libraries.

This package includes libraries that are central to the development and
execution of a KDE program, as well as internationalization files for
these libraries, misc HTML documentation, theme modules, and regression
tests.
"

homepage=https://www.trinitydesktop.org/
license="GPLv2+, LGPLv2+ | BSD 2-clause"

# Source documentation
docs="AUTHORS COPYING* DEBUG NAMING README TODO KDE?PORTING.html"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    patch -Np1 -i "${worktree}/patches/tdelibs/xcomposite-shared-masterbranch.patch"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$QICFLAGS"      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo ${QILDFLAGS} | sed 's/-s//')" \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DCMAKE_SKIP_RPATH=OFF                                 \
     -DCMAKE_INSTALL_PREFIX=/opt/trinity                    \
     -DCONFIG_INSTALL_DIR=/etc/trinity                      \
     -DSYSCONF_INSTALL_DIR=/etc/trinity                     \
     -DCMAKE_LIBRARY_PATH=/opt/trinity/lib${libSuffix}      \
     -DCMAKE_INCLUDE_PATH=/opt/trinity/include              \
     -DXDG_MENU_INSTALL_DIR=/etc/xdg/menus                  \
     -DWITH_GCC_VISIBILITY=ON                               \
     -DWITH_CUPS=OFF                                        \
     -DWITH_ARTS=OFF                                        \
     -DWITH_LIBART=ON                                       \
     -DWITH_LIBIDN=OFF                                      \
     -DWITH_TIFF=ON                                         \
     -DWITH_JASPER=ON                                       \
     -DWITH_OPENEXR=ON                                      \
     -DWITH_AVAHI=OFF                                       \
     -DWITH_ISPELL=OFF                                      \
     -DWITH_ASPELL=ON                                       \
     -DWITH_HSPELL=OFF                                      \
     -DDEFAULT_SPELL_CHECKER=ASPELL                         \
     -DWITH_ELFICON=ON                                      \
     -DWITH_TDEHWLIB=OFF                                    \
     -DWITH_LOGINDPOWER=OFF                                 \
     -DWITH_UDEVIL=ON                                       \
     -DWITH_UPOWER=OFF                                      \
     -DWITH_UDISKS=OFF                                      \
     -DWITH_UDISKS2=OFF                                     \
     -DWITH_CONSOLEKIT=OFF                                  \
     -DWITH_NETWORK_MANAGER_BACKEND=OFF                     \
     -DWITH_LZMA=ON                                         \
     -DWITH_XRANDR=ON                                       \
     -DWITH_XCOMPOSITE=ON                                   \
     -DWITH_MITSHM=ON                                       \
     -DWITH_IMAGETOPS_BINARY=ON                             \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # This symlink will be handled from the post-install
    # script to point to the correct location
    rm -f "${destdir}/opt/trinity/share/icons/default.tde"

    # To handle (dot) .new files via graft(1)

    find "${destdir}/etc" -type d -print | while read -r directory
    do
        ( cd -- "$directory" && touch .graft-config )
    done

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/tdelibs/recipe


code:
echo "Updating desktop database: update-desktop-database -q opt/trinity/share/applications/tde"
chroot "$rootdir" /usr/bin/update-desktop-database -q opt/trinity/share/applications/tde 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/crystalsvg"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/crystalsvg 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/hicolor 2> /dev/null

echo "Updating ICON cache: gtk-update-icon-cache -q -f -i opt/trinity/share/icons/locolor"
chroot "$rootdir" /usr/bin/gtk-update-icon-cache -q -f -i opt/trinity/share/icons/locolor 2> /dev/null

path: recipes/tde/tdeutils/post-install


code:
# Build recipe for tdeutils.
#
# Copyright (c) 2021-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=tdeutils
version=20220503_37fdaba
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
TDE utilities.

It includes several (official) utilities for the
Trinity Desktop Environment (TDE).
"

homepage=https://www.trinitydesktop.org/
license="GPLv2+, GFDLv1.2"

# Source documentation
docs="AUTHORS COPYING* README*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$QICFLAGS"      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DCMAKE_SKIP_RPATH=OFF                                 \
     -DCMAKE_INSTALL_PREFIX=/opt/trinity                    \
     -DCONFIG_INSTALL_DIR=/etc/trinity                      \
     -DSYSCONF_INSTALL_DIR=/etc/trinity                     \
     -DCMAKE_LIBRARY_PATH=/opt/trinity/lib${libSuffix}      \
     -DCMAKE_INCLUDE_PATH=/opt/trinity/include              \
     -DXDG_MENU_INSTALL_DIR=/etc/xdg/menus                  \
     -DWITH_GCC_VISIBILITY=ON                               \
     -DBUILD_ALL=ON                                         \
     -DWITH_DPMS=ON                                         \
     -DWITH_ASUS=ON                                         \
     -DWITH_VAIO=ON                                         \
     -DWITH_THINKPAD=ON                                     \
     -DWITH_I8K=ON                                          \
     -DWITH_SNMP=OFF                                        \
     -DWITH_SENSORS=ON                                      \
     -DWITH_XMMS=ON                                         \
     -DWITH_TDENEWSTUFF=ON                                  \
     -DBUILD_KSIM=OFF \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/tdeutils/recipe


code:
# Build recipe for tqca-trinity.
#
# Copyright (c) 2020-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=tqca
version=20220503_8dbed86
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
The TQt cryptographic architecture.

This library provides an easy API for the following features:

  SSL/TLS
  X509
  SASL
  RSA
  Hashing (SHA1, MD5)
  Ciphers (BlowFish, 3DES, AES)

Functionality is supplied via plugins. This is useful for avoiding
dependence on a particular crypto library and makes upgrading easier,
as there is no need to recompile your application when adding or
upgrading a crypto plugin.  Also, by pushing crypto functionality into
plugins, your application is free of legal issues, such as export
regulation.
"

homepage=https://www.trinitydesktop.org/
license=LGPLv2.1

# Source documentation
docs="COPYING README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_C_FLAGS_RELWITHDEBINFO:STRING="$QICFLAGS"      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DCMAKE_INSTALL_PREFIX=/usr                            \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCONFIG_INSTALL_DIR=/etc/trinity                      \
     -DSYSCONF_INSTALL_DIR=/etc/trinity                     \
     -DXDG_MENU_INSTALL_DIR=/etc/xdg/menus                  \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DCMAKE_SKIP_RPATH=OFF                                 \
     -DBUILD_TQCA=ON                                        \
     -DBUILD_TQCA_TLS=ON                                    \
     -DWITH_ALL_OPTIONS=ON                                  \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/tqca/recipe


code:
echo "Updating desktop database: update-desktop-database -q usr/share/applications"
chroot "$rootdir" /usr/bin/update-desktop-database -q usr/share/applications 2> /dev/null


code:
# Build recipe for tqt3 (trinity).
#
# Copyright (c) 2019-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=tqt3
version=20220430_ec04b50a
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
Qt is a multiplatform C++ GUI application framework.

Qt 3.3 introduces new features and many improvements over
the 3.2.x series. See the changes file for details.

The Qt version 3.3 series is binary compatible with the
3.2.x series - applications compiled for 3.2 will continue
to run with 3.3.
"

homepage=https://www.trinitydesktop.org/
license="GPLv2+, GPLv3+ | The Q Public License"

# Source documentation
docs="FAQ LICENSE* README*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    # Remove unneeded specs for targets other than GNU/Linux
    ( cd mkspecs && find . -maxdepth 1 \( -type d -a ! -name 'linux-g++' \) -exec rm -rf -- '{}' \; )

    # Do not build the HTML documentation in order to save disk space
    #sed -i '/htmldocs/d' src/qt_install.pri

    # Set custom compilation flags from Qi
    sed -i \
     -e "s:QMAKE_CFLAGS_RELEASE.*=:QMAKE_CFLAGS_RELEASE=${QICXXFLAGS} :" \
      mkspecs/linux*/qmake.conf

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

    LD_LIBRARY_PATH="${PWD}/lib:${LD_LIBRARY_PATH}"
    LD_LIBRARY_PATH="${LD_LIBRARY_PATH%%:*}";	# Get the rid of ":".
    export LD_LIBRARY_PATH
    echo "New LD_LIBRARY_PATH: $LD_LIBRARY_PATH"

    echo yes | ./configure \
     -L/usr/lib${libSuffix} \
     -I/usr/include/freetype2 \
     -I/usr/include/tirpc \
     -prefix "/usr" \
     -libdir "/usr/lib${libSuffix}" \
     -sysconfdir "/etc/tqt3" \
     -headerdir "/usr/include/tqt3" \
     -plugindir "/usr/lib${libSuffix}/tqt3/plugins" \
     -datadir "/usr/share/tqt3" \
     -translationdir "/usr/share/tqt3/translations" \
     -docdir "$docsdir" \
     -no-exceptions \
     -qt-gif \
     -system-zlib \
     -system-libpng \
     -system-libjpeg \
     -system-libmng \
     -qt-imgfmt-mng \
     -qt-imgfmt-png \
     -qt-imgfmt-jpeg \
     -plugin-imgfmt-mng \
     -thread \
     -shared \
     -fast \
     -glibmainloop \
     -tablet \
     -enable-opengl \
     -dlopen-opengl \
     -nis \
     -sm \
     -xshape \
     -xinerama \
     -xcursor \
     -xrandr \
     -xft \
     -xrender \
     -xkb \
     -release

    make -i -j${jobs} sub-tools
    make -j${jobs} INSTALL_ROOT="$destdir" install

    unset -v LD_LIBRARY_PATH

    # Strip remaining binaries and libraries
    find "$destdir" -type f | xargs file | \
     awk '/ELF/ && /executable/ || /shared object/' | \
      cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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


code:
# Build recipe for tqtinterface.
#
# Copyright (c) 2020-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=tqtinterface
version=20220503_33d1412
release=1

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"

description="
The Trinity Qt Interface.

This package includes libraries that abstract the underlying Qt system
from the actual Trinity code, allowing easy, complete upgrades to new
versions of Qt.

It also contains various functions that have been removed from newer
versions of Qt, but are completely portable and isolated from other APIs
such as Xorg.  This allows the Trinity project to efficiently perform
certain operations that are infeasible or unneccessarily difficult when
using pure Qt4 or above.
"

homepage=https://www.trinitydesktop.org/
license=GPLv2+

# Source documentation
docs="AUTHORS COPYING README qtinterface/TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_EXPORT_COMPILE_COMMANDS=ON                     \
     -DCMAKE_BUILD_TYPE=RelWithDebInfo                      \
     -DCMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING="$QICXXFLAGS"  \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$(echo $QILDFLAGS | sed 's/-s//')" \
     -DCMAKE_INSTALL_PREFIX=/usr                            \
     -DLIB_SUFFIX=${libSuffix}                              \
     -DCMAKE_VERBOSE_MAKEFILE=ON                            \
     -DQT_VERSION=3                                         \
     -DWITH_QT3=ON                                          \
     -DWITH_QT4=OFF                                         \
     -G Ninja ..

    ninja -j${jobs}
    DESTDIR="$destdir" ninja -j${jobs} install

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

    cd ..

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

path: recipes/tde/tqtinterface/recipe


code:
# Build recipe for acl.
#
# Copyright (c) 2016-2018, 2021 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=acl
version=2.3.1
release=1

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

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

# Remote source(s)
fetch=https://download.savannah.gnu.org/releases/acl/$tarname

description="
Access Control Lists.

The POSIX Access Control Lists, are used to define more fine-grained
discretionary access rights for files and directories.
"

homepage=https://savannah.nongnu.org/projects/acl
license="GPLv2+, LGPLv2.1"

# Source documentation
docs="README doc/CHANGES doc/COPYING* doc/TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/acl/recipe


code:
if test -x /etc/rc.d/rc.alsa
then
    /etc/rc.d/rc.alsa start
fi

path: recipes/tools/alsa-utils/post-install


code:
# Build recipe for alsa-utils.
#
# Copyright (c) 2017-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=alsa-utils
version=1.2.6
release=1

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

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

# Remote source(s)
fetch=ftp://ftp.alsa-project.org/pub/utils/$tarname

description="
The ALSA utilities.

The alsa-utils package contains various utilities
which are useful for controlling your sound card.
"

homepage=https://alsa-project.org
license=GPLv2+

# Source documentation
docs="COPYING ChangeLog TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --disable-xmlto \
     --disable-rst2man \
     --disable-alsaconf \
     --with-curses=ncursesw \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Include rc file
    mkdir -p "${destdir}/etc/rc.d"
    cp -p "${worktree}/archive/alsa-utils/rc.alsa" "${destdir}/etc/rc.d/"
    chmod 755 "${destdir}/etc/rc.d/rc.alsa"

    touch "${destdir}/etc/rc.d/.graft-config"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/alsa-utils/recipe


code:
# Build recipe for attr.
#
# Copyright (c) 2016-2018, 2021 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=attr
version=2.5.1
release=1

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

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

# Remote source(s)
fetch=https://download.savannah.gnu.org/releases/attr/$tarname

description="
Extended attributes.

The extended attributes are name:value pairs associated
permanently with files and directories.

For more information, type: \"man 5 attr\".
"

homepage=https://savannah.nongnu.org/projects/attr
license="GPLv2+, LGPLv2.1"

# Source documentation
docs="README doc/CHANGES doc/COPYING*"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # To handle config file(s)
    touch "${destdir}/etc/.graft-config"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/attr/recipe


code:
# Build recipe for btrfs-progs.
#
# Copyright (c) 2021-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=btrfs-progs
version=5.16
release=2

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

tarname=${program}-v${version}.tar.gz

# Remote source(s)
fetch=https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/$tarname

description="
Userspace utilities to manage btrfs filesystems.

Btrfs is a copy on write (COW) filesystem for Linux aimed at implementing
advanced features while focusing on fault tolerance, repair and easy
administration.
"

homepage=https://www.kernel.org/pub/linux/kernel/people/kdave/btrfs-progs/
license=GPLv2+

# Source documentation
docs="CHANGES COPYING README* VERSION"
docsdir="${docdir}/${program}-${version}"

# The source has a custom directory name
srcdir="${tarname%.tar*}"

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

    cd "$srcdir"

    # Fix conflict with the sysinfo definition under Musl
    patch -Np1 -i "${worktree}/patches/btrfs-progs/sysinfo-glibc.patch"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
     CFLAGS="$QICFLAGS -O3" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-zstd \
     --disable-backtrace \
     --with-convert=ext2 \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Install Bash completion file
    install -p -m 644 btrfs-completion -D \
     "${destdir}/usr/share/bash-completion/completions/btrfs"

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/btrfs-progs/recipe


code:
# Build recipe for coreutils.
#
# Copyright (c) 2016-2021 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=coreutils
version=9.0
release=2

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

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

# Remote source(s)
fetch=https://ftpmirror.gnu.org/coreutils/$tarname

description="
The GNU core utilities (version $version).

The GNU core utilities are the basic file, shell and text manipulation
utilities of the GNU operating system.  These are the core utilities
which are expected to exist on every operating system.
"

homepage=https://www.gnu.org/software/coreutils
license=GPLv3+

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README THANKS THANKS-to-translators TODO"
docsdir="${docdir}/${program}"

# Limit package name to the program name
full_pkgname="${program}@${pkgcategory}"

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

    cd "$srcdir"

    # chmod: fix exit status when ignoring symlinks
    # https://debbugs.gnu.org/cgi/bugreport.cgi?bug=50784
    patch -Np1 -i "${worktree}/patches/coreutils/chmod-fix.patch"

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

    ./configure FORCE_UNSAFE_CONFIGURE="1" DEFAULT_POSIX2_VERSION="199209" \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-install-program=arch \
     --enable-no-install-program=kill,uptime,hostname \
     --with-tty-group=tty \
     --without-libgmp \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Create link to "ginstall", since many sources relies on it
    ( cd "${destdir}/usr/bin" && ln -sf install ginstall )

    # Remove generated charset.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"
    rmdir "${destdir}/usr/lib${libSuffix}" || true

    # Add "DIR_COLORS" file
    mkdir -p "${destdir}/etc/profile.d"
    cat src/dircolors.hin > "${destdir}/etc/DIR_COLORS"

    # Include our custom dircolors file for profile.d
    cat "${worktree}/archive/coreutils/etc/profile.d/dircolors.sh" \
      > "${destdir}/etc/profile.d/dircolors.sh"

    # To handle config file(s)
    touch "${destdir}/etc/profile.d/.graft-config" \
          "${destdir}/etc/.graft-config"

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/coreutils/recipe


code:
# Build recipe for cryptsetup.
#
# Copyright (c) 2022 DustDFG, <dfgdust@gmail.com>.
#
# 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=cryptsetup
version=2.4.3
release=1

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

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

# Remote source(s)
fetch=https://www.kernel.org/pub/linux/utils/cryptsetup/v2.4/$tarname

description="
Cryptsetup is a utility used to conveniently set up disk encryption based
on the DMCrypt kernel module.

These include plain dm-crypt volumes, LUKS volumes, loop-AES, TrueCrypt
(including VeraCrypt extension) and BitLocker formats. The project also
includes a veritysetup utility used to conveniently setup DMVerity block
integrity checking kernel module and integritysetup to setup DMIntegrity
block integrity kernel module.
"

homepage=https://gitlab.com/cryptsetup/cryptsetup/
license="GPLv2 & LGPL2.1"

# Source documentation
docs="COPYING COPYING.LGPL README.md"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    patch -Np0 -i "${worktree}/patches/cryptsetup/libssh2.patch"

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

    autoreconf

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-ssh-token \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/cryptsetup/recipe


code:
# Build recipe for ddrescue.
#
# Copyright (c) 2022 DustDFG, <dfgdust@gmail.com>.
#
# 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=ddrescue
version=1.26
release=2

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/gnu/ddrescue/$tarname

description="
GNU ddrescue is a data recovery tool.

GNU ddrescue copies data from one file or block device (hard disc, cdrom, etc)
to another, trying to rescue the good parts first in case of read errors.
"

homepage=https://www.gnu.org/software/ddrescue/
license=GPLv2+

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CXXFLAGS+="$QICXXFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress info documents deleting index file for the package (if needed)
    if test -d "${destdir}/${infodir}"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/${mandir}"
    then
        (
            cd "${destdir}/${mandir}"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/ddrescue/recipe


code:
# Build recipe for dialog.
#
# Copyright (c) 2017-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=dialog
version=1.3-20220117
release=1

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

tarname=${program}-${version}.tgz

# Remote source(s)
fetch=https://invisible-mirror.net/archives/dialog/$tarname

description="
Display dialog boxes in scripts.

Dialog is a program that will let you present a variety
of questions or display messages in nice looking color
non-graphical dialog boxes from a shell or perl script.
"

homepage=https://www.gnu.org/software/ncurses
license=LGPLv2.1

# Source documentation
docs="CHANGES COPYING README VERSION"
docsdir="${docdir}/${program}-${version}"

# Custom source directory
srcdir=${program}-${version}

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --enable-widec \
     --enable-nls \
     --disable-rpath-hack \
     --build="$(gcc -dumpmachine)"

    make -j${jobs}
    make -j${jobs} DESTDIR="$destdir" install

    # Insert the look & feel for Dragora 3+.  ;-)

    mkdir -p "${destdir}/etc"
    cp -p "${worktree}/archive/dialog/dialogrc" "${destdir}/etc/"
    chmod 644 "${destdir}/etc/dialogrc"

    # To manage .new (config) files via graft(8)
    touch "${destdir}/etc/.graft-config"

    # Compress man page and copy the documentation

    lzip -9 "${destdir}/${mandir}/man1/dialog.1"

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

path: recipes/tools/dialog/recipe


code:
# Build recipe for diffutils.
#
# Copyright (c) 2016-2017 Matias Fonzo, <selk@dragora.org>.
# Copyright (c) 2019, 2021 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=diffutils
version=3.8
release=1

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/gnu/diffutils/$tarname

description="
Utilities to differentiate files.

The set of utilities contains GNU diff programs showing
the differences between files and directories.
"

homepage=https://www.gnu.org/software/diffutils
license=GPLv3+

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README* THANKS TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Remove generated charset.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"
    rmdir "${destdir}/usr/lib${libSuffix}" || true

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/diffutils/recipe


code:
# Build recipe for dosfstools.
#
# Copyright (c) 2019, 2021 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=dosfstools
version=4.2
release=1

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

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

# Remote source(s)
fetch=https://github.com/dosfstools/dosfstools/releases/download/v${version}/$tarname

description="
DOS filesystem tools.

The dosfstools package includes the mkdosfs (a.k.a. mkfs.dos and
mkfs.vfat) and dosfsck (a.k.a. fsck.msdos and fsck.vfat) utilities,
which respectively make and check MS-DOS FAT filesystems on hard
drives or on floppies.
"

homepage=https://github.com/dosfstools/dosfstools
license=GPLv3+

# Source documentation
docs="COPYING ChangeLog NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-compat-symlinks \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install-strip

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/dosfstools/recipe


code:
# Build recipe for dragora-installer.
#
# Copyright (c) 2019-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=dragora-installer
version=20220213
release=1

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

description="
Installer of Dragora GNU/Linux-Libre.

It contains the installer, help files and parts to perform
a complete installation of Dragora GNU/Linux-Libre.
"

homepage=https://www.dragora.org
license=GPLv3+

build()
{
    # Define package location according to supported architectures
    case $arch in
    amd64 | x32 )
        installer_arch=amd64
        ;;
    i586)
        installer_arch=i586
        ;;
    armhf)
        installer_arch=armhf
        ;;
    *)
        printf '%s\n' "" \
         "The Dragora installer will not be available for the architecture in" \
         "which it is being compiled.  This package will not be produced." \
         "Please contact the developers at <dragora-users@nongnu.org>." \
         "" 1>&2
        sleep 7
        return 0
        ;;
    esac

    mkdir -p "${destdir}"/usr/sbin \
             "${destdir}"/usr/libexec/dragora-installer

    cp -p "${worktree}"/archive/dragora-installer/dragora-installer \
          "${destdir}"/usr/sbin/

    cp -p "${worktree}"/archive/dragora-installer/parts/* \
          "${destdir}"/usr/libexec/dragora-installer/

    for file in "${destdir}"/usr/sbin/* \
                "${destdir}"/usr/libexec/dragora-installer/*
    do
        sed -e "s|@PARTS@|/usr/libexec/dragora-installer/|g" \
            -e "s|@ARCH@|${installer_arch}|g" \
            -i "$file"
    done
    unset -v file

    chmod 755 "${destdir}"/usr/sbin/dragora-installer
    chmod 644 "${destdir}"/usr/libexec/dragora-installer/*

    unset -v installer_arch
}

path: recipes/tools/dragora-installer/recipe


code:
# Build recipe for e2fsprogs.
#
# Copyright (c) 2016-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=e2fsprogs
version=1.46.5
release=1

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

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

# Remote source(s)
fetch=https://downloads.sourceforge.net/e2fsprogs/$tarname

description="
Ext2 file system utilities.

The e2fsprogs package contains the utilities for handling the ext2 file
system.  It also supports the ext3 and ext4 journaling file systems.
"

homepage=https://e2fsprogs.sourceforge.net
license="GPLv2+, LGPLv2, MIT-style licenses"

# Source documentation
docs="NOTICE README RELEASE-NOTES SUBMITTING-PATCHES"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS -O3" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-symlink-install \
     --enable-threads=posix \
     --enable-elf-shlibs \
     --disable-libblkid \
     --disable-libuuid \
     --disable-fsck \
     --disable-uuidd \
     --with-root-prefix=/usr \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1

    make -j${jobs} MKDIR_P="mkdir -p" DESTDIR="$destdir" install
    make -j${jobs} MKDIR_P="mkdir -p" DESTDIR="$destdir" install-libs

    # Remove generated charset.alias and generated locale.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias" \
          "${destdir}/usr/share/locale/locale.alias"

    # To handle config file(s)
    touch "${destdir}/etc/.graft-config"

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        # Decompress provided gzipped info file
        gzip -d "${destdir}/${infodir}/libext2fs.info.gz"

        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/* || true
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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


code:
# Build recipe for ed.
#
# Copyright (c) 2016-2017 Matias Fonzo, <selk@dragora.org>.
# Copyright (c) 2019-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=ed
version=1.18
release=2

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/gnu/ed/$tarname

description="
Unix standard text editor.

Ed is a line-oriented text editor.  It is used to create,
display, modify and otherwise manipulate text files.
"

homepage=https://www.gnu.org/software/ed
license=GPLv3+

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS+="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --infodir=$infodir \
     --mandir=$mandir \
     --build="$(gcc -dumpmachine)"

    make -j${jobs}
    make -j${jobs} check
    make -j${jobs} DESTDIR="$destdir" install

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/ed/recipe


code:
# Build recipe for espeak.
#
# Copyright (c) 2018 Thiago Seus, <thiago.seus@yahoo.com.br>.
# Copyright (c) 2020, 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=espeak
version=1.48.04
release=3

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

tarname=${program}-${version}-source.zip

# Remote source(s)
fetch="https://downloads.sourceforge.net/project/espeak/espeak/espeak-${version%.*}/$tarname"

description="
Speech Synthesizer.

eSpeak is a compact, multi-language, text-to-speech synthesizer.
"

homepage=https://espeak.sourceforge.net
license=GPLv3+

# Source documentation
docs="ChangeLog.txt License.txt ReadMe docs/"
docsdir="${docdir}/${program}-${version}"

# The package has a custom source directory
srcdir=${program}-${version}-source

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

    cd "$srcdir/src"

    # Use the PortAudio (sound interface library) version 19
    ln -sf portaudio19.h portaudio.h

    make -j${jobs} CXXFLAGS="$QICXXFLAGS -Wno-narrowing" LDFLAGS="$QILDFLAGS" \
     PREFIX=/usr LIBDIR=/usr/lib${libSuffix}

    make -j${jobs} PREFIX=/usr LIBDIR=/usr/lib${libSuffix} \
     DESTDIR="$destdir" install

    cd ..

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

    # Rename docs/ directory for the package
    mv "${destdir}/${docsdir}/docs" "${destdir}/${docsdir}/html"
}

path: recipes/tools/espeak/recipe


code:
# Build recipe for espeakup.
#
# Copyright (c) 2018 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=espeakup
version=0.80
release=1

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

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

# Remote source(s)
fetch=https://github.com/williamh/espeakup/archive/v${version}/$tarname

description="
eSpeakup connector.

espeakup is a program which makes it possible for speakup to use the
eSpeak software synthesizer.  It does this by reading speakup's
softsynth device and passing the text to espeak which actually speaks.
"

homepage=https://github.com/williamh/espeakup
license=GPLv3+

# Source documentation
docs="ChangeLog COPYING README TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # To support extra compilation/linker flags
    patch -p1 < "${worktree}/patches/espeakup/Makefile.diff"

    make -j${jobs} EXTRA_CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" EXTRA_LDFLAGS="$QILDFLAGS" \
     PREFIX=/usr MANDIR=$mandir

    make -j${jobs} PREFIX=/usr MANDIR=$mandir \
     DESTDIR="$destdir" install

    lzip -9 "${destdir}/${mandir}/man8/espeakup.8"

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

path: recipes/tools/espeakup/recipe


code:
# Build recipe for file.
#
# Copyright (c) 2016-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=file
version=5.41
release=1

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

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

# Remote source(s)
fetch=ftp://ftp.astron.com/pub/file/$tarname

description="
A file type guesser.

The file command is 'a file type guesser', that is, a command-line tool
that tells you in words what kind of data a file contains.
"

homepage=https://darwinsys.com/file
license=Custom

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README* RELEASE* TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --sysconfdir=/etc/file \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-fsect-man5 \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} check
    make -j${jobs} DESTDIR="$destdir" install

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/file/recipe


code:
# Build recipe for findutils.
#
# Copyright (c) 2016-2017 Matias Fonzo, <selk@dragora.org>.
# Copyright (c) 2019, 2021 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=findutils
version=4.8.0
release=1

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

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

# Remote source(s)
fetch=https://ftp.gnu.org/gnu/findutils/$tarname

description="
Utilities to find files.

The set of GNU find utilities contains tools to find files
such as exact name, creation date, size, permissions, etc.
"

homepage=https://www.gnu.org/software/findutils
license=GPLv3+

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README* THANKS TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --libexecdir=/usr/lib${libSuffix}/locate \
     --localstatedir=/var/lib/locate \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install

    # Remove locate implementation, replaced by mlocate
    rm -f "${destdir}/usr/bin/locate"             \
          "${destdir}/usr/bin/updatedb"           \
          "${destdir}/${mandir}/man1/locate.1"    \
          "${destdir}/${mandir}/man1/updatedb.1"  \
          "${destdir}/${mandir}/man5/locatedb.5"

    rm -rf "${destdir}/usr/lib${libSuffix}/locate" \
           "${destdir}/var/lib/locate"

    # Remove generated charset.alias
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"
    rmdir "${destdir}/usr/lib${libSuffix}" || true

    # Compress info documents deleting index file for the package
    if test -d "${destdir}/$infodir"
    then
        rm -f "${destdir}/${infodir}/dir"
        lzip -9 "${destdir}/${infodir}"/*
    fi

    # Compress and link man pages (if needed)
    if test -d "${destdir}/$mandir"
    then
        (
            cd "${destdir}/$mandir"
            find . -type f -exec lzip -9 {} +
            find . -type l | while read -r file
            do
                ln -sf "$(readlink -- "$file").lz" "${file}.lz"
                rm -- "$file"
            done
        )
    fi

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

path: recipes/tools/findutils/recipe