blob: e7794c375093143c85c1654cc6ca3f49845072ea (
plain)
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
48
49
50
51
52
53
54
55
56
57
58
|
#!/usr/bin/env python3
# Generates a simplified file with variables that
# can be imported from the main vendorized Makefile.
import os
import sys
import configparser
from provider import getDefaultProvider
from provider import getProviderData
VERSION = os.environ.get('VERSION', 'unknown')
TEMPLATE = """
# Variables for the build of {applicationName}.
# Generated automatically. Do not edit.
APPNAME := {applicationName}
BINNAME := {binaryName}
VERSION := {version}
"""
def writeOutput(data, outfile):
configString = TEMPLATE.format(
binaryName=data['binaryName'],
applicationName=data['applicationName'],
version=data['version'],
)
with open(outfile, 'w') as outf:
outf.write(configString)
if __name__ == "__main__":
env_provider_conf = os.environ.get('PROVIDER_CONFIG')
if env_provider_conf:
if os.path.isfile(env_provider_conf):
print("[+] Overriding provider config per "
"PROVIDER_CONFIG variable")
configfile = env_provider_conf
config = configparser.ConfigParser()
config.read(configfile)
provider = getDefaultProvider(config)
data = getProviderData(provider, config)
if len(sys.argv) != 2:
print('Usage: generate-vendor-make.py <output_file>')
sys.exit(1)
outputf = sys.argv[1]
data['version'] = VERSION
writeOutput(data, outputf)
|