Exemplo n.º 1
0
    def pull_files(self, files, dst_parent):
        os.makedirs(dst_parent, exist_ok=True)

        if self.config.container_mode:
            for f in files:
                dst_path = os.path.join(dst_parent, os.path.basename(f))
                if os.path.isdir(f):
                    if os.path.exists(dst_path):
                        shutil.rmtree(dst_path)
                    shutil.copytree(f, dst_path)
                else:
                    if os.path.exists(dst_path):
                        os.remove(dst_path)
                    shutil.copy(f, dst_parent, follow_symlinks=False)
        else:  # Docker
            mounts = self.render_mounts(
                self.get_docker_mounts(transparent=[self.config.root_dir]))
            command_create = 'docker create {} {}'.format(
                mounts, self.docker_image)
            container = run_subprocess_check_output(command_create).strip()

            for f in files:
                command_copy = 'docker cp {}:{} {}'.format(
                    container, f, dst_parent)
                run_subprocess_check_call(command_copy)

            command_remove = 'docker rm {}'.format(container)
            run_subprocess_check_call(command_remove,
                                      stdout=subprocess.DEVNULL)
Exemplo n.º 2
0
    def run(self, path_arg=None):
        try:
            os.makedirs(self.config.build_dir)
        except FileExistsError:
            pass
        except Exception:
            logger.warning('Failed to create the build directory: {}'.format(
                str(sys.exc_info()[0])))

        self.config.container.setup_dependencies()

        if self.config.prebuild:
            run_subprocess_check_call(self.config.prebuild,
                                      cwd=self.config.cwd,
                                      shell=True)

        self.build()

        self.install_additional_files()

        if self.config.postbuild:
            run_subprocess_check_call(self.config.postbuild,
                                      cwd=self.config.build_dir,
                                      shell=True)

        self.click_build()
Exemplo n.º 3
0
    def run(self, path_arg=None):
        try:
            os.makedirs(self.config.build_dir, exist_ok=True)
        except Exception:
            logger.warning('Failed to create the build directory: {}'.format(str(sys.exc_info()[0])))

        try:
            os.makedirs(self.config.build_home, exist_ok=True)
        except Exception:
            logger.warning('Failed to create the build home directory: {}'.format(str(sys.exc_info()[0])))

        self.config.container.setup()

        if self.config.prebuild:
            run_subprocess_check_call(self.config.prebuild, cwd=self.config.cwd, shell=True)

        self.build()

        self.install_additional_files()

        if self.config.postbuild:
            run_subprocess_check_call(self.config.postbuild, cwd=self.config.build_dir, shell=True)

        self.click_build()

        if not self.config.skip_review:
            review = ReviewCommand(self.config)
            review.check(self.click_path, raise_on_error=False)
Exemplo n.º 4
0
    def run(self, path_arg=""):
        if not self.config.lib_configs:
            print_warning('No libraries defined.')

        single_lib = path_arg
        found = False

        for lib in self.config.lib_configs:
            if not single_lib or single_lib == lib.name:
                print_info("Building {}".format(lib.name))
                found = True

                lib.container_mode = self.config.container_mode
                lib.docker_image = self.config.docker_image
                lib.build_arch = self.config.build_arch
                lib.container = Container(lib, lib.name)
                lib.container.setup_dependencies()

                try:
                    os.makedirs(lib.build_dir)
                except FileExistsError:
                    pass
                except Exception:
                    print_warning('Failed to create the build directory: {}'.format(str(sys.exc_info()[0])))

                if lib.prebuild:
                    run_subprocess_check_call(lib.prebuild, cwd=self.config.cwd, shell=True)

                self.build(lib)

                if lib.postbuild:
                    run_subprocess_check_call(lib.postbuild, cwd=lib.build_dir, shell=True)

        if single_lib and not found:
            raise ValueError('Cannot build unknown library {}. You may add it to the clickable.json'.format(single_lib))
Exemplo n.º 5
0
    def run(self, path_arg=None):
        if self.config.desktop:
            print_warning('Skipping install, running in desktop mode')
            return
        elif self.config.container_mode:
            print_warning('Skipping install, running in container mode')
            return

        cwd = '.'
        if path_arg:
            click = os.path.basename(path_arg)
            click_path = path_arg
        else:
            click = self.config.get_click_filename()
            click_path = os.path.join(self.config.build_dir, click)
            cwd = self.config.build_dir

        if self.config.ssh:
            command = 'scp {} phablet@{}:/home/phablet/'.format(click_path, self.config.ssh)
            run_subprocess_check_call(command, cwd=cwd, shell=True)

        else:
            self.device.check_any_attached()

            if self.config.device_serial_number:
                command = 'adb -s {} push {} /home/phablet/'.format(self.config.device_serial_number, click_path)
            else:
                self.device.check_multiple_attached()
                command = 'adb push {} /home/phablet/'.format(click_path)

            run_subprocess_check_call(command, cwd=cwd, shell=True)

        self.device.run_command('pkcon install-local --allow-untrusted /home/phablet/{}'.format(click), cwd=cwd)
Exemplo n.º 6
0
 def is_elf_file(self, path):
     try:
         run_subprocess_check_call(
             "readelf {} -l > /dev/null 2>&1".format(path), shell=True)
         return True
     except:
         return False
Exemplo n.º 7
0
    def run(self, path_arg=""):
        if not self.config.lib_configs:
            logger.warning('No libraries defined.')

        single_lib = path_arg
        found = False

        for lib in self.config.lib_configs:
            if not single_lib or single_lib == lib.name:
                logger.info("Building {}".format(lib.name))
                found = True

                lib.container_mode = self.config.container_mode
                lib.docker_image = self.config.docker_image
                lib.build_arch = self.config.build_arch
                lib.container = Container(lib, lib.name)
                lib.container.setup()

                # This is a workaround for lib env vars being overwritten by
                # project env vars, especially affecting Container Mode.
                lib.set_env_vars()

                try:
                    os.makedirs(lib.build_dir, exist_ok=True)
                except Exception:
                    logger.warning(
                        'Failed to create the build directory: {}'.format(
                            str(sys.exc_info()[0])))

                try:
                    os.makedirs(lib.build_home, exist_ok=True)
                except Exception:
                    logger.warning(
                        'Failed to create the build home directory: {}'.format(
                            str(sys.exc_info()[0])))

                if lib.prebuild:
                    run_subprocess_check_call(lib.prebuild,
                                              cwd=self.config.cwd,
                                              shell=True)

                self.build(lib)

                if lib.postbuild:
                    run_subprocess_check_call(lib.postbuild,
                                              cwd=lib.build_dir,
                                              shell=True)

        if single_lib and not found:
            raise ClickableException(
                'Cannot build unknown library {}, which is not in your clickable.json'
                .format(single_lib))
Exemplo n.º 8
0
    def run(self, path_arg=None):
        self.container.check_docker()

        command = 'docker pull {}'.format(self.container.base_docker_image)
        run_subprocess_check_call(command)

        if 'armhf' in self.container.base_docker_image:
            image = self.container.base_docker_image.replace('armhf', 'amd64')
            command = 'docker images -q {}'.format(image)
            image_exists = run_subprocess_check_output(command).strip()

            if image_exists:
                command = 'docker pull {}'.format(image)
                run_subprocess_check_call(command)
Exemplo n.º 9
0
    def run(self, path_arg=None):
        try:
            os.makedirs(self.config.build_dir)
        except FileExistsError:
            pass
        except Exception:
            print_warning('Failed to create the build directory: {}'.format(str(sys.exc_info()[0])))

        self.container.setup_dependencies()

        if self.config.prebuild:
            run_subprocess_check_call(self.config.prebuild, cwd=self.config.cwd, shell=True)

        self.build()

        if self.config.postbuild:
            run_subprocess_check_call(self.config.postbuild, cwd=self.config.build_dir, shell=True)
Exemplo n.º 10
0
    def run(self, path_arg=None):
        if self.config.is_desktop_mode():
            logger.debug('Skipping install, running in desktop mode')
            return
        elif self.config.container_mode:
            logger.debug('Skipping install, running in container mode')
            return

        cwd = '.'
        if path_arg:
            click = os.path.basename(path_arg)
            click_path = path_arg
        else:
            click = self.config.install_files.get_click_filename()
            click_path = os.path.join(self.config.build_dir, click)
            cwd = self.config.build_dir

        if self.config.ssh:
            command = 'scp {} phablet@{}:/home/phablet/'.format(
                click_path, self.config.ssh)
            run_subprocess_check_call(command, cwd=cwd, shell=True)

        else:
            self.device.check_any_attached()

            if self.config.device_serial_number:
                command = 'adb -s {} push {} /home/phablet/'.format(
                    self.config.device_serial_number, click_path)
            else:
                self.device.check_multiple_attached()
                command = 'adb push {} /home/phablet/'.format(click_path)

            run_subprocess_check_call(command, cwd=cwd, shell=True)

        if path_arg:
            logger.info(
                "Skipping uninstall step, because you specified a click package."
            )
        else:
            self.try_uninstall()

        self.device.run_command(
            'pkcon install-local --allow-untrusted /home/phablet/{}'.format(
                click),
            cwd=cwd)
        self.device.run_command('rm /home/phablet/{}'.format(click), cwd=cwd)
Exemplo n.º 11
0
    def run(self, path_arg=None):
        if self.config.desktop:
            print_warning('Skipping install, running in desktop mode')
            return
        elif self.config.container_mode:
            print_warning('Skipping install, running in container mode')
            return

        cwd = '.'
        if path_arg:
            click = os.path.basename(path_arg)
            click_path = path_arg
        else:
            click = '{}_{}_{}.click'.format(self.config.find_package_name(),
                                            self.config.find_version(),
                                            self.config.arch)
            click_path = os.path.join(self.config.dir, click)
            cwd = self.config.dir

        if self.config.ssh:
            command = 'scp {} phablet@{}:/home/phablet/'.format(
                click_path, self.config.ssh)
            run_subprocess_check_call(command, cwd=cwd, shell=True)

        else:
            self.device.check_any_attached()

            if self.config.device_serial_number:
                command = 'adb -s {} push {} /home/phablet/'.format(
                    self.config.device_serial_number, click_path)
            else:
                self.device.check_multiple_attached()
                command = 'adb push {} /home/phablet/'.format(click_path)

            run_subprocess_check_call(command, cwd=cwd, shell=True)

        self.device.run_command(
            'pkcon install-local --allow-untrusted /home/phablet/{}'.format(
                click),
            cwd=cwd)
Exemplo n.º 12
0
    def run(self, path_arg=""):
        if not self.config.lib_configs:
            print_warning('No libraries defined.')

        single_lib = path_arg
        found = False

        for lib in self.config.lib_configs:
            if not single_lib or single_lib == lib.name:
                print_info("Building {}".format(lib.name))
                found = True

                lib.container_mode = self.config.container_mode
                lib.docker_image = self.config.docker_image
                lib.build_arch = self.config.build_arch

                try:
                    os.makedirs(lib.build_dir)
                except FileExistsError:
                    pass
                except Exception:
                    print_warning('Failed to create the build directory: {}'.format(str(sys.exc_info()[0])))

                container = Container(lib)
                container.setup_dependencies()

                if lib.prebuild:
                    run_subprocess_check_call(lib.prebuild, cwd=self.config.cwd, shell=True)

                self.build(lib, container)

                if lib.postbuild:
                    run_subprocess_check_call(lib.postbuild, cwd=lib.build_dir, shell=True)

        if single_lib and not found:
            raise ValueError('Cannot build unknown library {}. You may add it to the clickable.json'.format(single_lib))
Exemplo n.º 13
0
def update_image(image):
    if image_exists(image):
        command = 'docker pull {}'.format(image)
        run_subprocess_check_call(command)
Exemplo n.º 14
0
 def run(self, path_arg=None):
     command = 'adb pull /home/phablet/Pictures/Screenshots'
     run_subprocess_check_call(command, cwd=self.config.cwd)