Skip to content

Commit

Permalink
Allow single repo check
Browse files Browse the repository at this point in the history
  • Loading branch information
adrianschroeter committed Nov 22, 2024
1 parent c1510cd commit 5d54b83
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions src/suse-distro-blockchain/suse-distro-check.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@
if network != alias:
continue
for k in cfg[alias]:
print(f"check {alias} {k}")
if alias == 'main' and k == 'network':
network = cfg[alias][k]
print(f"{k}")
if k == 'http_provider':
provider_url = cfg[alias][k]
if k == 'chainid':
Expand Down Expand Up @@ -64,6 +62,19 @@ def main(argv: List[str] = None) -> None:
import glob
import re
import os
import argparse

parser = argparse.ArgumentParser(
description="Validate you repository via the blockchain.",
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
)
parser.add_argument(
"aliases",
metavar="zyppc alias",
nargs="+",
help="The alias of a repository defined in zypp repo file",
)
args = parser.parse_args(argv)

repos = []
reposdirs = [ "/etc/zypp/repos.d" ]
Expand All @@ -72,7 +83,11 @@ def main(argv: List[str] = None) -> None:
continue
for reponame in sorted(glob.glob('%s/*.repo' % reposdir)):
repocfg = INIConfig(open(reponame))

for alias in repocfg:
if len(args.aliases) > 0 and not alias in args.aliases[0]:
continue

repoattr = {'enabled': 0, 'priority': 99, 'autorefresh': 1, 'type': 'rpm-md', 'metadata_expire': 900}
for k in repocfg[alias]:
repoattr[k] = repocfg[alias][k]
Expand Down Expand Up @@ -104,7 +119,7 @@ def main(argv: List[str] = None) -> None:
try:
build = contract.functions.get_product_build(verification).call()
except:
print(f"Warning: repo not registered in the block chain")
print(f"Warning: repo not registered in the block chain with verification id {verification}")
continue
# we get always an empty product atm when it is not matching
if build[0] == 0:
Expand Down
2 changes: 1 addition & 1 deletion suse-distro-check.conf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ network=holesky
# Public holesky test network
http_provider=https://ethereum-holesky-rpc.publicnode.com
chainid=17000
contract=0x12aedb6639c160b051be89b77717f46eafac282b
contract=0xc2228C3508577Df667BB6A39Dc8E25C1e0751d28

[anvil]
# for local development
Expand Down

0 comments on commit 5d54b83

Please sign in to comment.