Skip to content

Commit

Permalink
zfsbootmenu: make zbm.autosize a system hook
Browse files Browse the repository at this point in the history
Vendor a subset of Terminus console fonts and add a basic installation
routine to Dracut/mkinitcpio modules.
  • Loading branch information
zdykstra committed Sep 14, 2023
1 parent 640af57 commit 6235e90
Show file tree
Hide file tree
Showing 15 changed files with 147 additions and 9 deletions.
94 changes: 94 additions & 0 deletions LICENSE.fonts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Copyright (C) 2020 Dimitar Toshkov Zhekov,
with Reserved Font Name "Terminus Font".

This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL


-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------

PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.

The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.

DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.

"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).

"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).

"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.

"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.

PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:

1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.

2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.

3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.

4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.

5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.

TERMINATION
This license becomes null and void if any of the above conditions are
not met.

DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
4 changes: 4 additions & 0 deletions dracut/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -179,4 +179,8 @@ install() {
create_zbm_conf
create_zbm_profiles
create_zbm_traceconf

if command -v setfont >/dev/null 2>&1; then
install_zbm_fonts && dracut_install setfont
fi
}
2 changes: 0 additions & 2 deletions etc/zfsbootmenu/release.conf.d/common.conf
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
zfsbootmenu_early_setup+=" /zbm/contrib/20-console-autosize.sh "

# zbm-kcl
install_optional_items+=" /zbm/bin/zbm-kcl "

Expand Down
4 changes: 4 additions & 0 deletions initcpio/install/zfsbootmenu
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,10 @@ build() {
create_zbm_traceconf
create_zbm_entrypoint

if command -v setfont >/dev/null 2>&1; then
install_zbm_fonts && add_binary setfont
fi

add_runscript
}

Expand Down
7 changes: 0 additions & 7 deletions testing/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,6 @@ fi
if [ -n "${DISPLAY_TYPE}" ]; then
# Use the indicated graphical display
DISPLAY_ARGS=( "-display" "${DISPLAY_TYPE}" )

# Add release hooks, supported only under Dracut
if ((DRACUT)); then
cat <<-EOF >> "${TESTDIR}/dracut.conf.d/testing.conf"
zfsbootmenu_early_setup+=" $( realpath -e ../contrib )/20-console-autosize.sh "
EOF
fi
else
# Suppress graphical display (implies serial mode)
DISPLAY_ARGS=( "-nographic" )
Expand Down
Binary file added zfsbootmenu/fonts/ter-v14b.psf
Binary file not shown.
Binary file added zfsbootmenu/fonts/ter-v16b.psf
Binary file not shown.
Binary file added zfsbootmenu/fonts/ter-v18b.psf
Binary file not shown.
Binary file added zfsbootmenu/fonts/ter-v20b.psf
Binary file not shown.
Binary file added zfsbootmenu/fonts/ter-v22b.psf
Binary file not shown.
Binary file added zfsbootmenu/fonts/ter-v24b.psf
Binary file not shown.
Binary file added zfsbootmenu/fonts/ter-v28b.psf
Binary file not shown.
Binary file added zfsbootmenu/fonts/ter-v32b.psf
Binary file not shown.
35 changes: 35 additions & 0 deletions zfsbootmenu/hooks/early-setup.d/20-console-autosize.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/bin/bash
# vim: softtabstop=2 shiftwidth=2 expandtab

## This early-setup hook attempts to get a physical (non-serial) console
## to at least 100 columns.

#shellcheck disable=SC1091
source /lib/zfsbootmenu-kcl.sh || exit 1
source /lib/kmsg-log-lib.sh || exit 1

if [ -z "${control_term}" ] && [ -f /etc/zfsbootmenu.conf ]; then
#shellcheck disable=SC1091
source /etc/zfsbootmenu.conf
fi

# Control terminal MUST be defined to proceed
[ -c "${control_term}" ] || exit 1

# Ensure that control_term is not a serial console
tty_re='/dev/tty[0-9]'
[[ ${control_term} =~ ${tty_re} ]] || exit 1

# rd.vconsole.font is consumed by the Dracut i18n module, which is forced to run before this hook
# If the user has specified a specific font/size, do not attempt to override it

if get_zbm_bool 1 zbm.autosize && ! font=$( get_zbm_arg rd.vconsole.font ) ; then
cd /usr/share/zfsbootmenu/fonts/ || exit 0
for font in ter-v32b ter-v28b ter-v24b ter-v20b ter-v14b ; do
setfont "${font}" >/dev/null 2>&1
if [ "${COLUMNS}" -ge 100 ]; then
zdebug "set font to ${font}, screen is ${COLUMNS}x${LINES}"
break
fi
done
fi
10 changes: 10 additions & 0 deletions zfsbootmenu/install-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ install_zbm_docs() {
return $ret
}

install_zbm_fonts() {

[ -d "${zfsbootmenu_module_root}/fonts" ] || return 1

# Install into a non-standard path so that the Dracut i18n module doesn't stomp over our custom fonts

for font in "${zfsbootmenu_module_root}/fonts"/*.psf; do
zbm_install_file "${font}" "/usr/share/zfsbootmenu/fonts/${font##*/}"
done
}

populate_hook_dir() {
local hfile ret hlev
Expand Down

0 comments on commit 6235e90

Please sign in to comment.