Skip to content

Commit

Permalink
yum-sync: avoid passing arch to reposync by default, add option to ov…
Browse files Browse the repository at this point in the history
…erride, refactor

Signed-off-by: Harry Chen <i@harrychen.xyz>
  • Loading branch information
Harry-Chen committed Dec 2, 2023
1 parent 1d16b9d commit 9b8f3c8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions yum-sync.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#!/usr/bin/env python3
import hashlib
import traceback
import json
import os
import re
import shutil
import sys
import subprocess as sp
import tempfile
import argparse
Expand Down Expand Up @@ -146,11 +143,13 @@ def main():
parser.add_argument("base_url", type=str, help="base URL")
parser.add_argument("os_version", type=str, help="e.g. 7-8,9")
parser.add_argument("component", type=str, help="e.g. mysql56-community,mysql57-community")
parser.add_argument("arch", type=str, help="e.g. x86_64")
parser.add_argument("arch", type=str, help="e.g. x86_64,aarch64")
parser.add_argument("repo_name", type=str, help="e.g. @{comp}-el@{os_ver}")
parser.add_argument("working_dir", type=Path, help="working directory")
parser.add_argument("--download-repodata", action='store_true',
help='download repodata files instead of generating them')
parser.add_argument("--pass-arch-to-reposync", action='store_true',
help='''pass --arch to reposync to further filter packages by 'arch' field in metadata (NOT recommended, prone to missing packages in some repositories, e.g. mysql)''')
args = parser.parse_args()

os_list = []
Expand Down Expand Up @@ -223,10 +222,11 @@ def combination_os_comp(arch: str):

cmd_args = [
"dnf", "reposync",
"-a", arch, "-c", conf.name,
"-c", conf.name,
"--delete", "-p", str(args.working_dir.absolute())]
print("Launching dnf reposync", flush=True)
# print(cmd_args)
if args.pass_arch_to_reposync:
cmd_args += ["--arch", arch]
print(f"Launching dnf reposync with command: {cmd_args}", flush=True)
ret = sp.run(cmd_args)
if ret.returncode != 0:
failed.append((name, arch))
Expand All @@ -238,12 +238,12 @@ def combination_os_comp(arch: str):
download_repodata(url, path)
else:
cmd_args = ["createrepo_c", "--update", "-v", "-c", cache_dir, "-o", str(path), str(path)]
# print(cmd_args)
print(f"Launching createrepo with command: {cmd_args}", flush=True)
ret = sp.run(cmd_args)
calc_repo_size(path)

if len(failed) > 0:
print("Failed YUM repos: ", failed)
print(f"Failed YUM repos: {failed}", flush=True)
else:
if len(REPO_SIZE_FILE) > 0:
with open(REPO_SIZE_FILE, "a") as fd:
Expand Down

0 comments on commit 9b8f3c8

Please sign in to comment.