summaryrefslogtreecommitdiffstats
path: root/install
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-07-12 04:23:36 +0200
committerDave Reisner <dreisner@archlinux.org>2011-07-24 00:42:47 +0200
commitd8505d4a4b646083ccdc959713951cb8174bbf47 (patch)
tree68c470827883c399cf20166991f23a33cbecb4b9 /install
parentc9c9cb509f3718e6581f8789c2ae6efe57b189b1 (diff)
downloadmkinitcpio-d8505d4a4b646083ccdc959713951cb8174bbf47.tar.gz
mkinitcpio-d8505d4a4b646083ccdc959713951cb8174bbf47.tar.xz
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 <dreisner@archlinux.org>
Diffstat (limited to 'install')
-rw-r--r--install/consolefont52
1 files changed, 27 insertions, 25 deletions
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<<HELPEOF
- This hook loads consolefont specified in rc.conf during early userspace.
+help() {
+ cat <<HELPEOF
+This hook loads consolefont specified in rc.conf during early userspace.
HELPEOF
}
+
+# vim: set ft=sh ts=4 sw=4 et: