示例#1
0
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)
示例#2
0
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)
示例#3
0
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])
示例#4
0
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])
示例#5
0
 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])
示例#6
0
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 {}',
      ]])
示例#7
0
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]])
示例#8
0
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 {}",
    ],
])
示例#9
0
 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])