Commit f0d3b377 authored by Cyril Brulebois's avatar Cyril Brulebois Committed by intrigeri

Add apt-get wrapper.

This wrapper makes it possible to keep track of both binary and source
package downloads, by writing /debootstrap/{bin,src}uris respectively,
alongside the debootstrap-generated /debootstrap/deburis (for binary
downloads during bootstrap phase).

Each file follows the following format:
  package version uri

The source uri only contains the dsc file, but it would be easy to list
all files if later needed.
Signed-off-by: default avatarCyril Brulebois <cyril@debamax.com>
parent f2cb90be
......@@ -99,3 +99,6 @@ fi
# custom APT sources
tails-custom-apt-sources > config/chroot_sources/tails.chroot
# custom debootstrap script, setting some APT magic to log downloads:
sed "s,%%topdir%%,$(pwd)," data/debootstrap/tails-wheezy > /usr/share/debootstrap/scripts/tails-wheezy
......@@ -201,4 +201,8 @@ echo \"Warning: Fake start-stop-daemon called, doing nothing\"" > "$TARGET/sbin/
progress $bases $bases CONFBASE "Configuring base system"
info BASESUCCESS "Base system installed successfully."
# Tails-specific part:
chroot $TARGET /usr/sbin/dpkg-divert --divert /usr/bin/apt-get.real --rename /usr/bin/apt-get
cp -f %%topdir%%/data/wrappers/apt-get $TARGET/usr/bin/apt-get
}
#!/bin/sh
set -e
set -u
# XXX: what if a package is called install or source...
mode=unknown
for param in "$@"; do
case "$param" in
install | download | upgrade | dist-upgrade)
mode=binuris
;;
source)
mode=srcuris
;;
update | autoclean | autoremove | purge)
mode=noop
;;
esac
done
# let's fail as early as possible:
if [ "$mode" = unknown ]; then
echo "E: unsupported apt-get operation, mode is still unknown" >&2
echo "E: requested operation follows:" "$@" >&2
exit 1
fi
if [ "$mode" = binuris ]; then
apt-get.real "$@" --print-uris|perl -ne 'if (/^'\''(.+)'\'' ([^_]+)_([^_]+)_/) { my ($url, $package, $version)=($1,$2,$3); $version =~ s/%3a/:/g; print "$package $version $url\n"; }' >> /debootstrap/$mode
apt-get.real "$@"
elif [ "$mode" = srcuris ]; then
# all uris: perl -ne 'if (/^'\''(.+)'\'' (\S+)/) { my ($url, $filename) = ($1, $2); print "$filename $url\n"; }'
# only dsc: perl -ne 'if (/^'\''(.+)'\'' (\S+\.dsc)/) { my ($url, $filename) = ($1, $2); print "$filename $url\n"; }'
apt-get.real "$@" --print-uris|perl -ne 'if (/^'\''(.+)'\'' (\S+\.dsc)/) { my ($url, $filename) = ($1, $2); print "$filename $url\n"; }' >> /debootstrap/$mode.tmp
apt-get.real "$@"
while read filename uri; do
# extract source and version w/o taking the GnuPG version in the signature section, and add uri after that
s_v=$(awk '/^(Source|Version):/ {print $2}' "$filename" | head -2 | xargs)
echo "$s_v $uri" >> /debootstrap/$mode
done < /debootstrap/$mode.tmp
rm /debootstrap/$mode.tmp
else
# handle both noop and unknown here, each into its own file; unknown should be empty:
echo "command:" "$@" >> /debootstrap/$mode
apt-get.real "$@"
fi
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment