46 lines
1.6 KiB
Python
46 lines
1.6 KiB
Python
#! /usr/bin/env python3
|
|
|
|
if __name__ == "__main__":
|
|
import argparse
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import yaml
|
|
|
|
parser = argparse.ArgumentParser(description="Run script for all versions.")
|
|
parser.add_argument("script", metavar="script", type=str, nargs=1,
|
|
help="The script to run with the config file as argument.")
|
|
parser.add_argument("args", metavar="args", nargs='*', help="Args to add aditional.")
|
|
parser.add_argument("-s", "--staging", dest="staging", action="store_const",
|
|
const=True, default=False, help="Generate staging config.")
|
|
args = parser.parse_args()
|
|
|
|
# Load configuration
|
|
ownPath = os.path.split(sys.argv[0])[0]
|
|
filePath = None
|
|
if args.staging:
|
|
filePath = os.path.join(ownPath, "Wine-staging-x86_64.yaml")
|
|
else:
|
|
filePath = os.path.join(ownPath, "Wine-x86_64.yaml")
|
|
fileData = open(filePath, "r").read()
|
|
config = yaml.load(open(os.path.join(ownPath, "sources.yaml"), "r").read(), Loader=yaml.SafeLoader)
|
|
|
|
|
|
# Run script for each version
|
|
for version, i in config.items():
|
|
# Gen config file
|
|
tmp = fileData.replace("{{VERSION}}", version)
|
|
for jID, j in i.items():
|
|
tmp = tmp.replace("{{" + jID + "}}", j)
|
|
|
|
# Generate config file
|
|
outFile = tempfile.mktemp(".yaml")
|
|
with open(outFile, "w") as f:
|
|
f.write(tmp)
|
|
|
|
# Call script
|
|
try:
|
|
subprocess.call([args.script[0], outFile] + args.args)
|
|
finally:
|
|
os.remove(outFile) |