Skip to content

Commit

Permalink
rpmbuild: specify disttag when running fedora-review
Browse files Browse the repository at this point in the history
Fix FrostyX/fedora-review-service#28
Fix https://pagure.io/FedoraReview/issue/486

The fedora-review commands fails with the following error:

    ERROR: 'No disttag in package and no DISTTAG flag.
    Use --define DISTTAG to set proper dist e. g., --define DISTTAG=fc21.'

It is strange to me why it cannot find any disttag in the package but
it is easy for us to specify it, so why not.
  • Loading branch information
FrostyX committed Aug 6, 2023
1 parent bddee02 commit ed21b02
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 24 deletions.
19 changes: 19 additions & 0 deletions common/copr_common/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,22 @@ def script_requires_user(username):
)
sys.stderr.write(msg)
sys.exit(1)


def chroot_to_branch(chroot):
"""
Get a git branch name from chroot. Follow the fedora naming standard.
"""
name, version, _arch = chroot.rsplit("-", 2)
if name == "fedora":
if version == "rawhide":
return "master"
abbrev = "f"
elif name == "epel" and int(version) <= 6:
abbrev = "el"
elif name == "mageia" and version == "cauldron":
abbrev = "cauldron"
version = ""
elif name == "mageia":
abbrev = "mga"
return "{}{}".format(abbrev, version)
2 changes: 1 addition & 1 deletion common/python-copr-common.spec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
%endif

Name: python-copr-common
Version: 0.19
Version: 0.19.1.dev
Release: 1%{?dist}
Summary: Python code used by Copr

Expand Down
2 changes: 1 addition & 1 deletion frontend/copr-frontend.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# https://fedoraproject.org/wiki/Packaging:Guidelines#Packaging_of_Additional_RPM_Macros
%global macrosdir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)

%global copr_common_version 0.15.1.dev
%global copr_common_version 0.19.1.dev

# Please bump the %%flavor_guard version every-time some incompatible change
# happens (since the last release) in %%flavor_files set of files. Those files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@
revision = 'bf4b5dc74740'
down_revision = '38ea34def9a'

# pylint: disable=wrong-import-position
from alembic import op
import sqlalchemy as sa

from sqlalchemy.orm import sessionmaker
from copr_common.helpers import chroot_to_branch

import sys, os
sys.path.append(os.getcwd())
from coprs.models import MockChroot
from coprs.helpers import chroot_to_branch
from coprs.logic.coprs_logic import BranchesLogic

def upgrade():
Expand Down
2 changes: 1 addition & 1 deletion frontend/coprs_frontend/commands/create_chroot.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import click

from copr_common.helpers import chroot_to_branch
from coprs import exceptions
from coprs import db
from coprs.helpers import chroot_to_branch
from coprs.logic import coprs_logic


Expand Down
19 changes: 0 additions & 19 deletions frontend/coprs_frontend/coprs/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -315,25 +315,6 @@ def url_for_other_page(self, request, page):
return flask.url_for(request.endpoint, **args)


def chroot_to_branch(chroot):
"""
Get a git branch name from chroot. Follow the fedora naming standard.
"""
os, version, arch = chroot.rsplit("-", 2)
if os == "fedora":
if version == "rawhide":
return "master"
os = "f"
elif os == "epel" and int(version) <= 6:
os = "el"
elif os == "mageia" and version == "cauldron":
os = "cauldron"
version = ""
elif os == "mageia":
os = "mga"
return "{}{}".format(os, version)


def parse_package_name(pkg):
"""
Parse package name from possibly incomplete nvra string.
Expand Down
2 changes: 1 addition & 1 deletion rpmbuild/copr-rpmbuild.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
%global rpm_python python3-rpm
%global sitelib %python3_sitelib

%global copr_common_version 0.12.1.dev
%global copr_common_version 0.19.1.dev

# do not build debuginfo sub-packages
%define debug_package %nil
Expand Down
3 changes: 3 additions & 0 deletions rpmbuild/copr_rpmbuild/automation/fedora_review.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import os
import shutil
from copr_common.helpers import chroot_to_branch
from copr_rpmbuild.helpers import run_cmd
from copr_rpmbuild.automation.base import AutomationTool

Expand Down Expand Up @@ -39,10 +40,12 @@ def run(self):
"""
Run `fedora-review` tool inside the `resultdir`
"""
branch = chroot_to_branch(self.task["chroot"])
cmd = [
"fedora-review", "--no-colors", "--prebuilt", "--rpm-spec",
"--name", self.package_name,
"--mock-config", self.mock_config_file,
"--define", "DISTTAG={0}".format(branch),
]

try:
Expand Down

0 comments on commit ed21b02

Please sign in to comment.