changeset 642:c92dc77da038

Since gene2fs can't produce large images in a reasonable amount of time, make a 64 meg image and resize it if necessary. (This means the minimum image size is 64 megs, because gene2fs won't run unless you specify a size, but it knows right away if the size you gave it wasn't big enough. I don't understand this either.)
author Rob Landley <rob@landley.net>
date Sat, 21 Mar 2009 22:56:15 -0500
parents 243594326fb2
children 87ef47d783f5
files host-tools.sh system-image.sh
diffstat 2 files changed, 40 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/host-tools.sh	Fri Mar 20 21:52:26 2009 -0500
+++ b/host-tools.sh	Sat Mar 21 22:56:15 2009 -0500
@@ -78,7 +78,6 @@
   do
     [ ! -f "${HOSTTOOLS}/$i" ] &&
       (ln -s `PATH="$OLDPATH" which $i` "${HOSTTOOLS}/$i" || dienow)
-
   done
 
   # Build toybox
@@ -162,6 +161,32 @@
   cleanup genext2fs
 fi
 
+# Build e2fsprogs.
+
+# Busybox used to provide ext2 utilities (back around 1.2.2), but the
+# implementation was horrible and got removed.  Someday the new Lua
+# toybox should provide these.
+
+# This mostly isn't used creating a system image, which uses genext2fs instead.
+# If SYSIMAGE_HDA_MEGS is > 64, it'll resize2fs because genext2fs is
+# unreasonably slow at creating large files.
+
+# The hdb.img of run-emulator.sh and run-from-build.sh uses e2fsprogs'
+# fsck.ext2 and tune2fs.  These are installed by default in most distros
+# (which genext2fs isn't), and genext2fs doesn't have ext3 support anyway.
+
+if [ -z "$(which mke2fs)" ]
+then
+  setupfor e2fsprogs &&
+  ./configure &&
+  make -j "$CPUS" &&
+  cp misc/{mke2fs,tune2fs} resize/resize2fs "${HOSTTOOLS}" &&
+  cp e2fsck/e2fsck "$HOSTTOOLS"/fsck.ext2 &&
+  cd ..
+
+  cleanup e2fsprogs
+fi
+
 # Squashfs is an alternate packaging option.
 
 #if [ ! -f "${HOSTTOOLS}"/mksquashfs ]
--- a/system-image.sh	Fri Mar 20 21:52:26 2009 -0500
+++ b/system-image.sh	Sat Mar 21 22:56:15 2009 -0500
@@ -97,10 +97,22 @@
   echo "/dev d 755 0 0 - - - - -" > "$DEVLIST" &&
   echo "/dev/console c 640 0 0 5 1 0 0 -" >> "$DEVLIST" &&
 
-  genext2fs -z -D "$DEVLIST" -d "${NATIVE_ROOT}" \
-    -i 1024 -b $[$SYSIMAGE_HDA_MEGS*1024] "${SYSIMAGE}/${IMAGE}" &&
+  # Produce 64 meg filesystem, which should always be big enough.
+
+  genext2fs -z -D "$DEVLIST" -d "$NATIVE_ROOT" -b 65536 -i 1024 \
+    "$SYSIMAGE/$IMAGE" &&
   rm "$DEVLIST" || dienow
 
+  # Extend image size to HDA_MEGS if necessary, keeping it sparse.  (Feeding
+  # a larger -b size to genext2fs is insanely slow, and not particularly
+  # sparse.)
+
+  if [ $[1024*$SYSIMAGE_HDA_MEGS] -gt 65536 ]
+  then
+    dd if=/dev/zero of=woot.img bs=1k count=1 seek=$[1024*1024-1] &&
+    resize2fs "${SYSIMAGE}/${IMAGE}" ${SYSIMAGE_HDA_MEGS}M || dienow
+  fi
+
 #elif [ "$SYSIMAGE_TYPE" == "squashfs" ]
 #then
 # We used to do this, but updating the squashfs patch for each new kernel