#!/bin/sh # list the packages for which, among the candidate version and installed version, # one is from Ubuntu and the other is not # this is sloooow ... dpkg -l "$@" | awk '$1 == "ii" { print $2}' | while read pkg do apt-cache policy $pkg | awk '{ if (NR == 1) { package = substr($1, 1, length($1)-1) } else if ($1 == "Installed:") { installed = $2 } else if ($1 == "Candidate:") { candidate = $2 } else if ($NF == 500) { version=$(NF-1) } else if ($1 == 500) { repo_url = $2; if (match(repo_url, "\\.ubuntu\\.com") > 0) { from = "ubuntu" } else { from = "elsewhere" } if (version == candidate) { candidate_from = from } else if (version == installed) { installed_from = from } } }; END { # installed_from == "" when the installed version is the candidate version if (installed_from != "" && candidate_from != installed_from) { print package, "installed from", installed_from, "with candidate from", candidate_from } }' done