From f0d86b6d85d2eac3ff390a4f26375a65473de393 Mon Sep 17 00:00:00 2001 From: Dylan Araps Date: Mon, 7 Oct 2019 15:48:36 +0300 Subject: [PATCH] kiss: better junk removal. --- kiss | 60 +++++++++++++++++------------------------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) diff --git a/kiss b/kiss index 3d8ac4e..692e0e2 100755 --- a/kiss +++ b/kiss @@ -307,56 +307,30 @@ pkg_fixdeps() { pkg_junk() ( # Optionally remove "junk" files from packages. This includes 'info' # files, 'man' pages, gettext files, etc. This is configurable by the - # user to enable choice. + # user. # # This funcion runs as a sub-shell to avoid having to 'cd' back to the # prior directory before being able to continue. cd "$pkg_dir/$1" - # Man pages (kept by default). - [ "${KISS_KEEP_MAN:-1}" = 1 ] || { - log "$1" "Removing man pages" + # Default list of directories and their contents to be removed from + # built packages. This default assumes a prefix of '/usr' though the + # user can further configure it to search whatever paths they desire. + rm_default=usr/share/doc:usr/share/gtk-doc:usr/share/info:usr/share/polkit-1 + rm_default=$rm_default:usr/share/gettext:usr/share/locale + rm_default=$rm_default:etc/bash_completion.d:usr/share/zsh - rm -rf usr/share/man - } + # Split the environment variable on ':' and turn it into an argument + # list. This works exactly like '$KISS_PATH'. + # + # shellcheck disable=2046,2086 + { IFS=:; set -- ${KISS_RM:-$rm_default}; IFS=$old_ifs; } - # Info files (deleted by default). - [ "${KISS_KEEP_INFO:-0}" = 1 ] || { - log "$1" "Removing info files" - - rm -rf usr/share/info - } - - # Intl files (deleted by default). - [ "${KISS_KEEP_INTL:-0}" = 1 ] || { - log "$1" "Removing intl files" - - rm -rf usr/share/gettext - rm -rf usr/share/locale - } - - # Documentation (deleted by default). - [ "${KISS_KEEP_DOC:-0}" = 1 ] || { - log "$1" "Removing documentation" - - rm -rf usr/share/doc - rm -rf usr/share/gtk-doc - } - - # Shell completions (deleted by default). - [ "${KISS_KEEP_SHCOMP:-0}" = 1 ] || { - log "$1" "Removing shell completions" - - rm -rf etc/bash_completion.d - rm -rf usr/share/zsh - } - - # Misc junk (deleted by default). - [ "${KISS_KEEP_JUNK:-0}" = 1 ] || { - log "$1" "Removing junk" - - rm -rf usr/share/polkit-1 - } + # Loop over each junk entry and delete it if it exists. + for junk; do + [ -e "./$junk" ] && find "./$junk" -delete && + log "${PWD##*/}" "Removed $junk" + done ||: ) pkg_manifest() (