Commit 5ceb9744 authored by Mustafa Gezen's avatar Mustafa Gezen
Browse files

Add support for original imports

parent 8c4f3b88
......@@ -62,7 +62,7 @@ async def get_build(build_id: int):
@router.post("/{build_id}/cancel", status_code=202)
async def cancel_build(build_id: int):
async def cancel_build(request: Request, build_id: int):
get_user(request)
build_obj = await Build.filter(id=build_id, cancelled=False).get_or_none()
......
......@@ -71,8 +71,8 @@ async def get_import_logs(import_id: int):
@router.post("/{import_id}/cancel", status_code=202)
async def cancel_import(import_id: int):
user = get_user(request)
async def cancel_import(request: Request, import_id: int):
get_user(request)
import_obj = await Import.filter(id=import_id, cancelled=False).get_or_none()
if not import_obj:
......
......@@ -46,6 +46,9 @@ class Settings(BaseSettings):
no_storage_download: bool = False
no_storage_upload: bool = False
import_logs_dir: str = "/tmp"
original_import_branch_prefix: str = "r"
original_rpm_prefix: str = "https://git.rockylinux.org/original/rpms"
original_module_prefix: str = "https://git.rockylinux.org/original/modules"
# mbs
mbs_url: str
......
......@@ -26,7 +26,7 @@ from typing import Optional
from distrobuild.settings import settings
async def import_project(import_id: int, source_rpm: str, module_mode: bool = False,
async def import_project(import_id: int, source_rpm: str, module_mode: bool = False, original: bool = False,
single_tag: Optional[str] = None) -> dict:
upstream_prefix = f"ssh://{settings.ssh_user}@{settings.gitlab_host}:{settings.ssh_port}{settings.repo_prefix}"
......@@ -60,6 +60,14 @@ async def import_project(import_id: int, source_rpm: str, module_mode: bool = Fa
args.append("--single-tag")
args.append(single_tag)
if original:
args.append("--import-branch-prefix")
args.append(settings.original_import_branch_prefix)
args.append("--rpm-prefix")
args.append(settings.original_rpm_prefix)
args.append("--module-prefix")
args.append(settings.original_module_prefix)
f = open(f"{settings.import_logs_dir}/import-{import_id}.log", "w")
proc = await asyncio.create_subprocess_exec("srpmproc", *args, stdout=asyncio.subprocess.PIPE, stderr=f)
......
......@@ -25,10 +25,11 @@ from typing import List, Tuple
from tortoise.transactions import atomic
from distrobuild.common import tags
from distrobuild.models import ImportStatus, Package, Import, ImportCommit
from distrobuild.models import ImportStatus, Package, Import, ImportCommit, Repo
from distrobuild.session import koji_session, gl
from distrobuild.settings import settings
from distrobuild import srpmproc
from distrobuild_scheduler import logger
from distrobuild_scheduler.utils import gitlabify
......@@ -37,7 +38,8 @@ from distrobuild_scheduler.utils import gitlabify
async def do(package: Package, package_import: Import):
koji_session.packageListAdd(tags.base(), package.name, "distrobuild")
branch_commits = await srpmproc.import_project(package_import.id, package.name, package_import.module)
original = package.repo == Repo.ORIGINAL
branch_commits = await srpmproc.import_project(package_import.id, package.name, package_import.module, original)
for branch in branch_commits.keys():
commit = branch_commits[branch]
await ImportCommit.create(branch=branch, commit=commit, import__id=package_import.id)
......@@ -62,7 +64,7 @@ async def task(package_id: int, import_id: int, dependents: List[Tuple[int, int]
await do(package, package_import)
except Exception as e:
print(e)
logger.debug(e)
package_import.status = ImportStatus.FAILED
package.last_import = None
else:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment