forked from deadsnakes/runbooks
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgbp
More file actions
executable file
·35 lines (27 loc) · 997 Bytes
/
gbp
File metadata and controls
executable file
·35 lines (27 loc) · 997 Bytes
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
#!/usr/bin/env python3
from __future__ import annotations
import argparse
import os.path
import subprocess
import sys
from typing import NoReturn
HERE = os.path.abspath(os.path.dirname(__file__))
IMG = 'ghcr.io/deadsnakes/gbp'
def main() -> NoReturn:
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--volume', dest='volumes', action='append')
args, rest = parser.parse_known_args()
# we use the oldest supported distribution for pristine-tar
subprocess.check_call((os.path.join(HERE, 'pull-image'), IMG))
gitconfig = os.path.expanduser('~/.gitconfig')
interactive = '-ti' if sys.stdin.isatty() else '-i'
cmd = (
'docker', 'run', '--rm', interactive,
'--volume', f'{gitconfig}:/homedir/.gitconfig:ro',
'--volume', f'{os.getcwd()}:/tmp/src:rw',
*(f'--volume={volume}' for volume in args.volumes),
IMG, 'gbp', *rest,
)
os.execvp(cmd[0], cmd)
if __name__ == '__main__':
raise SystemExit(main())