Multiline Run scripts, and going pretty far for python 3.8

This commit is contained in:
jpic 2020-01-26 19:54:59 +01:00
parent c88aea9ba9
commit 895f0e164b
3 changed files with 26 additions and 13 deletions

11
pod.py
View File

@ -8,9 +8,16 @@ from podctl import *
podctl = Container( podctl = Container(
Base('quay.io/podman/stable'), Base('quay.io/podman/stable'),
Packages('python3', 'buildah', mgr='dnf'), Packages('python38', 'buildah', 'unzip', mgr='dnf'),
Run('''
curl -o setuptools.zip https://files.pythonhosted.org/packages/42/3e/2464120172859e5d103e5500315fb5555b1e908c0dacc73d80d35a9480ca/setuptools-45.1.0.zip
unzip setuptools.zip
mkdir -p /usr/local/lib/python3.8/site-packages/
sh -c "cd setuptools-* && python3.8 setup.py install"
easy_install-3.8 pip
'''),
Copy(['setup.py', 'podctl'], '/app'), Copy(['setup.py', 'podctl'], '/app'),
Pip('/app'), Pip('/app', pip='pip3.8'),
Config(cmd='podctl', author='jpic'), Config(cmd='podctl', author='jpic'),
Commit('docker.io/yourlabs/podctl'), Commit('docker.io/yourlabs/podctl'),
) )

View File

@ -1,8 +1,12 @@
class Pip: class Pip:
def __init__(self, *pip_packages): def __init__(self, *pip_packages, pip=None):
self.pip_packages = pip_packages self.pip_packages = pip_packages
self.pip = pip
def build(self, script): def build(self, script):
if self.pip:
script.append('_pip=' + self.pip)
else:
script.append(f''' script.append(f'''
if {script._run("bash -c 'type pip3'")}; then if {script._run("bash -c 'type pip3'")}; then
_pip=pip3 _pip=pip3

View File

@ -4,4 +4,6 @@ class Run:
def build(self, script): def build(self, script):
for command in self.commands: for command in self.commands:
script.run(command) for line in command.split('\n'):
if line.strip():
script.run(line.strip())