Beispiel #1
0
    def remove(self):
        """Remove current framework if installed

        Not that we only remove desktop file, launcher icon and dir content, we do not remove
        packages as they might be in used for other framework"""
        # check if it's installed and so on.
        super().remove()

        UI.display(DisplayMessage("Removing {}".format(self.name)))
        if self.desktop_filename:
            with suppress(FileNotFoundError):
                os.remove(get_launcher_path(self.desktop_filename))
                os.remove(
                    os.path.join(self.default_binary_link_path,
                                 self.exec_link_name))
        if self.icon_filename:
            with suppress(FileNotFoundError):
                os.remove(get_icon_path(self.icon_filename))
        with suppress(FileNotFoundError):
            shutil.rmtree(self.install_path)
        remove_framework_envs_from_user(self.name)
        self.remove_from_config()

        UI.delayed_display(DisplayMessage("Suppression done"))
        UI.return_main_screen()
Beispiel #2
0
    def remove(self):
        """Remove current framework if installed

        Not that we only remove desktop file, launcher icon and dir content, we do not remove
        packages as they might be in used for other framework"""
        # check if it's installed and so on.
        super().remove()

        UI.display(DisplayMessage("Removing {}".format(self.name)))
        if self.desktop_filename:
            with suppress(FileNotFoundError):
                os.remove(get_launcher_path(self.desktop_filename))
                os.remove(
                    os.path.join(self.default_binary_link_path,
                                 self.exec_link_name))
        if self.icon_filename:
            with suppress(FileNotFoundError):
                os.remove(get_icon_path(self.icon_filename))
        with suppress(FileNotFoundError):
            shutil.rmtree(self.install_path)
            path = os.path.dirname(self.install_path)
            while path is not DEFAULT_INSTALL_TOOLS_PATH:
                if os.listdir(path) == []:
                    logger.debug(
                        "Empty folder, cleaning recursively: {}".format(path))
                    os.rmdir(path)
                    path = os.path.dirname(path)
                else:
                    break
        remove_framework_envs_from_user(self.name)
        self.remove_from_config()

        UI.delayed_display(DisplayMessage("Suppression done"))
        UI.return_main_screen()
Beispiel #3
0
    def post_install(self):
        """Add necessary environment variables"""
        add_env_to_user(
            self.name,
            {"ANDROID_HOME": {
                "value": self.install_path,
                "keep": False
            }})
        # add "platform-tools" to PATH to ensure "adb" can be run once the platform tools are installed via
        # the SDK manager
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value": [
                        os.path.join("$ANDROID_HOME", "tools"),
                        os.path.join("$ANDROID_HOME", "platform-tools")
                    ]
                }
            })
        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))

        # print wiki page message
        UI.delayed_display(
            DisplayMessage(
                "SDK installed in {}. More information on how to use it on {}".
                format(
                    self.install_path,
                    "https://developer.android.com/sdk/installing/adding-packages.html"
                )))
Beispiel #4
0
    def post_install(self):
        """Add necessary environment variables"""
        # add a few fall-back variables that might be used by some tools
        # do not set ANDROID_SDK_HOME here as that is the path of the preference folder expected by the Android tools
        add_env_to_user(
            self.name, {
                "ANDROID_HOME": {
                    "value": self.install_path,
                    "keep": False
                },
                "ANDROID_SDK": {
                    "value": self.install_path,
                    "keep": False
                },
                "PATH": {
                    "value": [
                        os.path.join(self.install_path, "tools"),
                        os.path.join(self.install_path, "tools", "bin")
                    ]
                }
            })
        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))

        # print wiki page message
        UI.delayed_display(
            DisplayMessage(
                "SDK installed in {}. More information on how to use it on {}".
                format(
                    self.install_path,
                    "https://developer.android.com/sdk/installing/adding-packages.html"
                )))
Beispiel #5
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value":
                    "{}:{}".format(
                        os.path.join(self.install_path, "rustc", "bin"),
                        os.path.join(self.install_path, "cargo", "bin"))
                },
                "LD_LIBRARY_PATH": {
                    "value": os.path.join(self.install_path, "rustc", "lib")
                }
            })

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(
            glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0],
            'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'),
                   os.path.join('rustlib', 'etc'))

        UI.delayed_display(
            DisplayMessage(
                _("You need to restart your current shell session for your {} installation "
                  "to work properly").format(self.name)))
Beispiel #6
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value":
                    "{}:{}:{}".format(
                        os.path.join(self.install_path, "rustc", "bin"),
                        os.path.join(self.install_path, "cargo", "bin"),
                        "$HOME/.cargo/bin")
                }
            })

        # adjust for rust: some symlinks magic to have stdlib craft available
        arch_lib_folder = '{}-unknown-linux-gnu'.format(
            self.arch_trans[get_current_arch()])
        lib_folder = os.path.join(self.install_path,
                                  'rust-std-{}'.format(arch_lib_folder), 'lib',
                                  'rustlib', arch_lib_folder, 'lib')
        arch_dest_lib_folder = os.path.join(self.install_path, 'rustc', 'lib',
                                            'rustlib', arch_lib_folder, 'lib')
        os.mkdir(arch_dest_lib_folder)
        for f in os.listdir(lib_folder):
            os.symlink(os.path.join(lib_folder, f),
                       os.path.join(arch_dest_lib_folder, f))

        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #7
0
    def post_install(self):
        """Add necessary environment variables"""
        # add a few fall-back variables that might be used by some tools
        add_env_to_user(
            self.name, {
                "NDK_ROOT": {
                    "value": self.install_path,
                    "keep": False
                },
                "ANDROID_NDK": {
                    "value": self.install_path,
                    "keep": False
                },
                "ANDROID_NDK_HOME": {
                    "value": self.install_path,
                    "keep": False
                }
            })

        # print wiki page message
        UI.display(
            DisplayMessage(
                "NDK installed in {}. More information on how to use it on {}".
                format(
                    self.install_path,
                    "https://developer.android.com/tools/sdk/ndk/index.html#GetStarted"
                )))
Beispiel #8
0
    def check_data_and_start_download(self,
                                      url=None,
                                      checksum=None,
                                      license_txt=StringIO()):
        if url is None:
            logger.error(
                "Download page changed its syntax or is not parsable (url missing)"
            )
            UI.return_main_screen(status_code=1)
        if (self.checksum_type and checksum is None):
            logger.error(
                "Download page changed its syntax or is not parsable (checksum missing)"
            )
            logger.error("URL is: {}".format(url))
            UI.return_main_screen(status_code=1)
        self.download_requests.append(
            DownloadItem(url, Checksum(self.checksum_type, checksum)))

        if self.dry_run:
            UI.display(DisplayMessage("Found download URL: " + url))
            UI.return_main_screen(status_code=0)

        if license_txt.getvalue() != "":
            logger.debug("Check license agreement.")
            UI.display(
                LicenseAgreement(
                    strip_tags(license_txt.getvalue()).strip(),
                    self.start_download_and_install, UI.return_main_screen))
        elif self.expect_license and not self.auto_accept_license:
            logger.error(
                "We were expecting to find a license on the download page, we didn't."
            )
            UI.return_main_screen(status_code=1)
        else:
            self.start_download_and_install()
Beispiel #9
0
    def get_metadata_and_check_license(self, result):
        """Download files to download + license and check it"""
        logger.debug("Parse download metadata")

        error_msg = result[self.download_page].error
        if error_msg:
            logger.error("An error occurred while downloading {}: {}".format(
                self.download_page, error_msg))
            UI.return_main_screen(status_code=1)
        in_download = False
        sig_url = None
        for line in result[self.download_page].buffer:
            line_content = line.decode()
            (new_sig_url,
             in_download) = self.parse_download_link(line_content, in_download)
            if str(new_sig_url) > str(sig_url):
                # Avoid fetching development snapshots
                if 'DEVELOPMENT-SNAPSHOT' not in new_sig_url:
                    tmp_release = re.search("ubuntu(.....).tar",
                                            new_sig_url).group(1)
                    if tmp_release <= get_current_distro_version():
                        sig_url = new_sig_url
        if not sig_url:
            logger.error("Download page changed its syntax or is not parsable")
            UI.return_main_screen(status_code=1)
        if self.dry_run:
            UI.display(DisplayMessage("Found download URL: " + sig_url))
            UI.return_main_screen(status_code=0)
        DownloadCenter(urls=[
            DownloadItem(sig_url, None),
            DownloadItem(self.asc_url, None)
        ],
                       on_done=self.check_gpg_and_start_download,
                       download=False)
Beispiel #10
0
    def decompress_and_install(self, fds):
        UI.display(DisplayMessage("Installing {}".format(self.name)))
        # empty destination directory if reinstall
        for dir_to_remove in self._paths_to_clean:
            with suppress(FileNotFoundError):
                shutil.rmtree(dir_to_remove)
            # marked them as cleaned
            self._paths_to_clean = []

        os.makedirs(self.install_path, exist_ok=True)
        decompress_fds = {}
        for fd in fds:
            direct_copy = False
            for ext in self.DIRECT_COPY_EXT:
                if fd.name.endswith(ext):
                    direct_copy = True
                    break
            if direct_copy:
                shutil.copy2(
                    fd.name,
                    os.path.join(self.install_path, os.path.basename(fd.name)))
            else:
                decompress_fds[fd] = Decompressor.DecompressOrder(
                    dir=self.dir_to_decompress_in_tarball,
                    dest=self.install_path)
        Decompressor(decompress_fds, self.decompress_and_install_done)
        UI.display(UnknownProgress(self.iterate_until_install_done))
Beispiel #11
0
    def post_install(self):
        """Add rust necessary env variables"""
        add_env_to_user(
            self.name, {
                "PATH": {
                    "value":
                    "{}:{}".format(
                        os.path.join(self.install_path, "rustc", "bin"),
                        os.path.join(self.install_path, "cargo", "bin"))
                },
                "LD_LIBRARY_PATH": {
                    "value": os.path.join(self.install_path, "rustc", "lib")
                }
            })

        # adjust for rust 1.5 some symlinks magic to have stdlib craft available
        os.chdir(os.path.join(self.install_path, "rustc", "lib"))
        os.rename("rustlib", "rustlib.init")
        os.symlink(
            glob(os.path.join('..', '..', 'rust-std-*', 'lib', 'rustlib'))[0],
            'rustlib')
        os.symlink(os.path.join('..', 'rustlib.init', 'etc'),
                   os.path.join('rustlib', 'etc'))

        UI.delayed_display(
            DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #12
0
 def post_install(self):
     """Add Terraform necessary env variables"""
     add_env_to_user(self.name,
                     {"PATH": {
                         "value": os.path.join(self.install_path)
                     }})
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #13
0
 def post_install(self):
     """Add the Geckodriver binary dir to PATH"""
     add_env_to_user(self.name,
                     {"PATH": {
                         "value": os.path.join(self.install_path)
                     }})
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #14
0
 def language_select_callback(self, url):
     url = url.replace("&amp;", "&")
     logger.debug("Found download link for {}".format(url))
     if self.dry_run:
         UI.display(DisplayMessage("Found download URL: " + url))
         UI.return_main_screen(status_code=0)
     self.download_requests.append(DownloadItem(url, None))
     self.start_download_and_install()
Beispiel #15
0
 def post_install(self):
     """Add the necessary Maven environment variables"""
     add_env_to_user(
         self.name,
         {"PATH": {
             "value": os.path.join(self.install_path, "bin")
         }})
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #16
0
 def post_install(self):
     """Print wiki page message"""
     UI.display(
         DisplayMessage(
             "NDK installed in {}. More information on how to use it on {}".
             format(
                 self.install_path,
                 "https://developer.android.com/tools/sdk/ndk/index.html#GetStarted"
             )))
Beispiel #17
0
 def post_install(self):
     """Add necessary environment variables"""
     add_env_to_user(self.name, {
         "PATH": {
             "value": [os.path.join(self.install_path, "platform-tools")]
         }
     })
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #18
0
    def decompress_and_install(self, fd):
        UI.display(DisplayMessage("Installing {}".format(self.name)))
        # empty destination directory if reinstall
        for dir_to_remove in self._paths_to_clean:
            with suppress(FileNotFoundError):
                shutil.rmtree(dir_to_remove)

        Decompressor({fd: Decompressor.DecompressOrder(dir=self.dir_to_decompress_in_tarball, dest=self.install_path)},
                     self.decompress_and_install_done)
        UI.display(UnknownProgress(self.iterate_until_install_done))
Beispiel #19
0
    def post_install(self):
        """Add nodejs necessary env variables and move module folder"""
        if not self.prefix_set():
            with open(os.path.join(os.environ['HOME'], '.npmrc'), 'a+') as file:
                file.write("prefix = ${HOME}/.npm_modules\n")

        add_env_to_user(self.name, {"PATH": {"value": "{}:{}".format(os.path.join(self.install_path, "bin"),
                                                                     os.path.join(os.path.expanduser('~'),
                                                                                  ".npm_modules", "bin"))}})
        UI.delayed_display(DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #20
0
 def post_install(self):
     """Add the necessary OpenJFX environment variables"""
     add_env_to_user(
         self.name, {
             "PATH_TO_FX": {
                 "value": os.path.join(self.install_path, "lib"),
                 "keep": False
             }
         })
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #21
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name,
         {"PATH": {
             "value": os.path.join(self.install_path, "bin")
         }})
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart a shell session for your installation to work"
               )))
Beispiel #22
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name,
         {"PATH": {
             "value": os.path.join(self.install_path, "bin")
         }})
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart your current shell session for your {} installation "
               "to work properly").format(self.name)))
Beispiel #23
0
 def post_install(self):
     """Create the Arduino launcher"""
     icon_path = join(self.install_path, 'lib', 'arduino_icon.ico')
     comment = _("The Arduino Software IDE")
     categories = "Development;IDE;"
     create_launcher(self.desktop_filename,
                     get_application_desktop_file(name=_("Arduino"),
                                                  icon_path=icon_path,
                                                  exec='"{}" %f'.format(self.exec_path),
                                                  comment=comment,
                                                  categories=categories))
     if not self.was_in_arduino_group:
         UI.delayed_display(DisplayMessage(_("You need to logout and login again for your installation to work")))
Beispiel #24
0
 def post_install(self):
     """Add go necessary env variables"""
     add_env_to_user(
         self.name, {
             "PATH": {
                 "value": os.path.join(self.install_path, "bin")
             },
             "GOROOT": {
                 "value": self.install_path,
                 "keep": False
             }
         })
     UI.delayed_display(
         DisplayMessage(self.RELOGIN_REQUIRE_MSG.format(self.name)))
Beispiel #25
0
 def start_download_and_install(self):
     self.last_progress_download = None
     self.last_progress_requirement = None
     self.balance_requirement_download = None
     self.pkg_size_download = 0
     self.result_requirement = None
     self.result_download = None
     self._download_done_callback_called = False
     UI.display(DisplayMessage("Downloading and installing requirements"))
     self.pbar = ProgressBar().start()
     self.pkg_to_install = RequirementsHandler().install_bucket(self.packages_requirements,
                                                                self.get_progress_requirement,
                                                                self.requirement_done)
     DownloadCenter(urls=self.download_requests, on_done=self.download_done, report=self.get_progress_download)
Beispiel #26
0
 def post_install(self):
     """Add the necessary Scala environment variables"""
     add_env_to_user(
         self.name, {
             "PATH": {
                 "value": os.path.join(self.install_path, "bin")
             },
             "SCALA_HOME": {
                 "value": self.install_path
             }
         })
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart the shell session for your installation to work"
               )))
Beispiel #27
0
 def post_install(self):
     """Add necessary environment variables"""
     add_env_to_user(
         self.name,
         {"ANDROID_NDK": {
             "value": self.install_path,
             "keep": False
         }})
     """Print wiki page message"""
     UI.display(
         DisplayMessage(
             "NDK installed in {}. More information on how to use it on {}".
             format(
                 self.install_path,
                 "https://developer.android.com/tools/sdk/ndk/index.html#GetStarted"
             )))
Beispiel #28
0
    def decompress_and_install_done(self, result):
        self._install_done = True
        error_detected = False
        for fd in result:
            if result[fd].error:
                logger.error(result[fd].error)
                error_detected = True
            fd.close()
        if error_detected:
            UI.return_main_screen()

        self.post_install()

        # Mark as installation done in configuration
        self.mark_in_config()

        UI.delayed_display(DisplayMessage("Installation done"))
        UI.return_main_screen()
Beispiel #29
0
 def post_install(self):
     """Create the Arduino launcher"""
     icon_path = join(self.install_path, 'lib', 'arduino_icon.ico')
     comment = _("The Arduino Software IDE")
     categories = "Development;IDE;"
     create_launcher(self.desktop_filename,
                     get_application_desktop_file(name=_("Arduino"),
                                                  icon_path=icon_path,
                                                  try_exec=self.exec_path,
                                                  exec=self.exec_link_name,
                                                  comment=comment,
                                                  categories=categories))
     # add the user to arduino group
     if not self.was_in_arduino_group:
         with futures.ProcessPoolExecutor(max_workers=1) as executor:
             f = executor.submit(_add_to_group, self._current_user, self.ARDUINO_GROUP)
             if not f.result():
                 UI.return_main_screen(status_code=1)
         UI.delayed_display(DisplayMessage(_("You need to logout and login again for your installation to work")))
Beispiel #30
0
 def post_install(self):
     """Add nodejs necessary env variables and move module folder"""
     subprocess.call([
         os.path.join(self.install_path, "bin", "npm"), "config", "set",
         "prefix", "~/.node_modules"
     ])
     add_env_to_user(
         self.name, {
             "PATH": {
                 "value":
                 "{}:{}".format(
                     os.path.join(self.install_path, "bin"),
                     os.path.join(os.path.expanduser('~'), ".node_modules",
                                  "bin"))
             }
         })
     UI.delayed_display(
         DisplayMessage(
             _("You need to restart your current shell session for your {} installation "
               "to work properly").format(self.name)))