Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[terminfo-db] Add a builder for the terminfo database #9165

Merged
merged 12 commits into from
Aug 6, 2024
73 changes: 73 additions & 0 deletions T/TermInfoDB/build_tarballs.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
using BinaryBuilder

# This is based on https://www.freshports.org/misc/terminfo-db/
name = "TermInfoDB"
version = v"2023.12.9"

v = string(version.major, lpad(version.minor, 2, '0'), lpad(version.patch, 2, '0'))
sources = [
FileSource("https://invisible-island.net/archives/ncurses/current/terminfo-$v.src.gz",
"2debcf2fd689988d44558bcd8a26a104b96542ffc9540f19e2586b3aeecd1c79"),
DirectorySource("./bundled"),
]

script = raw"""
cd ${WORKSPACE}/srcdir/

# Adopting the wisdom of https://mywiki.wooledge.org/ParsingLs (🙏 Mosè)
shopt -s nullglob

# Install `tree` to get an overview of what's going to be included in the JLL
apk update
apk add tree

ararslan marked this conversation as resolved.
Show resolved Hide resolved
gunzip terminfo-*
mkdir -p "${prefix}/share/terminfo"
tic -sx -o "${prefix}/share/terminfo" ./terminfo-*

# The terminfo filesystem-based database contains both upper- and lowercase directory
# names, which presents a problem for case-insensitive filesystems. Let's rename all
# files and directories to lowercase, dealing with conflicts by overwriting and hoping
# for the best.
pushd "${prefix}/share/terminfo/"
for dir in *; do
lcdir="${dir,,}"
mkdir -vp "${lcdir}"
for file in ${dir}/*; do
ararslan marked this conversation as resolved.
Show resolved Hide resolved
ararslan marked this conversation as resolved.
Show resolved Hide resolved
lcfile="${file,,}"
if [ "${dir}/${file}" = "${lcdir}/${lcfile}" ]; then
# Already all lowercase, nothing to do
continue
fi
mv -fv "${dir}/${file}" "${lcdir}/${lcfile}.TEMP"
rm -fv "${lcdir}/${lcfile}"
mv -fv "${lcdir}/${lcfile}.TEMP" "${lcdir}/${lcfile}"
if [ -e "${dir}/${file}" ] || [ -e "${lcdir}/${lcfile}.TEMP" ]; then
echo "ERROR: '${dir}/${file}' not successfully renamed to lowercase!!!"
exit 1
fi
done
if [ -z "$(ls -A "${dir}")" ]; then
rm -rfv "${dir}"
fi
done
tree
ararslan marked this conversation as resolved.
Show resolved Hide resolved
popd

install_license "${WORKSPACE}/srcdir/COPYING"
"""

platforms = [AnyPlatform()]

# I'd rather not list out >2k individual `FileProduct`s so let's just call the entry
# for xterm our "product" and hope the rest are there
products = [
FileProduct("share/terminfo/x/xterm", :terminfo_xterm),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can share/terminfo be the "file" product?

Copy link
Member Author

@ararslan ararslan Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wondered that as well. I had assumed not but I just checked the implementation of FileProduct and it only requires ispath, not isfile, which suggests that it could potentially work. @giordano, is there any reason why we couldn't do what @tecosaur noted?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think that'd work as well

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does versioning work if we change this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't change the version number, Pkg will only install the latest one.

]

dependencies = [
HostBuildDependency("Ncurses_jll"), # for `tic`
]

build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies;
julia_compat="1.6")
29 changes: 29 additions & 0 deletions T/TermInfoDB/bundled/COPYING
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
Copyright 2018-2022,2023 Thomas E. Dickey
Copyright 1998-2017,2018 Free Software Foundation, Inc.

Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, distribute with modifications, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Except as contained in this notice, the name(s) of the above copyright
holders shall not be used in advertising or otherwise to promote the
sale, use or other dealings in this Software without prior written
authorization.

-- vile:txtmode fc=72
-- $Id: COPYING,v 1.12 2023/01/07 17:55:53 tom Exp $