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!
瀏覽代碼

Added --squeeze argument to focker image build.

master
父節點
當前提交
d6d4d9e454
共有 4 個文件被更改,包括 60 次插入2 次删除
  1. +14
    -0
      example/squeeze/Fockerfile
  2. +2
    -0
      example/squeeze/files/g
  3. +1
    -0
      focker/focker.py
  4. +43
    -2
      focker/image.py

+ 14
- 0
example/squeeze/Fockerfile 查看文件

@@ -0,0 +1,14 @@
base: freebsd-latest

steps:
- run:
- touch /a
- touch /b
- touch /c
- run:
- touch /d
- touch /e
- touch /f
- copy:
- [ files/g, /g ]


+ 2
- 0
example/squeeze/files/g 查看文件

@@ -0,0 +1,2 @@
foo bar


+ 1
- 0
focker/focker.py 查看文件

@@ -83,6 +83,7 @@ def create_parser():
parser.set_defaults(func=command_image_build)
parser.add_argument('focker_dir', type=str)
parser.add_argument('--tags', '-t', type=str, nargs='+', default=[])
parser.add_argument('--squeeze', '-s', action='store_true')
parser = ListForwarder([subparsers.add_parser(cmd) for cmd in ['tag', 't']])
parser.set_defaults(func=command_image_tag)


+ 43
- 2
focker/image.py 查看文件

@@ -12,15 +12,55 @@ from .steps import create_step
from .snapshot import new_snapshot
from tabulate import tabulate
import subprocess
from .misc import find_prefix
def build(spec, args):
def validate_spec(spec):
if 'base' not in spec:
raise ValueError('Missing base in specification')
if 'steps' not in spec:
raise ValueError('Missing steps in specification')
def build_squeeze(spec, args):
validate_spec(spec)
base = spec['base']
base, sha256 = zfs_find(base, focker_type='image', zfs_type='snapshot')
root = '/'.join(base.split('/')[:-1])
print('base:', base, 'root:', root)
steps = spec['steps']
if not isinstance(steps, list):
steps = [ steps ]
for st in steps:
st = create_step(st)
sha256 = st.hash(sha256, args=args)
if zfs_exists_snapshot_sha256(sha256):
name = zfs_snapshot_by_sha256(sha256)
print('Reusing:', name)
return (name, sha256)
name = find_prefix(root + '/', sha256)
def atomic():
for st in steps:
st = create_step(st)
st.execute(zfs_mountpoint(name), args=args)
zfs_set_props(name,
{ 'focker:sha256': sha256 })
name = new_snapshot(base, atomic, name)
return (name, sha256)
def build(spec, args):
validate_spec(spec)
base = spec['base']
base, base_sha256 = zfs_find(base, focker_type='image', zfs_type='snapshot')
@@ -67,7 +107,8 @@ def command_image_build(args):
with open(fname, 'r') as f:
spec = yaml.safe_load(f)
print('spec:', spec)
image, image_sha256 = build(spec, args)
image, image_sha256 = build_squeeze(spec, args) \
if args.squeeze else build(spec, args)
zfs_untag(args.tags)
zfs_tag(image.split('@')[0], args.tags)


Loading…
取消
儲存