浏览代码

We need to calculate filesystem size right when we run genext2fs.
As was, size was calculated right when 'make' was run, at which
point the rootfs may well be empty...

Eric Andersen 20 年之前
父节点
当前提交
66adf26aa4
共有 1 个文件被更改,包括 24 次插入22 次删除
  1. 24 22
      target/ext2/ext2root.mk

+ 24 - 22
target/ext2/ext2root.mk

@@ -39,32 +39,20 @@ genext2fs: $(GENEXT2_DIR)/genext2fs
 #
 #
 #############################################################
 #############################################################
 
 
-# How much KB we want to add to the calculated size for slack space
-GENEXT2_REALSIZE=$(subst total,, $(shell LANG=C du $(TARGET_DIR) -s -c -k | grep total ))
-GENEXT2_ADDTOROOTSIZE=$(shell if [ $(GENEXT2_REALSIZE) -ge 20000 ] ; then echo 16384; else echo 16; fi)
-GENEXT2_SIZE=$(shell expr $(GENEXT2_REALSIZE) + $(GENEXT2_ADDTOROOTSIZE) + 200)
-# We currently add about 400 device nodes, so add that into the total
-GENEXT2_INODES=$(shell expr $(shell find $(TARGET_DIR) | wc -l) + 400)
-#GENEXT2_SIZE=100000
+EXT2_OPTS :=
 
 
-EXT2_OPTS := 
+ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_SQUASH)),y)
+EXT2_OPTS += -q
+endif
 
 
-ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
-EXT2_OPTS += -b $(GENEXT2_SIZE)
-else
+ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
 EXT2_OPTS += -b $(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS))
 EXT2_OPTS += -b $(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS))
 endif
 endif
 
 
-ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0)
-EXT2_OPTS += -i $(GENEXT2_INODES)
-else
+ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0)
 EXT2_OPTS += -i $(strip $(BR2_TARGET_ROOTFS_EXT2_INODES))
 EXT2_OPTS += -i $(strip $(BR2_TARGET_ROOTFS_EXT2_INODES))
 endif
 endif
 
 
-ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_SQUASH)),y)
-EXT2_OPTS += -q
-endif
-
 ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0)
 ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0)
 EXT2_OPTS += -r $(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS))
 EXT2_OPTS += -r $(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS))
 endif
 endif
@@ -87,21 +75,35 @@ $(EXT2_BASE): genext2fs
 	@rm -rf $(TARGET_DIR)/usr/man
 	@rm -rf $(TARGET_DIR)/usr/man
 	@rm -rf $(TARGET_DIR)/usr/share/man
 	@rm -rf $(TARGET_DIR)/usr/share/man
 	@rm -rf $(TARGET_DIR)/usr/info
 	@rm -rf $(TARGET_DIR)/usr/info
+ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
+	GENEXT2_REALSIZE=`LANG=C du -l -s -c -k $(TARGET_DIR) | grep total | sed -e "s/total//"`; \
+	GENEXT2_ADDTOROOTSIZE=`if [ $$GENEXT2_REALSIZE -ge 20000 ] ; then echo 16384; else echo 1200; fi`; \
+	GENEXT2_SIZE=`expr $$GENEXT2_REALSIZE + $$GENEXT2_ADDTOROOTSIZE`; \
+	GENEXT2_ADDTOINODESIZE=`find $(TARGET_DIR) | wc -l`; \
+	GENEXT2_INODES=`expr $$GENEXT2_ADDTOINODESIZE + 400`; \
+	set -x; \
+	$(GENEXT2_DIR)/genext2fs \
+		-b $$GENEXT2_SIZE \
+		-i $$GENEXT2_INODES \
+		-d $(TARGET_DIR) \
+		$(EXT2_OPTS) $(EXT2_BASE)
+else
 	$(GENEXT2_DIR)/genext2fs \
 	$(GENEXT2_DIR)/genext2fs \
 		-d $(TARGET_DIR) \
 		-d $(TARGET_DIR) \
 		$(EXT2_OPTS) \
 		$(EXT2_OPTS) \
 		$(EXT2_BASE)
 		$(EXT2_BASE)
-		
+endif
+
 $(EXT2_BASE).gz: $(EXT2_BASE)
 $(EXT2_BASE).gz: $(EXT2_BASE)
 	@gzip --best -fv $(EXT2_BASE)
 	@gzip --best -fv $(EXT2_BASE)
-	
+
 EXT2_COPYTO := $(strip $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_COPYTO)))
 EXT2_COPYTO := $(strip $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_COPYTO)))
-	
+
 ext2root: $(EXT2_TARGET)
 ext2root: $(EXT2_TARGET)
 	@ls -l $(EXT2_TARGET)
 	@ls -l $(EXT2_TARGET)
 ifneq ($(EXT2_COPYTO),)
 ifneq ($(EXT2_COPYTO),)
 	@cp -f $(EXT2_TARGET) $(EXT2_COPYTO)
 	@cp -f $(EXT2_TARGET) $(EXT2_COPYTO)
-endif	
+endif
 
 
 ext2root-source: $(DL_DIR)/$(GENEXT2_SOURCE)
 ext2root-source: $(DL_DIR)/$(GENEXT2_SOURCE)