Skip to content
This repository has been archived by the owner on Oct 13, 2023. It is now read-only.

Commit

Permalink
Merge pull request #748 from jupierce/srpm_plashet
Browse files Browse the repository at this point in the history
[ART-6419] Temporary? support for building srpm directories containing RHCOS srpms
  • Loading branch information
jupierce committed Mar 24, 2023
2 parents 5434545 + a061310 commit e6774dd
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 2 deletions.
54 changes: 54 additions & 0 deletions doozerlib/cli/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import subprocess
import urllib.request, urllib.parse, urllib.error
from typing import Dict
import tempfile
import traceback
import koji
Expand Down Expand Up @@ -39,6 +40,7 @@
from doozerlib import coverity
from doozerlib.exceptions import DoozerFatalError
from doozerlib import exectools
from doozerlib.rhcos import RHCOSBuildInspector
from doozerlib.util import green_print, red_print, yellow_print, color_print, dict_get
from doozerlib.util import analyze_debug_timing, get_cincinnati_channels, extract_version_fields, go_arch_for_brew_arch
from doozerlib.util import get_release_calc_previous
Expand Down Expand Up @@ -1637,6 +1639,58 @@ def release_calc_previous(version, arch, graph_url, graph_content_stable, graph_
print(','.join(results))


@cli.command('config:rhcos-srpms')
@click.option("--version", metavar="RHCOS_VER", help="RHCOS version for which to collection SRPMS (e.g. 413.92.202303212039-0).", required=True)
@click.option("-o", "--output", metavar="DIR", help="Output directory to sync to", required=True)
@click.option("--brew-root", metavar="DIR", default='/mnt/redhat/brewroot', help="Brewroot directory from which to source RPMs.", required=True)
@click.option("-a", "--arch",
metavar='ARCH',
help="Arch for which the repo should be generated (if not specified, use all runtime arches).",
default=None, required=False)
@pass_runtime
def config_rhcos_src(runtime, version, output, brew_root, arch):
runtime.initialize(clone_distgits=False)

package_build_objects: Dict[str, Dict] = dict()
if arch:
arches = [arch]
else:
arches = runtime.arches

for arch_entry in arches:
runtime.logger.info(f'Pulling RHCOS package information for {version} and arch={arch_entry}')
inspector = RHCOSBuildInspector(runtime, pullspec_for_tag={}, brew_arch=arch_entry, build_id=version)
package_build_objects.update(inspector.get_package_build_objects())

brew_root_path = pathlib.Path(brew_root)
brew_packages_path = brew_root_path.joinpath('packages')

if not brew_packages_path.is_dir():
print(f'Brewroot packages must be a directory: {str(brew_packages_path)}')
exit(1)

output_path = pathlib.Path(output)
output_path.mkdir(parents=True, exist_ok=True)

for package_name, build_obj in package_build_objects.items():
package_nvr = build_obj['nvr']

src_dir_path = brew_packages_path.joinpath(package_name, build_obj['version'], build_obj['release'], 'src')
out_base_dir_path = output_path.joinpath(package_name, build_obj['version'], build_obj['release'])
out_base_dir_path.mkdir(parents=True, exist_ok=True)
out_src_dir = out_base_dir_path.joinpath('src')
if out_src_dir.exists():
if out_src_dir.is_symlink():
print(f'Output directory already contains a symlink for {package_nvr}. Skipping.')
continue
else:
print(f'File already exists; cannot replace with brewroot content: {str(out_src_dir)}')
exit(1)

out_src_dir.symlink_to(str(src_dir_path.absolute()))
runtime.logger.info(f'Populated {str(out_src_dir)}')


@cli.command("beta:reposync", short_help="Sync yum repos listed in group.yaml to local directory.")
@click.option("-o", "--output", metavar="DIR", help="Output directory to sync to", required=True)
@click.option("-c", "--cachedir", metavar="DIR", help="Cache directory for yum", required=True)
Expand Down
5 changes: 3 additions & 2 deletions doozerlib/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ def repo_file(self, repo_type, enabled_repos=[], empty_repos=[], arch=None):
:param repo_type: Whether to prefer signed or unsigned repos.
:param enabled_repos: A list of group.yml repo names which should be enabled. If a repo is enabled==1
in group.yml, that setting takes precedence over this list. If not enabled==1 in group.yml and not
found in this list, the repo will be returned as enabled==0.
found in this list, the repo will be returned as enabled==0. If '*' is included in the list,
all repos will be enabled.
:param empty_repos: A list of repo names to return defined as no-op yum repos.
:param arch: The architecture for which this repository should be generated. If None, all architectures
will be included in the returned str.
Expand All @@ -257,7 +258,7 @@ def repo_file(self, repo_type, enabled_repos=[], empty_repos=[], arch=None):
for r in self._repos.values():

enabled = r.enabled # If enabled in group.yml, it will always be enabled.
if enabled_repos and r.name in enabled_repos:
if enabled_repos and (r.name in enabled_repos or '*' in enabled_repos):
enabled = True

if arch: # Generating a single arch?
Expand Down

0 comments on commit e6774dd

Please sign in to comment.