Created
May 19, 2017 15:03
-
-
Save croepha/0185fa264a1fb3b454469cd3c7419a09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from launchpadlib.launchpad import Launchpad | |
from launchpadlib.uris import lookup_service_root | |
instance = lookup_service_root('production') | |
launchpad = Launchpad.login_with('lp-shell', instance, version='devel') | |
loaded = launchpad.load('/~snappy-dev/+snap/core') | |
for build in loaded.builds: | |
if build.store_upload_revision == 1689: | |
break | |
for manifest in build.getFileUrls(): | |
if manifest.endswith('.manifest'): | |
break | |
import httplib2 | |
h = httplib2.Http(".cache") | |
(resp_headers, content) = h.request(manifest, "GET") | |
import subprocess | |
import apt | |
cache = apt.Cache() | |
packages = [] | |
for line in content.split('\n'): | |
if line: | |
line = line.replace('\t', ' ') | |
package, version = line.split() | |
_p = package.split(':') | |
if len(_p) > 1: | |
package, arch = _p | |
pn1 = "%s-dbgsym:%s" % (package, arch) | |
pn2 = "%s-dbg:%s" % (package, arch) | |
else: | |
pn1 = "%s-dbgsym" % package | |
pn2 = "%s-dbg" % package | |
did_one = False | |
if pn1 in cache: | |
if version in cache[pn1].versions: | |
packages.append("%s=%s" % (pn1, version)) | |
did_one = True | |
if pn2 in cache: | |
if version in cache[pn2].versions: | |
packages.append("%s=%s" % (pn2, version)) | |
did_one = True | |
if not did_one: | |
print "Could not find deubg package for ", line | |
subprocess.check_call("apt-get -qq download " + ' '.join(packages), shell=True) | |
import glob | |
for deb_file in glob.glob("*.deb") + glob.glob("*.ddeb"): | |
_ = subprocess.check_call("dpkg -x %s root/" % deb_file, shell=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment