Ejemplo n.º 1
0
    def find_build_original(self):

        def orig_srpm_path(line):
            if line.startswith("/"):
                filepath = line
            elif line.startswith("repo:"):
                # TODO 暂时未发现repo,遇到后再补充
                filepath = line.replace("repo:stx", self.distro_repo, 1)
            elif line.startswith("3rd_party:"):
                filepath = line.replace("3rd_party:", self.third_party + "/", 1)
            elif line.startswith("mirror:"):
                filepath = line.replace("mirror:", self.distro_repo + "/", 1) \
                    .replace("CentOS/tis-r3-CentOS/kilo/", "") \
                    .replace("CentOS/tis-r3-CentOS/mitaka/", "")
            else:
                filepath = self.distro_repo + "/" + line
            if os.path.exists(filepath):
                return filepath
            log.error("Invalid srpm path '%s', evaluated as '%s', found in '%s'", line, filepath, srpm_path)

        srpm_path = os.path.join(self.pkgdir, "%s/srpm_path" % self.DISTRO)
        if os.path.exists(srpm_path):
            with open(srpm_path) as f:
                for line in f.readlines():
                    line = line.strip()
                    if line and line.endswith('.src.rpm'):
                        self.original_file = orig_srpm_path(line)

        spec_path = os.path.join(self.pkgdir, self.DISTRO)
        for filename in os.listdir(spec_path):
            if filename.endswith(".spec"):
                self.original_file = os.path.join(spec_path, filename)
        if not self.original_file:
            log.error("Please provide only one of srpm_path or .spec files, not None, in '%s'" % spec_path)
Ejemplo n.º 2
0
def popen_communicate(cmd, input=None, timeout=None, **kwargs):
    log.info("\n%s\n%s\n......\n" % ("".ljust(100, "*"), " ".join(cmd)))
    ret = subprocess.Popen(cmd, **kwargs)
    out, err = ret.communicate(input=input, timeout=timeout)
    log.info("Return Code: %s", ret.returncode)
    if out and type(out) == bytes:
        log.debug(out.decode("utf-8"))
    if err and type(err) == bytes:
        log.error(err.decode("utf-8"))
    return ret.returncode
Ejemplo n.º 3
0
def copy(src, dist):
    log.debug("Copy From %s to %s" % (src, dist))
    if os.path.isfile(src):
        shutil.copy2(src, dist)
    elif os.path.isdir(src):
        for name in os.listdir(src):
            fullpath = os.path.join(src, name)
            if os.path.isdir(fullpath):
                shutil.copytree(fullpath, os.path.join(dist, name))
            elif os.path.isfile(fullpath):
                shutil.copy2(fullpath, dist)
    else:
        log.error("Copy Failed. src path %s is not exist" % src)
Ejemplo n.º 4
0
 def orig_srpm_path(line):
     if line.startswith("/"):
         filepath = line
     elif line.startswith("repo:"):
         # TODO 暂时未发现repo,遇到后再补充
         filepath = line.replace("repo:stx", self.distro_repo, 1)
     elif line.startswith("3rd_party:"):
         filepath = line.replace("3rd_party:", self.third_party + "/", 1)
     elif line.startswith("mirror:"):
         filepath = line.replace("mirror:", self.distro_repo + "/", 1) \
             .replace("CentOS/tis-r3-CentOS/kilo/", "") \
             .replace("CentOS/tis-r3-CentOS/mitaka/", "")
     else:
         filepath = self.distro_repo + "/" + line
     if os.path.exists(filepath):
         return filepath
     log.error("Invalid srpm path '%s', evaluated as '%s', found in '%s'", line, filepath, srpm_path)
Ejemplo n.º 5
0
 def monitor_procdata(self):
     for pd in self.procdata:
         p = pd['proc']
         result = p.exitcode
         if result is None:
             continue
         p.join()
         build = pd['build']
         if result == SUCCESS:
             log.info("%s] Success Build", build.pkg.rjust(20))
             build.success = True
             build.update_repo(max_workers=self.max_workers)
         elif result == FAIL:
             log.warn(
                 "%s] Error Build. Try to build again if other packages will succeed.",
                 build.pkg.rjust(17))
         elif result == SKIP:
             log.info("%s] Skipping already built pkg", build.pkg.rjust(20))
             build.success = True
         else:
             log.error("%s] Unknown exist code %d", build.pkg.rjust(20),
                       result)
             del self.builds[build.pkg]
         self.procdata.remove(pd)
Ejemplo n.º 6
0
 def find_build_data(self, build_srpm_data_file=None):
     if build_srpm_data_file is None:
         build_srpm_data_file = os.path.join(self.pkgdir, "%s/build_srpm.data" % self.OS)
     if not os.path.exists(build_srpm_data_file):
         log.error("%s not found", build_srpm_data_file)
     stx_env = {
         'FILES_BASE': "%s/files" % self.OS,
         'CGCS_BASE': self.distro_repo,
         'PKG_BASE': self.pkgdir,
         'STX_BASE': self.distro_repo,
         'PATCHES_BASE': "%s/patches" % self.OS,
         'DISTRO': self.OS
     }
     self.__dict__.update(shell.fetch_all_params(build_srpm_data_file, stx_env))
     if not self.TIS_PATCH_VER:
         log.error("TIS_PATCH_VER must be set in %s", build_srpm_data_file)
     if self.TIS_PATCH_VER.startswith("GITREVCOUNT"):
         if not self.TIS_BASE_SRCREV:
             log.error("TIS_BASE_SRCREV must be set in %s", build_srpm_data_file)
         items = self.TIS_PATCH_VER.split("+")
         count = 0 if len(items) == 1 else int(items[1]) + \
                                           shell.git_commit_count(self.pkgdir, self.TIS_BASE_SRCREV) + \
                                           shell.git_plus_by_status(self.pkgdir)
         self.TIS_PATCH_VER = str(count)
Ejemplo n.º 7
0
def find_out_files(d, suffix):
    files = find_files(d, suffix)
    if not files:
        log.error("Can not find out '%s' files in %s" % (suffix, d))
    return files
Ejemplo n.º 8
0
 def on_build_process_finished(self, builder):
     if builder.success:
         log.info("BUILD SUCCESS : %s", builder.pkg)
     else:
         self.failed_list.append(builder.pkg)
         log.error("BUILD FAILED : %s", builder.pkg)
Ejemplo n.º 9
0
 def test_log_error(self):
     try:
         log.error("%s %d", "test for debug", 1)
         assert True
     except Exception as e:
         assert False
Ejemplo n.º 10
0
 def on_build_process_finished(self, builder):
     if builder.success:
         log.info("BUILD SUCCESS : %s", builder.pkg)
     else:
         log.error("BUILD FAILED : %s", builder.pkg)