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!
Sfoglia il codice sorgente

Added --squeeze argument to focker image build.

master
parent
commit
d6d4d9e454
4 ha cambiato i file con 60 aggiunte e 2 eliminazioni
  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 Vedi File

@@ -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 Vedi File

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


+ 1
- 0
focker/focker.py Vedi File

@@ -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 Vedi File

@@ -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…
Annulla
Salva