Skip to content

Commit dd69714

Browse files
authored
Merge pull request #182 from nicolasbock/issue_119
Add command line option to specify `FEATURES`
2 parents c3efce9 + 1281c68 commit dd69714

File tree

3 files changed

+36
-13
lines changed

3 files changed

+36
-13
lines changed

ebuildtester.bash-completion

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
_ebuildtester() {
2-
local cur prev opts
2+
local cur prev opts prefix
33
COMPREPLY=()
44
cur="${COMP_WORDS[COMP_CWORD]}"
55
prev="${COMP_WORDS[COMP_CWORD-1]}"
@@ -27,22 +27,31 @@ _ebuildtester() {
2727
--with-X
2828
--with-vnc
2929
--profile
30+
--features
3031
--docker-image
3132
--docker-command
3233
--pull
3334
--show-options
3435
)
3536

36-
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
37-
COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) )
38-
return 0
39-
fi
40-
4137
case "${prev}" in
4238
--portage-dir|--overlay-dir)
4339
COMPREPLY=( $(compgen -o dirnames -A directory ${cur}) )
4440
;;
41+
--features)
42+
if [[ ${cur} =~ ^- ]]; then
43+
prefix=("-P" "-")
44+
else
45+
prefix=()
46+
fi
47+
echo
48+
COMPREPLY=( $(compgen ${prefix[@]} -W "ccache sandbox userfetch" -- ${cur#-}) )
49+
;;
4550
esac
4651

52+
if [[ ( ${cur} =~ ^-.* && ${prev} != --features ) || ${COMP_CWORD} -eq 1 ]] ; then
53+
COMPREPLY=( $(compgen -W "${opts[*]}" -- ${cur}) )
54+
return 0
55+
fi
4756
}
4857
complete -F _ebuildtester ebuildtester

ebuildtester/docker.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -202,15 +202,11 @@ def _tweak_settings(self):
202202

203203
options.log.info("tweaking portage settings")
204204

205-
features = "-sandbox -usersandbox"
206-
207-
if options.options.binhost:
208-
features += " getbinpkg"
209-
210205
# Disable the usersandbox feature, it's not working well inside a
211206
# docker container.
212-
self.execute("echo FEATURES=\\\"{}\\\" "
213-
">> /etc/portage/make.conf".format(features))
207+
self.execute(
208+
f"echo FEATURES=\\\"{' '.join(options.options.features)}\\\" "
209+
">> /etc/portage/make.conf")
214210

215211
self.execute(("echo MAKEOPTS=\\\"-j%d\\\" " %
216212
(options.options.threads)) +

ebuildtester/parse.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,13 @@ def parse_commandline(args):
108108
"--profile",
109109
help="The profile to use (default = %(default)s)",
110110
default="default/linux/amd64/17.1")
111+
parser.add_argument(
112+
'--features',
113+
help="Set FEATURES, see https://wiki.gentoo.org/wiki/FEATURES "
114+
"(default = %(default)s)",
115+
default=["-sandbox", "-usersandbox", "userfetch"],
116+
nargs="+",
117+
action="append")
111118
parser.add_argument(
112119
"--docker-image",
113120
help="Specify the docker image to use (default = %(default)s)",
@@ -142,6 +149,17 @@ def parse_commandline(args):
142149
else:
143150
options.atom = []
144151

152+
temp = []
153+
for feature in options.features:
154+
if type(feature) is list:
155+
temp += feature
156+
else:
157+
temp.append(feature)
158+
options.features = temp
159+
160+
if options.binhost:
161+
options.features.append("getbinpkg")
162+
145163
if options.with_vnc:
146164
options.atom += ["net-misc/tigervnc", "x11-wm/icewm"]
147165

0 commit comments

Comments
 (0)