I have written a patch to debootstrap which implements support for
acquiring .debs via a tarball instead of the network.  

the way this works is you give debootstrap a mirror of
tar://some/where/basedebs.tgz  instead of a normal file:// or http://
URL.  debootstrap will extract the tarball in $TARGET/var and then
proceed as if it just downloaded all the packages via the network. 

the tarball must contain cache/apt/archives/ and lib/apt/lists (or
state/apt/lists).  

i wrote a basic script to build a basedebs.tgz its included in this
patch.  for this script to work i needed a --download-only option to
debootstrap, so i added that as well.  

Note that this does not attempt to solve the root filesystem base
tarball that some people want for setting up NFS roots.  i don't think
that needs to be supported in either debootstrap or the
boot-floppies.  rather i think someone should make a debian package
say nfsroot-pmac which in its build process runs debootstrap and then
tars up the result. (or something similar).  

this tarball acquisition method for debootstrap would simply be to
solve the ppp problem we have now, without saying `ffs! buy a CD!
foad!'  

all b-f would have to do is add a single extra option: `tarball on
mounted filesystem'  where the user would pick a basedebs.tgz on a
mounted filesystem (hard disk partition most likely) and dbootstrap
would just run debootstrap using tar://instmnt/basedebs.tgz as its
mirror.  easy.  

i post this here just to get comments on the implementation.  if we
decide that supporting a basedebs.tgz in b-f is useful i think this is
the least problematic way to go about it.  i see no reason for b-f to
support a root filesystem tarball since the only reason anyone seems
to want one is setting up NFS roots for different archetecures, that
task does not use b-f, so these can be built/kept somewhere else.    

-- 
Ethan Benson
http://www.alaska.net/~erbenson/
diff -urN debootstrap.orig/debootstrap-0.1.12/debootstrap 
debootstrap/debootstrap-0.1.12/debootstrap
--- debootstrap.orig/debootstrap-0.1.12/debootstrap     Mon Jun 11 02:50:55 2001
+++ debootstrap/debootstrap-0.1.12/debootstrap  Wed Jun 20 05:55:16 2001
@@ -14,6 +14,11 @@
   shift
 fi
 
+if [ "$1" = "--download-only" ]; then
+  DOWNLOAD_ONLY=yes
+  shift
+fi
+
 if [ "$1" = "--arch" ]; then
   ARCH="$2"
   shift; shift;
@@ -54,7 +59,7 @@
        error 1 "Couldn't work out current architecture"
 fi
 
-export MIRRORS ARCH SUITE TARGET
+export MIRRORS ARCH SUITE TARGET DOWNLOAD_ONLY
 
 if [ "$JUST_PRINT_DEBS" = "" -a -x /usr/bin/id ] && [ `id -u` -ne 0 ]; then
   error 1 "debootstrap can only run as root"
diff -urN debootstrap.orig/debootstrap-0.1.12/functions 
debootstrap/debootstrap-0.1.12/functions
--- debootstrap.orig/debootstrap-0.1.12/functions       Sun May 27 20:43:02 2001
+++ debootstrap/debootstrap-0.1.12/functions    Wed Jun 20 05:55:16 2001
@@ -61,6 +61,9 @@
     "main")
       export DOWNLOAD=download_main
       ;;
+    "tar")
+      export DOWNLOAD=unpack_basetar
+      ;;
     *)
       error 1 "unknown mirror style"
       ;;
@@ -300,6 +303,29 @@
       error 1 "Couldn't download $p"
     fi
   done
+}
+
+unpack_basetar ()
+{
+  local t1="${MIRRORS%% *}"
+
+  if [ "${t1#tar:}" != "$t1" ]; then
+    local basetar="${t1#tar:}"
+    if [ "${basetar#//}" != "$basetar" ]; then
+      basetar="/${basetar#//}"
+    fi
+    if [ -e "$basetar" ]; then
+      mkdir -p $TARGET/var
+      cd $TARGET/var
+      info "Extracting base archive tarball $basetar..."
+      zcat "$basetar" | tar -xf - || error 1 "Extraction failed"
+      return 0
+    else
+      error 1 "$basetar: No such file or directory"
+    fi
+  else
+    error 1 "unknown location $t1"
+  fi
 }
 
 ################################################################ extraction
diff -urN debootstrap.orig/debootstrap-0.1.12/mkbasetar 
debootstrap/debootstrap-0.1.12/mkbasetar
--- debootstrap.orig/debootstrap-0.1.12/mkbasetar       Wed Dec 31 14:00:00 1969
+++ debootstrap/debootstrap-0.1.12/mkbasetar    Wed Jun 20 05:55:16 2001
@@ -0,0 +1,67 @@
+#! /bin/sh -e
+
+TMP="${TMPDIR:-/var/tmp}"
+FILE="$(pwd)/basedebs.tgz"
+umask 022
+
+info()
+{
+  echo "I: $1"
+}
+
+error()
+{
+  echo 1>&2 "E: $2"
+  exit $1
+}
+
+if [ "$1" = "--arch" ]; then
+  ARCH="$2"
+  shift; shift;
+fi
+
+if [ "$1" = "--file" ]; then
+  FILE="$2"
+  case "$FILE" in
+    /*)
+    ;;
+    *)
+    FILE="$(pwd)/$FILE"
+    ;;
+  esac
+  shift; shift;
+fi
+
+if [ "$1" = "" ]; then
+  info "args are: [--arch arch] [--file filename] <suite> [<mirror> [<script>]]"
+  error 1 "You must specify a suite."
+fi
+
+SUITE="$1"
+mkdir -m 755 "$TMP/debootstrap.$$" || error 1 "Could not create temporary directory"
+TARGET="$TMP/debootstrap.$$"
+
+if [ "$3" != "" ]; then
+  MIRRORS="$3"
+  if [ "$4" != "" ]; then
+    SCRIPT="$4"
+  fi
+fi
+
+if [ -n "$ARCH" ] ; then
+  ARGS="--download-only --arch $ARCH $SUITE $TARGET $MIRRORS $SCRIPT"
+else
+  ARGS="--download-only $SUITE $TARGET $MIRRORS $SCRIPT"
+fi
+
+debootstrap $ARGS
+rm -f "$FILE"
+tempfile -n "$FILE"
+cd "$TMP/debootstrap.$$/var"
+info "Building basedebs tarball: $FILE..."
+tar -cf - cache/apt/archives lib/apt/lists | gzip -c > "$FILE" || \
+  error 1 "Creation of basedebs tarball failed"
+
+info "base archive $FILE created successfully"
+
+exit 0
diff -urN debootstrap.orig/debootstrap-0.1.12/potato 
debootstrap/debootstrap-0.1.12/potato
--- debootstrap.orig/debootstrap-0.1.12/potato  Wed May  9 02:32:52 2001
+++ debootstrap/debootstrap-0.1.12/potato       Wed Jun 20 05:55:16 2001
@@ -1,5 +1,13 @@
 
-mirror_style release
+case "${MIRRORS%% *}" in
+  tar://*)
+  mirror_style tar
+  ;;
+  *)
+  mirror_style release
+  ;;
+esac
+
 download_style apt var-state
 
 required="base-files base-passwd bash bsdutils debconf-tiny debianutils diff dpkg 
e2fsprogs fileutils findutils grep gzip hostname ldso libdb2 libgdbmg1 libncurses5 
libnewt0 libpam-modules libpam-runtime libpam0g libpopt0 libreadline4 libstdc++2.10 
login makedev mawk modutils mount ncurses-base ncurses-bin passwd perl-5.005-base 
perl-base procps sed shellutils slang1 sysklogd sysvinit tar textutils update 
util-linux whiptail"
@@ -14,6 +22,10 @@
 esac
 
 download $required $base
+
+if [ "$DOWNLOAD_ONLY" = yes ] ; then
+    exit 0
+fi
 
 extract $required
 
diff -urN debootstrap.orig/debootstrap-0.1.12/sid.is-broken 
debootstrap/debootstrap-0.1.12/sid.is-broken
--- debootstrap.orig/debootstrap-0.1.12/sid.is-broken   Sat Apr 21 05:06:08 2001
+++ debootstrap/debootstrap-0.1.12/sid.is-broken        Wed Jun 20 05:55:16 2001
@@ -1,5 +1,13 @@
 
-mirror_style release
+case "${MIRRORS%% *}" in
+  tar://*)
+  mirror_style tar
+  ;;
+  *)
+  mirror_style release
+  ;;
+esac
+
 download_style apt
 
 required="apt base-files base-passwd bash bsdutils debconf debianutils diff dpkg 
e2fsprogs fileutils findutils grep gzip hostname ldso libc6 libdb2 libgdbmg1 
libncurses5 libnewt0 libpam-modules libpam-runtime libpam0g libpopt0 libreadline4 
libstdc++2.10 libstdc++2.10-glibc2.2 login makedev mawk mbr modutils mount 
ncurses-base ncurses-bin passwd perl-5.6-base perl-base procps sed shellutils slang1 
sysklogd sysvinit tar textutils update util-linux whiptail"
@@ -7,6 +15,10 @@
 base="at bsdmainutils console-apt console-data console-tools console-tools-libs cpio 
cron ed exim gettext-base groff grub ifupdown info ipchains libident libncurses4 
libopenldap-runtime libopenldap1 libpcre2 libpcre3 libwrap0 logrotate mailx man-db 
manpages modconf nano net-tools netbase netkit-inetd netkit-ping nvi ppp setserial 
syslinux tasksel tcpd telnet"
 
 download $required $base
+
+if [ "$DOWNLOAD_ONLY" = yes ] ; then
+    exit 0
+fi
 
 extract $required
 
diff -urN debootstrap.orig/debootstrap-0.1.12/slink 
debootstrap/debootstrap-0.1.12/slink
--- debootstrap.orig/debootstrap-0.1.12/slink   Sat Apr 21 05:06:17 2001
+++ debootstrap/debootstrap-0.1.12/slink        Wed Jun 20 05:55:16 2001
@@ -1,5 +1,13 @@
 
-mirror_style main
+case "${MIRRORS%% *}" in
+  tar://*)
+  mirror_style tar
+  ;;
+  *)
+  mirror_style main
+  ;;
+esac
+
 download_style apt var-state
 
 required="base-files base-passwd bash bsdutils debianutils diff dpkg e2fsprogs 
fileutils findutils grep gzip hostname ldso libdb2 libgdbmg1 libncurses4 ncurses3.4 
libpam0g libpam0g-util libpwdb0g libreadlineg2 libstdc++2.9 login makedev mawk 
modutils mount ncurses-base ncurses-bin newt0.25 passwd perl-base procps sed 
shellutils slang1 sysklogd sysvinit tar textutils update util-linux whiptail"
@@ -14,6 +22,10 @@
 esac
 
 download $required $base
+
+if [ "$DOWNLOAD_ONLY" = yes ] ; then
+    exit 0
+fi
 
 extract $required
 
diff -urN debootstrap.orig/debootstrap-0.1.12/woody 
debootstrap/debootstrap-0.1.12/woody
--- debootstrap.orig/debootstrap-0.1.12/woody   Fri Jun 15 17:18:57 2001
+++ debootstrap/debootstrap-0.1.12/woody        Wed Jun 20 05:55:16 2001
@@ -1,8 +1,20 @@
 
-mirror_style release
+case "${MIRRORS%% *}" in
+  tar://*)
+  mirror_style tar
+  ;;
+  *)
+  mirror_style release
+  ;;
+esac
+
 download_style apt
 
 download $required $base
+
+if [ "$DOWNLOAD_ONLY" = yes ] ; then
+    exit 0
+fi
 
 extract $required
 

PGP signature

Reply via email to