You could try something like this:
apt-get -s upgrade | awk '/^Inst/ {print $2}' |
xargs apt-cache policy |
awk '/:$|^$/ && ! /Version table:/ {print "\n" $0 } ; /:\/\// { print $2 }'
Output (run just now on my debian sid system) looks like this:
sqlite3:
http://my.local.mirror.redacted/debian
libsqlite3-0:
http://my.local.mirror.redacted/debian
libsqlite3-0:i386:
http://my.local.mirror.redacted/debian
python-newt:
http://my.local.mirror.redacted/debian
libnewt0.52:
http://my.local.mirror.redacted/debian
libruby:
http://my.local.mirror.redacted/debian
http://my.local.mirror.redacted/debian
mercurial:
http://my.local.mirror.redacted/debian
mercurial-common:
http://my.local.mirror.redacted/debian
http://my.local.mirror.redacted/debian
sysstat:
http://my.local.mirror.redacted/debian
libmilter1.0.1:
http://my.local.mirror.redacted/debian
Some of the packages have two URLs. That's because my system is amd64 with i386 as an added architecture, and these packages have both amd64 and i386 versions available for upgrade.
If you prefer to have the full output line, so that it looks like this:
mercurial-common:
990 http://my.local.mirror.redacted/debian unstable/main amd64 Packages
990 http://my.local.mirror.redacted/debian unstable/main i386 Packages
then just delete { print $2 }
from the second awk
script.
awk
script to add a\n
newline before each package - that makes it easier to post-process in 'paragraph mode', e.g. withperl -00
or similar. – cas Mar 04 '16 at 05:31