Exemplo n.º 1
0
    def __install(self, config):
        remove_common_prefix = (config.has('remove_common_prefix') and
                                config.is_affirmative('remove_common_prefix'))
        destination = config.get(
            'target', self.directory.install_directory(self.feature_name))
        url_type = config.get('type', config.get('url'))
        try:
            if url_type.endswith("tar.gz") or url_type.endswith(
                    "tar.bz2") or url_type.endswith("tar"):
                lib.extract_targz(config.get('url'),
                                  destination,
                                  remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("zip"):
                lib.extract_zip(config.get('url'),
                                destination,
                                remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("dmg"):
                if not system.is_osx():
                    self.logger.warn(
                        "Non OSX based distributions can not install a dmg!")
                else:
                    lib.extract_dmg(config.get('url'),
                                    destination,
                                    remove_common_prefix=remove_common_prefix)
        except ExtractException:
            self.logger.warn("Unable to extract file for feature %s" %
                             self.feature_name)
Exemplo n.º 2
0
 def _install_node(self):
     """ Install node.js """
     binary_url = binary_url_template.format(**self._system_info())
     self.logger.debug("Downloading and extracting node from %s..." % binary_url)
     lib.extract_targz(binary_url, self.directory.install_directory(self.feature_name),
                       remove_common_prefix=True)
     self._configure_npmrc()
Exemplo n.º 3
0
 def __install_p4v_linux(self, url):
     """ Install perforce applications and binaries for linux """
     lib.extract_targz(url,
                       self.directory.install_directory(self.feature_name),
                       remove_common_prefix=True)
     bin_path = os.path.join(self.directory.install_directory(self.feature_name), 'bin')
     for f in os.listdir(bin_path):
         self.directory.symlink_to_bin(f, os.path.join(bin_path, f))
     return True
Exemplo n.º 4
0
 def _install_node(self):
     """ Install node.js """
     binary_url = binary_url_template.format(**self._system_info())
     self.logger.debug("Downloading and extracting node from %s..." %
                       binary_url)
     lib.extract_targz(binary_url,
                       self.directory.install_directory(self.feature_name),
                       remove_common_prefix=True)
     self._configure_npmrc()
Exemplo n.º 5
0
def install_brew(target_path):
    """ Install brew to the target path """
    if not os.path.exists(target_path):
        try:
            os.makedirs(target_path)
        except OSError:
            logger.warn("Unable to create directory %s for brew." % target_path)
            logger.warn("Skipping...")
            return
    extract_targz(HOMEBREW_URL, target_path, remove_common_prefix=True)
Exemplo n.º 6
0
 def test_targz(self):
     """ Test if the targz extract works """
     TEST_URI = "http://testme.com/test.tar.gz"
     httpretty.register_uri(httpretty.GET, TEST_URI,
                            body=open("./test_data/test_tar.tar.gz", 'rb').read())
     test_dir = tempfile.mkdtemp()
     try:
         lib.extract_targz(TEST_URI, test_dir, remove_common_prefix=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter"))
         assert os.path.isdir(os.path.join(test_dir, "sprinter"))
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 7
0
 def test_targz(self):
     """ Test if the targz extract works """
     TEST_URI = "http://testme.com/test.tar.gz"
     httpretty.register_uri(httpretty.GET, TEST_URI,
                            body=open("./test_data/test_tar.tar.gz", 'rb').read())
     test_dir = tempfile.mkdtemp()
     try:
         lib.extract_targz(TEST_URI, test_dir, remove_common_prefix=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter"))
         assert os.path.isdir(os.path.join(test_dir, "sprinter"))
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 8
0
 def integrate_dmg_with_overwrite(self):
     """ Test if the dmg install works, with an overwrite """
     test_dir = tempfile.mkdtemp()
     try:
         os.mkdir(os.path.join(test_dir, "sprinter"))
         lib.extract_targz(TEST_TARGZ, test_dir, remove_common_prefix=True)
         assert not os.path.exists(os.path.join(test_dir, "sprinter", "sprinter"))
         lib.extract_targz(TEST_TARGZ, test_dir, remove_common_prefix=True, overwrite=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter", "formulas"))
         lib.extract_dmg("https://dl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg", test_dir, overwrite=True)
         assert os.path.exists(os.path.join(test_dir, "Google Chrome.app")), "app was not extracted!"
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 9
0
 def integrate_dmg_with_overwrite(self):
     """ Test if the dmg install works, with an overwrite """
     test_dir = tempfile.mkdtemp()
     try:
         os.mkdir(os.path.join(test_dir, "sprinter"))
         lib.extract_targz(TEST_TARGZ, test_dir, remove_common_prefix=True)
         assert not os.path.exists(os.path.join(test_dir, "sprinter", "sprinter"))
         lib.extract_targz(TEST_TARGZ, test_dir, remove_common_prefix=True, overwrite=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter", "formulas"))
         lib.extract_dmg("https://dl.google.com/chrome/mac/stable/GGRM/googlechrome.dmg", test_dir, overwrite=True)
         assert os.path.exists(os.path.join(test_dir, "Google Chrome.app")), "app was not extracted!"
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 10
0
def install_brew(target_path):
    """ Install brew to the target path """
    if not os.path.exists(target_path):
        try:
            os.makedirs(target_path)
        except OSError:
            LOGGER.warn("Unable to create directory %s for brew." % target_path + 
                        " Trying sudo...")
            lib.call("sudo mkdir -p %s" % target_path, stdout=None,
                     output_log_level=logging.DEBUG)
            lib.call("sudo chown %s %s" % (getpass.getuser(), target_path), 
                     output_log_level=logging.DEBUG, stdout=None)
    extract_targz(HOMEBREW_URL, target_path, remove_common_prefix=True)
Exemplo n.º 11
0
 def test_targz_with_overwrite(self):
     """ Test if the targz extract works, and overwrites """
     TEST_URI = "http://testme.com/test.tar.gz"
     httpretty.register_uri(httpretty.GET, TEST_URI,
                            body=open("./test_data/test_tar.tar.gz").read())
     test_dir = tempfile.mkdtemp()
     try:
         os.mkdir(os.path.join(test_dir, "sprinter"))
         lib.extract_targz(TEST_URI, test_dir, remove_common_prefix=True)
         assert not os.path.exists(os.path.join(test_dir, "sprinter", "sprinter"))
         lib.extract_targz(TEST_URI, test_dir, remove_common_prefix=True, overwrite=True)
         assert os.path.exists(os.path.join(test_dir, "sprinter", "formulas"))
     finally:
         shutil.rmtree(test_dir)
Exemplo n.º 12
0
    def __install(self, config):
        remove_common_prefix = config.has("remove_common_prefix") and config.is_affirmative("remove_common_prefix")
        destination = config.get("target", self.directory.install_directory(self.feature_name))
        try:
            if config.get("type", config.get("url")).endswith("tar.gz"):
                lib.extract_targz(config.get("url"), destination, remove_common_prefix=remove_common_prefix)

            elif config.get("type", config.get("url")).endswith("zip"):
                lib.extract_zip(config.get("url"), destination, remove_common_prefix=remove_common_prefix)

            elif config.get("type", config.get("url")).endswith("dmg"):
                if not self.system.isOSX():
                    self.logger.warn("Non OSX based distributions can not install a dmg!")
                else:
                    lib.extract_dmg(config.get("url"), destination, remove_common_prefix=remove_common_prefix)
        except ExtractException:
            self.logger.warn("Unable to extract file for feature %s" % self.feature_name)
Exemplo n.º 13
0
    def __install(self, config):
        remove_common_prefix = (config.has('remove_common_prefix') and
                                config.is_affirmative('remove_common_prefix'))
        url_type = config.get('type', config.get('url'))
        try:
            if url_type.endswith("tar.gz") or url_type.endswith("tar.bz2") or url_type.endswith("tar"):
                lib.extract_targz(config.get('url'), self._get_destination(),
                                  remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("zip"):
                lib.extract_zip(config.get('url'), self._get_destination(),
                                remove_common_prefix=remove_common_prefix)

            elif config.get('type', config.get('url')).endswith("dmg"):
                if not system.is_osx():
                    self.logger.warn("Non OSX based distributions can not install a dmg!")
                else:
                    lib.extract_dmg(config.get('url'), self._get_destination(),
                                    remove_common_prefix=remove_common_prefix)
        except ExtractException:
            self.logger.warn("Unable to extract file for feature %s" % self.feature_name)