291 lines
10 KiB
Python
Executable File
291 lines
10 KiB
Python
Executable File
#!/usr/bin/python
|
|
from optparse import OptionParser
|
|
import re
|
|
import urlparse
|
|
from launchpadlib.launchpad import Launchpad
|
|
from subprocess import call
|
|
import subprocess
|
|
import sys
|
|
import os
|
|
import glob
|
|
import shutil
|
|
import requests
|
|
|
|
ide_packages = [
|
|
"ubuntu-sdk-ide",
|
|
"ubuntu-sdk-dev",
|
|
"ubuntu-clicksdk-qmake",
|
|
"apparmor",
|
|
"apparmor-easyprof",
|
|
"apparmor-easyprof-ubuntu",
|
|
"at",
|
|
"autoconf",
|
|
"automake",
|
|
"autotools-dev",
|
|
"base-files",
|
|
"binutils",
|
|
"bsdmainutils",
|
|
"build-essential",
|
|
"busybox-initramfs",
|
|
"bzip2",
|
|
"ca-certificates",
|
|
"click",
|
|
"click-apparmor",
|
|
"click-dev",
|
|
"click-reviewers-tools",
|
|
"cmake",
|
|
"cmake-data",
|
|
"cmake-extras",
|
|
"cpio",
|
|
"cpp",
|
|
"cpp-4.9",
|
|
"cron",
|
|
"dbus",
|
|
"dctrl-tools",
|
|
"debhelper",
|
|
"debootstrap",
|
|
"devscripts",
|
|
"dh-apparmor",
|
|
"dh-make",
|
|
"dh-python",
|
|
"diffstat",
|
|
"distro-info-data",
|
|
"dpkg-dev",
|
|
"libdpkg-perl",
|
|
"dput",
|
|
"fakeroot",
|
|
"file",
|
|
"g++",
|
|
"g++-4.9",
|
|
"gcc",
|
|
"gcc-4.9",
|
|
"gdb",
|
|
"gdb-multiarch",
|
|
"gdbserver",
|
|
"gettext",
|
|
"gettext-base",
|
|
"gir1.2-click-0.4",
|
|
"gir1.2-gee-0.8",
|
|
"gir1.2-glib-2.0",
|
|
"gir1.2-json-1.0",
|
|
"groff-base",
|
|
"hardening-includes",
|
|
"ifupdown",
|
|
"init-system-helpers",
|
|
"initramfs-tools",
|
|
"initramfs-tools-bin",
|
|
"intltool",
|
|
"intltool-debian",
|
|
"iproute2",
|
|
"isc-dhcp-client",
|
|
"isc-dhcp-common",
|
|
"iso-codes",
|
|
"klibc-utils",
|
|
"kmod",
|
|
"krb5-locales",
|
|
"libalgorithm-c3-perl",
|
|
"libalgorithm-diff-perl",
|
|
"libalgorithm-diff-xs-perl",
|
|
"libalgorithm-merge-perl",
|
|
"libapparmor-perl",
|
|
"libapt-pkg-perl",
|
|
"libarchive-extract-perl",
|
|
"libarchive-zip-perl",
|
|
"libarchive13",
|
|
"libasan1",
|
|
"libasn1-8-heimdal",
|
|
"libasprintf-dev",
|
|
"libasprintf0c2",
|
|
"libatm1",
|
|
"libatomic1",
|
|
"libauthen-sasl-perl",
|
|
"libbabeltrace-ctf1",
|
|
"libbabeltrace1",
|
|
"libboost-filesystem1.55.0",
|
|
"libboost-iostreams1.55.0",
|
|
"libboost-program-options1.55.0",
|
|
"libboost-system1.55.0",
|
|
"libbotan-1.10-0",
|
|
"libc-dev-bin",
|
|
"libc6-dbg",
|
|
"libc6-dev",
|
|
"libcap-ng0",
|
|
"libcgi-fast-perl",
|
|
"libcgi-pm-perl",
|
|
"libclass-accessor-perl",
|
|
"libclass-c3-perl",
|
|
"libclass-c3-xs-perl",
|
|
"libclick-0.4-0",
|
|
"libclone-perl",
|
|
"libcloog-isl4",
|
|
"libcommon-sense-perl",
|
|
"libcpan-meta-perl",
|
|
"libcroco3",
|
|
"libcurl3",
|
|
"libcurl3-gnutls",
|
|
"libdata-optlist-perl",
|
|
"libdata-section-perl",
|
|
"libdbus-1-3",
|
|
"libdbus-glib-1-2",
|
|
"libdigest-hmac-perl",
|
|
"libdistro-info-perl",
|
|
"libdns-export100",
|
|
"libdpkg-perl",
|
|
"libemail-valid-perl",
|
|
"libencode-locale-perl",
|
|
"liberror-perl",
|
|
"libmpfr4",
|
|
"libmpc3",
|
|
"perl",
|
|
"libisl13",
|
|
"make",
|
|
"matchbox-common",
|
|
"matchbox-window-manager",
|
|
"matchbox-desktop",
|
|
"matchbox-panel",
|
|
"matchbox-panel-manager",
|
|
"matchbox-keyboard",
|
|
"libfakekey0",
|
|
"libmatchbox1",
|
|
"libxsettings-client0",
|
|
"ttf-dejavu",
|
|
"matchbox-keyboard-im",
|
|
"libpango1.0-0",
|
|
"libpangox-1.0-0",
|
|
"libpangoxft-1.0-0",
|
|
"libstartup-notification0",
|
|
"libxft2",
|
|
"libpthread-stubs0-dev",
|
|
"libxau-dev",
|
|
"libxcb-xinerama0",
|
|
"libxcb1-dev",
|
|
"libxdmcp-dev",
|
|
"x11proto-core-dev",
|
|
"xorg-sgml-doctools",
|
|
"zlib1g",
|
|
"gcc-4.9-base",
|
|
"libstdc++-4.9-dev"
|
|
|
|
]
|
|
|
|
|
|
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_deb(archive, package, series, arch):
|
|
re_version = re.compile(r"^\d+\:")
|
|
arch_series = series.getDistroArchSeries(archtag=arch)
|
|
x = archive.getPublishedBinaries(binary_name=package,
|
|
distro_arch_series=arch_series,
|
|
status="Published", pocket='Release',
|
|
exact_match=True)
|
|
|
|
webroot = create_webroot_url_from_self_link(archive.self_link)
|
|
version = x[0].binary_package_version
|
|
version = re_version.sub("", version, 1)
|
|
if archive.owner.name == "ubuntu-archive":
|
|
yield "%subuntu/+archive/primary/+files/%s_%s_%s.deb" \
|
|
% (webroot, x[0].binary_package_name, version, arch)
|
|
else:
|
|
yield "%s/~ubuntu-sdk-team/+archive/ubuntu/ppa/+files/%s_%s_%s.deb" \
|
|
% (webroot, x[0].binary_package_name, version, arch)
|
|
|
|
|
|
def main():
|
|
parser = OptionParser(usage="usage: %prog [options] source ...")
|
|
parser.add_option(
|
|
"-l", "--launchpad", dest="launchpad_instance", default="production")
|
|
parser.add_option(
|
|
"-a", "--arch", dest="arch", default="armhf", choices=['armhf', 'i386', 'amd64',], help="architecture of the package")
|
|
|
|
options, args = parser.parse_args()
|
|
arch = options.arch
|
|
launchpad = Launchpad.login_anonymously('just testing',
|
|
options.launchpad_instance)
|
|
ubuntu = launchpad.distributions["ubuntu"]
|
|
distro_archive = ubuntu.main_archive
|
|
overlay_archive = launchpad.people["ubuntu-sdk-team"].\
|
|
getPPAByName(name="ppa")
|
|
series = ubuntu.getSeries(name_or_version="vivid")
|
|
|
|
arch_series = series.getDistroArchSeries(archtag=arch)
|
|
|
|
build_directory = "./click-%s/" % arch
|
|
if not os.path.exists(build_directory):
|
|
os.makedirs(build_directory)
|
|
src="./click/"
|
|
src_files = os.listdir(src)
|
|
for file_name in src_files:
|
|
full_file_name = os.path.join(src, file_name)
|
|
if (os.path.isfile(full_file_name)):
|
|
shutil.copy(full_file_name, build_directory)
|
|
|
|
for ide_package in ide_packages:
|
|
re_version = re.compile(r"^\d+\:")
|
|
archive = overlay_archive
|
|
x = overlay_archive.getPublishedBinaries(
|
|
binary_name=ide_package,
|
|
distro_arch_series=arch_series,
|
|
status="Published", pocket='Release',
|
|
exact_match=True)
|
|
|
|
if len(x) == 0:
|
|
archive = distro_archive
|
|
x = distro_archive.getPublishedBinaries(
|
|
binary_name=ide_package,
|
|
distro_arch_series=arch_series,
|
|
status="Published", pocket='Release',
|
|
exact_match=True)
|
|
if len(x) == 0:
|
|
print("Could not find "+ide_package)
|
|
sys.exit(1)
|
|
else:
|
|
print(ide_package+" found in Archive")
|
|
else:
|
|
print(ide_package+" found in SDK PPA")
|
|
|
|
x = x[0].binary_package_version
|
|
|
|
generator = get_deb(archive, ide_package, series, arch)
|
|
for i in generator:
|
|
request = requests.get(i)
|
|
if request.status_code != 200:
|
|
i = re.sub('_%s.deb' % arch, '_all.deb', i)
|
|
|
|
if ide_package != 'ubuntu-ui-toolkit':
|
|
binary_package_name = re.sub(r'-opensource-src',
|
|
r'',
|
|
ide_package.rstrip())
|
|
else:
|
|
binary_package_name = re.sub(r'ubuntu-ui-toolkit',
|
|
r'ubuntu-sdk',
|
|
ide_package.rstrip())
|
|
call(["wget", i, "-nv"])
|
|
for deb_file in glob.glob('%s*deb' % ide_package):
|
|
call(["dpkg-deb", "-x", deb_file, build_directory])
|
|
for junk_files in glob.glob("*.deb"):
|
|
os.remove(junk_files)
|
|
# click_package_rev = subprocess.Popen(["bzr", "revno"], stdout=subprocess.PIPE).communicate()[0]
|
|
# click_package_rev = click_package_rev.rstrip()
|
|
# manifest_file = open('click/manifest.json','r')
|
|
# manifest_with_orig_version = manifest_file.read()
|
|
# manifest_file.close()
|
|
# manifest_with_new_version = re.sub("\"version\":\s+\".*\"", "\"version\": \"%s\"" % click_package_rev, manifest_with_orig_version)
|
|
# manifest_file = open('click/manifest.json','w')
|
|
# manifest_file.write(manifest_with_new_version)
|
|
# manifest_file.close()
|
|
|
|
|
|
|
|
call(["create_kit.sh","-a",arch])
|
|
s=open("%s/manifest.json" % build_directory).read()
|
|
s=s.replace('armhf', '%s' % arch)
|
|
f=open("%s/manifest.json" % build_directory, 'w')
|
|
f.write(s)
|
|
f.close()
|
|
call(["click", "build", build_directory])
|
|
main()
|