summaryrefslogtreecommitdiff
path: root/profiles
diff options
context:
space:
mode:
authorBertrand Jacquin <beber@meleeweb.net>2014-08-29 00:18:06 +0200
committerBertrand Jacquin <beber@meleeweb.net>2014-08-29 00:26:01 +0200
commit5063e38680e6b1c4e97446fb7569bcf36e7ff46b (patch)
treede12ba973a020b67ff661bf727d28393522d015d /profiles
parentprofiles/common: profile.bashrc: Drop /usr/share/locale if nothing (diff)
downloadportage-5063e38680e6b1c4e97446fb7569bcf36e7ff46b.tar.xz
profiles/common: profile.bashrc: Generic way to drop empty directories
Diffstat (limited to 'profiles')
-rw-r--r--profiles/common/profile.bashrc30
1 files changed, 28 insertions, 2 deletions
diff --git a/profiles/common/profile.bashrc b/profiles/common/profile.bashrc
index 84df63fa..01693368 100644
--- a/profiles/common/profile.bashrc
+++ b/profiles/common/profile.bashrc
@@ -43,9 +43,34 @@ function __drop-nls-locales () {
einfo "Removing ${REPLY#${ED}}"
rm -rf "${REPLY}"
done
+}
+
+function __drop-empty-dir () {
+ if [[ ! ${ED} ]] ; then
+ local ED="${D}"
+ fi
- # Drop /usr/share/locale if nothing inside
- rmdir "${ED}/usr/share/locale" 2> /dev/null
+ if [[ ! -d "${ED}" ]] ; then
+ return 0
+ fi
+
+ local i
+
+ while (( i++ < 64 )) &&
+ [[ $(find "${ED}" -type d -empty) ]] ; do
+ find "${ED}/" \
+ -type d \
+ -empty |
+ sort |
+ while read ; do
+ einfo "Removing ${REPLY#${ED}}"
+ rm -rf "${REPLY}"
+ done
+ done
+
+ if (( i >= 64 )) ; then
+ eerror "${FUNCNAME} recursed more than ${i} time, that's bad"
+ fi
}
function __install_own_file () {
@@ -99,6 +124,7 @@ function post_src_install () {
function pre_pkg_preinst () {
__drop-nls-man-pages
__drop-nls-locales
+ __drop-empty-dir
}
# vim: syntax=sh