IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

64 wiersze
1.7KB

  1. from .zfs import *
  2. import os
  3. import yaml
  4. from .steps import create_step
  5. from .snapshot import new_snapshot
  6. def process_step(step, name):
  7. cmd=['jail', '-c']
  8. cmd.append('path=' + '/focker/' + name)
  9. def process_steps(steps, name):
  10. if isinstance(steps, list):
  11. for step in steps:
  12. process_step(step, name)
  13. else:
  14. process_step(steps, name)
  15. def build(spec):
  16. if 'base' not in spec:
  17. raise ValueError('Missing base in specification')
  18. if 'steps' not in spec:
  19. raise ValueError('Missing steps in specification')
  20. base = spec['base']
  21. base, base_sha256 = zfs_snapshot_by_tag_or_sha256(base)
  22. root = '/'.join(base.split('/')[:-1])
  23. print('base:', base, 'root:', root)
  24. steps = spec['steps']
  25. if not isinstance(steps, list):
  26. steps = [ steps ]
  27. for st in steps:
  28. st = create_step(st)
  29. st_sha256 = st.hash(base_sha256)
  30. for pre in range(7, 64):
  31. name = root + '/' + st_sha256[:pre]
  32. if not zfs_exists(name):
  33. break
  34. snap_name = new_snapshot(base, lambda: st.execute(zfs_mountpoint(name)), name)
  35. feed = {
  36. 'focker:sha256': st_sha256
  37. }
  38. zfs_tag(name, feed)
  39. # zfs_tag(snap_name, feed)
  40. base = snap_name
  41. base_sha256 = st_sha256
  42. def command_image_build(args):
  43. fname = os.path.join(args.focker_dir, 'Fockerfile')
  44. print('fname:', fname)
  45. if not os.path.exists(fname):
  46. raise ValueError('No Fockerfile could be found in the specified directory')
  47. with open(fname, 'r') as f:
  48. spec = yaml.safe_load(f)
  49. print('spec:', spec)
  50. build(spec)