apenwarr-redo/docs/cookbook/container/dockjson.py
Avery Pennarun 2e4d3d518e cookbook/container/default.sha256.do: use explicit close_fds=False.
Some people have /usr/bin/python as a link to python3. The script is
designed to work in either python2 or python3, but python3's subprocess
model defaults to close_fds=True, which closes the jobserver fds and
causes an error.  Explicitly force close_fds=False to get identical
behaviour on python2 and python3.

Reported-by: Tharre <tharre3@gmail.com>
2019-05-15 15:19:06 -07:00

21 lines
608 B
Python
Executable file

#!/usr/bin/env python
"""Generate a docker 1.0-style manifest for a docker image."""
import json, os, sys, time
j = json.load(open('template.json'))
layerid = open(sys.argv[1] + '.list.sha256').read().strip()
j['id'] = layerid
if len(sys.argv) > 2 and sys.argv[2]:
parentid = open(sys.argv[2] + '.list.sha256').read().strip()
j['parent'] = parentid
t = time.time()
gt = time.gmtime(t)
nsec = int(t * 1e9) % 1000000000
j['created'] = time.strftime('%Y-%m-%dT%H:%M:%S', gt) + ('.%09dZ' % nsec)
nbytes = os.stat(sys.argv[1] + '.layer').st_size
j['Size'] = nbytes
json.dump(j, sys.stdout, indent=2)