Пример #1
0
    def inject_environment_config(self):
        if not self.do_inject_environment_config:
            return

        for shell in SHELL_CONFIG:
            if shell == 'gui':
                if system.is_debian():
                    self._inject_config_source(".env", SHELL_CONFIG['gui']['debian'])
            else:
                if (self.global_config.has_option('shell', shell)
                   and lib.is_affirmative(self.global_config.get('shell', shell))):

                    rc_file, rc_path = self._inject_config_source(".rc", SHELL_CONFIG[shell]['rc'])
                    env_file, env_path = self._inject_config_source(".env", SHELL_CONFIG[shell]['env'])
                    # If an rc file is sourced by an env file, we should alert the user.
                    if (self.phase is PHASE.INSTALL
                       and self.injections.in_noninjected_file(env_path, rc_file)
                       and self.global_injections.in_noninjected_file(env_path, rc_file)):
                        self.logger.info("You appear to be sourcing %s from inside %s." % (rc_file, env_file))
                        self.logger.info("Please ensure it is wrapped in a #SPRINTER_OVERRIDES block " +
                                         "to avoid repetitious operations!")
                    full_rc_path = os.path.expanduser(os.path.join("~", rc_file))
                    full_env_path = os.path.expanduser(os.path.join("~", env_file))
                    if lib.is_affirmative(self.global_config.get('global', 'env_source_rc')):
                        self.global_injections.inject(
                            full_env_path,
                            source_template % (full_rc_path, full_rc_path))
                    else:
                        self.global_injections.inject(full_env_path, '')
                    if system.is_osx() and not self.injections.in_noninjected_file(env_path, rc_file):
                        if self.phase is PHASE.INSTALL:
                            self.logger.info("On OSX, login shell are the default, which only source config files")
Пример #2
0
 def __get_package_manager(self):
     """
     Installs and verifies package manager
     """
     package_manager = ""
     args = ""
     sudo_required = True
     if system.is_osx():
         package_manager = "brew"
         sudo_required = False
         args = " install"
     elif system.is_debian():
         package_manager = "apt-get"
         args = " -y install"
     elif system.is_fedora():
         package_manager = "yum"
         args = " install"
     elif system.is_arch():
         package_manager = "pacman"
         args = " --noconfirm -S"
     if lib.which(package_manager) is None:
         self.logger.warn(
             "Package manager %s not installed! Packages will not be installed."
             % package_manager)
         self.package_manager = None
     self.package_manager = package_manager
     self.sudo_required = sudo_required
     self.args = args
Пример #3
0
 def __get_package_manager(self):
     """
     Installs and verifies package manager
     """
     package_manager = ""
     args = ""
     sudo_required = True
     if system.is_osx():
         package_manager = "brew"
         sudo_required = False
         args = " install"
     elif system.is_debian():
         package_manager = "apt-get"
         args = " -y install"
     elif system.is_fedora():
         package_manager = "yum"
         args = " install"
     elif system.is_arch():
         package_manager = "pacman"
         args = " --noconfirm -S"
     if lib.which(package_manager) is None:
         self.logger.warn("Package manager %s not installed! Packages will not be installed."
                          % package_manager)
         self.package_manager = None
     self.package_manager = package_manager
     self.sudo_required = sudo_required
     self.args = args
Пример #4
0
    def inject_environment_config(self):
        if not self.do_inject_environment_config:
            return

        for shell in SHELL_CONFIG:
            if shell == 'gui':
                if system.is_debian():
                    self._inject_config_source(".gui",
                                               SHELL_CONFIG['gui']['debian'])
            else:
                if (self.global_config.has_option('shell', shell)
                        and lib.is_affirmative(
                            self.global_config.get('shell', shell))):

                    rc_file, rc_path = self._inject_config_source(
                        ".rc", SHELL_CONFIG[shell]['rc'])
                    env_file, env_path = self._inject_config_source(
                        ".env", SHELL_CONFIG[shell]['env'])
                    # If an rc file is sourced by an env file, we should alert the user.
                    if (self.phase is PHASE.INSTALL
                            and self.injections.in_noninjected_file(
                                env_path, rc_file)
                            and self.global_injections.in_noninjected_file(
                                env_path, rc_file)):
                        self.logger.info(
                            "You appear to be sourcing %s from inside %s." %
                            (rc_file, env_file))
                        self.logger.info(
                            "Please ensure it is wrapped in a #SPRINTER_OVERRIDES block "
                            + "to avoid repetitious operations!")
                    full_rc_path = os.path.expanduser(
                        os.path.join("~", rc_file))
                    full_env_path = os.path.expanduser(
                        os.path.join("~", env_file))
                    if lib.is_affirmative(
                            self.global_config.get('global', 'env_source_rc')):
                        self.global_injections.inject(
                            full_env_path,
                            source_template % (full_rc_path, full_rc_path))
                    else:
                        self.global_injections.inject(full_env_path, '')
                    if system.is_osx(
                    ) and not self.injections.in_noninjected_file(
                            env_path, rc_file):
                        if self.phase is PHASE.INSTALL:
                            self.logger.info(
                                "On OSX, login shell are the default, which only source config files"
                            )