-Build maliit plugin for the touch SDK IDE
This commit is contained in:
79
get_package_source.py
Executable file
79
get_package_source.py
Executable file
@@ -0,0 +1,79 @@
|
||||
#!/usr/bin/python
|
||||
from optparse import OptionParser
|
||||
import re
|
||||
import urlparse
|
||||
from launchpadlib.launchpad import Launchpad
|
||||
from subprocess import call
|
||||
import sys
|
||||
import os
|
||||
import glob
|
||||
|
||||
def create_webroot_url_from_self_link(self_link):
|
||||
scheme, netloc, _, _, _ = urlparse.urlsplit(self_link)
|
||||
netloc = netloc.lstrip("api.")
|
||||
return u"%s://%s/" % (scheme, netloc)
|
||||
|
||||
|
||||
def get_dsc(archive, package, series):
|
||||
re_version = re.compile(r"^\d+\:")
|
||||
x = archive.getPublishedSources(exact_match=True, source_name=package,
|
||||
distro_series=series)
|
||||
webroot = create_webroot_url_from_self_link(archive.self_link)
|
||||
version = x[0].source_package_version
|
||||
version = re_version.sub("", version, 1)
|
||||
if archive.owner.name == "ubuntu-archive":
|
||||
yield "%subuntu/+archive/primary/+files/%s_%s.dsc" \
|
||||
% (webroot, x[0].source_package_name, version)
|
||||
else:
|
||||
yield "%s/~ci-train-ppa-service/+archive/ubuntu/stable-phone-overlay/+files/%s_%s.dsc" \
|
||||
% (webroot, x[0].source_package_name, version)
|
||||
|
||||
|
||||
def main():
|
||||
parser = OptionParser(usage="usage: %prog [options] pkgname ...")
|
||||
parser.add_option(
|
||||
"-l", "--launchpad", dest="launchpad_instance", default="production")
|
||||
options, args = parser.parse_args()
|
||||
launchpad = Launchpad.login_anonymously('just testing', options.launchpad_instance)
|
||||
ubuntu = launchpad.distributions["ubuntu"]
|
||||
distro_archive = ubuntu.main_archive
|
||||
overlay_archive = launchpad.people["ci-train-ppa-service"].\
|
||||
getPPAByName(name="stable-phone-overlay")
|
||||
series = ubuntu.getSeries(name_or_version="xenial")
|
||||
|
||||
for source_package in args:
|
||||
re_version = re.compile(r"^\d+\:")
|
||||
|
||||
#first try the overlay archive
|
||||
archive = overlay_archive
|
||||
x = overlay_archive.getPublishedSources(exact_match=True,
|
||||
source_name=source_package,
|
||||
distro_series=series)
|
||||
if len(x) == 0:
|
||||
archive = distro_archive
|
||||
x = distro_archive.getPublishedSources(exact_match=True,
|
||||
source_name=source_package,
|
||||
distro_series=series)
|
||||
if len(x) == 0:
|
||||
print("Could not find "+source_package)
|
||||
sys.exit(1)
|
||||
else:
|
||||
print(source_package+" found in Archive")
|
||||
else:
|
||||
print(source_package+" found in overlay ppa")
|
||||
|
||||
x = x[0].source_package_version
|
||||
|
||||
generator = get_dsc(archive, source_package, series)
|
||||
for i in generator:
|
||||
call(["dget", i, "--quiet", "--download-only"])
|
||||
for dsc_file in glob.glob('%s*dsc' % source_package):
|
||||
call(["dpkg-source", "-x", dsc_file])
|
||||
for junk_files in glob.glob("*.?z"):
|
||||
os.remove(junk_files)
|
||||
for junk_files in glob.glob("*.dsc"):
|
||||
os.remove(junk_files)
|
||||
for fetched_module_directory in glob.glob('%s*' % source_package):
|
||||
os.rename(fetched_module_directory, source_package)
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user