Example #1
0
    def setup_assets(self) -> None:
        # We do _setup_from_setup first since it is legacy and let the
        # declarative items take over.
        self._setup_gui()

        icon_path = self._finalize_icon()
        if icon_path is not None:
            if str(icon_path).startswith(self._prime_dir):
                icon_path = icon_path.relative_to(self._prime_dir)
            relative_icon_path: Optional[str] = str(icon_path)
        else:
            relative_icon_path = None

        snap_name = self._project_config.project.info.name
        for app_name, app in self._snap_meta.apps.items():
            app.write_command_wrappers(prime_dir=self._prime_dir)
            app.write_application_desktop_file(
                snap_name=snap_name,
                prime_dir=self._prime_dir,
                gui_dir=self.meta_gui_dir,
                icon_path=relative_icon_path,
            )
            app.validate_command_chain_executables(self._prime_dir)

        if self._config_data.get("type", "") == "gadget":
            if not os.path.exists("gadget.yaml"):
                raise errors.MissingGadgetError()
            file_utils.link_or_copy("gadget.yaml",
                                    os.path.join(self.meta_dir, "gadget.yaml"))
Example #2
0
    def setup_assets(self) -> None:
        # We do _setup_from_setup first since it is legacy and let the
        # declarative items take over.
        self._setup_gui()

        if 'icon' in self._config_data:
            # TODO: use developer.ubuntu.com once it has updated documentation.
            icon_ext = self._config_data['icon'].split(os.path.extsep)[-1]
            icon_dir = os.path.join(self.meta_dir, 'gui')
            icon_path = os.path.join(icon_dir, 'icon.{}'.format(icon_ext))
            if not os.path.exists(icon_dir):
                os.mkdir(icon_dir)
            if os.path.exists(icon_path):
                os.unlink(icon_path)
            os.link(self._config_data['icon'], icon_path)

        if self._config_data.get('type', '') == 'gadget':
            if not os.path.exists('gadget.yaml'):
                raise errors.MissingGadgetError()
            file_utils.link_or_copy('gadget.yaml',
                                    os.path.join(self.meta_dir, 'gadget.yaml'))
Example #3
0
    def setup_assets(self) -> None:
        # We do _setup_from_setup first since it is legacy and let the
        # declarative items take over.
        self._setup_gui()

        if "icon" in self._config_data:
            # TODO: use developer.ubuntu.com once it has updated documentation.
            icon_ext = self._config_data["icon"].split(os.path.extsep)[-1]
            icon_dir = os.path.join(self.meta_dir, "gui")
            icon_path = os.path.join(icon_dir, "icon.{}".format(icon_ext))
            if not os.path.exists(icon_dir):
                os.mkdir(icon_dir)
            if os.path.exists(icon_path):
                os.unlink(icon_path)
            file_utils.link_or_copy(self._config_data["icon"], icon_path)

        if self._config_data.get("type", "") == "gadget":
            if not os.path.exists("gadget.yaml"):
                raise errors.MissingGadgetError()
            file_utils.link_or_copy("gadget.yaml",
                                    os.path.join(self.meta_dir, "gadget.yaml"))
Example #4
0
    def setup_assets(self) -> None:
        # We do _setup_from_setup first since it is legacy and let the
        # declarative items take over.
        self._setup_gui()

        # Extracted metadata (e.g. from the AppStream) can override the
        # icon location.
        if self._extracted_metadata:
            icon_path = self._extracted_metadata.get_icon()
        else:
            icon_path = None

        snap_name = self._project_config.project.info.name
        for app_name, app in self._snap_meta.apps.items():
            app.write_command_wrappers(prime_dir=self._prime_dir)
            app.write_application_desktop_file(
                snap_name=snap_name,
                prime_dir=self._prime_dir,
                gui_dir=self.meta_gui_dir,
                icon_path=icon_path,
            )
            app.validate_command_chain_executables(self._prime_dir)

        if "icon" in self._config_data:
            # TODO: use developer.ubuntu.com once it has updated documentation.
            icon_ext = self._config_data["icon"].split(os.path.extsep)[-1]
            icon_path = os.path.join(self.meta_gui_dir,
                                     "icon.{}".format(icon_ext))
            os.makedirs(self.meta_gui_dir, exist_ok=True)
            if os.path.exists(icon_path):
                os.unlink(icon_path)
            file_utils.link_or_copy(self._config_data["icon"], icon_path)

        if self._config_data.get("type", "") == "gadget":
            if not os.path.exists("gadget.yaml"):
                raise errors.MissingGadgetError()
            file_utils.link_or_copy("gadget.yaml",
                                    os.path.join(self.meta_dir, "gadget.yaml"))