浏览代码

purge-locales: Handle empty locale directories better

If a locale directory is empty, shell code like "for langdir in
$$dir/*;" will loop once with langdir set to "path/to/dir/*", rather
than not looping at all, which would obviously be the desired
behavior.

Then "grep -qx $${langdir##*/}" ungoes two shell expansions (how?)
that transform the expression from "${langdir##*/}" to "*" to "list of
all files in buildroot root dir".  Which is most certainly not what
this command was supposed to do.

If one of those files happens to be an 8GB flash image, grep consumes
all available memory and crashes trying to search it.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
Trent Piepho 9 年之前
父节点
当前提交
bbe29b9896
共有 1 个文件被更改,包括 4 次插入1 次删除
  1. 4 1
      Makefile

+ 4 - 1
Makefile

@@ -583,7 +583,10 @@ define PURGE_LOCALES
 	do \
 	do \
 		for langdir in $$dir/*; \
 		for langdir in $$dir/*; \
 		do \
 		do \
-			grep -qx $${langdir##*/} $(LOCALE_WHITELIST) || rm -rf $$langdir; \
+			if [ -e "$${langdir}" ]; \
+			then \
+				grep -qx "$${langdir##*/}" $(LOCALE_WHITELIST) || rm -rf $$langdir; \
+			fi \
 		done; \
 		done; \
 	done
 	done
 	if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \
 	if [ -d $(TARGET_DIR)/usr/share/X11/locale ]; \