on apt-get install, dump corresponding source packages to /var/cache/apt-src
todo: think names, paths; package; add cleanup cmd to throw away sources for pkgs not currently installed, like apt-get autoclean
DPkg::Pre-Invoke { "/usr/sbin/apt-src-on-install pre || true"; }
DPkg::Post-Invoke { "/usr/sbin/apt-src-on-install post || true"; }
#!/bin/sh
installed() {
dpkg-query --show \
--showformat='${Status} ${Version} ${Source} ${Package}\n' \
| perl -ne '
next unless s/^install ok installed //;
s/(\S+) +(\S+).*/$2=$1/;
print;' \
| sort \
| uniq
}
mkdir -p /var/cache/apt-src
cd /var/cache/apt-src
if test "$1" = "pre"; then
installed > installed-pre
elif test "$1" = "post"; then
installed > installed-post
diff installed-pre installed-post \
| sed -n 's/^> //p' \
| xargs -rt apt-get --download-only source
fi