1#!/usr/bin/env python
2#
3# Copyright 2018 Google Inc.
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8
9"""Create the asset."""
10
11
12import argparse
13import common
14import os
15import shutil
16import subprocess
17import utils
18
19# Use libOpenCL.so from the ocl-icd-opencl-dev Debian package.
20PKGS = [
21    'ocl-icd-opencl-dev',
22    'ocl-icd-libopencl1',
23]
24
25def create_asset(target_dir):
26  """Create the asset."""
27  with utils.tmp_dir():
28    # Download required Debian packages.
29    subprocess.check_call(['apt-get', 'download'] + PKGS)
30    # Extract to CWD.
31    for f in os.listdir('.'):
32      subprocess.check_call(['dpkg-deb', '--extract', f, '.'])
33    # Copy usr/lib/x86_64-linux-gnu/* to target_dir.
34    lib_dir = os.path.join(os.getcwd(), 'usr', 'lib', 'x86_64-linux-gnu')
35    for f in os.listdir(lib_dir):
36      shutil.move(os.path.join(lib_dir, f), target_dir)
37
38
39def main():
40  parser = argparse.ArgumentParser()
41  parser.add_argument('--target_dir', '-t', required=True)
42  args = parser.parse_args()
43  create_asset(args.target_dir)
44
45
46if __name__ == '__main__':
47  main()
48