cookbook/container: example of building+running docker containers.
This got... long... and complicated. But I think it's a really good demonstration of getting redo to do complicated things elegantly. At least, I hope it is.
This commit is contained in:
parent
01497f55e9
commit
3923a7d3f8
38 changed files with 1375 additions and 7 deletions
16
docs/cookbook/container/default.sha256.do
Normal file
16
docs/cookbook/container/default.sha256.do
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env python
|
||||
"""Calculate the sha256 digest of a given file."""
|
||||
import hashlib, os, subprocess, sys
|
||||
|
||||
subprocess.check_call([
|
||||
'redo-ifchange',
|
||||
sys.argv[2],
|
||||
])
|
||||
|
||||
h = hashlib.sha256()
|
||||
f = open(sys.argv[2])
|
||||
while 1:
|
||||
b = f.read(65536)
|
||||
if not b: break
|
||||
h.update(b)
|
||||
open(sys.argv[3], 'w').write(h.hexdigest() + '\n')
|
||||
Loading…
Add table
Add a link
Reference in a new issue