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

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

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

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

description="
A lossless audio CODEC similar to MP3.

FLAC is an audio CODEC similar to MP3, but lossless, meaning
that audio is compressed without losing any information.
"

homepage=https://www.xiph.org/flac/
license="LGPLv2.1, GPLv2+ | BSD 3-clause"

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

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

    cd "$srcdir"

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

    if ! test -d /usr/lib64
    then
        extra_options="--disable-asm-optimizations"
    else
        extra_options="--enable-64-bit-words"
    fi

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" \
    LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-shared=yes \
     --enable-static=yes \
     --enable-debug=no \
     --enable-stack-smash-protection \
     --disable-thorough-tests \
     --build="$(gcc -dumpmachine)" \
     $extra_options

    unset -v extra_options

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

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

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

path: recipes/tools/flac/recipe


code:
libs/mpfr
libs/readline

repo_name: dustdfg/dragora

license: mit


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

# Exit immediately on any error
set -e

program=gawk
version=5.1.1
release=1

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

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

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

description="
Pattern scanning and processing language.

The awk utility interprets a special-purpose programming language
that makes it possible to handle simple data-reformatting jobs
with just a few lines of code.  It is a free version of 'awk'.

GNU awk implements the AWK utility which is part of
IEEE Std 1003.1 Shell and Utilities (XCU).
"

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

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

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

    cd "$srcdir"

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

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

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

    # Not needed for us when 'gawk.sh' is installed
    rm -f "${destdir}/etc/profile.d/gawk.csh"

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

    # Replace hard link with a soft link
    (
        cd "${destdir}/usr/bin" || exit 1
        ln -sf gawk-${version} gawk
    )

    # Provide manual page compatibility
    (
        cd "${destdir}/${mandir}/man1" || exit 1
        ln -sf gawk.1 awk.1
    )

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

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

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

path: recipes/tools/gawk/recipe


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

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

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="
Utility and mouse server for virtual consoles.

The gpm daemon tries to be a useful mouse server for applications
running on the GNU/Linux console.  Its roots are in the "selection"
package, by Andrew Haylett, and the original code comes from
selection itself.

This package is intended as a replacement for selection, to provide
additional facilities.
"

homepage=https://www.nico.schottelius.org/software/gpm/
license=GPLv2+

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

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

    cd "$srcdir"

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

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

    make -j${jobs} V=1
    make -j${jobs} DESTDIR="$destdir" install
    strip --strip-debug "${destdir}/usr/lib${libSuffix}/libgpm.a"

    # Emacs already cover this
    rm -rf "${destdir}/usr/share/emacs"

    # Make symlink for compatibility, just in case
    ln -s libgpm.so.2.1.0 "${destdir}/usr/lib${libSuffix}/libgpm.so"

    # Include configuration files for GPM

    mkdir -p "${destdir}/etc/gpm"
    cp -p conf/*.conf "${destdir}/etc/gpm"
    chmod 644 "${destdir}/etc/gpm"/*.conf
    touch "${destdir}/etc/gpm/.graft-config"

    # Include menu-driven tool to configure the mouse

    mkdir -p "${destdir}/usr/sbin"
    cp -p "${worktree}/archive/dragora-tools/dragora-mouse" \
          "${destdir}/usr/sbin"
    chmod 755 "${destdir}/usr/sbin/dragora-mouse"

    # Make compatible symlinks for the invocation.
    #
    # gpmconfig was the name used for Dragora-2
    ln -sf dragora-mouse "${destdir}/usr/sbin/gpmconfig"

    # Perhaps, for Slackware users?
    ln -sf dragora-mouse "${destdir}/usr/sbin/mouseconfig"

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

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

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

path: recipes/tools/gpm/recipe


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

# Exit immediately on any error
set -e

program=gptfdisk
version=1.0.9
release=1

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

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

# Remote source(s)
fetch=https://sourceforge.net/projects/gptfdisk/files/gptfdisk/${version}/$tarname

description="
GPT partitioning and MBR repair software.

GPT fdisk is a disk partitioning tool loosely modeled on Linux fdisk,
but used for modifying GUID Partition Table (GPT) disks.  The related
FixParts utility fixes some common problems on Master Boot Record (MBR)
disks.
"

homepage=https://www.rodsbooks.com/gdisk/
license=GPLv2+

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

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

    cd "$srcdir"

    patch -Np1 -i "${worktree}/patches/gptfdisk/util-linux-2.38.patch"

    # This patch modifies the Makefile file
    # so that it provides an install target.
    # Thanks to "Beyond Linux From Scratch"
    patch -Np1 -i \
     "${worktree}/patches/gptfdisk/gptfdisk-1.0.9-convenience-1.patch"

    # Build with ICU support
    patch -Np1 -i "${worktree}/patches/gptfdisk/Makefile-ICU.diff"

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

    sed -i 's|ncursesw/||' gptcurses.cc
    sed -i 's|sbin|usr/sbin|' Makefile

    make -j${jobs} V=1 CPPFLAGS="$QICPPFLAGS" \
     CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS"
    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/tools/gptfdisk/recipe


code:
# Build recipe for graft.
#
# 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=graft
version=2.16
arch=noarch
release=6

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

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

# Remote source(s)
fetch="
 https://dragora.mirror.garr.it/current/sources/$tarname
 rsync://rsync.dragora.org/current/sources/$tarname
"
#fetch=http://peters.gormand.com.au/Home/tools/graft/$tarname

description="
A package management utility (version $version).

Graft provides a mechanism for managing multiple packages under a single
directory hierarchy. Packages are installed in self contained directory
trees and symbolic links from a common area are made to the package files.

This approach allows multiple versions of the same package to coexist on
the same system. One version is the commonly available version and
symbolic links will be made to this version. New versions can be tested
and once acceptable can replace the current commonly available version.
Older versions can still be used for legacy systems by using the 'real'
path name to the package instead of the 'common' path name.
"

homepage=https://peters.gormand.com.au/Home/tools/graft
license=GPLv2+

# Source documentation
docs="CHANGES COPYING README THOUGHTS doc/graft.html doc/graft.pdf doc/graft.txt"
docsdir="${docdir}/${program}"

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

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

    cd "$srcdir"

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

    cp -f Makefile.dist Makefile

    make \
     PACKAGEDIR=/usr/pkg       \
     TARGETDIR=/               \
     BIN="${destdir}/usr/bin"  \
     MAN="${destdir}/$mandir"  \
     DOC="${destdir}/$docsdir" \
     install

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

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

    # Remove shipped .nograft from DOC
    rm -f "${destdir}/$docsdir.nograft"
}

path: recipes/tools/graft/recipe


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

# Exit immediately on any error
set -e

program=grep
version=3.7
release=1

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

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

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

description="
A string search tool.

The grep command searches one or more input files for lines
containing a match to a specified pattern.  By default,
grep outputs the matching lines.
"

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

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

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

    cd "$srcdir"

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

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

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

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

    # Provide from Dragora better wrapper scripts for egrep and fgrep
    cp -f "${worktree}/archive/grep/usr/bin/egrep" "${destdir}/usr/bin"
    cp -f "${worktree}/archive/grep/usr/bin/fgrep" "${destdir}/usr/bin"
    chmod 755 "${destdir}/usr/bin/egrep" "${destdir}/usr/bin/fgrep"

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

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

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

path: recipes/tools/grep/recipe


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

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

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

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

description="
System for typesetting documents.

The groff (GNU roff) software is a typesetting package which
reads plain text mixed with formatting commands and produces
formatted output.
"

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

# Source documentation
docs="
 BUG-REPORT COPYING ChangeLog FDL LICENSES \
 NEWS PROBLEMS README TODO
"

docsdir="${docdir}/${program}-${version}"

# Limite the number of parallel jobs for this version of groff
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 -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-rpath \
     --with-doc=no \
     --without-x \
     --build="$(gcc -dumpmachine)"

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

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

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


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

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

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

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

description="
Set ATA/SATA drive parameters.

The hdparm package contains a utility that is useful for
controlling ATA/SATA controllers and hard drives both to
increase performance and sometimes to increase stability.
"

homepage=https://sourceforge.net/projects/hdparm/
license=BSD

# Source documentation
docs="Changelog LICENSE.TXT README* TODO hdparm.lsm"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    # Change optimization level
    sed -i "s%-O2%${QICFLAGS}%" Makefile

    # Compile and install it as static
    make -j${jobs} LDFLAGS="$QILDFLAGS -static" \
     binprefix=/usr DESTDIR="$destdir" install

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

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

path: recipes/tools/hdparm/recipe


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

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

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

# Remote source(s)
fetch="
  https://github.com/htop-dev/htop/releases/download/${version}/$tarname
  https://dl.bintray.com/htop/source/$tarname
"

description="
An interactive process viewer for Unix systems.

Comparison between htop and classic top
* In htop you can scroll the list vertically and horizontally
  to see all processes and full command lines.
* In top you are subject to a delay for each unassigned
  key you press (especially annoying when multi-key escape
  sequences are triggered by accident).
* htop starts faster (top seems to collect data for a while
  before displaying anything).
* In htop you don't need to type the process number to
  kill a process, in top you do.
* In htop you don't need to type the process number or
  the priority value to renice a process, in top you do.
* In htop you can kill multiple processes at once.
* top is older, hence, more tested.
"

homepage=https://hisham.hm/htop/
license=GPLv2+

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

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

    cd "$srcdir"

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS -O3" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-unicode \
     --with-sensors \
     --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/tools/htop/recipe


code: modules/perl/xml-parser


code:
# Build recipe for intltool.
#
# Copyright (c) 2017 Mateus P. Rodrigues <mprodrigues@dragora.org>.
# Copyright (c) 2017-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=intltool
version=0.51.0
release=1

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

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

# Remote source(s)
fetch=https://launchpad.net/intltool/trunk/${version}/+download/$tarname

description="
Tools for internationalization.

intltool is a set of tools to centralize translation of many
different file formats using GNU gettext-compatible PO files.
"

homepage=https://freedesktop.org/wiki/Software/intltool
license=GPLv2

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

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

    cd "$srcdir"

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

    # Fix a warning that is caused by perl-5.22+
    # (thanks to "Linux From Scratch")
    sed -i 's:\\\${:\\\$\\{:' intltool-update.in

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --libdir=/usr/lib${libSuffix} \
    --infodir=$infodir \
    --mandir=$mandir \
    --docdir=$docsdir \
    --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/tools/intltool/recipe


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

# Exit immediately on any error
set -e

program=isapnptools
version=1.27
release=5

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

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

# Remote source(s)
fetch=http://www.roestockfox.co.uk/files/isapnptools/$tarname

description="
ISA plug and play configuration utility.

Two programs, one allows the dumping of resource data and generation of
a skeleton configuration file, the other configures ISA PnP hardware
using a configuration file.
"

homepage=https://www.roestockfox.co.uk/isapnptools/index.html
license=GPLv2+

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

build()
{

    # Check architecture
    case $arch in
    i?86)
        true
        ;;
    *)
        echo "isapnptools is for the x86 platform-only ..." 1>&2
        return 0
        ;;
    esac

    unpack "${tardir}/$tarname"

    cd "$srcdir"

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

    # Fix compilation on musl
    patch -p1 < "${worktree}/patches/isapnptools/isapnptools-musl-2.patch"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS -fcommon" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --disable-realtime \
     --disable-pci \
     --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/tools/isapnptools/recipe


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

# Exit immediately on any error
set -e

program=jack-audio-connection-kit
pkgname=jack1
version=0.125.0
release=3

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

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

# Remote source(s)
fetch=http://crux.ster.zone/downloads/jack-audio-connection-kit/$tarname

description="
The Jack Audio Connection Kit (version 1).

JACK is a low-latency audio server, written primarily for the Linux
operating system.  It can connect a number of different applications to
an audio device, as well as allowing them to share audio between
themselves. Its clients can run in their own processes (ie. as a
normal application), or can they can run within a JACK server (ie. a
"plugin").

JACK is different from other audio server efforts in that it has been
designed from the ground up to be suitable for professional audio
work.  This means that it focuses on two key areas: synchronous
execution of all clients, and low latency operation.
"

homepage=https://jackaudio.org
license="GPLv2+, LGPLv2.1"

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

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

    cd "$srcdir"

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

    # Note about `--enable-portaudio': it gives problems in the compilation.

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --enable-alsa \
     --disable-portaudio \
     --disable-oss \
     --enable-posix-shm=yes \
     --enable-sse=auto \
     --with-default-tmpdir=/tmp \
     --build="$(gcc -dumpmachine)"

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

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

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

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


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

# Exit immediately on any error
set -e

program=kbd
version=2.4.0
release=2

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

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

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

description="
Keyboard utilities for GNU/Linux.

The kbd package contains key-table files and keyboard utilities.
"

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

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

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

    cd "$srcdir"

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

    # Use patches from Fedora to improve kbd
    patch -Np1 -i "${worktree}/patches/kbd/kbd-1.15-keycodes-man.patch"
    patch -Np1 -i "${worktree}/patches/kbd/kbd-1.15-unicode_start.patch"
    patch -Np1 -i "${worktree}/patches/kbd/kbd-2.0.4-covscan-fixes.patch"

    # Fix inconsistent behaviour of Backspace and Delete keys
    # for i386 keymaps (Thanks to "Linux From Scratch")
    patch -Np1 -i "${worktree}/patches/kbd/kbd-2.4.0-backspace-1.patch"

    # Remove the redundant resizecons program (it requires the defunct
    # svgalib to provide the video mode files - for normal use setfont
    # sizes the console appropriately) together with its manpage.
    # (Thanks again to "Linux From Scratch")
    sed -i '/RESIZECONS_PROGS=/s/yes/no/' configure
    sed -i 's/resizecons.8 //' docs/man/man8/Makefile.in

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

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

    # Include Dragora's menu-driven tool to configure the keyboard map

    mkdir -p "${destdir}/usr/sbin"
    cp -p "${worktree}/archive/dragora-tools/dragora-keymap" \
          "${destdir}/usr/sbin"
    chmod 755 "${destdir}/usr/sbin/dragora-keymap"

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

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

path: recipes/tools/kbd/recipe


code:
libs/ncurses
libs/pcre


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

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

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

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

description="
A text file viewer.

Less is a pager.  A pager is a program that displays text files.

This package also includes the 'lesspipe.sh' script.
"

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

# Source documentation
docs="COPYING 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 \
     --with-regex=pcre2 \
     --with-secure \
     --build="$(gcc -dumpmachine)"

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

    # Include our custom lesspipe.sh version (which has support for lzip)

    cp -p "${worktree}/archive/less/usr/bin/lesspipe.sh" "${destdir}/usr/bin"
    chmod 755 "${destdir}/usr/bin/lesspipe.sh"

    # Include profile file
    mkdir -p "${destdir}/etc/profile.d"
    cat "${worktree}/archive/less/etc/profile.d/less.sh" \
      > "${destdir}/etc/profile.d/less.sh"

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

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

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

path: recipes/tools/less/recipe


code:
# Build recipe for lm-sensors.
#
# 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=lm-sensors
version=3-6-0
release=1

pkgversion="$(echo $version | tr - .)"

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

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

# Remote source(s)
fetch=https://github.com/lm-sensors/lm-sensors/archive/V${version}/$tarname
#fetch=https://ftp.gwdg.de/pub/linux/misc/lm-sensors/$tarname

description="
Hardware monitoring support.

The lm-sensors package provides support for the hardware monitoring
drivers in the Linux Kernel.  This is useful for monitoring the
temperature of the CPU and adjusting the performance of some hardware
(such as cooling fans).
"

homepage=https://hwmon.wiki.kernel.org/lm_sensors
license="GPLv2+, LGPLv2.1"

# Source documentation
docs="CHANGES CONTRIBUTORS COPYING* README doc/fancontrol.txt"
docsdir="${docdir}/${program}-${pkgversion}"

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

    cd $srcdir

    make -j${jobs} V=1 MACHINE=$arch LIBICONV=-lc \
     BUILD_STATIC_LIB=0 \
     PREFIX=/usr LIBDIR=/usr/lib${libSuffix} MANDIR=$mandir \
     DESTDIR="$destdir" install

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

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

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

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

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

path: recipes/tools/lm-sensors/recipe


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

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

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

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

description="
Utility to rotate system logs automatically.

The logrotate utility is designed to simplify the administration of
log files on a system which generates a lot of log files.  Logrotate
allows for the automatic rotation compression, removal and mailing of
log files.  Logrotate can be set to handle a log file daily, weekly,
monthly or when the log file gets to a certain size.
"

homepage=https://github.com/logrotate/logrotate
license=GPLv2+

# Source documentation
docs="ChangeLog.md COPYING 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 -static" \
     $configure_args \
     --mandir=$mandir \
     --with-compress-command="/usr/bin/lzip -9"\
     --with-uncompress-command="/usr/bin/lzip -d" \
     --with-compress-extension=.lz \
     --with-default-mail-command=/usr/bin/mail \
     --with-acl \
     --without-selinux \
     --build="$(gcc -dumpmachine)"

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

    mkdir -p "${destdir}/etc/logrotate.d" "${destdir}/etc/cron.daily"

    cp -p examples/logrotate.conf "${destdir}/etc"
    chmod 644 "${destdir}/etc/logrotate.conf"

    # To make use of the compression by default
    sed -i "s|#compress|compress|" "${destdir}/etc/logrotate.conf"

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

    cp -p "${worktree}/archive/logrotate/logrotate.cron" \
          "${destdir}/etc/cron.daily/logrotate"
    chmod 755 "${destdir}/etc/cron.daily/logrotate"

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

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

path: recipes/tools/logrotate/recipe


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

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

pkgname=lvm2

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

# Remote source(s)
fetch=https://sourceware.org/ftp/lvm2/releases/$tarname

description="
Logical Volume Management tools.

LVM2 refers to the userspace toolset that provide
logical volume management facilities on GNU/linux.
"

homepage=https://www.sourceware.org/lvm2
license="GPLv2+, LGPL2.1"

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

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

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

    cd "$srcdir"

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

    # Apply patches from Alpine Linux in order to build against Musl
    patch -p1 < "${worktree}/patches/lvm2/fix-stdio-usage.patch"
    patch -p1 < "${worktree}/patches/lvm2/mallinfo.patch"
    patch -p1 < "${worktree}/patches/lvm2/library_dir-default-config.patch"
    patch -p1 < "${worktree}/patches/lvm2/mlockall-default-config.patch"

    # --enable-static_link does not work in this version
    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --with-usrlibdir=/usr/lib${libSuffix} \
     --with-udev-prefix="" \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-pkgconfig \
     --enable-applib \
     --enable-cmdlib \
     --enable-dmeventd \
     --enable-udev_rules \
     --enable-udev_sync \
     --disable-readline \
     --with-lvm1=internal \
     --with-thin=internal \
     --with-device-uid=0 \
     --with-device-gid=11 \
     --with-device-mode=0660 \
     --build="$(gcc -dumpmachine)"

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

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

    # Manage .new (config) files via graft(8)
    touch "${destdir}/etc/lvm/.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:
# Build recipe for lziprecover.
#
# 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=lziprecover
version=1.23
release=2

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

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

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

homepage=https://lzip.nongnu.org/lziprecover.html

description="
Data recovery tool and decompressor for files in the lzip.

Lziprecover is a data recovery tool and decompressor for files in the
lzip compressed data format (.lz).  Lziprecover is able to repair
slightly damaged files, produce a correct file by merging the good
parts of two or more damaged copies, extract data from damaged files,
decompress files and test integrity of files.

For more information, visit: $homepage
"

license=GPLv2+

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

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

    cd "$srcdir"

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

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

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

    # Compress info documents and manual page

    rm -f "${destdir}/${infodir}/dir";	# Redundancy
    lzip -9 \
     "${destdir}/${infodir}/lziprecover.info" \
     "${destdir}/${mandir}/man1/lziprecover.1"

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

path: recipes/tools/lziprecover/recipe


code:
libs/libpipeline
db/gdbm


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

# Exit immediately on any error
set -e

program=man-db
version=2.9.4
release=3

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

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

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

description="
Programs for finding and viewing man pages.

The man-db package contains programs for finding and viewing manual pages.
"

homepage=https://man-db.nongnu.org
license=GPLv2+

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-setuid \
     --disable-cache-owner \
     --enable-static=no \
     --enable-shared=yes \
     --with-sections="1 1p 8 2 3 3p 4 5 6 7 9 0p tcl n l p o 1x 2x 3x 4x 5x 6x 7x 8x" \
     --with-db=gdbm \
     --with-systemdtmpfilesdir="no" \
     --with-systemdsystemunitdir="no" \
     --build="$(gcc -dumpmachine)"

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

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

    # Insert our man_db config
    cp -p "${worktree}/archive/man-db/etc/man_db.conf" \
          "${destdir}/etc/"
    chmod 644 "${destdir}/etc/man_db.conf"

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

    # Include cron job

    mkdir -p "${destdir}/etc/cron.daily/"
    cp -p "${worktree}/archive/man-db/etc/cron.daily/man-db" \
          "${destdir}/etc/cron.daily/"
    chmod 0755 "${destdir}/etc/cron.daily/man-db"

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

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

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

path: recipes/tools/man-db/recipe


code:
libs/ncurses
libs/glib2
libs/pcre


code:
# Build recipe for mc (Midnight Commander).
#
# 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=mc
version=4.8.27
release=1

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

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

# Remote source(s)
fetch=http://ftp.midnight-commander.org/$tarname

description="
File manager and user shell.

GNU Midnight Commander can be used locally or remotely, on the console
or under X Window System.  By using full screen space of the terminals,
it provides an intuitive user interface to the operating system,
aiming to be a useful tool for users with any level of experience,
from a newbie to a guru.
"

homepage=https://www.midnight-commander.org
license=GPLv3+

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

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

    cd "$srcdir"

    # Apply a patch in order to build against Musl
    # (Thanks to "Alpine Linux")
    patch -p1 < "${worktree}/patches/mc/fix-cchar_t.patch"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-nls \
     --with-search-engine=pcre \
     --with-screen=ncurses \
     --without-x \
     --with-gpm-mouse \
     --build="$(gcc -dumpmachine)"

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

    # To manage .new files
    touch "${destdir}/etc/mc/.graft-config"

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

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

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

path: recipes/tools/mc/recipe


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

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

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

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

description="
mdadm is a tool for managing Linux Software RAID arrays.

It can create, assemble, report on, and monitor arrays.  It can also
move spares between raid arrays when needed.
"

homepage=https://neil.brown.name/blog/mdadm
license=GPLv2+

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

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

    cd "$srcdir"

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

    make -j${jobs} CXFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     BINDIR=/usr/sbin MANDIR=$mandir
    make -j${jobs} MANDIR=$mandir BINDIR=/usr/sbin DESTDIR=$destdir install

    mkdir -p "${destdir}/etc"
    cp -p mdadm.conf-example "${destdir}/etc/mdadm.conf"
    chmod 644 "${destdir}/etc/mdadm.conf"
    touch "${destdir}"/etc/.graft-config

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

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

path: recipes/tools/mdadm/recipe


code:
# Build recipe for mlocate.
#
# Copyright (c) 2017 Alan Beadle, <ab.beadle@gmail.com>.
# 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=mlocate
version=0.26
release=2

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

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

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

description="
mlocate is a locate/updatedb implementation.

The 'm' stands for 'merging': updatedb reuses the existing database to
avoid rereading most of the file system, which makes updatedb faster
and does not trash the system caches as much.
"

homepage=https://pagure.io/mlocate
license=GPLv2+

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

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

    cd "$srcdir"

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

    patch -Np1 -i "${worktree}/patches/mlocate/01-fortify-source-compat.patch"

    # Update for hosts based on musl
    cp -f "${worktree}/archive/common/config.guess" admin/config.guess
    cp -f "${worktree}/archive/common/config.sub" admin/config.sub

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

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

    mv "${destdir}/usr/bin/locate" "${destdir}/usr/bin/mlocate"
    ln -s mlocate "${destdir}/usr/bin/locate"

    # To increase security changing the default 2755
    chmod 2711 "${destdir}/usr/bin/mlocate"

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

    # Copy custom files

    mkdir -p "${destdir}/etc/cron.daily/"
    cp -p "${worktree}/archive/mlocate/etc/cron.daily/mlocate" \
          "${destdir}/etc/cron.daily/"
    chmod 0755 "${destdir}/etc/cron.daily/mlocate"
    cp -p "${worktree}/archive/mlocate/etc/updatedb.conf" \
          "${destdir}/etc/"
    chmod 0644 "${destdir}/etc/updatedb.conf"

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

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

    # A symbolic link if someone requests locate(1)
    ln -s locate.1.lz "${destdir}/${mandir}/man1/mlocate.1.lz"

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

path: recipes/tools/mlocate/recipe


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

# Exit immediately on any error
set -e

program=moe
version=1.12
release=1

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

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

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

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

description="
The GNU moe editor.

GNU moe is a powerful, 8-bit clean, console text editor for ISO-8859
and ASCII character encodings.  It has a modeless, user-friendly
interface, online help, multiple windows, unlimited undo/redo
capability, unlimited line length, global search/replace (on all
buffers at once), block operations, automatic indentation, word
wrapping, file name completion, directory browser, duplicate removal
from prompt histories, delimiter matching, text conversion from/to
UTF-8, romanization, etc.

For more information, visit: $homepage
"

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

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

    cd "$srcdir"

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

    ./configure CXXFLAGS="$QICXXFLAGS -Wall -W" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --infodir=$infodir \
     --mandir=$mandir \
     --build="$(gcc -dumpmachine)"

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

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

    # Compress documentation deleting redundancy

    lzip -9 "${destdir}/${infodir}/moe.info" \
            "${destdir}/${mandir}/man1/moe.1"

    rm -f "${destdir}/${infodir}/dir"

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

path: recipes/tools/moe/recipe


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

# Exit immediately on any error
set -e

program=nano
version=6.0
release=1

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

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

# Remote source(s)
fetch=https://www.nano-editor.org/dist/latest/$tarname

description="
The GNU nano editor.

GNU nano is designed to be a free replacement for the Pico text editor,
part of the Pine email suite from The University of Washington. It aims
to \"emulate Pico as closely as possible and perhaps include extra
functionality\".
"

homepage=https://www.nano-editor.org
license="GPLv3+, GFDL1.2"

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

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

    cd "$srcdir"

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

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

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

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

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

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

path: recipes/tools/nano/recipe


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

# Exit immediately on any error
set -e

program=ntfs-3g_ntfsprogs
pkgname=ntfs-3g
version=2021.8.22
release=2

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

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

# Remote source(s)
fetch=https://tuxera.com/opensource/$tarname

description="
Drivers and utilities for the NTFS file system.

The ntfs-3g package contains a stable, read-write open source driver for
NTFS partitions.  NTFS partitions are used by most Microsoft operating
systems, ntfs-3g allows you to mount NTFS partitions in read-write mode
from your GNU/Linux system.  It uses the FUSE kernel module to be able to
implement NTFS support in user space.  The package also contains various
utilities useful for manipulating NTFS partitions.
"

homepage=https://www.tuxera.com/community/open-source-ntfs-3g/
license="GPLv2+, LGPLv2+"

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

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

    cd "$srcdir"

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

    # Make sure to point to the /usr hierarchy
    sed -i 's#$(DESTDIR)/sbin#$(DESTDIR)/usr/sbin#g' src/Makefile.in

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-extras \
     --enable-posix-acls \
     --enable-xattr-mappings \
     --enable-crypto \
     --with-fuse=external \
     --disable-ldconfig \
     --build="$(gcc -dumpmachine)" \
     rootbindir=/usr/bin \
     rootsbindir=/usr/sbin \
     rootlibdir=/usr/lib${libSuffix} \

    make -j${jobs} V=1 \
     rootbindir=/usr/bin \
     rootsbindir=/usr/sbin \
     rootlibdir=/usr/lib${libSuffix} \
     DESTDIR="$destdir" install

    install -p -m 755 "${worktree}/archive/ntfs-3g/mount.ntfs" \
                      "${destdir}/usr/bin/mount.ntfs"

    # Check if 'ntfsallocate' was installed, if not remove its manpage
    if test ! -e "${destdir}/usr/bin/ntfsallocate"
    then
        rm -f "${destdir}/${mandir}/ntfsfallocate.8"
    fi

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

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


code:
# Build recipe for parted.
#
# Copyright (c) 2022 Matias Fonzo, <selk@dragora>.
#
# 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=parted
version=3.5
release=1

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

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

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

description="
GNU Parted manipulates partition tables.

This is useful for creating space for new operating systems,
reorganizing disk usage, copying data on hard disks and disk
imaging.  The package contains a library, libparted, as well
as a command-line frontend, parted, which can also be used
in scripts.
"

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

# Source documentation
docs="AUTHORS BUGS COPYING ChangeLog NEWS README THANKS TODO doc/API doc/FAT"
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-device-mapper \
     --enable-part-static \
     --enable-pc98=no \
     --enable-Werror=no \
     --build="$(gcc -dumpmachine)"

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

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

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

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

path: recipes/tools/parted/recipe


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

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

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

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

description="
A tool to patch files.

The patch package contains a program to modify or create files through
the aplication of a patch file created with the diff(1) program.
"

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

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

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

    cd "$srcdir"

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

    # Update for hosts based on musl
    cp -f "${worktree}/archive/common/config.guess" build-aux/config.guess
    cp -f "${worktree}/archive/common/config.sub" build-aux/config.sub

    # https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2018-1000156
    patch -p1 < "${worktree}/patches/patch/Fix_segfault_with_mangled_rename_patch.patch"
    patch -p1 < "${worktree}/patches/patch/Allow_input_files_to_be_missing_for_ed-style_patches.patch"
    patch -p1 < "${worktree}/patches/patch/Fix_arbitrary_command_execution_in_ed-style_patches.patch"

    autoreconf -vif

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

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

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

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

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

path: recipes/tools/patch/recipe


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

# Exit immediately on any error
set -e

program=pciutils
version=3.7.0
release=2

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

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

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

description="
The PCI utilities.

The pciutils package is a set of programs for listing PCI devices,
inspecting their status and setting their configuration registers.
"

homepage=https://mj.ucw.cz/sw/pciutils/
license=GPLv2+

# Source documentation
docs="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 .

    # Make

    make -j${jobs} V=1 CPPFLAGS="$QICPPFLAGS" \
    OPT="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     PREFIX=/usr \
     LIBDIR=/usr/lib${libSuffix} \
     IDSDIR=/usr/share/hwdata \
     SHARED=yes \
     LIBKMOD=yes \
     PCI_IDS=pci.ids \
     PCI_COMPRESSED_IDS=0 \
     ZLIB=no

    # Install

    make -j${jobs} V=1 OPT="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     PREFIX=/usr \
     LIBDIR=/usr/lib${libSuffix} \
     IDSDIR=/usr/share/hwdata \
     SHARED=yes \
     LIBKMOD=yes \
     PCI_IDS=pci.ids \
     PCI_COMPRESSED_IDS=0 \
     ZLIB=no \
     DESTDIR="$destdir" install install-lib

    # Fix library permissions
    chmod 755 "${destdir}/usr/lib${libSuffix}/libpci.so.${version}"

    # This is provided by the 'hwids' package
    rm -rf "${destdir}/usr/share/hwdata"

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

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

path: recipes/tools/pciutils/recipe


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

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

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

# Remote source(s)
fetch=https://pm-utils.freedesktop.org/releases/$tarname

description="
Power management utilities.

The power management utilities provide simple shell command line
tools to suspend and hibernate the computer.  They can be used to
run user supplied scripts on suspend and resume.
"

homepage=https://pm-utils.freedesktop.org
license=GPLv2+

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --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/tools/pm-utils/recipe


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

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

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

# Remote source(s)
fetch=https://deb.debian.org/debian/pool/main/p/pmount/$tarname

description="
Mount removable devices like a normal user.

pmount is a wrapper around the standard mount program which permits normal
users to mount removable devices without a matching /etc/fstab entry.
This provides a robust basis for automounting frameworks like GNOME's
Utopia project and confines the amount of code that runs as root to a
minimum.
"

homepage=https://launchpad.net/pmount
license=GPLv3+

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

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

    cd "$srcdir"

    # Apply a patch from Dragora
    patch -Np1 -i "${worktree}/patches/pmount/pmount-missing_header.diff"

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

    # 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 \
     --disable-hal \
     --build="$(gcc -dumpmachine)"

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

    # To handle dot (.new) files via graft(1)
    touch "${destdir}/etc/.graft-config"

    # Set permissions and ownerships for pmount
    (
        cd "${destdir}/usr/bin"
        for file in pmount pumount
        do
            chown :plugdev "$file"
            chmod 6710 "$file"	# SetUID+SetGID
        done
    )

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

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

path: recipes/tools/pmount/recipe


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

# Exit immediately on any error
set -e

program=procps-ng
version=3.3.17
release=1

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

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

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

description="
The /proc file system utilities.

Procps-ng is the package that has a bunch of small utilities that give
information about processes using the /proc filesystem.

The package includes: sysctl, pgrep, top, w, pwdx, vmstat, pkill,
tload, slabtop, pidof, uptime, watch, free, pmap, ps.
"

homepage=https://sourceforge.net/projects/procps-ng
license="GPLv2+, LGPLv2+"

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

# The source directory has a different name
srcdir=procps-${version}

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

    cd "$srcdir"

    # Apply a patch taken from "Alpine Linux"
    patch -Np1 -i "${worktree}/patches/procps-ng/musl-fixes.patch"

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

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

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

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

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

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

path: recipes/tools/procps-ng/recipe


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

# Exit immediately on any error
set -e

program=psmisc
version=23.4
release=1

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

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

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

description="
Small utilities for the /proc filesystem.

The psmisc package contains programs for displaying
information about running processes.
"

homepage=https://gitlab.com/psmisc/psmisc
license=GPLv2+

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" \
    LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --mandir=$mandir \
     --disable-harden-flags \
     --enable-nls \
     --build="$(gcc -dumpmachine)"

    echo "#include <limits.h>" >> config.h

    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/tools/psmisc/recipe


code:
# Build recipe for qi.
#
# 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=qi
version=2.10-rc1
arch=noarch
release=1

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

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

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

description="
A user-friendly package manager (version $version).

Qi is a simple but well-integrated package manager.  It can create,
install, remove, and upgrade software packages.  Qi produces binary
packages using recipes, which are files containing specific instructions
to build each package from source.  Qi can manage multiple packages
under a single directory hierarchy.  This method allows to maintain a
set of packages and multiple versions of them.  This means that Qi could
be used as the main package manager or complement the existing one.

Qi offers a friendly command line interface, a global configuration
file, a simple recipe layout to deploy software packages; also works
with binary packages in parallel, speeding up installations and packages
in production.  The format used for packages is a simplified and safer
variant of POSIX pax archive compressed in lzip format.

Qi is a modern (POSIX-compliant) shell script released under the
terms of the GNU General Public License.  There are only two major
dependencies for the magic: graft(1) and tarlz(1), the rest is expected
to be found in any Unix-like system.
"

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

# Source documentation
docs="AUTHORS COPYING CREDITS NEWS README.md doc/example.order doc/recipe*"
docsdir="${docdir}/${program}"

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

build()
{
    # Figure out architecture name for default package names in Dragora 3+
    #
    # See git_tree/targets/ for 'package_arch' on it.
    #
    case $(gcc -dumpmachine) in
    aarch64-*)
        package_arch=arm64
        ;;
    arm-*-musleabi)
        package_arch=armfp
        ;;
    arm-*-musleabihf)
        package_arch=armhf
        ;;
    armv7hl-*-musleabihf)
        package_arch=armhl
        ;;
    *x32-*)
        package_arch=x32
        ;;
    x86_64-*)
        package_arch=amd64
        ;;
    powerpc64le-*)
        package_arch=ppc64le
        ;;
    esac

    unpack "${tardir}/$tarname"

    cd "$srcdir"

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

    ./configure \
     --prefix=/usr \
     --libexecdir=/usr/libexec \
     --bindir=/usr/bin \
     --sbindir=/usr/sbin \
     --sysconfdir=/etc \
     --localstatedir=/var \
     --infodir=/usr/share/info \
     --mandir=/usr/share/man \
     --docdir=/usr/share/doc \
     --packagedir=/usr/pkg \
     --targetdir=/ \
     --arch="${package_arch:-$(uname -m)}"

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

    ln -s qi "${destdir}/usr/bin/dragora-qi"

    # Copy the config file used in the temporary system
    if test -r /tools/etc/qirc && test ! -e /etc/qirc
    then
        cp -p /tools/etc/qirc "${destdir}/etc/"
        cp -p /tools/etc/qirc "${destdir}/etc/qirc.bak"
        chmod 644 "${destdir}"/etc/qirc*
    fi

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

    # Compress and copy source documents

    rm -f "${destdir}/${infodir}/dir"
    lzip -9 "${destdir}/${infodir}/qi.info" \
            "${destdir}/${mandir}/man1/qi.1"

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

path: recipes/tools/qi/recipe


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

# Exit immediately on any error
set -e

program=quota
version=4.06
release=1

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

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

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

description="
User space tools to manage the disk quota system.

Tools for the disk quota system as part of the Linux Kernel.
"

homepage=https://sourceforge.net/projects/linuxquota
license="GPLv2+ | BSD"

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

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

    cd "$srcdir"

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

    # Apply patches to work under Musl (patches from Khem Raj)
    patch -p1 < "${worktree}/patches/quota/fcntl.patch"

    ./configure CPPFLAGS="-D_GNU_SOURCE -D_BSD_SOURCE" \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --sysconfdir=/etc/quota \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-werror \
     --enable-rpc=yes \
     --enable-ldapmail=no \
     --build="$(gcc -dumpmachine)"

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

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

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

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

path: recipes/tools/quota/recipe


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

# Exit immediately on any error
set -e

program=reiser4progs
version=1.2.2
release=1

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

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

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

description="
Utilities for manipulating Reiser4 filesystems.

It contains the library for reiser4 filesystem access and manipulation
and reiser4 utilities.
"

homepage=https://www.namesys.com
license=GPLv2

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

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

    cd "$srcdir"

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

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

    make -j${jobs} V=1 CFLAGS="$QICFLAGS -O3" LDFLAGS="$QILDFLAGS -static"
    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"
}