Remove .debs from the instance filesystem
authorIustin Pop <iustin@google.com>
Wed, 20 Feb 2008 10:29:32 +0000 (10:29 +0000)
committerIustin Pop <iustin@google.com>
Wed, 20 Feb 2008 10:29:32 +0000 (10:29 +0000)
This patch removes the .debs which were used in the debootstrap process
via a find and xargs invocation (as opposed to chroot $TMPDIR apt-get
clean).

The main reason for this is that:
  - we don't want the created cache to contain the debs (it's
    unreasonably larger than needed)
  - but we want an instance created with the cache to be the same as
    without cache

The patch also adds â€˜-f’ to the rm and mv invocations which didn't have
it.

Reviewed-by: imsnah

create

diff --git a/create b/create
index 661f364..9bede89 100755 (executable)
--- a/create
+++ b/create
@@ -60,7 +60,7 @@ mount $blockdev $TMPDIR
 # default due to the standard umask)
 if [ -f "$CACHE_FILE" ]; then
        find "$CACHE_FILE" -perm -0200 -daystart -mtime +14 -print0 | \
-               xargs -r0 rm
+               xargs -r0 rm -f
 fi
 
 if [ -f "$CACHE_FILE" ]; then
@@ -75,6 +75,10 @@ else
 
        debootstrap --include="$EXTRAPKG" etch $TMPDIR $MIRROR
 
+       # remove the downloaded debs, as they are no longer needed
+       find "$TMPDIR/var/cache/apt/archives" -type f -name '*.deb' -print0 | \
+               xargs -r0 rm -f
+
        # remove the persistent-net rules, otherwise it will remember the node's
        # interfaces as eth0, eth1, ...
 
@@ -83,7 +87,7 @@ else
        if [ ! -e no_cache ]; then
                TMP_CACHE=`mktemp "${CACHE_FILE}.XXXXXX"`
                tar cf "$TMP_CACHE" -C $TMPDIR .
-               mv "$TMP_CACHE" "$CACHE_FILE"
+               mv -f "$TMP_CACHE" "$CACHE_FILE"
        fi
 fi