code:
# Build recipe for popt.
#
# Copyright (C) 2017 Alan Beadle, ab.beadle@gmail.com.
# Copyright (c) 2018-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=popt
version=1.18
release=1

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

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

# Remote source(s)
fetch="
  https://ftp.rpm.org/popt/releases/popt-1.x/$tarname
  ftp://anduin.linuxfromscratch.org/BLFS/popt/$tarname
"

description="
Popt is a C library for parsing command line parameters.

Popt was heavily influenced by the getopt() and getopt_long()
functions, but it improves on them by allowing more powerful
argument expansion.
"

homepage=https://rpm5.org
license="MIT X Consortium"

# Source documentation
docs="CHANGES COPYING 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} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=yes \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1 libdir=/usr/lib${libSuffix} \
                       pkgconfigdir=/usr/lib${libSuffix}/pkgconfig

    make -j${jobs} libdir=/usr/lib${libSuffix} \
                   pkgconfigdir=/usr/lib${libSuffix}/pkgconfig \
                   DESTDIR="${destdir}" install-strip

    # Compress man pages
    lzip -9 "${destdir}/${mandir}"/man?/*

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

path: recipes/libs/popt/recipe


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

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

tarname=pa_stable_${version}.tgz

# Remote source(s)
fetch=http://www.portaudio.com/archives/$tarname

description="
Portable real-time audio library.

PortAudio is a free, cross-platform, open-source , audio I/O library.
It lets you write simple audio programs in C or C++ that will compile
and run on many platforms.
"

homepage=https://www.portaudio.com
license=BSD

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

# The package has a custom source directory
srcdir=portaudio

# Limit parallel jobs for this build
jobs=1

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

    cd "$srcdir"

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

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

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

    # Strip remaining libraries
    strip --strip-unneeded \
     "${destdir}/usr/lib${libSuffix}"/*.so.?.* 2> /dev/null || true
    strip --strip-debug \
     "${destdir}/usr/lib${libSuffix}"/*.a 2> /dev/null || true

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

repo_name: dustdfg/dragora

path: recipes/libs/portaudio/recipe

license: mit


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

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

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

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

description="
A library with line-editing capabilities.

GNU readline is a software library created and maintained by the
GNU Project.  It is licensed under the GPL, and used in projects
such as GNU bash.  It provides line-editing capabilities.
"

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

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

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/readline/readline81-???*
    do
        if test -f "$file"
        then
            patch -Np0 -i "$file"
        fi
    done

    # To avoid underlink against -lncursesw
    patch -Np1 -i "${worktree}/patches/readline/readline-ncurses-link.patch"

    # Reinstalling Readline will cause the old libraries to be moved to
    # <libraryname>.old, this avoid printing a harmful message about
    # the static libraries (thanks to LFS)
    sed -i '/MV.*old/d' Makefile.in
    sed -i '/{OLDSUFF}/c:' support/shlib-install

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

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

    # Copy our custom inputrc file
    mkdir -p "${destdir}/etc"
    cp -p "${worktree}/archive/readline/etc/inputrc" "${destdir}/etc/"
    chmod 644 "${destdir}/etc/inputrc"

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

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

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

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

path: recipes/libs/readline/recipe


code:
# Build recipe for tiff.
#
# Copyright (C) 2018, 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=tiff
version=4.3.0
release=2

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

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

# Remote source(s)
fetch=https://download.osgeo.org/libtiff/$tarname

description="
TIFF library and utilities.

The tiff package contains the TIFF libraries and associated utilities.
The libraries are used by many programs for reading and writing TIFF
files and the utilities are useful for general work with TIFF files.
"

homepage=https://www.simplesystems.org/libtiff/
license=Custom

# Source documentation (already copied by the build system)
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" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=yes \
     --enable-shared=yes \
     --enable-cxx \
     --enable-zstd \
     --enable-lzma \
     --build="$(gcc -dumpmachine)"

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

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

path: recipes/libs/tiff/recipe


code:
# Build recipe for tslib.
#
# Copyright (c) 2017 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
# Copyright (c) 2017-2019, 2021 Matias Fonzo, <mprodrigues@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=tslib
version=1.22
release=1

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

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

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

description="
Touchscreen access library.

tslib consists of the library libts and tools that help you calibrate
and use it in your environment.
"

homepage=https://github.com/kergoth/tslib
license=LGPLv2.1

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README* THANKS"
docsdir="${docdir}/${pkgname}-${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} \
     --docdir=$docsdir \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-static=no \
     --enable-shared=yes \
     --build="$(gcc -dumpmachine)"

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

    # Handle config via graft(1)
    touch "${destdir}/etc/.graft-config"

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

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

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

path: recipes/libs/tslib/recipe


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

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

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

# Remote source(s)
fetch=https://zlib.net/$tarname

description="
A data compression library.

Zlib is a software library used for data compression.  Zlib was written
by Jean-loup Gailly and Mark Adler.  And is an abstraction of the
deflate compression algorithm used in their gzip file compression
program.
"

homepage=https://zlib.net
license="Custom, zlib"

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

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

    cd "$srcdir"

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

    ./configure \
     --prefix=/usr \
     --libdir=/usr/lib${libSuffix} \
     --shared

    make -j${jobs} CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS"
    make -j${jobs} DESTDIR="$destdir" install

    # Compress man pages
    lzip -9 "${destdir}/${mandir}"/man?/*.?

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

path: recipes/libs/zlib/recipe


code:
# Build recipe for lua.
#
# Copyright (C) 2020 Kevin "The Nuclear" Bloom, <kevin.bloom@posteo.net>.
# 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=lua
version=5.4.3
short_version="${version%.*}"
release=1

# Set custom package name to avoid conflicts on package upgrades
pkgname="lua${short_version%.*}"

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

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

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

description="
A lightweight programming language designed for extending applications.

Lua is a powerful, efficient, lightweight, embeddable scripting language.
It supports procedural programming, object-oriented programming, functional
programming, data-driven programming, and data description.
"

homepage=https://www.lua.org/
license="MIT License"

# Source documentation
docs="doc/*.html doc/*.css doc/*.gif doc/*.png"
docsdir="${docdir}/${pkgname}-${version}"

_make_target()
{
    make -j${jobs} \
     MYCFLAGS="$QICFLAGS -DLUA_COMPAT_5_2 -DLUA_COMPAT_5_1 -fPIC" \
     MYLDFLAGS="$QILDFLAGS" \
     INSTALL_LIB="${destdir}/usr/lib${libSuffix}" \
     INSTALL_LMOD="${destdir}/usr/share/lua/${short_version}" \
     INSTALL_CMOD="${destdir}/usr/lib${libSuffix}/lua/${short_version}" \
     INSTALL_DATA="cp -d" \
     INSTALL_MAN="${destdir}/${mandir}/man1" \
     INSTALL_TOP="${destdir}/usr" "$@"
}

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

    cd "$srcdir"

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

    patch -Np1 -i "${worktree}/patches/lua/lua-5.4.2-shared_library-1.patch"

    # Adjust Lua search path
    sed -e 's#/usr/local/#/usr/#' \
        -e "s#lib/lua#lib${libSuffix}/lua#" \
        -i src/luaconf.h

    _make_target linux
    _make_target install

    # Now build the shared library

    make clean

    _make_target TO_LIB="liblua.so liblua.so.${short_version} liblua.so.${version}" linux
    _make_target TO_LIB="liblua.so liblua.so.${short_version} liblua.so.${version}" install

    unset -v make_target

    # 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

    # Install a pkg-config file
    mkdir -p "${destdir}/usr/lib${libSuffix}/pkgconfig"
    cat << EOF > "${destdir}/usr/lib${libSuffix}/pkgconfig/lua.pc"
prefix=/usr
INSTALL_BIN=\${prefix}/bin
INSTALL_INC=\${prefix}/include
INSTALL_LIB=\${prefix}/lib
INSTALL_MAN=\${prefix}/share/man/man1
INSTALL_LMOD=\${prefix}/share/lua/${short_version}
INSTALL_CMOD=\${prefix}/lib${libSuffix}/lua/${short_version}
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib${libSuffix}
includedir=\${prefix}/include

Name: Lua
Description: An Extensible Extension Language
Version: ${version}
Requires:
Libs: -L\${libdir} -llua -lm -ldl
Cflags: -I\${includedir}
EOF

    unset -v short_version

    # Compress manual page(s)
    lzip -9 "${destdir}/${mandir}"/man1/*

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


code:
# Build recipe for luarocks.
#
# Copyright (C) 2020 Kevin "The Nuclear" Bloom, <kevin.bloom@posteo.net>.
# 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=luarocks
version=3.8.0
arch=noarch
release=1

# Define major version for Lua release
lua_version=5.4

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

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

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

description="
The package manager for Lua modules.

Luarocks allows you to create and install Lua modules
as self-contained packages called \"rocks\".
"

homepage=https://luarocks.org/
license="MIT License"

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

# Limit parallel jobs for this build
jobs=1

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

    cd "$srcdir"

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

    ./configure \
     --prefix=/usr \
     --with-lua=/usr \
     --with-lua-lib=/usr/lib${libSuffix} \
     --sysconfdir=/etc \
     --lua-version=${lua_version}

    make -j${jobs}
    make -j${jobs} DESTDIR="$destdir" install
    mkdir -p "${destdir}/usr/lib${libSuffix}/luarocks/rocks-${lua_version}"

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

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

path: recipes/lua/luarocks/recipe


code:
# Build recipe for man-pages (POSIX).
#
# Copyright (c) 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=man-pages-posix
version=2017-a
arch=noarch
release=1

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/linux/docs/man-pages/man-pages-posix/$tarname

description="
POSIX.1-2017 manual pages.

This package contains the POSIX.1-2017 man pages (pages in sections
except 0p, 1p, and 3p).  Some more information is given in the
\`Announce' file.  Some background on UNIX standards, including
POSIX, can be found in the standards(7) page provided as part of
the separate \"man-pages\" package.
"

homepage=https://www.kernel.org/doc/man-pages/index.html
license=Custom

# Source documentation
docs="*.Announce POSIX-COPYRIGHT README"
docsdir="${docdir}/${program}-${version}"

# The source has a custom directory
srcdir="${program}-${version%-*}"

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

    cd "$srcdir"

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

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

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

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

path: recipes/manuals/man-pages-posix/recipe


code:
# Build recipe for man-pages.
#
# 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=man-pages
version=5.13
arch=noarch
release=1

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

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

# Remote source(s)
fetch=https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/snapshot/$tarname

description="
Linux man pages Sections 2, 3, 4, 5, and 7.

This package contains Linux man pages for sections 1 through 8.  Some
more information is given in the \"man-pages-${version}.Announce\" file.
"

homepage=https://www.kernel.org/doc/man-pages/index.html
license=Custom

# Source documentation
docs="CONTRIBUTING Changes MAINTAINER_NOTES README *.Announce *.lsm"
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} prefix=/usr DESTDIR="$destdir" install

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

    # Do not include manual pages that belong to
    # other packages, which are considered newer

    echo ""
    echo "Searching for manual pages included in other packages ..."
    echo ""
    for file in "${mandir}"/man?/*
    do
        if test -f "${destdir}/$file"
        then
            echo "Removing pre-existing manual page: $file"
            echo "    Already included from $(realpath $file)."
            echo ""
            rm "${destdir}/$file"
        fi
    done
    unset -v file

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

path: recipes/manuals/man-pages/recipe


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

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

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

# Remote source(s)
fetch=https://alpine.x10host.com/alpine/release/src/$tarname

homepage=https://alpine.x10host.com/

description="
Alpine messaging system.

Alpine is an Alternatively Licensed Program for Internet News & Email,
is a tool for reading, sending, and managing electronic messages.
Alpine is the successor to Pine and was developed until 2008 by
Computing & Communications at the University of Washington.  Though
originally designed for inexperienced email users, Alpine supports many
advanced features, and an ever-growing number of configuration and
personal-preference options.

Alpine is maintained by Eduardo Chappa at $homepage
"

license="Apache License version 2"

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

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

    cd "$srcdir"

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

    touch imap/ip6
    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --without-krb5 \
     --with-interactive-spellcheck=aspell \
     --enable-quotas \
     --enable-debug=no

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

    # Make symlink to invoke alpine as "pine" :-)
    ln -s alpine "${destdir}/usr/bin/pine"

    # Build and install additional utilities
    (
        cd imap/mlock || exit 1
        mkdir -p "${destdir}/usr/sbin"
        make -j${jobs} V=1 CFLAGS="$QICFLAGS"
        chgrp mail mlock
        chmod 3711 mlock
        cp -p mlock "${destdir}/usr/sbin"
        strip --strip-unneeded "${destdir}/usr/sbin/mlock"
    )

    # 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/alpine/recipe


code:
echo "Refreshing SSL certificate database ..."
chroot "$rootdir" usr/sbin/update-ca-certificates --fresh > /dev/null 2>&1

# Re-create symlink for cert.pem

(
    rm -f etc/ssl/cert.pem
    cd etc/ssl && ln -sf certs/ca-certificates.crt cert.pem
)


code:
# Build recipe for ca-certificates (a version from Alpine Linux).
#
# 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=ca-certificates
version=20220111_d12d01b
release=1

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

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="
Common CA certificates PEM files.

This package comes from the CA certificates version found in
\"Alpine Linux\".
"

homepage=https://git.alpinelinux.org/cgit/ca-certificates/
license="GPLv2+ | MPLv2.0"

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

# Limit parallel jobs for this build
jobs=1

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

    cd "$srcdir"

    # Add updated source file with the included root certificates
    # https://hg.mozilla.org/mozilla-central/raw-file/tip/security/nss/lib/ckfw/builtins/certdata.txt
    cat "${worktree}/archive/ca-certificates/certdata.txt" > certdata.txt

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

    make -j${jobs} V=1
    make -j${jobs} V=1 DESTDIR="$destdir" install
    strip --strip-unneeded \
     "${destdir}/usr/bin/c_rehash" \
     "${destdir}/usr/sbin/update-ca-certificates"

    # Clean up broken symlinks, if any
    find "$destdir" -print | while read -r file
    do
        if test -L "$file" && test ! -e "$file"
        then
            echo "Deleting dangling symlink: $file"
            rm -f -- "$file"
        fi
    done

    mkdir -p "${destdir}"/etc/ca-certificates/update.d

    # To populate config file
    (
        echo "# Automatically generated by $full_pkgname"
        cd "${destdir}/usr/share/ca-certificates"
        find . -name '*.crt' | sort | cut -b3-
    ) > "${destdir}/etc/ca-certificates.conf"

    # Generate the bundle in similar way as update-ca-certificates would do
    find . -name '*.crt' | sort | while read -r file
    do
	cat -- "$file"
        echo ""
    done > "${destdir}/etc/ssl/certs/ca-certificates.crt"

    # Make run-parts script

cat << "EOF" > "${destdir}/etc/ca-certificates/update.d/certhash"
#! /bin/sh -
exec /usr/bin/c_rehash /etc/ssl/certs

EOF
    chmod 755 "${destdir}/etc/ca-certificates/update.d/certhash"

    # 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 connman.
#
# 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=connman
version=1.40
release=1

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/linux/network/connman/$tarname

description="
A connection manager.

ConnMan is a daemon for managing Internet connections within embedded
device and integrates a vast range of communication features usually
split between many daemons such as DHCP, DNS and NTP.  The result of
this consolidation is low memory consumption with a fast, coherent,
synchronized reaction to changing network conditions.
"

homepage=https://01.org/connman
license=GPLv2+

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

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

    cd "$srcdir"

    # A patch to compile under Musl (Thanks to "Alpine Linux")
    patch -Np1 -i "${worktree}/patches/connman/libresolv.patch"

    autoreconf -vif

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-pie \
     --enable-iwd \
     --disable-wispr \
     --disable-wireguard \
     --with-firewall=iptables \
     --with-dns-backend=internal \
     --build="$(gcc -dumpmachine)"

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

    # Install perp service for CONNMAN

    mkdir -p "${destdir}/etc/perp/connmand" \
             "${destdir}/var/lib/connman"

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

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

    # Be an active service by default
    chmod +t "${destdir}/etc/perp/connmand"

    # Insert configuration file from source
    mkdir -p "${destdir}/etc/connman"
    cp -p src/main.conf "${destdir}/etc/connman"/
    chmod 644 "${destdir}/etc/connman/main.conf"

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

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

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

path: recipes/networking/connman/recipe


code: networking/ca-certificates


code:
# Build recipe for curl.
#
# Copyright (c) 2018 Mateus P. Rodrigues, <mprodrigues@dragora.org>.
# Copyright (c) 2018-2019, 2021-2022 Matias A. 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=curl
version=7.81.0
release=1

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

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

# Remote source(s)
fetch=https://curl.haxx.se/download/$tarname

description="
Command line tool and library for transferring data with URLs.

cURL is a powerful command line tool for transferring data supporting
various protocolos, including DICT, FILE, FTP, FTPS, Gopher, HTTP,
HTTPS, IMAP, IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP,
SMB, SMBS, SMTP, SMTPS, Telnet and TFTP.
"

homepage=https://curl.haxx.se/
license="Custom MIT/X derivate"

# Source documentation
docs="CHANGES COPYING README RELEASE-NOTES"
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 \
     --enable-static=no \
     --enable-shared=yes \
     --enable-ipv6 \
     --enable-pthreads \
     --enable-threaded-resolver \
     --with-ca-path=/etc/ssl/certs \
     --with-ca-bundle=/etc/ssl/cert.pem \
     --with-libssh2 \
     --with-openssl \
     --build="$(gcc -dumpmachine)"

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

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

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

path: recipes/networking/curl/recipe


code:
# Build recipe for dhcpcd.
#
# Copyright (c) 2017 MMPG, <mmpg@vp.pl>.
# 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=dhcpcd
version=9.4.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://roy.marples.name/downloads/dhcpcd/$tarname

description="
dhcpcd is an implementation of the DHCP client specified in RFC2131.

A DHCP client is useful for connecting your computer to a network
which uses DHCP to assign network addresses. dhcpcd strives to be
a fully featured, yet very lightweight DHCP client.
"

homepage=https://roy.marples.name/projects/dhcpcd
license="2-clause BSD"

# Source documentation
docs="LICENSE README.md"
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} \
     --libexecdir=/usr/libexec/dhcpcd \
     --dbdir=/var/lib/dhcpcd \
     --build="$(gcc -dumpmachine)"

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

    # Install dhcpcd perp service(s)

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

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

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

    # Disable default service in favor of connmand
    chmod -t "${destdir}/etc/perp/dhcpcd"

    # Manage (dot) new files via graft(1)

    touch "${destdir}/etc/.graft-config" \
          "${destdir}/etc/perp/dhcpcd/.graft-config"

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

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

path: recipes/networking/dhcpcd/recipe


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

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/software/network/ethtool/$tarname

description="
Utility for controlling network drivers and hardware.

It can be used to:

Get identification and diagnostic information.
Get extended device statistics.
Control speed, duplex, autonegotiation and flow control (Ethernet).
Control checksum offload and other hardware offload features.
Control DMA ring sizes and interrupt moderation.
Control receive queue selection for multiqueue devices.
Upgrade firmware in flash memory.
"

homepage=https://mirrors.edge.kernel.org/pub/software/network/ethtool/
license=GPLv2+

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

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

    cd "$srcdir"

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

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

    make -j${jobs} V=1
    make -j${jobs} V=1 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/ethtool/recipe


code:
libs/nettle
libs/libunistring


code:
# Build recipe for gnutls.
#
# Copyright (c) 2018 Markus Tornow, <tornow@riseup.net>.
# 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=gnutls
version=3.7.3
release=1

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

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

# Remote source(s)
fetch=https://www.gnupg.org/ftp/gcrypt/gnutls/v3.6/"$tarname"

description="
The GnuTLS Transport Layer Security Library.

GnuTLS is a secure communications library implementing the SSL, TLS and
DTLS protocols and technologies around them.  It provides a simple C
language application programming  interface (API) to access the secure
communications protocols as well as APIs to parse and write X.509,
PKCS #12, and other required structures.

The project strives to provide a secure communications back-end, simple
to use and integrated with the rest of the base Linux libraries.  A
back-end designed to work and be secure out of the box, keeping the TLS
and PKI complexity outside the applications.
"

homepage=https://gnutls.org/
license="LGPLv2+, GPLv3+, GFDL1.3"

# Source documentation
docs="AUTHORS CONTRIBUTING.md ChangeLog LICENSE NEWS README.md THANKS"
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" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --libdir=/usr/lib${libSuffix} \
    --infodir=$infodir \
    --mandir=$mandir \
    --docdir=$docsdir \
    --htmldir=${docsdir}/html \
    --enable-static=no \
    --enable-threads=posix \
    --enable-guile \
    --with-p11-kit \
    --without-included-libtasn1 \
    --without-included-unistring \
    --build="$(gcc -dumpmachine)"

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

    # Move wrong installed .png files to the HTML location
    mv "${destdir}/$infodir"/*.png "${destdir}/${docsdir}/html"

    # 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/gnutls/recipe


code:
# Build recipe for hldig.
#
# 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=hldig
version=20210616_9427c9cd
release=2

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

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

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

homepage=https://github.com/solbu/hldig

description="
Internet search engine software (fork of htdig).

The ht://Dig system is a complete world wide web indexing and searching
system for a domain or intranet.  This system is not meant to replace
the need for powerful internet-wide search systems like Lycos, Infoseek,
Google and AltaVista.  Instead it is meant to cover the search needs for
a single company, campus, or even a particular sub section of a web site.
As opposed to some WAIS-based or web-server based search engines,
ht://Dig can easily span several web servers.  The type of these different
web servers doesn't matter as long as they understand common protocols
like HTTP.

ht://Dig was developed at San Diego State University as a way to search
the various web servers on the campus network.

hl://Dig is a fork of ht://Dig, a world-wide-web search system for an
intranet or small internet.  See:

$homepage
"

license=GPLv2+

# Source documentation
docs="AUTHORS.md CONDUCT.md CONTRIBUTING.md COPYING ChangeLog \
 ChangeLog.md README.md STATUS TESTING.md TRANSLATING.md VERSION"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    #autoreconf -v
    #rm -f libhtdigphp/config.log libhtdigphp/config.status

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS -std=c++14" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --with-gnu-ld \
     --with-cgi-bin-dir=/usr/lib${libSuffix}/cgi-bin \
     --with-search-dir=/usr/share/doc/${program}-${version}/examples \
     --with-image-dir=/var/lib/hldig/www \
     --with-config-dir=/etc/hldig \
     --with-common-dir=/etc/hldig \
     --with-database-dir=/var/lib/hldig \
     --build="$(gcc -dumpmachine)"

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

    # Make symlink at usr/bin for hlsearch(1)
    (
        cd "${destdir}/usr/bin"
        ln -sf /usr/lib${libSuffix}/cgi-bin/hlsearch .
    )

    # Make symlinks for compatibility with htdig commands
    (
        cd "${destdir}/usr/bin"
        for name in hl*
        do
            name="${name#hl}"
            ln -sf hl${name} ht${name}
        done
    )

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

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

    # Compress manual pages, copy the documentation

    lzip -9 "${destdir}/${mandir}"/man?/*.?

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

path: recipes/networking/hldig/recipe


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

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

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

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

description="
A collection of common network programs.

The inetutils package contains programs for basic networking.
"

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

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

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

    cd "$srcdir"

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

    # Note about `--disable-logger':
    # A better version is provided by the util-linux package

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-servers \
     --enable-ncurses \
     --enable-whois \
     --disable-syslogd \
     --disable-logger \
     --disable-rexec \
     --with-wrap \
     --build="$(gcc -dumpmachine)"

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

    # Delete bogus file
    rm -f "${destdir}/usr/lib${libSuffix}/charset.alias"
    rmdir "${destdir}/usr/lib${libSuffix}" || true

    # Install inetd perp service

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

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

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

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

    # Copy config file for inetd(8)
    cp -p "${worktree}/archive/inetutils/etc/inetd.conf" "${destdir}/etc/"
    chmod 644 "${destdir}/etc/inetd.conf"

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

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

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

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

path: recipes/networking/inetutils/recipe


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

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/linux/utils/net/iproute2/$tarname

description="
Collection of utilities for controlling TCP/IP.

iproute2 is a collection of utilities for controlling
TCP/IP networking and traffic control in GNU/Linux.
"

homepage=https://wiki.linuxfoundation.org/networking/iproute2
license=GPLv2+

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

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

    cd "$srcdir"

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

    # To disable building two modules that requires iptables
    # (Thanks to Linux From Scratch!)
    sed -i 's/.m_ipt.o//' tc/Makefile

    ./configure

    make -j${jobs} V=1 CCOPTS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
      SBINDIR=/usr/sbin \
      LIBDIR=/usr/lib${libSuffix} \
      DOCDIR=$docsdir \
      MANDIR=$mandir \
      DESTDIR="$destdir" install

    # Manage config file(s)
    touch "${destdir}/etc/iproute2/.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"
}


code:
libs/libmnl
libs/libnftnl
libs/libpcap


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

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

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

# Remote source(s)
fetch=https://www.netfilter.org/projects/iptables/files/$tarname

description="
The main firewall program in GNU/Linux.

iptables is the userspace command line program used to configure the
Linux 2.4.x and later packet filtering ruleset.  It is targeted towards
system administrators.

Since Network Address Translation is also configured from the packet
filter ruleset, iptables is used for this, too.

The iptables package also includes ip6tables. ip6tables is used for
configuring the IPv6 packet filter.
"

homepage=https://www.netfilter.org/projects/iptables/index.html
license="GPLv2 only"

# Source documentation
docs="COMMIT_NOTES COPYING INCOMPATIBILITIES"
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 -D_GNU_SOURCE" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --docdir=$docsdir \
     --mandir=$mandir \
     --enable-devel \
     --enable-libipq \
     --enable-bpf-compiler \
     --enable-nfsynproxy \
     --with-xt-lock-name=/var/lock/xtables.lock \
     --without-kernel \
     --build="$(gcc -dumpmachine)"

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

    # Manage dot new config file
    touch "${destdir}/etc/.graft-config"

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

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

path: recipes/networking/iptables/recipe


code:
devel/pkgconf
libs/glib2
networking/libressl
perl/perl5
libs/ncurses


code:
# Build recipe for irssi.
#
# Copyright (c) 2017, MMPG <mmpg@vp.pl>.
# Copyright (c) 2017-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=irssi
version=1.2.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://github.com/irssi/irssi/releases/download/${version}/$tarname

description="
A chat client for the console.

Irssi is an Internet Relay Chat client.  Designed to be both secure
and expandable, irssi is easily customized using modules and scripts.
"

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

# Source documentation
docs="AUTHORS COPYING NEWS 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" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-true-color \
     --with-proxy \
     --with-socks \
     --with-bot \
     --with-perl=vendor \
     --build="$(gcc -dumpmachine)"

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

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

    # Compress man page
    lzip -9 "${destdir}/${mandir}/man1/irssi.1"

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

path: recipes/networking/irssi/recipe


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

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/software/network/iw/$tarname

description="
nl80211 userspace tool.

iw is a new nl80211 based CLI configuration utility for wireless
devices.  It supports all new drivers that have been added to the
kernel recently.  The old tool iwconfig, which uses Wireless
Extensions interface, is deprecated and it's strongly recommended to
switch to iw and nl80211.
"

homepage=https://wireless.wiki.kernel.org/en/users/documentation/iw
license=Custom

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

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

    cd "$srcdir"

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

    # To install uncompressed manual pages
    # (Thanks to "Beyond Linux From Scratch")
    sed -i "/INSTALL.*gz/s/.gz//" Makefile

    sed -i "s#-O2 -g#${QICFLAGS}#" Makefile
    make -j${jobs} V=1 \
      SBINDIR=/usr/sbin \
      MANDIR=$mandir \
      DESTDIR="$destdir" install

    strip --strip-unneeded "${destdir}/usr/sbin/iw"
    lzip -9 "${destdir}/${mandir}/man8/iw.8"

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

path: recipes/networking/iw/recipe


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

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

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

# Remote source(s)
fetch=https://mirrors.edge.kernel.org/pub/linux/network/wireless/$tarname

description="
Wireless daemon for GNU/Linux.

The daemon and utilities for controlling and configuring the Wi-Fi
network hardware.
"

homepage=https://git.kernel.org/pub/scm/network/wireless/iwd.git/
license=LGPLv2+

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-pie \
     --enable-wired \
     --enable-hwsim \
     --enable-tools \
     --enable-ofono \
     --disable-systemd-service \
     --build="$(gcc -dumpmachine)"

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

    mkdir -p \
     "${destdir}/var/lib/iwd" \
     "${destdir}/var/lib/ead"

    # 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/iwd/recipe


code:
# Build recipe for libmnl.
#
# Copyright (c) 2017 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=libmnl
version=1.0.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://www.netfilter.org/projects/libmnl/files/$tarname

description="
libmnl is a minimalistic library oriented to Netlink developers.

There are a lot of common tasks in parsing, validating, constructing
of both the Netlink header and TLVs that are repetitive and easy to
get wrong.  This library aims to provide simple helpers that allows
you to re-use code and to avoid re-inventing the wheel.
"

homepage=https://www.netfilter.org/projects/libmnl
license=LGPLv2.1

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

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

    cd "$srcdir"

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

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

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

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

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

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

    for file in $docs
    do
        cp -p $file "${destdir}/$docsdir"
    done
}

path: recipes/networking/libmnl/recipe


code:
# Build recipe for libnfntl.
#
# 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=libnftnl
version=1.2.1
release=1

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

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

# Remote source(s)
fetch=https://netfilter.org/projects/libnftnl/files/$tarname

description="
A library providing a low-level netlink interface.

The library libnftnl has been previously known as libnftables.

This library is currently used by nftables.
"

homepage=https://netfilter.org/projects/libnftnl/
license=GPLv2+

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

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

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

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

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

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

path: recipes/networking/libnftnl/recipe


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

pkgname=libnl3

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

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

# Remote source(s)
fetch=https://github.com/thom311/libnl/releases/download/libnl3_5_0/$tarname

description="
Netlink protocol library suite.

The libnl suite is a collection of libraries providing APIs to netlink
protocol based Linux kernel interfaces.

Netlink is a IPC mechanism primarly between the kernel and user space
processes.  It was designed to be a more flexible successor to ioctl
to provide mainly networking related kernel configuration and
monitoring interfaces.
"

homepage=https://www.infradead.org/~tgr/libnl/
license=LGPLv2.1

# Source documentation
docs="COPYING ChangeLog"
docsdir="${docdir}/${pkgname}-${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} \
     --docdir=$docsdir \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-static=yes \
     --enable-shared=yes \
     --disable-debug \
     --build="$(gcc -dumpmachine)"

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

    # Manage dot new config file(s)
    touch "${destdir}/etc/libnl/.graft-config"

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

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

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

    for file in $docs
    do
        cp -p $file "${destdir}/$docsdir"
    done
}


code:
# Build recipe for libpcap.
#
# 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=libpcap
version=1.10.1
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="
A system-independent interface for user-level packet capture.

libpcap provides a portable framework for low-level network
monitoring. Applications include network statistics collection,
security monitoring, network debugging, etc.
"

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

# Source documentation
docs="CHANGES CONTRIBUTING.md CREDITS LICENSE README.md TODO 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} \
     --mandir=$mandir \
     --enable-shared \
     --with-pcap=linux \
     --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/libpcap/recipe


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

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

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

# Remote source(s)
fetch=https://ftp.openbsd.org/pub/OpenBSD/LibreSSL/$tarname

description="
A version of the TLS/crypto stack.

LibreSSL is a version of the TLS/crypto stack forked from OpenSSL in
2014, with goals of modernizing the codebase, improving security, and
applying best practice development processes.

Primary development occurs inside the OpenBSD source tree with the
usual care the project is known for.  On a regular basis the code
is re-packaged for portable use by other operating systems (Linux,
FreeBSD, Windows, etc).
"

homepage=https://www.libressl.org
license=Custom

# Source documentation
docs="COPYING ChangeLog 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} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-hardening \
     --enable-nc \
     --with-openssldir=/etc/ssl \
     --build="$(gcc -dumpmachine)"

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

    # This is provided by the ca-certificates package
    rm -f "${destdir}/etc/ssl/cert.pem"
    rmdir "${destdir}/etc/ssl/certs"

    # To manage config file(s)
    touch "${destdir}/etc/ssl/.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

    # Remove broken symlinks
    find "${destdir}/$mandir" -print | while read -r file
    do
        if test -L "$file" && test ! -e "$file"
        then
            echo "Deleting dangling symlink: $file"
            rm -f -- "$file"
        fi
    done

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

path: recipes/networking/libressl/recipe


code:
devel/cmake
networking/libpcap


code:
# Build recipe for lpppd (a fork of ppp).
#
# 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=lpppd
version=20210106_7454257
release=1

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

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="
PPP daemon and associated utilities.

The lpppd package is a fork based on Paul Mackerras' PPP:

  Targets glibc, musl libc and uClibc.
  Collecting patches from various sources.
  Use CMake build system.
  Support for non-Linux systems removed.
  Legacy protocol and library support removed.
  Some general code modernization.
  Building of plugins not supported at this time.
"

homepage=https://github.com/snickl/lpppd
license="GPLv2+ | Public domain, BSD-style notices"

# Source documentation
docs="CHANGELOG.md FAQ PLUGINS README* SETUP"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

    mkdir BUILD
    cd BUILD

    cmake \
     -DCMAKE_C_FLAGS_RELEASE:STRING="$QICFLAGS -fPIC -Wall -fno-strict-aliasing" \
     -DCMAKE_EXE_LINKER_FLAGS:STRING="$QILDFLAGS"  \
     -DCMAKE_INSTALL_PREFIX=/usr                   \
     -DCMAKE_BUILD_TYPE=Release                    \
     -DCMAKE_VERBOSE_MAKEFILE=ON                   \
     -DOPTION_LPPPD_INET6=ON                       \
     -DOPTION_LPPPD_PPPD_FILTER=ON                 \
     -DOPTION_LPPPD_PPPD_MULTILINK=ON              \
     -G Ninja ..

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

    cd ..

    # Include pppd headers to expose rp-pppoe plugins
    mkdir -p "${destdir}/usr/include/pppd"
    for file in pppd/*.h
    do
        cp -p $file "${destdir}/usr/include/pppd"/
        chmod 644 "${destdir}/usr/include/pppd/${file##*/}"
    done
    unset -v file

    mkdir -p "${destdir}/usr/include/net"
    cp -p include/net/ppp_defs.h "${destdir}/usr/include/net"/
    chmod 644  "${destdir}/usr/include/net/ppp_defs.h"

    # Add configuration files
    mkdir -p "${destdir}/etc/ppp/peers"
    for file in etc.ppp/*
    do
        cp -p $file "${destdir}/etc/ppp"/
        chmod 644 "${destdir}/etc/ppp/${file##*/}"
    done
    unset -v file

    chmod 600 "${destdir}"/etc/ppp/*-secrets*
    touch "${destdir}/etc/ppp/.graft-config"

    # Include scripts
    for file in plog poff pon
    do
        cp -p scripts/${file} "${destdir}/usr/sbin"/
        chmod 755 "${destdir}/usr/sbin/$file"
    done
    unset -v file

    # Include manual page for pon
    mkdir -p "${destdir}/${mandir}/man1"
    cp -p scripts/pon.1 "${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 -p "${destdir}/$docsdir"
    cp -p $docs "${destdir}/$docsdir"
}

path: recipes/networking/lpppd/recipe


code:
# Build recipe for lynx.
#
# Copyright (c) 2016-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=lynx
version=2.8.9rel.1
pkgversion=2.8.9
release=2

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

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

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

description="
A text browser for the World Wide Web.

Lynx is a general purpose distributed information browser for the
World Wide Web.

Use \"lynx -help\" to display a complete list of current options.
"

homepage=https://lynx.browser.org
license=GPLv2+

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

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --sysconfdir=/etc/lynx \
     --datadir=$docsdir \
     --mandir=$mandir \
     --with-zlib \
     --with-bzlib \
     --with-ssl \
     --with-screen=ncursesw \
     --enable-locale-charset \
     --enable-ipv6 \
     --enable-japanese-utf8 \
     --enable-nested-tables \
     --build="$(gcc -dumpmachine)"

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

    # Tweak configuration file (thanks to BLFS!)
    sed \
     -e '/#LOCALE/     a LOCALE_CHARSET:TRUE' \
     -e '/#DEFAULT_ED/ a DEFAULT_EDITOR:vi' \
     -e '/#PERSIST/    a PERSISTENT_COOKIES:TRUE' \
     -i "${destdir}/etc/lynx/lynx.cfg"

    # To handle dow new files via graft(8)
    touch "${destdir}/etc/lynx/.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
}

path: recipes/networking/lynx/recipe


code:
# Build recipe for ncftp.
#
# Copyright (c) 2018, 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=ncftp
version=3.2.6
release=3

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

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

# Remote source(s)
fetch=ftp://ftp.ncftp.com/ncftp/$tarname

description="
A File Transfer Protocol program.

NcFTP is a free set of programs that use the File Transfer Protocol.
It's been around for quite some time now (circa 1992) and many people
still use the program and contribute suggestions and feedback.

The main program is simply called \"ncftp\".  There are also separate
utility programs for one-shot FTP operations (i.e. for shell scripts
and command line junkies);  these include ncftpget, ncftpput, and
ncftpls.  Run each command without any arguments to see the usage
screen, or read the man page.
"

homepage=https://www.ncftp.com
license="Clarified Artistic License"

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

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

    cd "$srcdir"

    # Apply patches from Debian to refresh this source
    while read -r line
    do
        case $line in
        *.patch)
            patch -Np1 -i "${worktree}/patches/ncftp/${line}"
            ;;
        esac
    done < "${worktree}/patches/ncftp/series"

    # Update config detection for hosts
    cp -f "${worktree}/archive/common/config.guess" .
    cp -f "${worktree}/archive/common/config.sub" .

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

    # Unfortunately, this build system does
    # not pick up the FLAGS after `configure'
    CC=gcc CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS -DNO_SSLv2 -D_FILE_OFFSET_BITS=64 -Wall" \
    LDFLAGS="$QILDFLAGS -static" \
    ./configure $configure_args \
     --mandir=$mandir \
     --enable-ssp \
     --enable-readline \
     --build="$(gcc -dumpmachine)"

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

    # Replace hard link
    ln -sf ncftpbatch "${destdir}/usr/bin/ncftpspooler"

    # Include missing manpage for ncftpbookmarks
    # Thanks again to "Debian GNU/Linux" :-)

    install -p -m 0644 "${worktree}/archive/ncftp/ncftpbookmarks.1" \
     -D "${destdir}/${mandir}/man1/ncftpbookmarks.1"

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

    # Copy documentation

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

    # Redundancy
    rm -f "${destdir}/$docsdirmanifest.txt"
}

path: recipes/networking/ncftp/recipe


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

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

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

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

description="
Collection of basic networking programs.

A collection of programs that form the base set of the NET-3 networking
distribution for the GNU/Linux operating system.

This package includes the important tools for controlling the network
subsystem of the Linux kernel.  This includes arp, netstat, rarp and
route.  Additionally, this package contains utilities relating to
particular network hardware types (plipconfig, slattach, mii-tool)
and advanced aspects of IP configuration (iptunnel, ipmaddr).
"

homepage=https://net-tools.sourceforge.net/
license=GPLv2+

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

# The build system does not support parallel jobs
jobs=1

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

    cd "$srcdir"

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

    sed -i "s#-O2 -g#${QICFLAGS}#" Makefile

    yes "" | make config
    make -j${jobs} V=1 \
     BINDIR=/usr/bin SBINDIR=/usr/sbin \
     DESTDIR="$destdir" install

    # Delete included programs coming from the inetutils package
    for program in hostname dnsdomainname ifconfig \
                   domainname nisdomainname ypdomainname
    do
        rm "${destdir}/usr/bin/${program}"
        rm "${destdir}/${mandir}/man1/${program}.1" \
           "${destdir}/${mandir}/man8/${program}.8" || true;
    done
    unset -v program

    strip --strip-unneeded "${destdir}"/usr/bin/* \
     "${destdir}"/usr/sbin/* 2> /dev/null || true;

    rmdir "${destdir}/${mandir}/man1" || true;

    # 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/net-tools/recipe


code:
networking/libmnl
networking/libnftnl


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

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

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

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

description="
nftables replaces the popular {ip,ip6,arp,eb}tables.

This software provides a new in-kernel packet classification framework
that is based on a network-specific Virtual Machine (VM) and a new nft
userspace command line tool.  nftables reuses the existing Netfilter
subsystems such as the existing hook infrastructure, the connection
tracking system, NAT, userspace queueing and logging subsystem.
"

homepage=https://netfilter.org/projects/nftables/
license="GPLv2 only"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --disable-debug \
     --enable-python \
     --with-xtables \
     --with-cli=readline \
     --build="$(gcc -dumpmachine)"

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

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

path: recipes/networking/nftables/recipe


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

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

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

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

description="
HTTP/2 C library.

This is an implementation of the Hypertext Transfer Protocol version 2 in
C.  The framing layer of HTTP/2 is implemented as a reusable C library.
"

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

# Source documentation
docs="AUTHORS COPYING ChangeLog NEWS README.rst"
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" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-lib-only \
     --without-systemd \
     --build="$(gcc -dumpmachine)"

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

    # Current produced manpages correspond to the tools,
    # when we are providing only the library '--enable-lib-only'
    rm -rf "${destdir}/$mandir"

    # 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 nspr.
#
# 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=nspr
version=4.33
release=1

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

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

# Remote source(s)
fetch=https://archive.mozilla.org/pub/nspr/releases/v${version}/src/$tarname

description="
Netscape portable runtime functions.

NSPR is the Netscape Portable Runtime that provides a platform-neutral
API for system level and libc like functions.
"

homepage=https://www.mozilla.org/projects/nspr/about-nspr.html
license="MPL v2.0, GPLv2+"

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

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

    cd "${srcdir}/nspr"

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

    # This sed disables installing two unneeded scripts
    # (Thanks to "Beyond Linux From Scratch")
    sed -ri 's#^(RELEASE_BINS =).*#\1#' pr/src/misc/Makefile.in

    # This sed disables installing the static libraries
    # (Thanks to "Beyond Linux From Scratch")
    sed -i 's#$(LIBRARY) ##' config/rules.mk

    # Set specific options for the architecture
    case $arch in
    amd64)
        arch_options="--enable-64bit"
        ;;
    x32)
        arch_options="--enable-64bit --enable-x32"
        ;;
    esac

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

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

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

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

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

path: recipes/networking/nspr/recipe