Example #1
0
    def compile(self, quiet=False, show_cmd=False):
        """
        Compile the currently checked out repo, assuming it is currently at self.version
        :return: True upon success, False if not
        """
        if not self.repo.url:
            return True
        pwd = os.getcwd()
        os.chdir(self.build_path())

        if self.repo.build_info:
            print(self.repo.build_info)

        for what, command in [("Configuring %s..." % self.version,
                               npf.replace_path(self.repo.configure,
                                                build=self)),
                              ("Cleaning %s..." % self.version,
                               npf.replace_path(self.repo.clean, build=self)),
                              ("Building %s..." % self.version,
                               npf.replace_path(self.repo.make, build=self))]:
            if not command:
                continue
            if not quiet:
                print(what)
            if show_cmd and command:
                print(command)
            env = os.environ.copy()
            env.update(self.repo.env)
            p = subprocess.Popen(command,
                                 shell=True,
                                 stdin=PIPE,
                                 stdout=PIPE,
                                 stderr=PIPE,
                                 env=env)
            output, err = [x.decode() for x in p.communicate()]
            p.wait()
            if not p.returncode == 0:
                print("Aborted (error code %d) !" % p.returncode)
                print("stdout :")
                print(output)
                print("stderr :")
                print(err)
                self.__write_file('.build_version', '')
                os.chdir(pwd)
                print(
                    "Compilation of %s FAILED. Check the log above, or look at the source at %s"
                    % (self.repo.pretty_name(), self.build_path()))
                return False

        os.chdir(pwd)
        self.__write_file(Build.__get_build_version_path(self.repo),
                          self.version)
        return True
Example #2
0
 def is_compile_needed(self):
     bin_path=npf.replace_path(self.repo.get_bin_path(self.version),build=self)
     if os.path.exists(bin_path) and (
                 Build.get_current_version(self.repo) == self.version):
         return False
     else:
         return True
Example #3
0
 def is_compile_needed(self):
     bin_path=npf.replace_path(self.repo.get_local_bin_path(self.version),build=self)
     if not os.path.exists(bin_path):
         return "could not find %s" % bin_path
     elif not Build.get_current_version(self.repo) == self.version:
         return "current version is %s, the newest is %s" % (Build.get_current_version(self.repo), self.version)
     else:
         return None
Example #4
0
 def checkout(self, branch=None):
     if branch is None:
         branch = self.repo.version
     url = npf.replace_path(self.repo.url,Build(self.repo,branch,self.options.result_path))
     if not Path(self.repo.get_build_path()).exists():
         os.makedirs(self.repo.get_build_path())
     try:
         filename, headers = urllib.request.urlretrieve(url, self.repo.get_build_path() + os.path.basename(url))
     except URLError:
         print("ERROR : Could not download %s : bad URL?" % url)
         return False
     t = tarfile.open(filename)
     t.extractall(self.repo.get_build_path())
     t.close()
     os.unlink(filename)
     return True
Example #5
0
 def checkout(self, branch=None):
     if branch is None:
         branch = self.repo.version
     url = npf.replace_path(
         self.repo.url,
         Build(self.repo, branch, self.repo.options.result_path))
     if not Path(self.repo.get_build_path()).exists():
         os.makedirs(self.repo.get_build_path())
     try:
         proxy = urllib.request.ProxyHandler({})
         opener = urllib.request.build_opener(proxy)
         opener.addheaders = [('User-Agent', 'NPF')]
         urllib.request.install_opener(opener)
         filename, headers = urllib.request.urlretrieve(
             url,
             self.repo.get_build_path() + os.path.basename(url))
     except URLError:
         print("ERROR : Could not download %s : bad URL?" % url)
         return False
     t = tarfile.open(filename)
     t.extractall(self.repo.get_build_path())
     t.close()
     os.unlink(filename)
     return True