def layer(command=None, *args): "hints the start of a new layer" if not command: return eval([["hint", "layer"]]) # fall back to buildin layer macro else: lst = [["layer"]] for arg in args: lst.append([command, arg]) lst.append(["layer"]) return eval(lst)
def layer(command=None, *args): 'hint the start of a new layer' if not command: return eval([['hint', 'layer']]) # fall back to buildin layer macro else: lst = [['layer']] for arg in args: lst.append([command, arg]) lst.append(['layer']) return eval(lst)
def entrypoint_script(*lines): "write lines to /entrypoint and hint it as default command" lines = list(lines) if lines and not lines[0].startswith("#!"): lines.insert(0, "#!/bin/sh") return eval([["entrypoint", "/entrypoint"], ["write-script", "/entrypoint"] + lines])
def entrypoint_script(*lines): 'write lines to /entrypoint and hint it as default command' lines = list(lines) if lines and not lines[0].startswith('#!'): lines.insert(0, '#!/bin/sh') return eval([['entrypoint', '/entrypoint'], ['write-script', '/entrypoint'] + lines])
def package_manager(*packages): if not packages: return sh_packages = ' '.join(pkg for pkg in packages) expanded_lines = [line.format(sh_packages) for line in lines] return eval([['run'] + expanded_lines])
eval([[ 'defpm', 'apt', 'apt-get update', 'apt-get install -y {}', ], [ 'defpm', 'add-apt-repository', 'apt-get install software-properties-common', 'run add-apt-repository -y {}', ], [ 'defpm', 'apk', 'apk update', 'apk add {}', ], [ 'defpm', 'yum', 'yum install -y {}', ], [ 'defpm', 'dnf', 'dnf install -y {}', ], [ 'defpm', 'pip', 'pip install {}', ], [ 'defpm', 'pip3', 'pip3 install {}', ], [ 'defpm', 'npm', 'npm install -g {}', ], [ 'defpm', 'pacman', 'pacman -Sy --noconfirm {}', ], [ 'defpm', 'emerge', 'emerge {}', ]])
def from_ubuntu(version): import subprocess url = UBUNTU_URL_TEMPL.format(version, version) base = subprocess.check_output(['plash', 'build', '--from-url', url]).decode().rstrip('\n') return eval([['from', base]])
eval([ [ "defpm", "apt", "apt-get update", "apt-get install -y {}", ], [ "defpm", "add-apt-repository", "apt-get install software-properties-common", "run add-apt-repository -y {}", ], [ "defpm", "apk", "apk update", "apk add {}", ], [ "defpm", "yum", "yum install -y {}", ], [ "defpm", "dnf", "dnf install -y {}", ], [ "defpm", "pip", "pip install {}", ], [ "defpm", "pip3", "pip3 install {}", ], [ "defpm", "npm", "npm install -g {}", ], [ "defpm", "pacman", "pacman -Sy --noconfirm {}", ], [ "defpm", "emerge", "emerge {}", ], ])
def func(*args): # list(args) throws an exception exception for some really funny reason # therefore the list comprehension args = [i for i in args] return eval(macro[:-1] + [macro[-1] + args])