From patchwork Sun Dec 9 16:35:04 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [31/51] package/qemu: add option to remove unwanted keymaps Date: Sun, 09 Dec 2012 06:35:04 -0000 From: "Yann E. MORIN" X-Patchwork-Id: 204734 Message-Id: <1355070924-8009-32-git-send-email-yann.morin.1998@free.fr> To: buildroot@busybox.net Cc: "Yann E. MORIN" Signed-off-by: "Yann E. MORIN" --- package/qemu/Config.in | 12 ++++++++++ package/qemu/qemu.mk | 55 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 67 insertions(+), 0 deletions(-) diff --git a/package/qemu/Config.in b/package/qemu/Config.in index 8d647c9..d97e7da 100644 --- a/package/qemu/Config.in +++ b/package/qemu/Config.in @@ -131,4 +131,16 @@ config BR2_PACKAGE_QEMU_BLOBS Note2: This has nothing to do with the licensing of the blobs; some (most?) even have a free and/or open source license. +config BR2_PACKAGE_QEMU_KEYMAPS + string "Keymaps to keep" + default "all" + help + Enter the list of keymap(s) to keep. To keep many keymaps, you can + use shell globs, or you can enter a space-separated list of keymaps: + - empty to remove all keymaps + - 'all' to keep all keymaps + - 'fr*' to keep all french keymaps + - 'de fr* en-*' for german, french and english keymaps + - and so on (see the QEMU source for all supported keymaps) + endif # BR2_PACKAGE_QEMU diff --git a/package/qemu/qemu.mk b/package/qemu/qemu.mk index 1100621..62eb066 100644 --- a/package/qemu/qemu.mk +++ b/package/qemu/qemu.mk @@ -153,6 +153,61 @@ ifeq ($(BR2_PACKAGE_QEMU_BLOBS),) QEMU_OPTS += --disable-blobs endif +# Post-install removal of unwanted keymaps: +# - if we want 'all', we do nothing; +# - if we want none, we completely remove the keymap dir +# - otherwise: +# - we completely remove the keymap dir; and recreate it empty +# - we recursively copy only those keymaps we want (as keymaps may include +# some common files) +# +# NOTE-1: we need the un-quoted list of keymaps, so it is interpreted as a glob +# by the shell. +# NOTE-2: yes, all (current!) keymaps do include the 'common' keymap, which in +# turn includes the 'modifiers' keymap, so we could unconditionally +# copy those two, for a much simpler code. Doing it the way it's done +# is more generic, and will adapt to any future keymaps which has +# multiple includes, or none. +# NOTE-3: we can't use $(SED), because it expands to include the '-i' option, +# which we do *not* want here, because we are not munging a file, but +# using sed as a enhanced grep. +# +QEMU_KEYMAPS = $(call qstrip,$(BR2_PACKAGE_QEMU_KEYMAPS)) + +ifeq ($(QEMU_KEYMAPS),all) #--- Keep all keymaps ---# +define QEMU_POST_INSTALL_KEYMAPS + @: Nothing +endef + +else ifeq ($(QEMU_KEYMAPS),) #--- Remove all keymaps ---# +define QEMU_POST_INSTALL_KEYMAPS + rm -rf "$(TARGET_DIR)/usr/share/qemu/keymaps" +endef + +else #--- Keep selected keymaps ---# +define QEMU_POST_INSTALL_KEYMAPS + rm -rf "$(TARGET_DIR)/usr/share/qemu/keymaps" + mkdir -p "$(TARGET_DIR)/usr/share/qemu/keymaps" + add_keymap() { \ + local k="$${1}"; local dest="$${2}"; \ + if [ -n "$${k}" -a ! -f "$${dest}/$${k}" ]; then \ + cp -v "$${k}" "$${dest}"; \ + for k in $$(sed -r -e '/^include[[:space:]]+(.*)$$/!d;' \ + -e 's//\1/;' "$${k}" ); do \ + add_keymap "$${k}" "$${dest}"; \ + done; \ + fi; \ + }; \ + cd $(@D)/pc-bios/keymaps; \ + for k in $(QEMU_KEYMAPS); do \ + add_keymap "$${k}" "$(TARGET_DIR)/usr/share/qemu/keymaps"; \ + done +endef + +endif # Keymaps to keep + +QEMU_POST_INSTALL_TARGET_HOOKS += QEMU_POST_INSTALL_KEYMAPS + # Note: although QEMU uses a ./configure script, it is not compatible with # the traditional autotools options (eg. --target et al.), so we have # to override the default provided by the autotools-package infra, and