From d8505d4a4b646083ccdc959713951cb8174bbf47 Mon Sep 17 00:00:00 2001 From: Dave Reisner Date: Mon, 11 Jul 2011 22:23:36 -0400 Subject: install/consolefont: cleanup and refactor * Provide support for uncompressed font files as well as compressed * Avoiding using an unnecessary temp file * Support $BASEDIR * Warn when no font is found * Only add the runtime hook if a font is added Signed-off-by: Dave Reisner --- install/consolefont | 52 +++++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 25 deletions(-) (limited to 'install/consolefont') diff --git a/install/consolefont b/install/consolefont index 395387b..271fc2f 100644 --- a/install/consolefont +++ b/install/consolefont @@ -1,32 +1,34 @@ -# vim: set ft=sh: +#!/bin/bash + +build() { + local file ext -build() -{ - MODULES="" - BINARIES="" - FILES="" - SCRIPT="consolefont" eval "$(grep -e "^CONSOLEFONT=" /etc/rc.conf)" - if [ -n "$CONSOLEFONT" ]; then - if [ -e /usr/share/kbd/consolefonts/$CONSOLEFONT.psfu.gz ]; then - CONSOLEFONT_FILE_GZ="/usr/share/kbd/consolefonts/$CONSOLEFONT.psfu.gz" - CONSOLEFONT_FILE="$(mktemp ${TMPDIR}/consolefont.psfu.XXXXXX)" - zcat ${CONSOLEFONT_FILE_GZ} > ${CONSOLEFONT_FILE} - add_file ${CONSOLEFONT_FILE} /consolefont.psfu - elif [ -e /usr/share/kbd/consolefonts/$CONSOLEFONT.psf.gz ]; then - CONSOLEFONT_FILE_GZ="/usr/share/kbd/consolefonts/$CONSOLEFONT.psf.gz" - CONSOLEFONT_FILE="$(mktemp ${TMPDIR}/consolefont.psf.XXXXXX)" - zcat ${CONSOLEFONT_FILE_GZ} > ${CONSOLEFONT_FILE} - add_file ${CONSOLEFONT_FILE} /consolefont.psf - else - echo "consolefont: Font file does not exist or does not end with .psf.gz or .psfu.gz." - fi + if [[ -n "$CONSOLEFONT" ]]; then + for file in "$BASEDIR/usr/share/kbd/consolefonts/$CONSOLEFONT".psf?(u)?(.gz); do + if [[ -e $file ]]; then + [[ $file =~ \.(psfu?)(\.gz)?$ ]] && ext=${BASH_REMATCH[1]} + if [[ $file = *.gz ]]; then + gzip -cd "$file" > "$BUILDROOT/consolefont.$ext" + else + add_file "${file#$BASEDIR}" "/consolefont.$ext" + fi + SCRIPT=consolefont + return 0 + fi + done + error "consolefont: requested font not found: \`%s'" "$CONSOLEFONT" + return 1 + else + warning "consolefont: no font found in %s/etc/rc.conf" "${BASEDIR%/}" + return 1 fi } -help () -{ -cat<