-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathtoltecmk-contained
More file actions
executable file
·59 lines (46 loc) · 1.6 KB
/
toltecmk-contained
File metadata and controls
executable file
·59 lines (46 loc) · 1.6 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
#!/usr/bin/env python3
# Copyright (c) 2021 The Toltec Contributors
# SPDX-License-Identifier: MIT
import argparse
import os
import subprocess
from pathlib import Path
from toltec import parse_recipe
from toltecmk import make_argparser
# Prefix for all Toltec Docker images
IMAGE_PREFIX = "ghcr.io/toltec-dev/"
args = make_argparser().parse_args()
recipe_bundle = parse_recipe(args.recipe_dir)
# Don't recipes in a bundle share most information?
recipe = next(iter(recipe_bundle.values()))
image = IMAGE_PREFIX + recipe.image
toltecmk_dir = str(Path(__file__).resolve().parent)
mounts = [ (args.recipe_dir, '/recipe'),
(args.work_dir, '/build'),
(args.dist_dir, '/pkg'),
(toltecmk_dir, '/toltecmk'),
]
for m in mounts:
if not os.path.exists(m[0]):
os.makedirs(m[0])
if args.source_dir:
mounts.append((args.source_dir, '/src'))
cmd = ['podman', 'run', '-it', '--rm']
for m in mounts:
cmd.append('-v')
cmd.append(':'.join(m))
cmd.append(image)
cmd += ['bash', '-c']
# currently required by toltecmk and missing in images
internal_cmd = []
internal_cmd += ['apt update && apt install -yq python3-dateutil python3-requests && ']
internal_cmd += ['/toltecmk/toltecmk',
'-w', '/build',
'-d', '/pkg',
'/recipe']
if args.source_dir: internal_cmd += ['-s', '/src']
if args.arch_name: internal_cmd += ['-a', args.arch_name]
if args.package_name: internal_cmd += ['-p', args.package_name]
cmd.append(' '.join(internal_cmd))
print(' '.join('"' + c + '"' if ' ' in c else c for c in cmd))
subprocess.call(cmd)