#!/bin/sh
# This script is is part of autopkgtest
# Copyright (C) 2006-2014 Canonical Ltd.
# Author: Martin Pitt <martin.pitt@ubuntu.com>
#
# --setup-commands script for making dpkg/apt readonly, to approximate what
# happens with Ubuntu system images. This can be used to test click packages
# with locally unpacking test dependencies instead of actually installing them.
# Use this in schroot, lxc, or QEMU runner.

set -e
M=$(mktemp --directory /run/ro-apt.XXXXX)
mount -t tmpfs tmpfs "$M"
cp -a /var/lib/dpkg/status /var/lib/dpkg/lock "$M"
cp -a /var/cache/apt "$M/cache_apt"
mount -o remount,ro "$M"
mount -o bind,ro "$M/status" /var/lib/dpkg/status
mount -o bind,ro "$M/lock" /var/lib/dpkg/lock
mount -o bind,ro "$M/cache_apt" /var/cache/apt
