Skip to content

Commit c8df529

Browse files
committed
[scag] Add option to switch between Gramine repositories
Gramine maintains two repositories: stable and unstable. The unstable repository is mostly used for testing release candidates. This commit adds an option to switch between these repositories. Signed-off-by: Mariusz Zaborski <[email protected]>
1 parent 50ef6e1 commit c8df529

File tree

6 files changed

+33
-12
lines changed

6 files changed

+33
-12
lines changed

Documentation/manpages/scag-setup.rst

+5
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ Options
2727
Initialize an empty directory with an example application from
2828
the given framework.
2929

30+
.. option:: --gramine_unstable
31+
32+
Use a pre-release version of Gramine.
33+
3034
.. option:: --framework <framework>
3135

3236
The framework used by the scaffolded application.
@@ -120,6 +124,7 @@ Example of the generated file (from
120124
121125
[gramine]
122126
passthrough_env = []
127+
gramine_unstable = false
123128
124129
[python_plain]
125130
application = "hello_world.py"

graminescaffolding/__main__.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,15 @@ def cli_version(project_dir, bootstrap):
136136
help='The directory of the application to scaffold.')
137137
@gramine_option_prompt('--bootstrap', required=False, is_flag=True,
138138
default=False, help='Bootstrap directory with framework example.')
139+
@gramine_option_prompt('--gramine_unstable', required=False, is_flag=True,
140+
default=False, help='Use gramine unstable repo.')
139141
@gramine_option_prompt('--passthrough_env', required=False, multiple=True,
140142
help='List of passthrough environment variables.')
141143
@click.argument('args', nargs=-1, type=click.UNPROCESSED)
142144
@click.pass_context
143-
def setup(ctx, framework, project_dir, bootstrap, passthrough_env, args):
145+
def setup(ctx, framework, project_dir, bootstrap, gramine_unstable,
146+
passthrough_env, args
147+
):
144148
"""
145149
Build Gramine application using Scaffolding framework.
146150
@@ -155,7 +159,8 @@ def setup(ctx, framework, project_dir, bootstrap, passthrough_env, args):
155159
ctx.fail(f'{err}')
156160

157161
framework = gramine_load_framework(framework)
158-
parser = framework.cmdline_setup_parser(project_dir, passthrough_env)
162+
parser = framework.cmdline_setup_parser(
163+
project_dir, gramine_unstable, passthrough_env)
159164
if bootstrap:
160165
if len(args) > 0:
161166
print(

graminescaffolding/builder.py

+18-8
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ def _init_jinja_env(self):
178178
types.MappingProxyType({}))
179179
templates.globals['passthrough_env'] = list(
180180
self.config['gramine'].get('passthrough_env', []))
181+
templates.globals['gramine_unstable'] = self.config['gramine'].get(
182+
'gramine_unstable', False)
181183

182184
return templates
183185

@@ -385,7 +387,7 @@ def get_docker_run_cmd(self, docker_id):
385387

386388

387389
@classmethod
388-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
390+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
389391
@click.command()
390392
def click_parser():
391393
return cls(project_dir, {
@@ -394,6 +396,7 @@ def click_parser():
394396
},
395397
'gramine': {
396398
'passthrough_env': passthrough_env,
399+
'gramine_unstable': gramine_unstable,
397400
},
398401
})
399402
return click_parser
@@ -406,7 +409,7 @@ class PythonBuilder(Builder):
406409
)
407410

408411
@classmethod
409-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
412+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
410413
@click.command()
411414
@utils.gramine_option_prompt('--application', type=str,
412415
required=True,
@@ -419,6 +422,7 @@ def click_parser(application):
419422
},
420423
'gramine': {
421424
'passthrough_env': passthrough_env,
425+
'gramine_unstable': gramine_unstable,
422426
},
423427
cls.framework: {
424428
'application': application,
@@ -449,7 +453,7 @@ class NodejsBuilder(Builder):
449453
)
450454

451455
@classmethod
452-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
456+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
453457
@click.command()
454458
@utils.gramine_option_prompt('--application', required=True, type=str,
455459
prompt="Which script is the main one")
@@ -460,6 +464,7 @@ def click_parser(application):
460464
},
461465
'gramine': {
462466
'passthrough_env': passthrough_env,
467+
'gramine_unstable': gramine_unstable,
463468
},
464469
cls.framework: {
465470
'application': application,
@@ -483,7 +488,7 @@ class ExpressjsBuilder(Builder):
483488
)
484489

485490
@classmethod
486-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
491+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
487492
@click.command()
488493
@utils.gramine_option_prompt('--application', required=True, type=str,
489494
prompt="Which script is the main one")
@@ -494,6 +499,7 @@ def click_parser(application):
494499
},
495500
'gramine': {
496501
'passthrough_env': passthrough_env,
502+
'gramine_unstable': gramine_unstable,
497503
},
498504
cls.framework: {
499505
'application': application,
@@ -517,7 +523,7 @@ class KoajsBuilder(Builder):
517523
)
518524

519525
@classmethod
520-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
526+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
521527
@click.command()
522528
@utils.gramine_option_prompt('--application', required=True, type=str,
523529
prompt="Which script is the main one")
@@ -528,6 +534,7 @@ def click_parser(application):
528534
},
529535
'gramine': {
530536
'passthrough_env': passthrough_env,
537+
'gramine_unstable': gramine_unstable,
531538
},
532539
cls.framework: {
533540
'application': application,
@@ -546,7 +553,7 @@ class JavaJARBuilder(Builder):
546553
)
547554

548555
@classmethod
549-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
556+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
550557
@click.command()
551558
@utils.gramine_option_prompt('--application', required=True, type=str,
552559
prompt="Which JAR is the main one")
@@ -557,6 +564,7 @@ def click_parser(application):
557564
},
558565
'gramine': {
559566
'passthrough_env': passthrough_env,
567+
'gramine_unstable': gramine_unstable,
560568
},
561569
cls.framework: {
562570
'application': application,
@@ -572,7 +580,7 @@ class JavaGradleBuilder(Builder):
572580
)
573581

574582
@classmethod
575-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
583+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
576584
@click.command()
577585
@utils.gramine_option_prompt('--application', required=True, type=str,
578586
prompt="Which JAR is the main one")
@@ -583,6 +591,7 @@ def click_parser(application):
583591
},
584592
'gramine': {
585593
'passthrough_env': passthrough_env,
594+
'gramine_unstable': gramine_unstable,
586595
},
587596
cls.framework: {
588597
'application': application,
@@ -603,7 +612,7 @@ class DotnetBuilder(Builder):
603612
)
604613

605614
@classmethod
606-
def cmdline_setup_parser(cls, project_dir, passthrough_env):
615+
def cmdline_setup_parser(cls, project_dir, gramine_unstable, passthrough_env):
607616
@click.command()
608617
@utils.gramine_option_prompt('--build_config', required=True,
609618
type=click.Choice(['Debug', 'Release']),
@@ -621,6 +630,7 @@ def click_parser(build_config, project_file, target):
621630
},
622631
'gramine': {
623632
'passthrough_env': passthrough_env,
633+
'gramine_unstable': gramine_unstable,
624634
},
625635
cls.framework: {
626636
'build_config': build_config,

graminescaffolding/templates/scag.toml

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ framework = "{{ scag.builder.framework }}"
88
{% block gramine -%}
99
[gramine]
1010
passthrough_env = {{ passthrough_env }}
11+
gramine_unstable = {{ gramine_unstable | lower }}
1112
{%- endblock %}
1213

1314
[{{ scag.builder.framework }}]

graminescaffolding/templates/sources.list

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{% block sources %}
22
deb http://deb.debian.org/debian/ bookworm main
33
deb http://security.debian.org/debian-security bookworm-security main
4-
deb https://packages.gramineproject.io/ bookworm main
4+
deb https://packages.gramineproject.io/ {% if gramine_unstable %}unstable-{% endif %}bookworm main
55
deb [arch=amd64] https://download.01.org/intel-sgx/sgx_repo/ubuntu jammy main
66
{% endblock %}
77

graminescaffolding/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def write_dl(self, rows, col_max=30, col_spacing=2):
5656

5757
for name in gramine_list_frameworks():
5858
parser = gramine_load_framework(name).cmdline_setup_parser(
59-
None, None)
59+
None, False, None)
6060
self.indent()
6161
opts = []
6262
for param in parser.params:

0 commit comments

Comments
 (0)