code:
# Build recipe for sed.
#
# 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=sed
version=4.8
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/sed/$tarname

description="
GNU stream editor.

Sed isn't really a true text editor or text processor.  Instead,
it is used to filter text, i.e., it takes text input and performs
some operation on it and outputs the modified text.

For more information, visit:  https://www.gnu.org/software/sed
"

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

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

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

    cd "$srcdir"

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

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

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

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

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

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

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

path: recipes/tools/sed/recipe


code:
# Build recipe for shadow.
#
# 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=shadow
version=4.11.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://github.com/shadow-maint/shadow/releases/download/${version}/$tarname

description="
The shadow tool suite.

The shadow package contains programs for handling
passwords in a secure way.
"

homepage=https://pkg-shadow.alioth.debian.org
license=BSD

# Source documentation
docs="COPYING NEWS README TODO"
docsdir="${docdir}/${pkgname}"

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

    cd "$srcdir"

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

    # Apply to use our custom definitions
    patch -Np1 -i "${worktree}/patches/shadow/shadow-login.defs.diff"

    # Disable the installation of the groups program and its man pages,
    # as Coreutils provides a better version.  Also, prevent the
    # installation of manual pages that were already installed in the
    # man-pages package (Thanks to "Linux From Scratch" :-)
    sed -i 's/groups$(EXEEXT) //' src/Makefile.in
    find man -type f -name Makefile.in -exec sed -i 's/groups\.1 / /'   {} \;
    find man -type f -name Makefile.in -exec sed -i 's/getspnam\.3 / /' {} \;
    find man -type f -name Makefile.in -exec sed -i 's/passwd\.5 / /'   {} \;

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --infodir=$infodir \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-shadowgrp \
     --disable-shared \
     --with-sha-crypt \
     --with-group-name-max-length=32 \
     --with-su \
     --without-libcrack \
     --build="$(gcc -dumpmachine)"

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

    # Include Dragora version of "shadowconfig.sh"
    cp -p "${worktree}/archive/shadow/usr/sbin/shadowconfig" \
          "${destdir}/usr/sbin/"
    chmod 755 "${destdir}/usr/sbin/shadowconfig"

    # Insert our default useradd file for default users definition
    mkdir -p "${destdir}/etc/default"
    install -p -m 644 "${worktree}/archive/shadow/etc/default/useradd" \
     "${destdir}/etc/default/useradd"

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

repo_name: dustdfg/dragora

path: recipes/tools/shadow/recipe

license: mit


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

# Exit immediately on any error
set -e

program=squashfs
pkgname=squashfs-tools
version=4.5
release=1

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

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

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

description="
Tools to create and extract Squashfs filesystems.

This is a squashed read-only filesystem for GNU/Linux.
"

homepage=https://github.com/plougher/squashfs-tools/
license=GPLv2+

# Source documentation
docs="
  ACKNOWLEDGEMENTS ACTIONS-README CHANGES COPYING README-${version} USAGE
  RELEASE-READMEs/DONATIONS RELEASE-READMEs/pseudo-file.example
"
docsdir="${docdir}/${pkgname}-${version}"

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

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

    cd "$srcdir"

    # Apply a patch to include LZIP support
    patch -p1 < "${worktree}/patches/squashfs-tools/squashfs-tools-4.5_lzip-0.diff"

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

    cd squashfs-tools

    make -j${jobs} CC=cc EXTRA_CFLAGS="$QICFLAGS -O3" LDFLAGS="$QILDFLAGS" \
     GZIP_SUPPORT=1 \
     LZIP_SUPPORT=1 \
     XZ_SUPPORT=1 \
     LZO_SUPPORT=0 \
     LZ4_SUPPORT=0 \
     ZSTD_SUPPORT=0 \
     COMP_DEFAULT=lzip \
     XATTR_SUPPORT=1 \
     install INSTALL_DIR="${destdir}/usr/bin"

    cd ../

    # Re-create symlinks for utilities
    (
        cd "${destdir}/usr/bin" || exit 1
        ln -sf mksquashfs sqfscat
        ln -sf unsquashfs sqfstar
    )

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

path: recipes/tools/squashfs-tools/recipe


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

# Exit immediately on any error
set -e

program=sudo
version=1.9.8p2
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.sudo.ws/dist/$tarname

description="
A tool to execute a command as another user.

Sudo (su \"do\") allows a system administrator to delegate authority to
give certain users (or groups of users) the ability to run some (or
all) commands as root or another user while providing an audit trail of
the commands and their arguments.
"

homepage=https://www.sudo.ws/sudo.html
license=ISC

# Source documentation
docs="ChangeLog NEWS README doc/CONTRIBUTORS doc/HISTORY doc/LICENSE"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --localstatedir=/var \
     --enable-gcrypt \
     --disable-root-sudo \
     --with-logfac=auth \
     --with-ignore-dot \
     --with-secure-path \
     --with-env-editor \
     --with-man \
     --without-pam \
     --build="$(gcc -dumpmachine)"

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

    chmod 4711 "${destdir}/usr/bin/sudo"

    # To handle config file(s) via graft(8)
    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/sudo/recipe


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

# Exit immediately on any error
set -e

program=tar
version=1.34
release=1

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

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

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

description="
Tool to package and manipulate files.

The tar program provides the ability to create tar archives, as well as
various other kinds of manipulation.  For example, you can use tar on
previously created archives to extract files, to store additional
files, or to update or list files which were already stored.

The name of tar comes from \"Tape ARchiver\".
"

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

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

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

    cd "$srcdir"

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

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

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

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

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

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

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

path: recipes/tools/tar/recipe


code:
# Build recipe for tarlz.
#
# 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=tarlz
version=0.22
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-mirror.savannah.gnu.org/releases/lzip/tarlz/$tarname

homepage=https://lzip.nongnu.org/tarlz.html
license=GPLv2+

description="
Archiver with multimember lzip compression (version $version).

Tarlz is a combined implementation of the tar archiver and the lzip
compressor. By default tarlz creates, lists and extracts archives in a
simplified posix pax format compressed with lzip on a per file basis.
Each tar member is compressed in its own lzip member, as well as the
end-of-file blocks. This method adds an indexed lzip layer on top of
the tar archive, making it possible to decode the archive safely in
parallel.  The resulting multimember tar.lz archive is fully backward
compatible with standard tar tools like GNU tar, which treat it like
any other tar.lz archive.  Tarlz can append files to the end of such
compressed archives.
"

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

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CXXFLAGS+="$QICXXFLAGS" LDFLAGS="$QILDFLAGS -static" \
     $configure_args \
     --infodir=$infodir \
     --mandir=$mandir \
     --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}/tarlz.info" \
     "${destdir}/${mandir}/man1/tarlz.1"

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

path: recipes/tools/tarlz/recipe


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

# Exit immediately on any error
set -e

program=tmux
version=3.2a
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/tmux/tmux/releases/download/${version}/$tarname

description="
Terminal multiplexer.

Tmux is a \"terminal multiplexer\", it enables a number of terminals
(or windows) to be accessed and controlled from a single terminal.
"

homepage=https://tmux.github.io/
license="ISC License"

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

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

    cd "$srcdir"

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

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


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

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

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

# Remote source(s)
fetch=http://mama.indstate.edu/users/ice/tree/src/"$tarname"

description="
Tree is a recursive directory listing command.

Tree produces a depth indented listing of files, which is colorized
ala dircolors if the LS_COLORS environment variable is set and output
is to tty. Tree has been ported and reported to work under the
following operating systems: Linux, FreeBSD, OS X, Solaris,
HP/UX, Cygwin, HP Nonstop and OS/2.
"

homepage=https://mama.indstate.edu/users/ice/tree/
license=GPLv2+

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

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

    cd "$srcdir"

    make -j${jobs} \
     CPPFLAGS="$QICPPFLAGS" \
     CFLAGS="$QICFLAGS -O3 -Wall -DLINUX -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" \
     LDFLAGS="$QILDFLAGS -static" \
     PREFIX="${destdir}/usr" \
     MANDIR="${destdir}/${mandir}" install

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

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

path: recipes/tools/tree/recipe


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

# Exit immediately on any error
set -e

program=udevil
version=20150504_ce9f1c5
release=5

# 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="
Mounts and unmounts devices without password.

udevil is a command line GNU/Linux program which mounts and unmounts
removable devices without a password, shows device info, and monitors
device changes.  It can also mount ISO files, nfs://, smb://,
ftp://, ssh:// and WebDAV URLs, and tmpfs/ramfs filesystems.
"

homepage=https://github.com/ignorantguru/udevil
license=GPLv3+

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

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

    cd "$srcdir"

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

    # https://github.com/IgnorantGuru/udevil/issues/89
    patch -Np1 -i "${worktree}/patches/udevil/exfat-nonempty-mountoption.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} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-systemd \
     --build="$(gcc -dumpmachine)"

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

    # Udev rule to enable kernel polling on removable devices
    install -p -m 644 \
     "${worktree}/archive/udevil/61-removable-storage-polling.rules" -D \
     "${destdir}/etc/udev/rules.d/61-removable-storage-polling.rules"

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

    # Restrict execution of udevil to the 'plugdev' group
    chown root:plugdev "${destdir}/usr/bin/udevil"
    chmod u+s,go-s,o-x "${destdir}/usr/bin/udevil"

    # Install devmon (udevil) perp service

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

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

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

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

    # To handle config file(s)
    touch "${destdir}/etc/perp/devmon/.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/udevil/recipe


code:
init/eudev
libs/libusb


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

# Exit immediately on any error
set -e

program=usbutils
version=014
release=1

# 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/usb/usbutils/$tarname

description="
USB utilities.

The usbutils package contains utilities used to display information
about USB buses in the system and the devices connected to them.
"

homepage=https://linux-usb.sourceforge.net
license="GPLv2.0, GPLv3.0"

# Source documentation
docs="NEWS"
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} \
     --datadir=/usr/share/hwdata \
     --mandir=$mandir \
     --disable-usbids \
     --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/usbutils/recipe


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

# Exit immediately on any error
set -e

program=util-linux
version=2.38
release=1

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

pkgname=util-linux-pass1

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

# Remote source(s)
fetch="https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v${version%.*}/$tarname"

description="
Suite of essential utilities.

The util-linux package contains miscellaneous utility programs for
handling file systems, consoles, partitions, and messages.
"

homepage=https://github.com/karelzak/util-linux
license="GPLv2+, LGPLv2.1 | Public domain, BSD with advertising"

# 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 \
     --enable-usrdir-path \
     --enable-static=no \
     --enable-shared=yes \
     --enable-sulogin-emergency-mount \
     --enable-use-tty-group \
     --enable-wall \
     --enable-write \
     --enable-libblkid \
     --enable-libmount \
     --enable-libuuid \
     --disable-raw \
     --without-btrfs \
     --without-python \
     --without-systemd \
     --without-readline \
     --build="$(gcc -dumpmachine)"

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

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

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

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


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

# Exit immediately on any error
set -e

program=util-linux
version=2.38
release=1

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

# The installation of this package replaces to
replace=util-linux-pass1

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

# Remote source(s)
fetch="https://mirrors.edge.kernel.org/pub/linux/utils/util-linux/v${version%.*}/$tarname"

description="
Suite of essential utilities.

The util-linux package contains miscellaneous utility programs for
handling file systems, consoles, partitions, and messages.
"

homepage=https://github.com/karelzak/util-linux
license="GPLv2+, LGPLv2.1 | Public domain, BSD with advertising"

# 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 \
     --enable-usrdir-path \
     --enable-static=no \
     --enable-shared=yes \
     --enable-sulogin-emergency-mount \
     --enable-use-tty-group \
     --enable-wall \
     --enable-write \
     --enable-libblkid \
     --enable-libmount \
     --enable-libuuid \
     --disable-raw \
     --with-btrfs \
     --with-python=3 \
     --with-readline \
     --without-systemd \
     --build="$(gcc -dumpmachine)"

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

    # Make `hwclock' available for the user
    chmod 755 "${destdir}/usr/sbin/hwclock"
    ( cd "${destdir}/usr/bin" && ln -s ../sbin/hwclock clock )

    # 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/util-linux/recipe


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

# Exit immediately on any error
set -e

program=vim
version=8.2.4212
release=1

pkgname=vim-tiny

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

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

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

homepage=https://www.vim.org

description="
The ubiquitous text editor (tiny version).

Vim is a highly configurable text editor built to make creating and
changing any kind of text very efficient.  It is included as \"vi\"
with most UNIX systems and with Apple OS X.

For more information, visit:  $homepage
"

license=Custom

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

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

    cd $srcdir

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

    # Workaround for the special 'srcdir' variable, it is internally
    # imported and exported from vim's ./configure
    saved_srcdir=$srcdir
    unset -v srcdir

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-gui=no \
     --enable-multibyte \
     --disable-netbeans \
     --disable-gtktest \
     --disable-icon-cache-update \
     --disable-desktop-database-update \
     --with-features=tiny \
     --with-compiledby="Dragora GNU/Linux-Libre" \
     --without-x \
     --build="$(gcc -dumpmachine)"

    # Restore 'srcdir'
    srcdir=$saved_srcdir
    unset -v saved_srcdir

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

    # Do not include this for our "tiny" package
    rm -rf "${destdir}/usr/share/applications" \
           "${destdir}/usr/share/icons"

    # Add wrappers script from Dragora for compatibility mode (vi)
    cp -f "${worktree}/archive/vim/usr/bin/vi" \
          "${destdir}/usr/bin"
    chmod 755 "${destdir}/usr/bin/vi"

    # 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/vim-tiny/recipe


code:
# Build recipe for vorbis-tools.
#
# 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=vorbis-tools
version=1.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://ftp.osuosl.org/pub/xiph/releases/vorbis/$tarname

description="
Command-line tools for encoding or playing Ogg files.

The vorbis-tools package contains command-line tools useful for
encoding, playing or editing files using the Ogg CODEC.
"

homepage=https://www.xiph.org/ogg/
license=GPLv2+

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

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

    cd "$srcdir"

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

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

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

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

path: recipes/tools/vorbis-tools/recipe


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

# Exit immediately on any error
set -e

program=which
version=2.21
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/which/$tarname

description="
Shows the full path of (shell) commands.

Which is a utility that prints out the full path of the executables
that the shell would execute when the passed program names would have
been entered on the shell prompt.
"

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

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

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

    cd "$srcdir"

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

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

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

    # Compress pages and copy documentation

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

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

path: recipes/tools/which/recipe


code:
# Build recipe for xfsprogs.
#
# 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=xfsprogs
version=5.18.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://mirrors.edge.kernel.org/pub/linux/utils/fs/xfs/xfsprogs/$tarname

description="
A high-performance journaling filesystem.

XFS combines advanced journaling technology with full 64-bit addressing
and scalable structures and algorithms.  This combination delivers the
most scalable high-performance filesystem ever conceived.
"

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

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

# Limit parallel jobs for this build
jobs=1

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

    cd "$srcdir"

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

    ./configure LDFLAGS="$QILDFLAGS" \
    OPTIMIZER="$QICFLAGS -O3" DEBUG="-DNDEBUG" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --libexecdir=/usr/libexec/xfsprogs \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-blkid=yes \
     --enable-gettext=yes \
     --enable-libicu=yes \
     --enable-lto=yes \
     --build="$(gcc -dumpmachine)"

    make -j${jobs} V=1

    make -j${jobs} V=1 \
     DIST_ROOT="$destdir" \
     PKG_ROOT_SBIN_DIR="/usr/sbin" \
     PKG_ROOT_LIB_DIR="/usr/lib${libSuffix}" \
     install install-dev

    # Remove cron job for the experimental xfs_scrub utility
    rm -f "${destdir}/usr/lib${libSuffix}/xfsprogs/xfs_scrub_all.cron"
    rmdir "${destdir}/usr/lib${libSuffix}/xfsprogs"

    # 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

    # Remove non-versioned location
    rm -rf "${destdir}/usr/share/doc/xfsprogs"

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

path: recipes/tools/xfsprogs/recipe


code:
libs/libetpan
gnupg/gpgme


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

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

path: recipes/x-apps/claws-mail/post-install


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

# Exit immediately on any error
set -e

program=claws-mail
version=4.0.0
release=1

# Define a category for the output of the package name
pkgcategory=x-apps

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

# Remote source(s)
fetch=https://www.claws-mail.org/releases/$tarname

description="
An email client (and news reader), based on GTK+.

Claws Mail is an email client (and news reader), based on GTK+,
featuring: Quick response, Graceful, and sophisticated interface
Easy configuration, intuitive operation, Abundant features,
Extensibility, Robustness and stability.

The appearance and interface are designed to be familiar to new users
coming from other popular email clients, as well as experienced users.
Almost all commands are accessible with the keyboard.

The messages are managed in the standard MH format, which features
fast access and data security.  You'll be able to import your emails
from almost any other email client, and export them just as easily.

Lots of extra functionality, like an RSS aggregator, calendar, or
laptop LED handling, are provided by extra plugins.

Claws Mail is distributed under the GPL.
"

homepage=https://claws-mail.org/
license=GPLv3+

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

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

    cd "$srcdir"

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

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

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

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

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

path: recipes/x-apps/claws-mail/recipe


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

path: recipes/x-apps/connman-gtk/post-install


code:
# Build recipe for connman-gtk.
#
# 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=connman-gtk
version=20180626_b72c6ab
release=1

# Define a category for the output of the package name
pkgcategory=x-apps

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 GTK GUI for ConnMan.

This package requires conmman.
"

homepage=https://github.com/jgke/connman-gtk
license=GPLv2+

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

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

    cd "$srcdir"

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

    mkdir -p build
    cd build

    # TODO: openconnect should be added.

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     -Duse_openconnect=no \
     ..

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

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

    cd ..

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

path: recipes/x-apps/connman-gtk/recipe


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

# Define a category for the output of the package name
pkgcategory=x-apps

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

# Remote source(s)
fetch=https://dl.suckless.org/tools/$tarname

description="
A dynamic menu for X, related to DWM.

dmenu is a dynamic menu for X, originally designed for dwm.  It manages
large numbers of user-defined menu items efficiently.
"

homepage=https://tools.suckless.org/dmenu/
license=MIT

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

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

    cd "$srcdir"

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

    cat "${worktree}/archive/dmenu/config.mk" > ./config.mk

    make -j${jobs} \
     X11INC=/usr/include/X11 \
     X11LIB=/usr/lib${libSuffix}/X11 \
     FREETYPEINC=/usr/include/freetype2
    make -j${jobs} PREFIX=/usr DESTDIR="$destdir" install

    strip --strip-unneeded "${destdir}/usr/bin"/* 2> /dev/null || true;
    lzip -9 "${destdir}/${mandir}/man1"/*.1

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

path: recipes/x-apps/dmenu/recipe


code:
# Make default symlink for xinitrc-dwm if 'xinitrc' does not exist,
# or if 'xinitrc' is a dangling symlink

if test ! -e etc/X11/xinit/xinitrc || {
   test -L etc/X11/xinit/xinitrc && test ! -e etc/X11/xinit/xinitrc
}
then
    cd etc/X11/xinit && ln -sf xinitrc-dwm xinitrc
fi

path: recipes/x-apps/dwm/post-install


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

# Define a category for the output of the package name
pkgcategory=x-apps

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

# Remote source(s)
fetch=https://dl.suckless.org/dwm/$tarname

description="
Dynamic Window Manager.

dwm is a dynamic window manager for X.  It manages windows in tiled,
monocle and floating layouts.  All of the layouts can be applied
dynamically, optimising the environment for the application in use
and the task performed.
"

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

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

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

    cd "$srcdir"

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

    # Set default font size to '14'
    patch -p0 < "${worktree}/patches/dwm/dwm-fontsize.diff"

    cat "${worktree}/archive/dwm/config.mk" > ./config.mk

    make -j${jobs} \
     X11INC=/usr/include/X11 \
     X11LIB=/usr/lib${libSuffix}/X11 \
     FREETYPEINC=/usr/include/freetype2

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

    strip --strip-unneeded "${destdir}/usr/bin/dwm"
    lzip -9 "${destdir}/${mandir}/man1/dwm.1"

    # Include xinitrc file to start DWM

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

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

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

path: recipes/x-apps/dwm/recipe


path: recipes/x-apps/emacs/post-install


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

# Exit immediately on any error
set -e

program=emacs
version=27.2
release=1

# Define a category for the output of the package name
pkgcategory=x-apps

tarname=${program}-${version}.tar.xz
# srcdir=${program}-${version}    # Not needed in major releases

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

description="
The Emacs text editor.

GNU Emacs is an extensible, customizable text editor and more.
At its core is an interpreter for Emacs Lisp, a dialect of the
Lisp programming language with extensions to support text
editing.
"

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

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    $configure_args \
    --libdir=/usr/lib${libSuffix} \
    --infodir=$infodir \
    --mandir=$mandir \
    --docdir=$docdir \
    --program-prefix= \
    --program-suffix= \
    --with-modules \
    --with-x \
    --with-x-toolkit=gtk3 \
    --without-libsystemd \
    --without-gconf \
    --without-gsettings \
    --without-compress-install \
    --build="$(gcc -dumpmachine)"

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

    # A world without systemd is a healthy world...
    rm -rf "${destdir}/usr/lib${libSuffix}/systemd"
    rmdir "${destdir}/usr/lib${libSuffix}" 2> /dev/null || true

    # Re-create directory for games
    mkdir -p "${destdir}/var/games/emacs"
    chown :games "${destdir}/var/games/emacs"

    if test -d "${destdir}/$infodir"
    then
        # Delete index file for the package
        rm -f "${destdir}/${infodir}/dir"

        # Compress info documents
        lzip -9 "${destdir}/${infodir}"/* || true
    fi

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

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

path: recipes/x-apps/emacs/recipe


path: recipes/x-apps/feh/post-install


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

# Exit immediately on any error
set -e

program=feh
version=3.8
release=1

# Define a category for the output of the package name
pkgcategory=x-apps

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

# Remote source(s)
fetch=https://feh.finalrewind.org/"$tarname"

description="
A fast and light image viewer.

Feh is a fast, lightweight image viewer which uses imlib2.  It is
command line-driven and supports multiple images through slideshows,
thumbnail browsing or multiple windows, and montages or index prints
(using TrueType fonts to display file info).  Advanced features include
fast dynamic zooming, progressive loading, loading via HTTP (with
reload support for watching webcams), recursive file opening (slideshow
of a directory hierarchy), and mouse wheel/keyboard control.
"

homepage=https://feh.finalrewind.org
license="MIT Expat variant"

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

# Limit parallel jobs for this build
jobs=1

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

    cd "$srcdir"

    # Replace default C flags with the ones provided by Qi
    sed -i "s/-g -O2/$QICFLAGS/" config.mk

    make -j${jobs} V=1 PREFIX=/usr
    make -j${jobs} V=1 \
     PREFIX=/usr \
     doc_dir="$destdir/$docsdir" \
     example_dir="$destdir/${docsdir}/examples" \
     DESTDIR="$destdir" install

    strip --strip-unneeded "${destdir}/usr/bin/feh"

    # 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/x-apps/feh/recipe


code:
libs/imlib2
libs/giblib


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

# Exit immediately on any error
set -e

program=scrot
version=0.10.0
release=1

# Define a category for the output of the package name
pkgcategory=x-apps

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

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

description="
Command line screen capture util.

scrot is a command-line screen capture util like \"import\", but using
imlib2.  It has lots of options for autogenerating filenames, and can
do fun stuff like taking screenshots of multiple displays and glueing
them together.
"

homepage=https://github.com/dreamer/scrot
license=MIT

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

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

    cd "$srcdir"

    rm -rf BUILD
    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     ..

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

    cd ..

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

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

path: recipes/x-apps/scrot/recipe


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

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

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

path: recipes/x-apps/spacefm/post-install


code:
# Build recipe for spacefm.
#
# 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=spacefm
version=20180304_e6f2918
release=2

# Define a category for the output of the package name
pkgcategory=x-apps

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="
SpaceFM file manager.

SpaceFM is a multi-panel tabbed file and desktop manager for GNU/Linux
with built-in VFS, udev- or HAL-based device manager, customisable menu
system, and bash-GTK integration. SpaceFM aims to provide a stable,
capable file manager with significant customisation capabilities.
"

homepage=https://ignorantguru.github.io/spacefm/
license="GPLv3+, LGPLv3"

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

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

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

    cd "$srcdir"

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

    patch -Np1 -i "${worktree}/patches/spacefm/spacefm-include-sysmacros.patch"

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

    # TODO: --enable-video-thumbnails requires FFmpeg

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

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

    # To handle (dot) .new files via graft(1)
    touch "${destdir}/etc/spacefm/.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/x-apps/spacefm/recipe


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

# Exit immediately on any error
set -e

program=st
version=0.8.5
release=1

# Define a category for the output of the package name
pkgcategory=x-apps

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

# Remote source(s)
fetch=https://dl.suckless.org/st/$tarname

description="
st is a simple terminal implementation for X.

st supports:
*   most VT10X escape sequences
*    serial line support
*    XIM support
*    utmp via utmp(1)
*    clipboard handling
*    mouse and keyboard shortcuts (via config.h)
*    UTF-8
*    wide-character support
*    resize
*    256 colors and true colors
*    antialiased fonts (using fontconfig)
*    fallback fonts
*    line drawing
"

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

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

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

    cd "$srcdir"

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

    cat "${worktree}/archive/st/config.mk" > ./config.mk

    make -j${jobs} \
     CFLAGS="$QICFLAGS -std=c99" \
     LDFLAGS="$QILDFLAGS" \
     X11INC=/usr/include/X11 \
     X11LIB=/usr/lib${libSuffix}/X11

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

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

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

path: recipes/x-apps/st/recipe


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

# Exit immediately on any error
set -e

program=vim
version=8.2.4212
release=1

pkgname=vim-huge

# Define a category for the output of the package name
pkgcategory=x-apps

# The installation of this package replaces to
replace=vim-tiny

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

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

homepage=https://www.vim.org

description="
The ubiquitous text editor (huge version, with X11 support).

Vim is a highly configurable text editor built to make creating and
changing any kind of text very efficient.  It is included as \"vi\"
with most UNIX systems and with Apple OS X.

For more information, visit:  $homepage
"

license=Custom

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

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

    cd $srcdir

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

    # Workaround for the special 'srcdir' variable, it is internally
    # imported and exported from vim's ./configure
    saved_srcdir=$srcdir
    unset -v srcdir

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --enable-gui=gtk2 \
     --enable-multibyte \
     --enable-perlinterp \
     --enable-pythoninterp \
     --enable-python3interp \
     --enable-rubyinterp \
     --enable-tclinterp \
     --disable-netbeans \
     --with-features=huge \
     --with-compiledby="Dragora GNU/Linux-Libre" \
     --with-x \
     --build="$(gcc -dumpmachine)"

    # Restore 'srcdir'
    srcdir=$saved_srcdir
    unset -v saved_srcdir

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

    # Add wrappers script from Dragora for compatibility mode (vi)
    cp -f "${worktree}/archive/vim/usr/bin/vi" \
          "${destdir}/usr/bin"
    chmod 755 "${destdir}/usr/bin/vi"

    # 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/x-apps/vim-huge/recipe


path: recipes/x-apps/xterm/post-install


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

# Define a category for the output of the package name
pkgcategory=x-apps

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

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

description="
Terminal emulator for X.

The xterm program is a terminal emulator for the X Window System.
It provides DEC VT102 and Tektronix 4014 compatible terminals for
programs that can't use the window system directly.
"

homepage=https://invisible-island.net/xterm
license=Custom

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

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

    cd "$srcdir"

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

    # Patch taken from Alpine Linux (Thanks!)
    # https://git.alpinelinux.org/cgit/aports/tree/community/xterm/posix-ptys.patch
    patch -p1 < "${worktree}/patches/xterm/posix-ptys.patch"

    # These commands modify the terminal description so that the
    # Backspace key is expected to send the character with ASCII
    # code 127.  This is done for consistency with the Linux console.
    # Thanks to Beyond Linux From Scratch!
    sed -i '/v0/{n;s/new:/new:kb=^?:/}' termcap && \
     printf '\tkbs=\\177,\n' >> terminfo

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    TERMINFO=/usr/share/terminfo \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --enable-exec-xterm \
     --enable-256-color \
     --enable-88-color \
     --enable-luit \
     --enable-wide-chars \
     --enable-dabbrev \
     --enable-setgid \
     --enable-imake \
     --disable-setuid \
     --disable-full-tgetent \
     --with-pcre2 \
     --with-app-defaults=/etc/X11/app-defaults \
     --with-tty-group=tty \
     --with-x \
     --build="$(gcc -dumpmachine)"

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

    # Conflicts with files provided by ncurses
    #make -j${jobs} DESTDIR="$destdir" install-ti

    # Append extra information.
    #
    # In order for xterm to follow the locale settings in the
    # environment, use TrueType fonts, and follow the GNU/Linux
    # convention about the code sent by the Backspace key, we add
    # the following definitions
    cat << EOF >> "${destdir}/etc/X11/app-defaults/XTerm"
*VT100*locale: true
*VT100*faceName: Monospace
*VT100*faceSize: 14
*backarrowKeyIsErase: true
*ptyInitialErase: true
EOF

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

    # Include desktop entries
    mkdir -p "${destdir}/usr/share/applications"
    cp -p xterm.desktop uxterm.desktop \
          "${destdir}/usr/share/applications/"

    # 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/x-apps/xterm/recipe


code:
# Update Glib schemas
glib-compile-schemas usr/share/glib-?.?*/schemas


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

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

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

# Remote source(s)
fetch="https://ftp.gnome.org/pub/gnome/sources/at-spi2-atk/${version%.*}/$tarname"

description="
A GTK+ module that bridges ATK to the new D-Bus based AT-SPI.

This package includes libatk-bridge, a library that bridges ATK to the
new D-Bus based AT-SPI, as well as a corresponding module for gtk+ 2.x.
Gtk+ 3.x now links against libatk-bridge directly rather than requiring
it to be loaded as a module.

These libraries depend on the at-spi2-core code that contains the
daemon for registering applications, D-Bus helper libraries and the
AT-SPI D-Bus specifications.
"

homepage=https://wiki.gnome.org/Accessibility/
license=LGPLv2+

docs="AUTHORS 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 .

    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     ..

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

    cd ..

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


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

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

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

# Remote source(s)
fetch="https://ftp.gnome.org/pub/gnome/sources/at-spi2-core/${version%.*}/$tarname"

description="
A part of the GNOME Accessibility Project.

It provides a Service Provider Interface for the Assistive Technologies
available on the GNOME platform and a library against which
applications can be linked.
"

homepage=https://wiki.gnome.org/Accessibility/
license=LGPLv2.1

docs="AUTHORS COPYING MAINTAINERS NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     ..

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

    cd ..

    # This is only for poseurs (or posers)..  Are you a POSEUR(tm)?
    rm -rf "${destdir}/usr/lib/systemd"
    rmdir "${destdir}/usr/lib" || true

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


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

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

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

# Remote source(s)
fetch="https://ftp.gnome.org/pub/gnome/sources/atk/${version%.*}/$tarname"

description="
A library of accessibility functions.

It is widely used by the GTK+ toolkit.
"

homepage=https://developer.gnome.org/atk/
license=LGPLv2+

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

    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     ..

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

    cd ..

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

path: recipes/x-libs/atk/recipe


code:
# Build recipe for Cairo (pass1).
#
# 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=cairo
version=1.17.4
release=1

pkgname=cairo-pass1

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

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

# Remote source(s)
#fetch=https://www.cairographics.org/releases/$tarname
fetch=https://cairographics.org/snapshots/$tarname

description="
Temporary installation of cairo.

This is a temporary installation that is replaced with additional
support included in the final cairo package.
"

homepage=https://www.cairographics.org/
license="LGPLv2.1 | MPLv1.1"

# Copy documentation
docsdir="${docdir}/${pkgname}-${version}"

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

    cd "$srcdir"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-tee \
     --enable-xlib \
     --enable-xcb \
     --enable-ft \
     --enable-xml \
     --disable-trace \
     --disable-xcb-shm \
     --disable-xlib-xcb \
     --disable-gtk-doc \
     --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
}


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

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

# The installation of this package replaces to
replace=cairo-pass1

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

# Remote source(s)
#fetch=https://www.cairographics.org/releases/$tarname
fetch=https://cairographics.org/snapshots/$tarname

description="
A vector graphics library.

Cairo is designed to produce identical output on all output media while
taking advantage of display hardware acceleration when available.
"

homepage=https://www.cairographics.org/
license="LGPLv2.1 | MPLv1.1"

# Copy documentation
docs="AUTHORS BIBLIOGRAPHY BUGS CODING_STYLE COPYING* HACKING NEWS README"
docsdir="${docdir}/${program}-${version}"

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

    cd "$srcdir"

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

    ./configure \
    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" CXXFLAGS="$QICXXFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --infodir=$infodir \
     --mandir=$mandir \
     --enable-static=no \
     --enable-shared=yes \
     --enable-tee \
     --enable-xlib \
     --enable-xcb \
     --enable-ft \
     --enable-svg \
     --enable-xml \
     --enable-gobject \
     --disable-trace \
     --disable-xcb-shm \
     --disable-xlib-xcb \
     --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/x-libs/cairo/recipe


code:
echo "Updating desktop database ..."
chroot "$rootdir" /usr/bin/update-desktop-database -q


code:
# Build recipe for desktop-file-utils.
#
# 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=desktop-file-utils
version=0.26
release=1

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

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

# Remote source(s)
fetch=https://www.freedesktop.org/software/desktop-file-utils/releases/$tarname

description="
Utilities for manipulating desktop files.

desktop-file-utils contains a few command line utilities for
working with desktop entries.
"

homepage=https://www.freedesktop.org/wiki/Software/desktop-file-utils/
license=GPLv2+

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

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

    cd "$srcdir"

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

    mkdir BUILD
    cd BUILD

    CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
    meson setup $configure_args \
     --libdir /usr/lib${libSuffix} \
     --buildtype=release \
     --strip \
     ..

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

    cd ..

    # To meet the XDG Base Directory specification
    mkdir -p "${destdir}/usr/share/applications"

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

# Exit immediately on any error
set -e

program=fontconfig
version=2.13.1
release=2

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

pkgname=fontconfig-pass1

description="
Temporary installation of fontconfig.

This is a temporary installation to satisfy the requirements of Xorg.
Later, this will be replaced with the fully \"fontconfig\" package.
"

homepage=https://www.freedesktop.org/wiki/Software/fontconfig/
license=Custom

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

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

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

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

    cd "$srcdir"

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

    # Make sure the system regenerates src/fcobjshash.h (Thanks to BLFS!)
    rm -f src/fcobjshash.h

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

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

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


code:
# This will be performed on the local filesystem
if test "$rootdir" = "" || test "$rootdir" = /
then
    echo "Rebuilding fontconfig cache: fc-cache -f --system-only"
    fc-cache -f --system-only
fi

path: recipes/x-libs/fontconfig/post-install


code:
# Build recipe for fontconfig.
#
# 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=fontconfig
version=2.13.1
release=2

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

# The installation of this package replaces to
replace=fontconfig-pass1

description="
Library for font configuration.

The fontconfig package is a library for configuring and customizing
font access.
"

homepage=https://www.freedesktop.org/wiki/Software/fontconfig/
license=Custom

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

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

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

    # Make sure the system regenerates src/fcobjshash.h (Thanks to BLFS!)
    rm -f src/fcobjshash.h

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

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

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

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

path: recipes/x-libs/fontconfig/recipe


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

# Exit immediately on any error
set -e

program=freetype
version=2.11.1
release=1

pkgname=freetype-pass1

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

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

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

description="
Temporary installation of freetype.

This is a temporary installation to satisfy the requirements of Xorg.
Later, this will be replaced with the fully \"freetype\" package.
"

homepage=https://www.freetype.org/
license="GPLv2 | FreeType License (FTL)"

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-static \
     --enable-shared \
     --with-bzip2=yes \
     --with-zlib=yes \
     --with-png=yes \
     --with-harfbuzz=no \
     --build="$(gcc -dumpmachine)" \
     ac_cv_prog_RC= ac_cv_prog_ac_ct_RC=

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

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


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

# Exit immediately on any error
set -e

program=freetype
version=2.11.1
release=1

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

# The installation of this package replaces to
replace=freetype-pass1

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

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

description="
A font engine.

FreeType is a software font engine that is designed to be small,
efficient, highly customizable, and portable while capable of
producing high-quality output (glyph images).  It can be used in
graphics libraries, display servers, font conversion tools,
text image generation tools, and many other products as well.
"

homepage=https://www.freetype.org/
license="GPLv2 | FreeType License (FTL)"

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

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

    cd "$srcdir"

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

    ./configure CPPFLAGS="$QICPPFLAGS" \
    CFLAGS="$QICFLAGS" LDFLAGS="$QILDFLAGS" \
     $configure_args \
     --libdir=/usr/lib${libSuffix} \
     --mandir=$mandir \
     --docdir=$docsdir \
     --disable-static \
     --enable-shared \
     --with-bzip2=yes \
     --with-zlib=yes \
     --with-png=yes \
     --with-harfbuzz=yes \
     --build="$(gcc -dumpmachine)" \
     ac_cv_prog_RC= ac_cv_prog_ac_ct_RC=

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

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

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

path: recipes/x-libs/freetype/recipe