code:
# Build recipe for nss.
#
# 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=nss
version=3_74
pkgversion=$(echo $version | tr _ .)
release=1

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

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

# Remote source(s)
fetch=https://ftp.mozilla.org/pub/security/nss/releases/NSS_${version}_RTM/src/$tarname

description="
Network security services.

Network Security Services (NSS) is a set of libraries designed to
support cross-platform development of security-enabled client and
server applications.  Applications built with NSS can support
SSL v3, TLS, PKCS #5, PKCS #7, PKCS #11, PKCS #12, S/MIME,
X.509 v3 certificates, and other security standards.
"

homepage=https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS
license="MPL v2.0, GPLv2+"

# Source documentation
docs="COPYING readme.md"
docsdir="${docdir}/${program}-${pkgversion}"

# Set 'srcdir' using previous 'pkgversion' variable
srcdir=${program}-${pkgversion}

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

    cd "${srcdir}/nss"

    # Apply a patch for build thanks to "Beyond Linux From Scratch"
    patch -Np2 -i "${worktree}/patches/nss/nss-3.74-standalone-1.patch"

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

    # Set specific options for the architecture
    case $arch in
    amd64 | x32 )
        arch_options='USE_64=1'
        ;;
    i586)
        arch_options='USE_64=0'
        ;;
    esac

    unset -v CFLAGS CXXFLAGS

    make -j${jobs} BUILD_OPT=1 \
     NSS_DISABLE_GTESTS=1 \
     NSPR_INCLUDE_DIR=/usr/include/nspr \
     USE_SYSTEM_ZLIB=1 \
     ZLIB_LIBS=-lz \
     NSS_ENABLE_WERROR=0 \
     NSS_USE_SYSTEM_SQLITE=1 \
     $arch_options

    unset -v arch_options

    # Proceed to install the software files
    cd ../dist

    mkdir -v -p "${destdir}/usr/lib${libSuffix}" \
                "${destdir}/usr/include/nss" \
                "${destdir}/usr/bin" \
                "${destdir}/usr/lib${libSuffix}/pkgconfig"

    install -v -p -m755 Linux*/lib/*.so "${destdir}/usr/lib${libSuffix}"
    install -v -p -m644 Linux*/lib/*.chk "${destdir}/usr/lib${libSuffix}"
    install -v -p -m644 Linux*/lib/libcrmf.a "${destdir}/usr/lib${libSuffix}"

    cp -v -pRL public/nss/* "${destdir}/usr/include/nss"
    cp -v -pRL private/nss/* "${destdir}/usr/include/nss"
    chmod 644 "${destdir}"/usr/include/nss/*

    for file in certutil cmsutil crlutil derdump modutil pk12util pp \
                signtool signver ssltap vfychain vfyserv nss-config ; \
    do
        install -v -p -m755 Linux*/bin/${file} "${destdir}/usr/bin"
    done
    unset -v file

    install -v -p -m644 Linux*/lib/pkgconfig/nss.pc \
     "${destdir}/usr/lib${libSuffix}/pkgconfig"

    # 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 || true
    strip --strip-debug "${destdir}/usr/lib${libSuffix}"/*.a

    cd ../nss
    mkdir -v -p "${destdir}/${mandir}/man1"
    cp -v -p doc/nroff/*.1 "${destdir}/${mandir}/man1"
    chmod 644 "${destdir}/${mandir}"/man1/*

    # 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 -v -p "${destdir}/$docsdir"
    cp -v -p $docs "${destdir}/$docsdir"
}

path: recipes/networking/nss/recipe


code:
# Build recipe for openssh.
#
# Copyright (c) 2018-2019, 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=openssh
version=8.8p1
release=1

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

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

# Remote source(s)
fetch=https://ftp3.usa.openbsd.org/pub/OpenBSD/OpenSSH/portable/$tarname

description="
The OpenSSH suite.

OpenSSH is the premier connectivity tool for remote login with the
SSH protocol.  It encrypts all traffic to eliminate eavesdropping,
connection hijacking, and other attacks.  In addition, OpenSSH provides
a large suite of secure tunneling capabilities, several authentication
methods, and sophisticated configuration options.
"

homepage=https://www.openssh.com
license=Custom

# Source documentation
docs="CREDITS ChangeLog LICENCE OVERVIEW PROTOCOL* README* TODO"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # A patch from Dragora to include a missing header at md5crypt.c file
    patch -p1 < "${worktree}/patches/openssh/openssh-include-stdio.h.patch"

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" LIBS="-ledit" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --sysconfdir=/etc/ssh \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-strip \
     --with-default-path='/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin' \
     --with-privsep-path=/var/lib/sshd \
     --with-privsep-user=sshd \
     --with-pid-dir=/var/run/sshd \
     --with-md5-passwords \
     --with-pie \
     --without-zlib-version-check \
     --build="$(gcc -dumpmachine)"

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

    # Make empty directories for the package
    mkdir -p "${destdir}/var/run/sshd" "${destdir}/var/lib/sshd"

    # Copy additional utilities

    cp -p contrib/ssh-copy-id "${destdir}/usr/bin"
    chmod 755 "${destdir}/usr/bin/ssh-copy-id"

    mkdir -p "${destdir}/${mandir}/man1"
    cp -p contrib/ssh-copy-id.1 "${destdir}/${mandir}/man1"

    # Install sshd perp service(s)

    mkdir -p "${destdir}/etc/perp/sshd"

    cp -p "${worktree}/archive/openssh/rc.log" \
          "${worktree}/archive/openssh/rc.main" \
          "${destdir}/etc/perp/sshd/"

    chmod 755 "${destdir}"/etc/perp/sshd/rc.*

    # THIS SERVICE IS DISABLED BY DEFAULT
    chmod -t "${destdir}/etc/perp/sshd"

    # Manage (dot) new files via graft(1)
    touch "${destdir}/etc/ssh/.graft-config" \
          "${destdir}/etc/perp/sshd/.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"
}

repo_name: dustdfg/dragora

path: recipes/networking/openssh/recipe

license: mit


code:
# Build recipe for p11-kit.
#
# Copyright (c) 2018-2019, 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=p11-kit
version=0.24.1
release=1

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

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

# Remote source(s)
fetch=https://github.com/p11-glue/p11-kit/releases/download/${version}/$tarname

description="
Provides a way to load and enumerate PKCS#11 modules.

Provides a way to load and enumerate PKCS#11 modules.  Provides a
standard configuration setup for installing PKCS#11 modules in such a
way that they're discoverable.

Also solves problems with coordinating the use of PKCS#11 by different
components or libraries living in the same process.
"

homepage=https://p11-glue.github.io/p11-glue/p11-kit.html
license="BSD 3-clause"

# Source documentation
docs="AUTHORS CONTRIBUTING.md 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" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-debug=no \
     --disable-rpath \
     --with-trust-paths=/etc/pki/anchors \
     --without-systemd \
     --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 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"
}


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

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

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

# Remote source(s)
fetch=https://dianne.skoll.ca/projects/rp-pppoe/download/$tarname

description="
PPP over Ethernet (xDSL support).

PPPoE (Point-to-Point Protocol over Ethernet) is a protocol used by many
DSL Internet Service Providers. RP-PPPoE is a free PPPoE client, relay
and server for GNU/Linux.
"

homepage=https://dianne.skoll.ca/projects/rp-pppoe/
license=GPLv2+

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

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

    cd "$srcdir"

    # Apply a patch from "Alpine Linux"
    patch -Np1 -i "${worktree}/patches/rp-pppoe/musl-fix.patch"

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

    cd src

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

    make -j${jobs} V=1 PLUGIN_DIR="/usr/libexec/rp-pppoe" all rp-pppoe.so
    make -j${jobs} PLUGIN_DIR="/usr/libexec/rp-pppoe" DESTDIR="$destdir" install

    cd ..

    # To manage .new configs via graft(1)
    touch "${destdir}/etc/ppp/.graft-config"

    # Make happy tutorials that point this out
    ln -s pppoe-stop "${destdir}/usr/sbin/adsl-stop"
    ln -s pppoe-start "${destdir}/usr/sbin/adsl-start"
    ln -s pppoe-start.8 "${destdir}/${mandir}/man8/adsl-start.8"
    ln -s pppoe-stop.8 "${destdir}/${mandir}/man8/adsl-stop.8"

    # 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/networking/rp-pppoe/recipe


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

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

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

# Remote source(s)
fetch=https://download.samba.org/pub/rsync/src/$tarname

description="
A fast, versatile, remote (and local) file-copying tool.

Rsync is a fast and extraordinarily versatile file copying tool.
It can copy locally, to/from another host over any remote shell,
or to/from a remote rsync daemon.
"

homepage=https://rsync.samba.org
license=GPLv3+

# Source documentation
docs="COPYING NEWS.md README.md 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} \
     --mandir=$mandir \
     --enable-zstd \
     --disable-debug \
     --disable-xxhash \
     --disable-lz4 \
     --with-protected-args \
     --without-included-zlib \
     --without-included-popt \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" 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

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

path: recipes/networking/rsync/recipe


code:
# Build recipe for tcp_wrappers.
#
# Copyright (c) 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=tcp_wrappers
version=7.6
release=3

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

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

# Remote source(s)
fetch=http://ftp.porcupine.org/pub/security/$tarname

description="
Monitor of incoming TCP connections.

TCP Wrapper is a host-based Networking ACL system, used to
filter network access to Internet Protocol servers on
(Unix-like) operating systems such as Linux or BSD.

It allows host or subnetwork IP addresses, names and/or
ident query replies, to be used as tokens on which to
filter for access control purposes.
"

homepage=ftp://ftp.porcupine.org/pub/security/index.html
license=BSD

# Source documentation
docs="BLURB CHANGES DISCLAIMER README README.NIS"
docsdir="${docdir}/${program}-${version}"

# Source directory
srcdir=${program}_${version}

# Limit parallel jobs for the compiler to 1
jobs=1

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

    cd "$srcdir"

    # Refresh old source code plus security issues via patches

    # Apply patches from Debian (Thanks!)
    while read -r line
    do
        patch -p1 < "${worktree}/patches/tcp_wrappers/${line}"
    done < "${worktree}/patches/tcp_wrappers/series"

    # Apply extras patches from "musl development overlay" (Thanks to "Gentoo Linux")
    patch -p1 < "${worktree}/patches/tcp_wrappers/tcp-wrappers-7.6.22-remove-DECLS.patch"
    patch -p1 < "${worktree}/patches/tcp_wrappers/tcp-wrappers-7.6-redhat-bug11881.patch"
    patch -p1 < "${worktree}/patches/tcp_wrappers/0001-Remove-fgets-extern-declaration.patch"

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

    make -j${jobs} COPTS="$QICFLAGS" LDOPTS="$QILDFLAGS" \
     STYLE="-DPROCESS_OPTIONS" REAL_DAEMON_DIR=/usr/sbin musl

    # Install manually

    mkdir -p "${destdir}/usr/include" \
     "${destdir}/usr/sbin" "${destdir}/usr/lib${libSuffix}"

    for file in safe_finger tcpd tcpdchk tcpdmatch try-from
    do
        cp -p $file "${destdir}/usr/sbin/"
        chmod 755   "${destdir}/usr/sbin/${file}"
    done
    unset -v file

    cp -p libwrap.a "${destdir}/usr/lib${libSuffix}/"
    chmod 644 "${destdir}/usr/lib${libSuffix}/libwrap.a"

    cp -p tcpd.h "${destdir}/usr/include/"
    chmod 644 "${destdir}/usr/include/tcpd.h"

    mkdir -p "${destdir}${mandir}/man3" \
     "${destdir}${mandir}/man5" "${destdir}${mandir}/man8"
    lzip -9c < hosts_access.3   > "${destdir}${mandir}/man3/hosts_access.3.lz"
    lzip -9c < hosts_access.5   > "${destdir}${mandir}/man5/hosts_access.5.lz"
    lzip -9c < hosts_options.5  > "${destdir}${mandir}/man5/hosts_options.5.lz"
    lzip -9c < tcpd.8           > "${destdir}${mandir}/man8/tcpd.8.lz"
    lzip -9c < tcpdchk.8        > "${destdir}${mandir}/man8/tcpdchk.8.lz"
    lzip -9c < tcpdmatch.8      > "${destdir}${mandir}/man8/tcpdmatch.8.lz"

    # 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 || true

    strip --strip-debug "${destdir}/usr/lib${libSuffix}/libwrap.a"

    # Copy local config files
    mkdir -p "${destdir}/etc"
    cp -p "${worktree}/archive/tcp_wrappers/etc/hosts.allow" "${destdir}/etc/"
    cp -p "${worktree}/archive/tcp_wrappers/etc/hosts.deny" "${destdir}/etc/"
    chmod 644 "${destdir}/etc/hosts.allow" "${destdir}/etc/hosts.deny"
    touch "${destdir}/etc/.graft-config"

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


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

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

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

# Remote source(s)
fetch=https://www.tcpdump.org/release/$tarname

description="
Dump traffic on a network.

tcpdump is a utility to dump the traffic on a network.

For more information, type \`man tcpdump'.
"

homepage=https://www.tcpdump.org
license=BSD

# Source documentation
docs="CHANGES CONTRIBUTING CREDITS LICENSE README.md VERSION"
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} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --with-crypto=yes \
     --with-cap-ng=yes \
     --with-system-libpcap \
     --build="$(gcc -dumpmachine)"

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

    # Replace hard link with a soft link

    if test -e "${destdir}/usr/sbin/tcpdump.${version}"
    then
        rm -f "${destdir}/usr/sbin/tcpdump"
        ln -s tcpdump.${version} "${destdir}/usr/sbin/tcpdump"
    fi

    # Compress and copy documentation

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

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

path: recipes/networking/tcpdump/recipe


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

path: recipes/networking/weechat/post-install


code:
# Build recipe for weechat.
#
# 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=weechat
version=3.4
release=1

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

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

# Remote source(s)
fetch=https://weechat.org/files/src/$tarname

homepage=https://weechat.org
license=GPLv3+

description="
WeeChat is a fast, light and extensible chat client.

WeeChat (Wee Enhanced Environment for Chat) is a free chat client,
fast and light, designed for many operating systems.  It is highly
customizable and extensible with scripts.

For more information, visit: $homepage
"

# 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

    # Note about NLS: it does not work with gettex-tiny, currently.

    cmake \
     -DCMAKE_C_FLAGS:STRING="$QICFLAGS"      \
     -DCMAKE_CXX_FLAGS:STRING="$QICXXFLAGS"  \
     -DCMAKE_EXE_LINKER_FLAGS:STRING="$QILDFLAGS"    \
     -DCMAKE_INSTALL_PREFIX=/usr                     \
     -DCMAKE_BUILD_TYPE=Release                      \
     -DCMAKE_VERBOSE_MAKEFILE=ON                     \
     -DCMAKE_SKIP_INSTALL_RPATH=YES                  \
     -DLIBDIR=/usr/lib${libSuffix}                   \
     -DENABLE_NLS=ON                                 \
     -DENABLE_JAVASCRIPT=OFF                         \
     -DENABLE_ENCHANT=OFF                            \
     -DENABLE_PHP=OFF                                \
     -DENABLE_MAN=ON                                 \
     -DENABLE_DOC=ON                                 \
     -G Ninja ..

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

    # Move generated documentation directory, if enabled

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

    if test -d "${destdir}/usr/share/doc/weechat"
    then
        for file in "${destdir}/usr/share/doc/weechat"/*
        do
            mv -f -- "$file" "${destdir}/$docsdir"
        done
        unset -v file
        rm -rf "${destdir}/usr/share/doc/weechat"
    fi

    cd ..

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

    # 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
}

path: recipes/networking/weechat/recipe


code:
# Build recipe for wget.
#
# Copyright (c) 2017-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=wget
version=1.21.2
release=2

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

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

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

description="
The non-interactive network downloader.

GNU Wget is a free software package for retrieving files using HTTP,
HTTPS, FTP and FTPS the most widely-used Internet protocols.  It is a
non-interactive commandline tool, so it may easily be called from
scripts, cron jobs, terminals without X-Windows support, etc.
"

homepage=https://www.gnu.org/software/wget
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" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --with-ssl=gnutls \
     --with-metalink \
     --build="$(gcc -dumpmachine)"

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

    # To handle config file on post-installation
    touch "${destdir}/etc/.graft-config"

    # 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/networking/wget/recipe


code:
# Build recipe for wget2.
#
# 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=wget2
version=2.0.0
release=3

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

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

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

description="
The non-interactive network downloader (version 2).

GNU Wget2 is the successor of GNU Wget, a file and recursive website
downloader.  Designed and written from scratch it wraps around libwget,
that provides the basic functions needed by a web client.

Wget2 works multi-threaded and uses many features to allow fast operation.

In many cases Wget2 downloads much faster than Wget1.x due to HTTP2,
HTTP compression, parallel connections and use of If-Modified-Since
HTTP header.
"

homepage=https://www.gnu.org/software/wget
license="GPLv3+, LGPLv3+"

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

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

    cd "$srcdir"

    # https://lists.gnu.org/archive/html/bug-wget/2021-09/msg00023.html
    patch -Np0 -i "${worktree}/patches/wget2/lzlib-link.patch"

    # 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} \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-static=no \
     --enable-shared=yes \
     --with-ssl=gnutls \
     --with-gpgme-prefix=/usr \
     --without-included-regex \
     --with-zlib \
     --with-lzip \
     --with-bzip2 \
     --with-lzma \
     --with-zstd \
     --without-brotlidec \
     --build="$(gcc -dumpmachine)"

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

    # This binary is the same as the main binary "wget2"
    rm "${destdir}/usr/bin/wget2_noinstall"

    # 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"
}


code:
# Build recipe for wireless_tools.
#
# 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=wireless_tools
version=30.pre9
release=1

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

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

# Remote source(s)
fetch=https://hewlettpackard.github.io/wireless-tools/$tarname

description="
Tools for Wireless extension.

The wireless tools package is a set of tools allowing manipulation of
the Wireless Extensions.  They use a textual interface to support the
full Wireless Extension.
"

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

# Custom source directory
srcdir="${program}.${version%.*}"

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

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

    cd "$srcdir"

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

    make -j${jobs} \
     BUILD_STRIPPING=y \
     PREFIX="${destdir}/usr" \
     INSTALL_MAN="${destdir}/$mandir" \
     INSTALL_LIB="${destdir}/usr/lib${libSuffix}" \
     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

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


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

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

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

# Remote source(s)
fetch=https://w1.fi/releases/$tarname

description="
IEEE 802.1X/WPA supplicant wireless client.

wpa_supplicant is a WPA Supplicant for Linux, BSD, Mac OS X, and
Windows with support for WPA and WPA2 (IEEE 802.11i / RSN).  It is
suitable for both desktop/laptop computers and embedded systems.

Supplicant is the IEEE 802.1X/WPA component that is used in the client
stations.  It implements key negotiation with a WPA Authenticator and
it controls the roaming and IEEE 802.11 authentication/association of
the WLAN driver.
"

homepage=https://w1.fi/wpa_supplicant/
license=BSD

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

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

    cd "$srcdir"

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

    cd wpa_supplicant
    cat "${worktree}/archive/wpa_supplicant/buildconfig" > .config
    make -j${jobs} V=1 BINDIR=/usr/sbin
    make -j${jobs} V=1 BINDIR=/usr/sbin DESTDIR="$destdir" install

    strip --strip-unneeded "${destdir}"/usr/sbin/*

    # Copy template config as main config, and also include the example

    mkdir -p "${destdir}/etc"
    cp -p wpa_supplicant_template.conf "${destdir}/etc/wpa_supplicant.conf"
    cp -p wpa_supplicant.conf "${destdir}/etc/wpa_supplicant-sample.conf"
    chmod 644 "${destdir}/etc"/*.conf
    chown root:root "${destdir}/etc"/*.conf

    # Install D-Bus configuration

    mkdir -p "${destdir}/usr/share/dbus-1/system-services"
    for file in dbus/*.service
    do
        cp -p $file "${destdir}/usr/share/dbus-1/system-services/"
        chmod 644 "${destdir}/usr/share/dbus-1/system-services/${file##*/}"
    done
    chown root:root "${destdir}"/usr/share/dbus-1/system-services/*

    mkdir -p "${destdir}/etc/dbus-1/system.d"
    cp -p dbus/dbus-wpa_supplicant.conf "${destdir}/etc/dbus-1/system.d/"
    chmod 644 "${destdir}/etc/dbus-1/system.d/dbus-wpa_supplicant.conf"
    chown root:root "${destdir}/etc/dbus-1/system.d/dbus-wpa_supplicant.conf"

    # To manage dot (new) files via graft(1)

    touch "${destdir}/etc/.graft-config" \
          "${destdir}/etc/dbus-1/system.d/.graft-config"

    # Install (missing) manpages

    mkdir -p "${destdir}/${mandir}/man8" "${destdir}/${mandir}/man5"
    (
        cd doc/docbook || exit 1;
        for page in *.8
        do
            lzip -9c < $page > "${destdir}/${mandir}/man8/${page}.lz"
        done
        rm -f "${destdir}/${mandir}/man8/wpa_gui.8.lz"

        lzip -9c < wpa_supplicant.conf.5 \
         > "${destdir}/${mandir}/man5/wpa_supplicant.conf.5.lz"
    )

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


code:
# Build recipe for perl.
#
# 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=perl
pkgname=perl5
version=5.32.1
release=1

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

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

# Remote source(s)
fetch=https://www.cpan.org/src/5.0/$tarname

description="
Practical Extraction and Report Language (version $version).

Perl 5 is a highly capable, feature-rich programming language with over
29 years of development.  Perl 5 runs on over 100 platforms from
portables to mainframes and is suitable for both rapid prototyping
and large scale development projects.

Perl is a language that combines some of the features of C,
sed, awk, and the shell.

For more information, visit:  https://www.perl.org
"

homepage=https://www.perl.org
license="Artistic | GPLv1"

# Source documentation
docs="AUTHORS Artistic Changes Copying README README.linux"
docsdir="${docdir}/${pkgname}"

# Limit parallel jobs to '1' due to perl-cross-static
jobs=1

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

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

    cd "$srcdir"

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

    ./Configure -de \
     -Dprefix=/usr \
     -Dinstallprefix=/usr \
     -Dsiteprefix=/usr/local \
     -Dprivlib=/usr/share/perl5 \
     -Darchlib=/usr/lib${libSuffix}/perl5 \
     -Dsitelib=/usr/local/share/perl5 \
     -Dsitearch=/usr/local/lib${libSuffix}/perl5 \
     -Dvendorprefix=/usr \
     -Dvendorlib=/usr/share/perl5/vendor_perl \
     -Dvendorarch=/usr/lib${libSuffix}/perl5/vendor_perl \
     -Dlibpth="/usr/local/lib${libSuffix} /usr/lib${libSuffix} /lib${libSuffix}" \
     -Dscriptdir=/usr/bin \
     -Duseshrplib \
     -Dusethreads \
     -Ubincompat5005 \
     -Uversiononly \
     -Duselargefiles \
     -Dusemymalloc=n \
     -Dldflags="$QILDFLAGS" \
     -Doptimize="$QICFLAGS" \
     -Dman1dir="${mandir}/man1" \
     -Dman3dir="${mandir}/man3" \
     -Dpager="/usr/bin/less -isR" \
     BUILD_ZLIB="False" BUILD_BZIP2="0"

    make -j${jobs} BUILD_ZLIB="False" BUILD_BZIP2="0"
    make -j${jobs} DESTDIR="$destdir" install

    # 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 || true

    find "$destdir" -type f | xargs file | awk '/current ar archive/' | \
     cut -f 1 -d : | xargs strip --strip-debug 2> /dev/null || 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"
}


code:
# Build recipe for sgmlspm.
#
# 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=SGMLSpm
version=1.1
release=2

pkgname=perl-sgmlspm

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

description="
A class for postprocessing the output of sgmls and nsgmls parsers.

SGMLS.PM is a Perl5 class library for the use with the SGMLS and
NSGMLS parsers.
"

homepage=https://metacpan.org/release/RAAB/SGMLSpm-1.1
license=GPLv2+

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/R/RA/RAAB/$tarname

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

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

    cd "$srcdir"

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

    perl Makefile.PL INSTALLDIRS=vendor

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

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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/perl/sgmlspm/recipe


code:
# Build recipe for uri.
#
# Copyright (c) 2018-2019, 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=URI
version=5.10
release=1

pkgname=perl-uri

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

description="
Uniform Resource Identifiers.

This module implements the URI class.  Objects of this class represent
\"Uniform Resource Identifier references\" as specified in RFC 2396
(and updated by RFC 2732).
"

homepage=https://metacpan.org/release/URI
license="The Perl 5 License"

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/O/OA/OALDERS/$tarname

# Source documentation
docs="CONTRIBUTING.md Changes LICENSE"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    perl Makefile.PL INSTALLDIRS=vendor

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

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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/perl/uri/recipe


code:
# Build recipe for xml-namespacesupport.
#
# 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=XML-NamespaceSupport
version=1.12
release=2

pkgname=perl-xml-namespacesupport

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

description="
A simple generic namespace processor.

This module offers a simple way to process namespaced XML names
(unames) from within any application that may need them.

It also helps maintain a prefix to namespace URI map, and provides
a number of basic checks.
"

homepage=https://search.cpan.org/dist/XML-NamespaceSupport
license="GPLv1+ | Artistic License"

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/P/PE/PERIGRIN/$tarname

# Source documentation
docs="Changes LICENSE README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    perl Makefile.PL INSTALLDIRS=vendor

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

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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 xml-parser.
#
# Copyright (c) 2017 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
# Copyright (c) 2017, 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=XML-Parser
version=2.46
release=2

pkgname=perl-xml-parser

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

description="
A perl module for parsing XML documents.

This is a Perl interface to the expat library.
"

homepage=https://search.cpan.org/~toddr/XML-Parser/
license="The Perl 5 License"

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/T/TO/TODDR/$tarname

# Source documentation
docs="Changes README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    perl Makefile.PL INSTALLDIRS=vendor

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

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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/perl/xml-parser/recipe


code:
# Build recipe for xml-sax-base.
#
# 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=XML-SAX-Base
version=1.09
release=1

pkgname=perl-xml-sax-base

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

description="
Base class SAX drivers and filters.

XML::SAX::Base is intended for use as a base class for SAX filter
modules and XML parsers generating SAX events.

If you simply wish to build a SAX handler class to 'consume' SAX events
you do not need to use XML::SAX::Base directly although you will need
to install XML::SAX.

This module used to be distributed as part of the XML:SAX distribution
but is now distributed separately and referenced as a dependency by
XML::SAX.
"

homepage=https://metacpan.org/release/XML-SAX-Base
license="The Perl 5 License"

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/G/GR/GRANTM/$tarname

# Source documentation
docs="Changes README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    perl Makefile.PL INSTALLDIRS=vendor

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

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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/perl/xml-sax-base/recipe


code:
# Determine location of Perl module

sax=$(perl -MXML::SAX -le 'print $INC{"XML/SAX.pm"}' 2> /dev/null) && \
sax="${sax%%.pm}/ParserDetails.ini"

# Set up the ParserDetails.ini file, if needed
echo "Setting init file, adding entries (if needed) ..."

if ! fgrep -qs -m1 "[XML::SAX::Expat]" "$sax"
then
    echo "$sax ..."
    printf "%s\n" \
     "[XML::SAX::Expat]" \
     "http://xml.org/sax/features/external-general-entities = 1" \
     "http://xml.org/sax/features/external-parameter-entities = 1" \
     "http://xml.org/sax/features/namespaces = 1" \
     "" >> $sax
fi
unset sax

path: recipes/perl/xml-sax-expat/post-install


code:
# Build recipe for xml-sax-expat.
#
# 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=XML-SAX-Expat
version=0.51
release=2

pkgname=perl-xml-sax-expat

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

description="
SAX2 driver for Expat (XML::Parser).

XML::SAX::Expat is an implementation of a SAX2 driver sitting on top of
Expat (XML::Parser).
"

homepage=https://metacpan.org/release/XML-SAX-Expat
license="The Perl 5 License"

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/B/BJ/BJOERN/$tarname

# Source documentation
docs="Changes README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    perl Makefile.PL INSTALLDIRS=vendor

    make -j${jobs} pure_install doc_install DESTDIR="$destdir"

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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/perl/xml-sax-expat/recipe


code:
# Determine location of Perl module

sax=$(perl -MXML::SAX -le 'print $INC{"XML/SAX.pm"}' 2> /dev/null) && \
sax="${sax%%.pm}/ParserDetails.ini"

# Set up the ParserDetails.ini file, if needed
echo "Setting init file, adding entries (if needed) ..."

if ! fgrep -qs -m1 "[XML::SAX::PurePerl]" "$sax"
then
    echo "$sax ..."
    printf "%s\n" \
     "[XML::SAX::PurePerl]" \
     "http://xml.org/sax/features/namespaces = 1" \
     "" >> $sax
fi
unset sax

path: recipes/perl/xml-sax/post-install


code:
# Build recipe for xml-sax.
#
# 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=XML-SAX
version=1.02
release=2

pkgname=perl-xml-sax

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

description="
Simple API for XML.

XML::SAX consists of several framework classes for using and building
Perl SAX2 XML parsers, filters, and drivers. It is designed around the
need to be able to \"plug in\" different SAX parsers to an application
without requiring programmer intervention. Those of you familiar with
the DBI will be right at home. Some of the designs come from the Java
JAXP specification (SAX part), only without the javaness.
"

homepage=https://search.cpan.org/dist/XML-SAX
license="GPLv1+ | Artistic License"

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/G/GR/GRANTM/$tarname

# Source documentation
docs="Changes LICENSE README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    yes | perl Makefile.PL INSTALLDIRS=vendor

    make -j${jobs} V=1 PERLLIB=blib/lib
    make -j${jobs} PERLLIB=blib/lib DESTDIR="$destdir" install

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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/perl/xml-sax/recipe


code:
# Build recipe for xml-simple.
#
# 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=XML-Simple
version=2.25
release=2

pkgname=perl-xml-simple

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

description="
An API for simple XML files.

XML::Simple provides an easy API to read and write XML (especially
config files).  It is deprecated and its use is discouraged.
"

homepage=https://metacpan.org/release/XML-Simple
license="GPLv1+ | Artistic License"

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

# Remote source(s)
fetch=https://cpan.metacpan.org/authors/id/G/GR/GRANTM/$tarname

# Source documentation
docs="Changes LICENSE README"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    perl Makefile.PL INSTALLDIRS=vendor

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

    # 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 || true

    # Clean up inventory file for Perl

    # This line removes 'destdir' adding the suffix '.lz' for manpages
    find "${destdir}/" -type f -name '.packlist' | while read -r file
    do
         sed -i \
          -e "s|${destdir}||g" \
          -e "s|\.[0-9][a-z]*|&.lz|g" \
          $file
    done

    find "${destdir}/" -type f -name 'perllocal.pod' -exec rm -f {} +

    # Compress manual pages
    if [ -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/perl/xml-simple/recipe


code:
# Build recipe for dbus-python.
#
# Copyright (C) 2020-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=dbus-python
version=1.2.18
release=1

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

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

# Remote source(s)
fetch=https://dbus.freedesktop.org/releases/${program}/$tarname

description="
Python bindings for D-Bus.

dbus_python provides Python bindings to the D-Bus API interface.
"

homepage=https://www.freedesktop.org/wiki/Software/DBusBindings
license="MIT Expat variant"

docs="AUTHORS CONTRIBUTING.md COPYING ChangeLog NEWS PKG-INFO 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 python3-build
    mkdir python3-build
    cd python3-build
    ../configure PYTHON=/usr/bin/python3 \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --enable-static=no \
     --enable-shared=yes \
     --docdir=$docsdir
    make -j${jobs} V=1
    cd ..
    make -j${jobs} V=1 -C python3-build DESTDIR="$destdir" install

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

path: recipes/python/dbus-python/recipe


code:
# Build recipe for mako.
#
# 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=Mako
version=1.1.6
release=1

pkgname=python-${program}

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

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

# Remote source(s)
fetch=https://files.pythonhosted.org/packages/af/b6/42cd322ae555aa770d49e31b8c5c28a243ba1bbb57ad927e1a5f5b064811/$tarname

description="
Mako is a template library written in Python.

It provides a familiar, non-XML syntax which compiles into Python
modules for maximum performance.  Mako's syntax and API borrows
from the best ideas of many others, including Django and
Jinja2templates, Cheetah, Myghty, and Genshi.  Conceptually,
Mako is an embedded Python (i.e. Python Server Page) language,
which refines the familiar ideas of componentized layout and
inheritance to produce one of the most straightforward and
flexible models available, while also maintaining close ties
to Python calling and scoping semantics.

The package name is called \"pymako\" in order to avoid possible
conflicts with another package name.
"

homepage=https://www.makotemplates.org
license=MIT

docs="AUTHORS CHANGES LICENSE PKG-INFO README.rst"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    python3 setup.py build
    python3 setup.py install --prefix=/usr --root="$destdir" --optimize=1

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

path: recipes/python/mako/recipe


code:
# Build recipe for markupsafe.
#
# 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=MarkupSafe
version=2.0.1
release=1

pkgname=python-${program}

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

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

# Remote source(s)
fetch=https://files.pythonhosted.org/packages/bf/10/ff66fea6d1788c458663a84d88787bae15d45daa16f6b3ef33322a51fc7e/$tarname

description="
A Python module that implements a XML/HTML/XHTML Markup safe string.

MarkupSafe implements a text object that escapes characters so it is
safe to use in HTML and XML.  Characters that have special meanings
are replaced so that they display as the actual characters.  This
mitigates injection attacks, meaning untrusted user input can safely
be displayed on a page.  Escaping is implemented in C so it is as
efficient as possible.
"

homepage=https://palletsprojects.com/p/markupsafe
license="BSD License (BSD-3-Clause)"

docs="CHANGES* LICENSE* PKG-INFO README*"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    python3 setup.py build
    python3 setup.py install --prefix=/usr --root="$destdir" --optimize=1

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

path: recipes/python/markupsafe/recipe


code:
# Build recipe for python3.
#
# Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
# 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=Python
version=3.10.2
short_version="${version%.*}"
release=1

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

# Define a custom package name
pkgname=python3

# The name of the tarball
tarname=${program}-${version}.tgz

# Remote source(s)
fetch=https://www.python.org/ftp/python/${version}/$tarname

description="
Multi-paradigm programming language (v3).

Python is an interpreted, interactive object-oriented programming
language suitable (amongst other uses) for distributed application
development, scripting, numeric computing and system testing.

Python is often compared to Tcl, Perl, Java, JavaScript, Visual
Basic or Scheme.
"

homepage=https://www.python.org/
license="Python Software Foundation License"

# Source documentation
docs="LICENSE README.rst"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    # Use system libraries instead of the bundle ones
    rm -rf Modules/expat Modules/zlib Modules/_ctypes/libffi*

    ./configure $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --build="$(gcc -dumpmachine)" \
     --enable-shared \
     --enable-loadable-sqlite-extensions \
     --enable-ipv6 \
     --enable-optimizations \
     --with-system-expat \
     --with-system-ffi \
     --with-ensurepip=yes \
     --with-dbmliborder=gdbm:ndbm \
     --build="$(gcc -dumpmachine)"

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

    # Make default symlink to invoke it as "python"
    ( cd "${destdir}/usr/bin" && ln -sf python3 python )

    # Include the Python tools under site-packages
    TOOL_DIR=/usr/lib/python${short_version}
    (
        cd Tools || exit 2

        # Do not clobber README file in site-packages directory
        test -f README && mv -f README README.Tools

        cp -rP ./* "${destdir}${TOOL_DIR}/"
    )

    # Make some useful symlinks at usr/bin
    (
        cd "${destdir}/usr/bin" || exit 2

        ln -sf "${TOOL_DIR}/i18n/msgfmt.py" msgfmt.py
        ln -sf "${TOOL_DIR}/i18n/pygettext.py" pygettext.py
        ln -sf "${TOOL_DIR}/pynche/pynche" pynche
    )
    unset -v short_version TOOL_DIR

    # 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 setuptools.
#
# 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=setuptools
version=60.5.0
release=1

pkgname=python-${program}

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

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

# Remote source(s)
fetch=https://files.pythonhosted.org/packages/69/77/aee1ecacea4d0db740046ce1785e81d16c4b1755af50eceac4ca1a1f8bfd/$tarname

description="
Easily build and distribute Python packages.

Setuptools is a fully-featured, actively-maintained, and stable library
designed to facilitate packaging Python projects, where packaging
includes:

- Python package and module definitions
- Distribution package metadata
- Test hooks
- Project installation
- Platform-specific details
- Python 3 support

For more information, see https://setuptools.readthedocs.io/en/latest/
"

homepage=https://pypi.org/project/setuptools/
license=MIT

docs="CHANGES* LICENSE* PKG-INFO README*"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    python3 setup.py build
    python3 setup.py install --prefix=/usr --root="$destdir" --optimize=1

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

path: recipes/python/setuptools/recipe


code:
# Build recipe for six.
#
# Copyright (C) 2018, MMPG <mmpg@vp.pl>
# Copyright (C) 2018-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=six
version=1.16.0
release=1

pkgname=python-${program}

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

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

# Remote source(s)
fetch=https://files.pythonhosted.org/packages/71/39/171f1c67cd00715f190ba0b100d606d440a28c93c7714febeca8b79af85e/$tarname

description="
A Python 2 and 3 compatibility library.

It provides utility functions for smoothing over the differences
between the Python versions with the goal of writing Python code
that is compatible on both Python versions.
"

homepage=https://github.com/benjaminp/six
license=MIT

docs="CHANGES LICENSE PKG-INFO README.rst"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    python3 setup.py build
    python3 setup.py install --prefix=/usr --root="$destdir" --optimize=1

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

path: recipes/python/six/recipe


code:
# Build recipe for asciidoctor.
#
# Copyright (C) 2019, 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=asciidoctor
version=2.0.17
pkgname=ruby-${program}
release=1

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

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

# Remote source(s)
fetch=https://rubygems.org/downloads/$tarname

description="
Asciidoctor is a fast, open source text processor.

It converts AsciiDoc content to HTML5, DocBook, PDF, and other formats.
Asciidoctor is written in Ruby and runs on all major operating systems.
"

homepage=https://asciidoctor.org
license=MIT

build()
{
    # Figure out directory for Ruby Gems
    _gemdir="$(ruby -W0 -e 'puts Gem.default_dir')"

    if test -z "_$gemdir"
    then
        echo "recipe: Error: the _gemdir variable is empty." 1>&2
        exit 1
    fi

    mkdir -p "${destdir}/${_gemdir}" "${destdir}/usr/bin"

    gem install \
     --ignore-dependencies \
     --no-user-install \
     --backtrace --verbose \
     --install-dir "${destdir}/${_gemdir}" \
     --bindir "${destdir}/usr/bin" \
     "${tardir}/$tarname"
}

path: recipes/ruby/asciidoctor/recipe


code:
# Build recipe for pygments.
#
# 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=pygments
version=2.3.0
pkgname=ruby-${program}
release=1

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

tarname=${program}.rb-${version}.gem

# Remote source(s)
fetch=https://rubygems.org/downloads/$tarname

description="
A Ruby wrapper for Pygments syntax highlighter.

pygments.rb is a Ruby wrapper for Pygments syntax highlighter.
"

homepage=https://github.com/pygments/pygments.rb
license=MIT

build()
{
    # Figure out directory for Ruby Gems
    _gemdir="$(ruby -W0 -e 'puts Gem.default_dir')"

    if test -z "_$gemdir"
    then
        echo "recipe: Error: the _gemdir variable is empty." 1>&2
        exit 1
    fi

    mkdir -p "${destdir}/${_gemdir}" "${destdir}/usr/bin"

    gem install \
     --ignore-dependencies \
     --no-user-install \
     --backtrace --verbose \
     --install-dir "${destdir}/${_gemdir}" \
     --bindir "${destdir}/usr/bin" \
     "${tardir}/$tarname"
}

path: recipes/ruby/pygments/recipe


code:
# Build recipe for ruby.
#
# Copyright (c) 2019, 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=ruby
version=3.0.3
pkgname=ruby3
release=1

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

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

# Remote source(s)
fetch="https://cache.ruby-lang.org/pub/ruby/${version%.*}/$tarname"

description="
Ruby programming language.

Ruby is a dynamic, open source programming language with a focus
on simplicity and productivity.  It has an elegant syntax that is
natural to read and easy to write.
"

homepage=https://www.ruby-lang.org
license="GPLv2+ | BSD + Custom declared files (see LEGAL)"

# Source documentation
docs="
  BSDL CONTRIBUTING.md COPYING* ChangeLog GPL KNOWNBUGS.rb
  LEGAL NEWS.md README*
"
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

    # Apply patches from "Alpine Linux"
    patch -Np1 -i "${worktree}/patches/ruby/test_insns-lower-recursion-depth.patch"
    patch -Np1 -i "${worktree}/patches/ruby/fix-get_main_stack.patch"
    patch -Np1 -i "${worktree}/patches/ruby/dont-install-bundled-gems.patch"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS -D_GNU_SOURCE -fno-omit-frame-pointer -fno-strict-aliasing" \
    CFLAGS="$QICFLAGS -fno-omit-frame-pointer -fno-strict-aliasing" \
    CXXFLAGS="$QICXXFLAGS -fno-omit-frame-pointer -fno-strict-aliasing" \
    LDFLAGS="$QILDFLAGS" INSTALL="install" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-shared \
     --enable-ipv6 \
     --enable-load-relative \
     --with-mantype=man \
     --with-sitedir=/usr/local/share/ruby \
     --with-sitearchdir=/usr/local/lib${libSuffix}/ruby \
     --without-compress-debug-sections \
     --disable-rpath \
     --build="$(gcc -dumpmachine)" \
     ac_cv_func_isnan=yes \
     ac_cv_func_isinf=yes

    make -j${jobs} V=1 optflags="-O3"
    make -j${jobs} DESTDIR="$destdir" 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

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


code:
libs/ncurses
libs/readline


code:
# Build recipe for GNU bash.
#
# Copyright (c) 2016-2019, 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=bash
version=5.1
release=4

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

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

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

description="
The Bourne Again SHell (version $version).

Bash is an sh-compatible shell that incorporates useful features from
the Korn shell (ksh) and C shell (csh).  It is intended to conform to
the IEEE POSIX P1003.2/ISO 9945.2 shell and tools standard.

It offers functional improvements over sh for both programming and
interactive use.
"

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

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

# Source documentation
docsdir="${docdir}/${program}"

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

    cd "$srcdir"

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

    # Apply patches from upstream
    for file in "${worktree}"/patches/bash/bash51-???*
    do
        if test -f "$file"
        then
            patch -Np0 -i "$file"
        fi
    done

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static-link \
     --with-installed-readline \
     --without-bash-malloc \
     --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
}

path: recipes/shells/bash/recipe


code:
# Build recipe for mksh (and lksh).
#
# Copyright (c) 2017-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=mksh
version=R59c
release=3

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

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

# Remote source(s)
fetch=https://www.mirbsd.org/MirOS/dist/mir/mksh/$tarname

description="
The MirBSD Korn Shell (version $version).

mksh is the MirBSD enhanced version of the Public Domain Korn shell
(pdksh), a Bourne-compatible shell which is largely similar to the
original AT&T Korn shell; mksh is the only pdksh derivate currently
being actively developed.  It includes bug fixes and feature
improvements, in order to produce a modern, robust shell good for
interactive and especially script use.
"

homepage=https://www.mirbsd.org/mksh.htm
license="The MirOS Licence, ISC, special terms for use the BSD daemon mascot"

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

# Source documentation
docsdir="${docdir}/${program}"

# Source directory name
srcdir=mksh

build()
{
    # Create package structure
    mkdir -p "${destdir}/etc/skel" \
             "${destdir}/usr/bin"  \
             "${destdir}/${mandir}/man1"

    unpack "${tardir}/$tarname"

    cd "$srcdir"

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

    # Create a separate build directory
    mkdir mksh-build lksh-build

    # Build and install mksh

    cd mksh-build
    (
        # Build and ignore tests for now in this version of mksh-r57
        # (../mksh/check.t:xxx-stat-1 needs further work)
        #sh ../Build.sh -r && ./test.sh

        env CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
            LDFLAGS="$QILDFLAGS" LDSTATIC=-static \
        sh ../Build.sh -r
    )

    cp -p mksh "${destdir}/usr/bin/"
    chmod 755 "${destdir}/usr/bin/mksh"

    #cp -p ../${srcdir}/dot.mkshrc "${destdir}/etc/skel/.mkshrc"
    cp -p "${archive}/etc/skel/.mkshrc" "${destdir}/etc/skel/"
    chmod 644 "${destdir}/etc/skel/.mkshrc"

    # To manage (dot new) config file
    touch "${destdir}/etc/skel/.graft-config"

    cd ..

    cp -p mksh.1 "${destdir}/${mandir}/man1/"
    chmod 644 "${destdir}/${mandir}/man1/mksh.1"

    # Build and install lksh (legacy)

    cd lksh-build
    (
        # Build and ignore tests for now in this version of mksh-r57
        # (../mksh/check.t:xxx-stat-1 needs further work)
        #sh ../Build.sh -L -r && ./test.sh

        env CPPFLAGS="$QICPPFLAGS -DMKSH_BINSHPOSIX" \
            CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" LDSTATIC=-static \
        sh ../Build.sh -L -r
    )

    cp -p lksh "${destdir}/usr/bin/"
    chmod 755 "${destdir}/usr/bin/lksh"

    cd ..

    cp -p lksh.1 "${destdir}/${mandir}/man1/"
    chmod 644 "${destdir}/${mandir}/man1/lksh.1"

    # Make symlink to compose the default shell
    ( cd "${destdir}/usr/bin" && ln -sf lksh sh )

    # Compress manual pages
    if test -d "${destdir}/$mandir"
    then
        lzip -9 "${destdir}/${mandir}"/man?/*
    fi

    # Build and copy documentation
    sh FAQ2HTML.sh
    mkdir -p "${destdir}/$docsdir"
    cp -p FAQ.htm "${destdir}/$docsdir"
}

path: recipes/shells/mksh/recipe


code:
tqt3:

    - CUPS support.

    - NAS support.

avahi-tqt:

    - This requires avahi (common).

tdelibs:

    - Enable CUPS support.

tdeutils:

    - Option '-DWITH_SNMP=' depends on the netsnmp package.

    - Option 'DBUILD_KSIM=' is OFF by default, it does not compile
      with (current) tdeutils version 14.0.10.  Build error.

path: recipes/tde/TODO


code:
# Build recipe for avahi-tqt.
#
# Copyright (c) 2020-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=avahi-tqt-trinity
pkgname=avahi-tqt
version=14.0.11
release=1

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

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

# Remote source(s)
fetch=https://mirror.ppa.trinitydesktop.org/trinity/releases/R${version}/main/dependencies/$tarname

description="
"

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

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README"
docsdir="${docdir}/${pkgname}-${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_CXX_FLAGS_RELEASE:STRING="$QICXXFLAGS"   \
     -DCMAKE_SHARED_LINKER_FLAGS:STRING="$QILDFLAGS"  \
     -DCMAKE_INSTALL_PREFIX=/opt/trinity              \
     -DLIB_SUFFIX=${libSuffix}                        \
     -DCMAKE_VERBOSE_MAKEFILE=ON                      \
     -DCMAKE_BUILD_TYPE=Release                       \
     -DCMAKE_SKIP_INSTALL_RPATH=YES                   \
     -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/avahi-tqt/recipe


code:
# Build recipe for cmake (trinity).
#
# 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=tde-common-cmake
pkgname=cmake-trinity
version=20220128_0560f24
arch=noarch
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="
A common dependency for build TDE r14.0.11+.
"

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

# Custom source directory name
srcdir=${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 -G Ninja ..

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

path: recipes/tde/cmake-trinity/recipe


code:
# Build recipe for dbus-1-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-1-tqt
version=20220503_face487
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="
A backport of Harald Fernengel's Qt4 D-Bus bindings.

Some Qt4 based code had no direct equivalent in Qt3. Cases where this
transition to Qt3 might not be fully correct are marked with FIXME-QT4

Depending on the use case it might be necessary to extend QDBusMesssage
to allow marshalling/de-marshalling based on an application provided
helper as the Qt3 QVariant can not handle all cases the Qt4 pendant can
(user defined types, etc).
"

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

# Source documentation
docs="AUTHORS COPYING* ChangeLog NEWS 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_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                            \
     -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"
}