#!/bin/bash -e

# debirf module: clean-root
# clean up debirf root
#
# *** REQUIRED MODULE ***
# WARNING: this module is necessary for proper functioning of debirf.
#
# The debirf scripts were written by
# Jameson Rollins <jrollins@fifthhorseman.net>
# and
# Daniel Kahn Gillmor <dkg@fifthhorseman.net>.
#
# They are Copyright 2007, and are all released under the GPL,
# version 3 or later.

# remove all cached apt information
debirf_exec apt-get --assume-yes --purge autoremove
debirf_exec apt-get clean
rm -f "$DEBIRF_ROOT/var/cache/apt/"*.bin
rm -rf "$DEBIRF_ROOT/var/lib/apt/lists/"*
mkdir "$DEBIRF_ROOT/var/lib/apt/lists/partial"

# remake proc directory
# (originally made as symlink by debootstrap with fakechroot)
rm -rf "$DEBIRF_ROOT/proc"
mkdir "$DEBIRF_ROOT/proc"

# setup dynamically updated /etc/mtab
ln -sf /proc/mounts "$DEBIRF_ROOT/etc/mtab"
