#!/bin/sh
#
#	apt-walkabout adopt
#
#	Copies the list of installed packages to your apt-walkabout
#	instance, along with a courtesy copy of source list.
#
#	Run this on your target system.
#	Run this before trying to "apt-walkabout fetch".
#
set -e

name=${1}
if [ -z "${name}" ]; then
    def=`hostname`
    echo -n "system name [${def}] ? "
    read name
    if [ -z "${name}" ]; then
        name=${def}
    fi
fi

if [ ! -f bin/adopt ]; then
    echo "aborted, we're not in an apt-walkabout instance"
    exit 1
fi

mkdir -p var/lib/dpkg
mkdir -p etc/apt

gzip --best --stdout /var/lib/dpkg/status > var/lib/dpkg/status.${name}.gz
gzip --best --stdout /etc/apt/sources.list > etc/apt/sources.list.${name}.gz
