Example #1
0
    def install(self):
        # check if java is installed
        r = subprocess.call("command -v java > /dev/null", shell=True)
        if r != 0:
            logger.error("Jython requires Java to be installed, but the 'java' command was not found in the path.")
            return

        # get content type.
        if is_file(self.download_url):
            path = fileurl_to_path(self.download_url)
            self.content_type = mimetypes.guess_type(path)[0]
        else:
            try:
                headerinfo = Downloader.read_head_info(self.download_url)
            except DownloadError:
                self.content_type = None
            else:
                self.content_type = headerinfo['content-type']
        if is_html(self.content_type):
            # note: maybe got 404 or 503 http status code.
            logger.error("Invalid content-type: `%s`" % self.content_type)
            return

        self.download()
        logger.info("\nThis could take a while. You can run the following command on another shell to track the status:")
        logger.info("  tail -f %s\n" % self.logfile)
        logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
        cmd = 'java -jar %s -s -d %s' % (self.download_file, self.install_dir)
        s = Subprocess(log=self.logfile, verbose=self.options.verbose)
        s.check_call(cmd)
        self.symlink()
        logger.info("\nInstalled %(pkgname)s successfully." % {"pkgname": self.pkg.name})
Example #2
0
    def run_command(self, options, args):
        download_url = PYTHONZ_UPDATE_URL
        headinfo = Downloader.read_head_info(download_url)
        content_type = headinfo['content-type']
        filename = "pythonz-latest"
        distname = "%s.tgz" % filename
        download_file = os.path.join(PATH_DISTS, distname)
        # Remove old tarball
        unlink(download_file)
        logger.info("Downloading %s as %s" % (distname, download_file))
        try:
            Downloader.fetch(download_url, download_file)
        except DownloadError:
            logger.error("Failed to download. `%s`" % download_url)
            sys.exit(1)

        extract_dir = os.path.join(PATH_BUILD, filename)
        rm_r(extract_dir)
        if not extract_downloadfile(content_type, download_file, extract_dir):
            sys.exit(1)

        try:
            logger.info("Installing %s into %s" % (extract_dir, ROOT))
            s = Subprocess()
            s.check_call([
                sys.executable,
                os.path.join(extract_dir, 'pythonz_install.py'), '--upgrade'
            ])
        except:
            logger.error("Failed to update pythonz.")
            sys.exit(1)
        logger.info("pythonz has been updated.")
Example #3
0
    def run_command(self, options, args):
        headinfo = Downloader.read_head_info(PYTHONZ_UPDATE_URL)
        content_type = headinfo["content-type"]
        filename = "pythonz-latest"
        distname = "%s.tgz" % filename
        download_file = os.path.join(PATH_DISTS, distname)
        # Remove old tarball
        unlink(download_file)
        logger.info("Downloading %s as %s" % (distname, download_file))
        try:
            Downloader.fetch(PYTHONZ_UPDATE_URL, download_file)
        except DownloadError:
            unlink(download_file)
            logger.error("Failed to download. `%s`" % PYTHONZ_UPDATE_URL)
            sys.exit(1)
        except:
            unlink(download_file)
            raise

        extract_dir = os.path.join(PATH_BUILD, filename)
        rm_r(extract_dir)
        if not extract_downloadfile(content_type, download_file, extract_dir):
            sys.exit(1)

        try:
            logger.info("Installing %s into %s" % (extract_dir, ROOT))
            s = Subprocess()
            s.check_call([sys.executable, os.path.join(extract_dir, "pythonz_install.py"), "--upgrade"])
        except:
            logger.error("Failed to update pythonz.")
            sys.exit(1)
        logger.info("pythonz has been updated.")
Example #4
0
    def install(self):
        # check if java is installed
        r = subprocess.call("command -v java > /dev/null", shell=True)
        if r != 0:
            logger.error("Jython requires Java to be installed, but the 'java' command was not found in the path.")
            return

        # get content type.
        if is_file(self.download_url):
            path = fileurl_to_path(self.download_url)
            self.content_type = mimetypes.guess_type(path)[0]
        else:
            try:
                headerinfo = Downloader.read_head_info(self.download_url)
            except DownloadError:
                self.content_type = None
            else:
                self.content_type = headerinfo['content-type']
        if is_html(self.content_type):
            # note: maybe got 404 or 503 http status code.
            logger.error("Invalid content-type: `%s`" % self.content_type)
            return

        self.download()
        logger.info("\nThis could take a while. You can run the following command on another shell to track the status:")
        logger.info("  tail -f %s\n" % self.logfile)
        logger.info("Installing %s into %s" % (self.pkg.name, self.install_dir))
        cmd = 'java -jar %s -s -d %s' % (self.download_file, self.install_dir)
        s = Subprocess(log=self.logfile, verbose=self.options.verbose)
        s.check_call(cmd)
        self.symlink()
        logger.info("\nInstalled %(pkgname)s successfully." % {"pkgname": self.pkg.name})
Example #5
0
 def _update_pythonz(self, options, args):
     download_url = PYTHONZ_UPDATE_URL
     headinfo = get_headerinfo_from_url(download_url)
     content_type = headinfo['content-type']
     filename = "pythonz-latest"
     distname = "%s.tgz" % filename
     download_file = os.path.join(PATH_DISTS, distname)
     # Remove old tarball
     unlink(download_file)
     try:
         d = Downloader()
         d.download(distname, download_url, download_file)
     except:
         logger.error("Failed to download. `%s`" % download_url)
         sys.exit(1)
     
     extract_dir = os.path.join(PATH_BUILD, filename)
     rm_r(extract_dir)
     if not extract_downloadfile(content_type, download_file, extract_dir):
         sys.exit(1)
     
     try:
         logger.info("Installing %s into %s" % (extract_dir, ROOT))
         s = Subprocess()
         s.check_call([sys.executable, os.path.join(extract_dir,'pythonz_install.py'), '--upgrade'])
     except:
         logger.error("Failed to update pythonz.")
         sys.exit(1)
     logger.info("The pythonz has been updated.")
Example #6
0
 def configure(self):
     s = Subprocess(log=self.logfile,
                    cwd=self.build_dir,
                    verbose=self.options.verbose)
     cmd = "./configure --prefix=%s %s %s" % (
         self.install_dir, self.options.configure, ' '.join(
             self.configure_options))
     if self.options.verbose:
         logger.log(cmd)
     s.check_call(cmd)
Example #7
0
 def configure(self):
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     cmd = "./configure --prefix=%s %s %s" % (
         self.install_dir,
         self.options.configure,
         " ".join(self.configure_options),
     )
     if self.options.verbose:
         logger.log(cmd)
     s.check_call(cmd)
Example #8
0
 def _apply_patches(self):
     try:
         s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
         for patch in self.patches:
             if type(patch) is dict:
                 for ed, source in patch.items():
                     s.shell('ed - %s < %s' % (source, ed))
             else:
                 s.shell("patch -p0 < %s" % patch)
     except:
         logger.error("Failed to patch `%s`.\n%s" % (self.build_dir, sys.exc_info()[1]))
         sys.exit(1)
Example #9
0
 def make(self):
     try:
         jobs = multiprocessing.cpu_count()
     except NotImplementedError:
         make = 'make'
     else:
         make = 'make -j%s' % jobs
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     s.check_call(make)
     if self.options.run_tests:
         if self.options.force:
             # note: ignore tests failure error.
             s.call("make test")
         else:
             s.check_call("make test")
Example #10
0
 def _apply_patches(self):
     try:
         s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
         for patch in self.patches:
             if type(patch) is dict:
                 for ed, source in patch.items():
                     s.shell('ed - %s < %s' % (source, ed))
             else:
                 s.shell("patch -p0 < %s" % patch)
     except Exception:
         raise RuntimeError("Failed to patch `%s`.\n%s" % (self.build_dir, sys.exc_info()[1]))
Example #11
0
 def make(self):
     try:
         jobs = multiprocessing.cpu_count()
     except NotImplementedError:
         make = 'make'
     else:
         make = 'make -j%s' % jobs
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     s.check_call(make)
     if self.options.run_tests:
         if self.options.force:
             # note: ignore tests failure error.
             s.call("make test")
         else:
             s.check_call("make test")
Example #12
0
 def make_install(self):
     s = Subprocess(log=self.logfile, cwd=self.build_dir, verbose=self.options.verbose)
     s.check_call("make install")
Example #13
0
 def make_install(self):
     s = Subprocess(log=self.logfile,
                    cwd=self.build_dir,
                    verbose=self.options.verbose)
     s.check_call("make install")