forked from clayrisser/forkbuntu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8d0641b
commit d45d6fe
Showing
24 changed files
with
470 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
from .base import Base | ||
from .dev import Dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from cement.core.controller import expose | ||
from cfoundation import Controller | ||
import json | ||
|
||
class Dev(Controller): | ||
class Meta: | ||
description = 'Development' | ||
label = 'dev' | ||
stacked_on = 'base' | ||
stacked_type = 'nested' | ||
|
||
@expose() | ||
def default(self): | ||
log = self.app.log | ||
c = self.app.conf | ||
s = self.app.services |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .cache import Cache | ||
from .clean import Clean | ||
from .configure import Configure | ||
from .extras import Extras | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from cfoundation import Service | ||
from munch import munchify, Munch, unmunchify | ||
from os import path | ||
import checksum | ||
import checksumdir | ||
import hashlib | ||
import yaml | ||
|
||
class Cache(Service): | ||
def checksum(self, checksum_path): | ||
value = None | ||
if path.exists(checksum_path): | ||
if path.isdir(checksum_path): | ||
value = checksumdir.dirhash(checksum_path) | ||
else: | ||
value = checksum.get_for_file(checksum_path).decode('utf-8') | ||
return value | ||
|
||
def register(self, key): | ||
c = self.app.conf | ||
step = getattr(self.app.steps, key) | ||
cache = self.get() | ||
cache[key] = [] | ||
for checksum_path in step.checksum_paths: | ||
cache[key].append(self.checksum(checksum_path)) | ||
with open(path.join(c.paths.cwt, '.cache.yml'), 'w') as f: | ||
yaml.dump(unmunchify(cache), f, default_flow_style=False) | ||
return cache | ||
|
||
def get(self, key=None): | ||
c = self.app.conf | ||
cache_path = path.join(c.paths.cwt, '.cache.yml') | ||
cache = Munch() | ||
if not path.exists(cache_path): | ||
return cache | ||
with open(cache_path, 'r') as f: | ||
data = munchify(yaml.load(f)) | ||
if data: | ||
cache = data | ||
if key: | ||
if not key in cache: | ||
return [] | ||
return cache[key] | ||
return cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
from pydash import _ | ||
|
||
steps_run = [] | ||
|
||
class Step(): | ||
global steps_run | ||
|
||
def __init__(self, name, app): | ||
self.name = name | ||
self.app = app | ||
self.log = app.log | ||
|
||
def run_required(self): | ||
steps = self.app.steps | ||
if not hasattr(self, 'requires'): | ||
return None | ||
for required in self.requires: | ||
if not _.includes(steps_run, required): | ||
getattr(steps, required).start() | ||
|
||
def checksum(self): | ||
s = self.app.services | ||
if not hasattr(self, 'checksum_paths'): | ||
return False | ||
for checksum_path in self.checksum_paths: | ||
checksum = s.cache.checksum(checksum_path) | ||
if not _.includes(s.cache.get(self.name), checksum): | ||
return False | ||
return True | ||
|
||
def register(self): | ||
s = self.app.services | ||
if hasattr(self, 'checksum_paths'): | ||
s.cache.register(self.name) | ||
|
||
def start(self): | ||
spinner = self.app.spinner | ||
self.run_required() | ||
spinner.start(self.messages.present) | ||
passed = self.checksum() | ||
if passed: | ||
self.cached() | ||
return None | ||
self.run() | ||
self.register() | ||
self.finish() | ||
|
||
def cached(self): | ||
global steps_run | ||
spinner = self.app.spinner | ||
steps_run.append(self.name) | ||
spinner.warn(self.messages.cache) | ||
|
||
def finish(self): | ||
global steps_run | ||
spinner = self.app.spinner | ||
steps_run.append(self.name) | ||
spinner.succeed(self.messages.past) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from .build_keyring import BuildKeyring | ||
from .clean import Clean | ||
from .configure_filesystem import ConfigureFilesystem | ||
from .create_extras import CreateExtras | ||
from .initialize import Initialize | ||
from .load_config import LoadConfig | ||
from .merge_filesystem import MergeFilesystem | ||
from .merge_iso import MergeIso | ||
from .pack_filesystem import PackFilesystem | ||
from .pack_iso import PackIso | ||
from .sign_iso import SignIso | ||
from .unpack_filesystem import UnpackFilesystem | ||
from .unpack_iso import UnpackIso |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from ..step import Step | ||
from munch import munchify | ||
from os import path | ||
|
||
class BuildKeyring(Step): | ||
messages = munchify({ | ||
'past': 'built keyring', | ||
'present': 'building keyring', | ||
'cache': 'using built keyring cache' | ||
}) | ||
requires = [ | ||
'merge_filesystem' | ||
] | ||
|
||
def __init__(self, name, app): | ||
super().__init__(name, app) | ||
c = app.conf | ||
self.checksum_paths = [path.join(c.paths.iso)] | ||
|
||
def run(self): | ||
s = self.app.services | ||
s.gpg.build_keyring() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from ..step import Step | ||
from munch import munchify | ||
from os import path | ||
|
||
class Clean(Step): | ||
messages = munchify({ | ||
'past': 'cleaned', | ||
'present': 'cleaning' | ||
}) | ||
requires = [ | ||
'pack_iso' | ||
] | ||
|
||
def run(self): | ||
s = self.app.services | ||
s.clean.tmp() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from ..step import Step | ||
from munch import munchify | ||
from os import path | ||
|
||
class ConfigureFilesystem(Step): | ||
messages = munchify({ | ||
'past': 'configured filesystem', | ||
'present': 'configuring filesystem', | ||
'cache': 'using configured filesystem cache' | ||
}) | ||
requires = [ | ||
'create_extras' | ||
] | ||
|
||
def __init__(self, name, app): | ||
super().__init__(name, app) | ||
c = app.conf | ||
self.checksum_paths = [path.join(c.paths.iso)] | ||
|
||
def run(self): | ||
s = self.app.services | ||
s.configure.filesystem() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from ..step import Step | ||
from munch import munchify | ||
from os import path | ||
|
||
class CreateExtras(Step): | ||
messages = munchify({ | ||
'past': 'created extras', | ||
'present': 'creating extras', | ||
'cache': 'using extras cache' | ||
}) | ||
requires = [ | ||
'build_keyring' | ||
] | ||
|
||
def __init__(self, name, app): | ||
super().__init__(name, app) | ||
c = app.conf | ||
self.checksum_paths = [path.join(c.paths.iso)] | ||
|
||
def run(self): | ||
s = self.app.services | ||
s.extras.create() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from ..step import Step | ||
from munch import munchify | ||
from time import sleep | ||
import json | ||
|
||
class Initialize(Step): | ||
messages = munchify({ | ||
'past': 'initialized', | ||
'present': 'initializing' | ||
}) | ||
|
||
def run(self): | ||
s = self.app.services | ||
s.setup.init() | ||
setattr(self.app, 'gpg_keys', s.gpg.get_keys()) | ||
gpg_keys = self.app.gpg_keys | ||
|
||
def finish(self): | ||
super().finish() | ||
log = self.app.log | ||
log.debug('gpg_keys: ' + json.dumps(self.app.gpg_keys, indent=4, sort_keys=True)) |
Oops, something went wrong.