[Merge] lp:~brian-murray/apt-clone/foreign-packages into lp:apt-clone
Michael Vogt
michael.vogt at canonical.com
Thu Jul 16 07:46:46 UTC 2015
Hi Brian, I think this needs some tweaking, the origins will always contain the "now" origin (which is the installed package).
This is what you get:
$ python3 -c 'import apt;print(apt.Cache()["libc6"].installed.origins)'
[
<Origin component:'main' archive:'wily' origin:'Ubuntu' label:'Ubuntu' site:'archive.ubuntu.com' isTrusted:True>,
<Origin component:'' archive:'now' origin:'' label:'' site:'' isTrusted:False>
]
One easy way would be to simply filter out all "now" lines:
e.g.
"""
for o in pkg.installed.origins:
if o.archive == "now" and o.origin == "":
continue
""""
Here is a full example:
"""#!/usr/bin/python3
import apt
if __name__ == "__main__":
foreign = []
cache = apt.Cache()
print("total:", len([pkg.name for pkg in cache if pkg.installed]))
for pkg in cache:
if not pkg.installed:
continue
for o in pkg.installed.origins:
if o.archive == "now" and o.origin == "":
continue
import lsb_release
distro_id = lsb_release.get_distro_information()['ID']
if o.origin != distro_id:
foreign.append("%s %s %s\n" % (
pkg.name, pkg.installed.version, o.origin))
break
print("foreign: ",len(foreign))
print(foreign)
"""
Otherwise it looks good.
--
https://code.launchpad.net/~brian-murray/apt-clone/foreign-packages/+merge/264912
Your team Ubuntu Core Development Team is requested to review the proposed merge of lp:~brian-murray/apt-clone/foreign-packages into lp:apt-clone.
More information about the Ubuntu-reviews
mailing list