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!
Browse Source

Add reusing of existing steps.

tags/0.92
parent
commit
174ecdfb6d
3 changed files with 26 additions and 1 deletions
  1. +3
    -1
      Fockerfile
  2. +5
    -0
      image.py
  3. +18
    -0
      zfs.py

+ 3
- 1
Fockerfile View File

@@ -1,6 +1,8 @@
base: freebsd-12.1
base: freebsd-latest
steps: steps:
- run: | - run: |
pkg -y install -y python3 && \ pkg -y install -y python3 && \
pkg -y install -y py37-pip pkg -y install -y py37-pip
- run: |
pkg install -y py37-yaml

+ 5
- 0
image.py View File

@@ -38,6 +38,11 @@ def build(spec):
for st in steps: for st in steps:
st = create_step(st) st = create_step(st)
st_sha256 = st.hash(base_sha256) st_sha256 = st.hash(base_sha256)
if zfs_exists_snapshot_sha256(st_sha256):
base = zfs_snapshot_by_sha256(st_sha256)
base_sha256 = st_sha256
print('Reusing:', base)
continue
for pre in range(7, 64): for pre in range(7, 64):
name = root + '/' + st_sha256[:pre] name = root + '/' + st_sha256[:pre]
if not zfs_exists(name): if not zfs_exists(name):


+ 18
- 0
zfs.py View File

@@ -54,6 +54,24 @@ def zfs_mountpoint(name):
return lst[0][0] return lst[0][0]
def zfs_exists_snapshot_sha256(sha256):
lst = zfs_parse_output(['zfs', 'list', '-o', 'focker:sha256', '-t', 'snap'])
lst = list(filter(lambda a: a[0] == sha256, lst))
if len(lst) == 0:
return False
return True
def zfs_snapshot_by_sha256(sha256):
lst = zfs_parse_output(['zfs', 'list', '-o', 'focker:sha256,name', '-t', 'snap', '-H'])
lst = list(filter(lambda a: a[0] == sha256, lst))
if len(lst) == 0:
raise ValueError('Snapshot with given sha256 does not exist: ' + sha256)
if len(lst) > 1:
raise ValueError('Ambiguous snapshot sha256: ' + sha256)
return lst[0][1]
def zfs_init(): def zfs_init():
poolname = zfs_parse_output(['zfs', 'list', '-H', '/']) poolname = zfs_parse_output(['zfs', 'list', '-H', '/'])
if len(poolname) == 0: if len(poolname) == 0:


Loading…
Cancel
Save