1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
#!/usr/bin/env python3
import sys
sys.path.append("/usr/share/botch")
from util import get_fh_out, read_tag_file
from debarch import match_architecture
def filter_src_builds_for(inSources, arch, outSources, verbose=False):
with outSources as outfile:
for packages in inSources:
for pkg in packages:
if not any(
[
a != "all" and match_architecture(arch, a)
for a in pkg["Architecture"].split()
]
):
continue
pkg.dump(outfile)
outfile.write(b"\n")
return True
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser(
description=(
"filter a Sources control file, such that it only "
"contains the stanzas for those source packages which "
"build binary dependent packages for a certain "
"architecture."
)
)
parser.add_argument(
"inSources", type=read_tag_file, nargs="+", help="input Sources files"
)
parser.add_argument("arch", type=str, help="selected architecture")
parser.add_argument("outSources", type=get_fh_out, help="output Sources file")
parser.add_argument("--verbose", action="store_true", help="be verbose")
args = parser.parse_args()
ret = filter_src_builds_for(
args.inSources, args.arch, args.outSources, args.verbose
)
exit(not ret)
|