-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathinstall-bundle
More file actions
executable file
·107 lines (96 loc) · 3.79 KB
/
install-bundle
File metadata and controls
executable file
·107 lines (96 loc) · 3.79 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#!/usr/bin/env python3
"""
Wrapper to install bundles with JHBuild
"""
import argparse
import os
from pathlib import Path
import re
import subprocess
import sys
# Find relevant directories
topdir = Path(__file__).parent.resolve()
cfgdir = topdir / "rcfiles"
jhbdir = topdir / ".bundler-esl"
moddir = topdir / "modulesets"
# Find available module sets
modulesets = sorted([item.replace(".modules", "") \
for item in os.listdir(moddir) if item.endswith(".modules")])
# Find available configurations
configs = [item.replace(".rc", "") \
for item in os.listdir(cfgdir) if item.endswith(".rc")]
systems = sorted(list(set([item.split("-")[0] for item in configs])))
vendors = sorted(list(set([item.split("-")[1] for item in configs])))
flavors = sorted(list(set([item.split("-")[2] for item in configs])))
# Init command-line options
parser = argparse.ArgumentParser(
description="Install bundles with JHBuild")
parser.add_argument("packages",
default=["esl-bundle"], nargs="*",
help="Packages to install (defaults to all ESL Bundle components)")
parser.add_argument("-c", "--compilers",
choices=vendors, default="gcc",
help="Vendor of the compilers to use to build packages")
parser.add_argument("-f", "--flavor",
choices=flavors, default="serial",
help="Build flavor to select for compiler options")
parser.add_argument("-m", "--moduleset",
choices=modulesets, default="esl",
help="Module set storing the packages to install")
parser.add_argument("-s", "--system",
choices=systems, default="generic",
help="System on which the bundle will be installed")
parser.add_argument("--conditions",
dest="conditions", action="append",
help="Inform JHBuild of specific conditions applying to the" + \
" current build, instead of just building everything" + \
" unconditionally (EXPERIMENTAL)")
parser.add_argument("--no-exit-on-error",
dest="nostop", action="store_true",
help="Tell JHBuild not to stop at the first error encountered")
parser.add_argument("--no-interact",
dest="unattended", action="store_true",
help="Tell JHBuild not to prompt the user for input")
args = parser.parse_args()
# Check selected options
modname = f"{args.moduleset}.modules"
if not (moddir / modname).exists():
parser.error(f"moduleset file not found: {modname}")
cfgname = f"{args.system}-{args.compilers}-{args.flavor}.rc"
cfgfile = cfgdir / cfgname
if not cfgfile.exists():
parser.error(f"config file not found: {cfgname}")
defname = jhbdir / "defaults.jhbuildrc"
if not defname.exists():
parser.error(f"default specs not found: {defname}")
# Make the custom JHBuild configuration available
envdir = os.environ.get("JHBUILD_CUSTOM_PATH", None)
if envdir is None:
os.environ["JHBUILD_CUSTOM_PATH"] = str(jhbdir)
else:
jhbdir = Path(envdir)
if not jhbdir.exists():
parser.error(
f"JHBuild settings directory not found:\n {jhbdir}"
"\n\nPlease make JHBUILD_CUSTOM_PATH point to a directory"
"\ncontaining valid defaults.jhbuildrc and distfiles files."
)
# Build command line for pass-through options
jh_opt = []
if args.conditions:
if len(args.conditions) > 0:
jh_opt += [f"--conditions='{item}'" for item in args.conditions]
if not args.nostop:
jh_opt.append("--exit-on-error")
if args.unattended:
jh_opt.append("--no-interact")
# Run JHBuild
jh_env = ["JHBUILD_CUSTOM_PATH=" + str(jhbdir)]
jh_cmd = [sys.executable, str(topdir / "bundler" / "jhbuild.py")]
jh_cfg = ["-f", str(cfgfile)]
jh_mod = ["-m", str(moddir / modname)]
jh_run = ["build"] + args.packages
print(" ".join(jh_env + jh_cmd + jh_opt + jh_cfg + jh_mod + jh_run))
ret = subprocess.call(" ".join(jh_cmd + jh_opt + jh_cfg + jh_mod + jh_run),
shell=True)
sys.exit(ret)