--- toast-linux	2005/02/07 06:10:40	1.138
+++ toast-linux	2005/02/13 05:01:13	1.139
@@ -20,7 +20,7 @@
 export SHELL=/bin/sh
 
 # es = estimated download size (in 1024-byte blocks, as per du -s); 0 = none
-# eb = estimated build time (where 10000 = median)
+# eb = estimated build time (in units of "du precompiled.tar.bz2")
 # flags = zero or more of the following letters, mashed together:
 #   c = critical task; don't bother to continue if this fails
 #   n = nonrepresentative task; don't factor install time into estimates
@@ -679,11 +679,13 @@
 gkrellm 656 1660 
 EOF
 
+  cddir="media/cdrom/toast-linux"
   mkdir -p "$numdir" "$namedir"
   i=0
   line=""
   prev=""
   while read name size time flags icmd; do
+    [ "$size" = "0" -a "$time" != "0" -a -d "$cddir" ] && continue
     line="$line $name "
     if echo "$line" | egrep -q "..{$COLUMNS}"; then
       newline=1
@@ -701,12 +703,21 @@
     ddir="$dir/download"
     idir="$dir/install"
 
+    precompiled="$cddir/$name.tar.bz2"
+    if [ -r "$precompiled" ]; then
+      size="0"
+      time="`du $precompiled | cut -f1`"
+      icmd="if [ -x mnt/bin/bzip2 ]; then chroot mnt tar xj; else tar xj -C mnt; fi < $precompiled && if [ -h mnt/bin/toast ]; then sbin/toast arm $name; else true; fi"
+    else
+      precompiled=""
+    fi
+
     mkdir "$dir" "$ddir" "$idir"
     echo "$num" > "$dir/num"
     echo "$name" > "$dir/name"
     [ -n "$size" ] || size=1000 # guess about one megabyte of source
     echo "$size" > "$ddir/estimate"
-    [ -n "$time" ] || time=10000 # defined to be the median time
+    [ -n "$time" ] || time=10000 # XXX replace with better estimate
     echo "$time" > "$idir/estimate"
     case "$flags" in *c*) : > "$dir/critical";; esac
     case "$flags" in *n*) : > "$idir/nonrepresentative";; esac
@@ -758,27 +769,10 @@
   cat tmp/partition >> "$namedir/partition/install/command"
   rm tmp/partition
 
-  cat > "$namedir/rootfs/download/command" << "EOF"
-#!/bin/sh -ex
-[ -r /media/cdrom/toast-linux/disk.tar.bz2 ] && exit 0
-if [ "`cd mnt; echo *`" != "boot lost+found" ]; then
-  echo "unexpected filesystem contents" >&2
-  exit 1
-fi
-mkdir -p mnt/toast/pkg/rootfs/v0/archive
-cd mnt/toast/pkg/rootfs/v0/archive
-wget http://www.kernel.org/pub/linux/libs/uclibc/root_fs_i386.bz2
-EOF
   ln -sf "../../../name/partition/install/time" "$namedir/rootfs/download/precondition"
-
   cat > "$namedir/rootfs/install/command" << "EOF"
 #!/bin/sh -ex
 
-if [ "`cd mnt; echo *`" != "boot lost+found toast" ]; then
-  echo "unexpected filesystem contents" >&2
-  exit 1
-fi
-
 for i in boot dev dev/pts etc/dhcpc etc/xml home media/floppy media/cdrom mnt proc root sys toast tmp usr/bin var/empty var/lock var/run var/log var/spool/mail; do
   mkdir -p "mnt/$i"
 done
@@ -869,19 +863,44 @@
 
 mount -t proc proc mnt/proc
 mount -t sysfs sys mnt/sys
+EOF
 
-file="/media/cdrom/toast-linux/disk.tar.bz2"
-if [ -r "$file" ]; then
-  cd mnt
-  tar xjf "$file"
-else
-  bunzip2 mnt/toast/pkg/rootfs/v0/archive/*
-  mount -t ext2 -o loop mnt/toast/pkg/rootfs/v0/archive/* mnt/mnt
-  mkdir -p mnt/toast/pkg/rootfs/v0/1/root
-  tar -c -C mnt/mnt . | tar -x -C mnt/toast/pkg/rootfs/v0/1/root
-  umount mnt/mnt
-  rm -fr mnt/toast/pkg/rootfs/v0/archive
+  if [ -d "$cddir" ]; then
+    cat > "$namedir/rootfs/download/command" << "EOF"
+#!/bin/sh
+echo "CD install detected; skipping"
+EOF
+    echo "0" > "$namedir/rootfs/download/estimate"
+    cat >> "$namedir/glibc/install/command" << "EOF"
+lib="/`cd mnt && echo toast/pkg/glibc/*/*/root/lib`"
+perl="/`cd mnt && echo toast/pkg/perl/*/*/root/bin/perl`"
+toast="/`cd mnt && echo toast/pkg/toast/*/*/root/bin/toast`"
+export LD_LIBRARY_PATH="$lib"
+export TOAST_ARMDIR=/usr
+exec chroot mnt "$lib/ld-linux.so.2" "$perl" -x "$toast" arm glibc perl wget toast
+EOF
+    return 0
+  fi
+
+  cat >> "$namedir/rootfs/install/command" << "EOF"
+
+bunzip2 mnt/toast/pkg/rootfs/v0/archive/*
+mount -t ext2 -o loop mnt/toast/pkg/rootfs/v0/archive/* mnt/mnt
+mkdir -p mnt/toast/pkg/rootfs/v0/1/root
+tar -c -C mnt/mnt . | tar -x -C mnt/toast/pkg/rootfs/v0/1/root
+umount mnt/mnt
+rm -fr mnt/toast/pkg/rootfs/v0/archive
+EOF
+
+  cat > "$namedir/rootfs/download/command" << "EOF"
+#!/bin/sh -ex
+if [ "`cd mnt; echo *`" != "boot lost+found" ]; then
+  echo "unexpected filesystem contents" >&2
+  exit 1
 fi
+mkdir -p mnt/toast/pkg/rootfs/v0/archive
+cd mnt/toast/pkg/rootfs/v0/archive
+wget http://www.kernel.org/pub/linux/libs/uclibc/root_fs_i386.bz2
 EOF
 
   cat > "$namedir/perl/download/command" << "EOF"
@@ -1225,6 +1244,8 @@
   if [ -r "$ffile" ]; then
     echo "$act process aborted"
   else
+    date +'%s' > "$topdir/$act-eta/tmp"
+    mv "$topdir/$act-eta.tmp" "$topdir/$act-eta"
     echo "$act process completed"
   fi
   : > "$efile"
@@ -1527,13 +1548,13 @@
   if ! [ -r "mnt/etc/toast.conf" ]; then
     [ -z "$TOAST_NICE" ] && export TOAST_NICE="-5"
     [ -z "$TOAST_ARMDIR" ] && export TOAST_ARMDIR="/usr"
-    [ -z "$TOAST_POSTARMPROG" ] && export TOAST_POSTARMPROG="postarm || ldconfig"
+    [ -z "$TOAST_POSTARMPROG" -a -h "mnt/bin/postarm" ] && export TOAST_POSTARMPROG="postarm"
     if [ -h "mnt/lib/ld-uClibc.so.0" ]; then
       export TOAST_PRELOAD="false"
       export TOAST_POSTARMPROG="true"
     fi
   fi
-  exec chroot mnt /bin/toast "$@"
+  exec chroot mnt /usr/bin/perl -x /bin/toast "$@"
 }
 
 postmortem()
@@ -1715,8 +1736,8 @@
 
 WGET = wget
 
-FROMCONF = dev toast-linux.stub mkhd floppy.vmx cd.vmx sbin/setup logotoppm
-FROMCONF2 = smartcat linux-config-smallk linux-config-largek busybox-config
+FROMCONF = dev toast-linux.stub mkhd floppy.vmx cd.vmx logotoppm
+FROMCONF2 = smartcat linux-config-smallk linux-config-largek busybox-config sbin/setup
 
 PKGS = TOOLCHAIN LINUX BUSYBOX E2FSPROGS NTFSPROGS PARTED DEVMAP LVM2 GENEXT2FS MTOOLS SYSLINUX CDRTOOLS
 
@@ -1839,7 +1860,7 @@
   rm -fr $(PKG_DIRS) symbols floppy* cd* root* toast-linux* $(FROMCONF) $(FROMCONF2) smallk largek sbin tmp mnt *.log
 
 vmclean:
-  rm -f toast*.vm* toast*.sav nvram* vmware.log
+  rm -f *.vm* *.sav nvram* vmware.log
 
 cleaner: clean vmclean
   rm -f *.tar.gz *.tar.bz2 *.tgz *.diff.gz
@@ -1994,8 +2015,13 @@
   mkdir -p $@/tmp
   cp !CONFIGURE! $@/tmp/configure
 
-cd: $(LARGEK) $(ISOLINUX) rootfs.gz logo.lss moreroot chroot
+precompiled: chroot
   rm -fr $@
+  mkdir $@
+  set -e; for i in `cd mnt/toast/pkg && echo *`; do tar cjf $@/$$i.tar.bz2 --owner=0 --group=0 -C mnt toast/pkg/$$i; (cd $@; du $$i.tar.bz2); done
+
+cd: $(LARGEK) $(ISOLINUX) rootfs.gz logo.lss moreroot precompiled
+  rm -fr $@
   !CONFIGURE! $@
   cp logo.lss $@/isolinux/logo.lss
   cp $(LARGEK) $@/isolinux/linux
@@ -2003,7 +2029,7 @@
   cp rootfs.gz $@/isolinux/initrd
   mkdir -p $@/toast-linux
   tar cjf $@/toast-linux/ram.tar.bz2 --owner=0 --group=0 -C moreroot .
-  tar cjf $@/toast-linux/disk.tar.bz2 --owner=0 --group=0 -C mnt toast
+  ln precompiled/* $@/toast-linux/
 
 floppy.img: floppy $(MFORMAT) $(SYSLINUX) $(MCOPY) $(MDIR)
   rm -f $@
@@ -2399,14 +2425,14 @@
 prompt 1
 timeout 200
 f1 help
-append initrd=initrd root=/dev/ram0 vga=ext rw
+append initrd=initrd root=/dev/ram0 rw vga=ext
 
 --- FILE cd/isolinux/isolinux.cfg ---
 display logo
 prompt 1
 timeout 200
 f1 help
-append initrd=initrd root=/dev/ram0 rw
+append initrd=initrd root=/dev/ram0 rw vga=ext
 
 --- FILE floppy/logo ---
 ^L
@@ -4743,10 +4769,10 @@
 #
 # Logo configuration
 #
-CONFIG_LOGO=y
-CONFIG_LOGO_LINUX_MONO=y
-CONFIG_LOGO_LINUX_VGA16=y
-CONFIG_LOGO_LINUX_CLUT224=y
+# CONFIG_LOGO is not set
+# CONFIG_LOGO_LINUX_MONO is not set
+# CONFIG_LOGO_LINUX_VGA16 is not set
+# CONFIG_LOGO_LINUX_CLUT224 is not set
 
 #
 # Sound