2
# this file is part of checkbox.
4
# copyright 2014 canonical ltd.
6
# maciej kisielewski <maciej.kisielewski@canonical.com>
8
# checkbox is free software: you can redistribute it and/or modify
9
# it under the terms of the gnu general public license version 3,
10
# as published by the free software foundation.
12
# checkbox is distributed in the hope that it will be useful,
13
# but without any warranty; without even the implied warranty of
14
# merchantability or fitness for a particular purpose. see the
15
# gnu general public license for more details.
17
# you should have received a copy of the gnu general public license
18
# along with checkbox. if not, see <http://www.gnu.org/licenses/>.
20
Download and extract .deb packages necessary to run checkbox-touch
21
Extraction is done to specific directories as required by click package
23
For typical development iteration, after hacking something in plainbox,
24
run ./get-libs --plainbox-only
36
from utils import get_package_from_url_and_extract
37
from utils import prepare_uris
38
from utils import rsync_tree
41
def extract_plainbox(src_tarball, version):
42
with tempfile.TemporaryDirectory() as tmp:
43
tarball = tarfile.open(src_tarball)
44
members = [member for member in tarball.getmembers()
45
if member.name.startswith(
46
"plainbox-{}/plainbox/".format(version)) or
47
member.name.startswith(
48
"plainbox-{}/plainbox.egg-info".format(version))]
49
tarball.extractall(tmp, members=members)
51
os.path.join(tmp, "plainbox-{}".format(version), "plainbox"),
52
os.path.join('lib', 'py', 'plainbox'),
56
os.path.join(tmp, "plainbox-{}".format(version),
58
os.path.join('lib', 'py', 'plainbox.egg-info'),
62
def get_plainbox_from_pypi(version='0.22.2'):
63
# plaibox_pypi contains URL from which to download plainbox
64
plainbox_pypi = ('https://pypi.python.org/packages/source'
65
'/p/plainbox/plainbox-{}.tar.gz'.format(version))
66
with tempfile.TemporaryDirectory() as tmp:
67
filename = os.path.join(tmp, plainbox_pypi.split('/')[-1])
68
print('retrieving {0}'.format(plainbox_pypi))
69
urllib.request.urlretrieve(plainbox_pypi, filename)
70
extract_plainbox(filename, version)
73
def get_local_plainbox():
74
# TODO: user shouldn't specify version of local plainbox
75
plainbox_setup_path = os.path.join(os.getcwd(), '..', 'plainbox',
77
plainbox_version = subprocess.check_output([plainbox_setup_path,
78
'--version']).decode(sys.stdout.encoding).strip()
80
plainbox_setup_dir = os.path.split(plainbox_setup_path)[0]
81
print('building local plainbox')
82
ret = subprocess.check_call([plainbox_setup_path, '-q', 'sdist'],
83
cwd=plainbox_setup_dir)
86
"Could not build plainbox using {}. Check above output"
87
.format(plainbox_setup_path))
88
filename = os.path.join(plainbox_setup_dir, 'dist', 'plainbox-{}.tar.gz'
89
.format(plainbox_version))
90
extract_plainbox(filename, plainbox_version)
94
parser = argparse.ArgumentParser("Get necessary libs for checkbox-touch")
95
parser.add_argument("--get-pypi-plainbox",
97
help="Use plainbox downloaded from pypi")
98
parser.add_argument("--plainbox-only", action='store_true',
99
help="Get plainbox only")
100
parser.add_argument("--get-autopilot",
102
help="Download libs for autopilot")
103
args = parser.parse_args()
104
if args.get_pypi_plainbox:
105
get_plainbox_from_pypi()
108
if args.plainbox_only:
109
# skip downloading rest of the libs
112
'libpython3.5', 'pyotherside', 'python3-xlsxwriter',
113
'python3-jinja2', 'python3-markupsafe', 'python3-padme',
114
'python3-requests', 'python3-urllib3', 'python3-guacamole',
115
'python3-requests-oauthlib']
116
# additional packages needed to support autopilot tests. these were obtained by
117
# running apt-cache depends on python3-autopilot
118
if args.get_autopilot:
120
'python3-autopilot', 'python3-psutil', 'python3-testtools',
121
'python3-pil', 'libjs-jquery', 'libjs-underscore', 'libwebp5',
122
'libwebpmux1', 'python3-decorator', 'python3-testscenarios',
123
'python3-subunit', 'python3-fixtures', 'python3-junitxml',
124
'python3-extras', 'python3-evdev']
125
uris = prepare_uris(packages)
126
# libs_urls contains list of .deb packages that will be downloaded and
127
# extracted. After extraction contents of ./usr/lib are copied to ./lib
129
with tempfile.TemporaryDirectory() as tmp:
130
get_package_from_url_and_extract(uris[lib], tmp)
131
# TODO: remove unwanted files from the extracted tree (e.g. *.h)
133
os.path.join(tmp, 'usr', 'lib'), 'lib',
135
# python3_libs_urls contains list of .deb packages that will be downloaded
136
# and extracted. After extraction contents of
137
# ./usr/lib/python3/dist-packages are copied to ./lib/py.
138
python3_libs = ['python3-xlsxwriter', 'python3-jinja2',
139
'python3-markupsafe', 'python3-padme', 'python3-requests',
140
'python3-urllib3', 'python3-guacamole',
141
'python3-requests-oauthlib']
143
# additional libs needed to support autopilot tests. these were obtained by
144
# running apt-cache depends on python3-autopilot
145
python3_ap_libs = ['python3-autopilot', 'python3-psutil',
146
'python3-pil', 'python3-decorator', 'python3-testtools',
147
'python3-subunit', 'python3-testscenarios', 'python3-junitxml', 'python3-fixtures',
148
'python3-extras', 'python3-evdev']
149
if args.get_autopilot:
150
python3_libs += python3_ap_libs
151
for pylib in [uris[lib] for lib in python3_libs]:
152
with tempfile.TemporaryDirectory() as tmp:
153
get_package_from_url_and_extract(pylib, tmp)
155
os.path.join(tmp, 'usr', 'lib', 'python3',
157
os.path.join('lib', 'py'),
159
with tempfile.TemporaryDirectory() as tmp:
160
get_package_from_url_and_extract(uris['pyotherside'], tmp)
162
tmp, 'usr', 'lib', 'arm-linux-gnueabihf', 'qt5', 'qml')
163
dest = os.path.join('lib', 'arm-linux-gnueabihf')
164
if os.path.exists(src) and os.path.isdir(src):
165
rsync_tree(src, dest, preserve_symlinks=1)
167
# Remove the python3.4 directory
168
# currently it only holds a few config-directories with symlinks
169
# and those are not used by anything from this location
170
if os.path.exists('lib/python3.4'):
171
shutil.rmtree('lib/python3.4')
174
if __name__ == "__main__":