def create_rpms(self, upstream_ref: str = None, rpm_dir: str = None) -> List[Path]: """ Create rpms from the upstream repo :param upstream_ref: git ref to upstream commit :param rpm_dir: path to the directory where the rpm is meant to be placed :return: a path to the rpm """ self.up.run_action(actions=ActionName.post_upstream_clone) try: self.up.prepare_upstream_for_srpm_creation( upstream_ref=upstream_ref) except Exception as ex: raise PackitRPMException( f"Preparing of the upstream to the RPM build failed: {ex}" ) from ex try: rpm_paths = self.up.create_rpms(rpm_dir=rpm_dir) except PackitRPMException: raise except Exception as ex: raise PackitRPMException( f"An unexpected error occurred when creating the RPMs: {ex}" ) from ex for rpm_path in rpm_paths: if not rpm_path.exists(): raise PackitRPMNotFoundException( f"RPM was created successfully, but can't be found at {rpm_path}" ) return rpm_paths
def _get_rpms_from_mock_output(output: str) -> List[str]: """ Try to find the rpm files in the `mock` command output. Args: output: Output of the `mock` command. Returns: List of names of the RPM files. """ logger.debug(f"The `mock` command output: {output}") reg = r"Results and/or logs in: (.*)(\s|$)" paths = re.findall(reg, output) rpms = list( filter( lambda rpm: rpm.endswith(".rpm") and not rpm.endswith(".src.rpm"), os.listdir(paths[0][0]), ) ) logger.debug(rpms) if not rpms: raise PackitRPMNotFoundException( "RPMs cannot be found, something is wrong." ) return rpms
def _get_rpms_from_rpmbuild_output(self, output: str) -> List[str]: """ Try to find the rpm files in the `rpmbuild -bb` command output. :param output: output of the `rpmbuild -bb` command :return: the names of the RPM files """ logger.debug(f"The `rpmbuild` command output: {output}") reg = r": (.+\.rpm)" logger.debug(re.findall(reg, output)) rpms = re.findall(reg, output) if not rpms: raise PackitRPMNotFoundException( "RPMs cannot be found, something is wrong.") return rpms
def _get_rpms_from_rpmbuild_output(output: str) -> List[str]: """ Try to find the rpm files in the `rpmbuild -bb` command output. Args: output: Output of the `rpmbuild -bb` command. Returns: List of names of the RPM files. """ logger.debug(f"The `rpmbuild` command output: {output}") reg = r": (\S+\.rpm)(\s|$)" rpms = re.findall(reg, output) rpms = [rpm for rpm, _ in rpms] logger.debug(rpms) if not rpms: raise PackitRPMNotFoundException( "RPMs cannot be found, something is wrong." ) return rpms