summaryrefslogtreecommitdiffstats
path: root/data
diff options
context:
space:
mode:
authorCyril Brulebois <cyril@debamax.com>2015-10-24 20:50:01 +0000
committerintrigeri <intrigeri@boum.org>2016-03-10 14:40:53 +0000
commitf0d3b377a07bc6c4841cb48b5a1519e3d157f2c7 (patch)
tree1ed7b89351d664d27264fbfc08a6d469d1a778ce /data
parentf2cb90be63e1a4f443820a156ad7def21730c286 (diff)
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: Cyril Brulebois <cyril@debamax.com>
Diffstat (limited to 'data')
-rwxr-xr-xdata/debootstrap/tails-wheezy4
-rwxr-xr-xdata/wrappers/apt-get46
2 files changed, 50 insertions, 0 deletions
diff --git a/data/debootstrap/tails-wheezy b/data/debootstrap/tails-wheezy
index bf3404f..e7301ce 100755
--- a/data/debootstrap/tails-wheezy
+++ b/data/debootstrap/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
}
diff --git a/data/wrappers/apt-get b/data/wrappers/apt-get
new file mode 100755
index 0000000..6269c66
--- /dev/null
+++ b/data/wrappers/apt-get
@@ -0,0 +1,46 @@
+#!/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