Fix podctl build itself
This commit is contained in:
parent
f235db33ca
commit
e80955936c
54
examples/simple/pod.py
Normal file
54
examples/simple/pod.py
Normal file
@ -0,0 +1,54 @@
|
||||
from podctl import *
|
||||
|
||||
ex = Container(
|
||||
Base('docker.io/alpine'),
|
||||
Packages('bash'),
|
||||
DumbInit('sleep 55'),
|
||||
Commit('test'),
|
||||
)
|
||||
|
||||
podctl2 = Container(
|
||||
Base('docker.io/alpine'),
|
||||
Packages('bash python-dev'),
|
||||
Commit('test2'),
|
||||
)
|
||||
|
||||
|
||||
async def test_pod_story2(pod):
|
||||
await pod.script('down')()
|
||||
|
||||
|
||||
async def test_pod_story(pod):
|
||||
await pod.script('down')()
|
||||
await pod.script('build')('ex')
|
||||
return
|
||||
assert await pod.script('up')() == 0
|
||||
assert await pod.script('down')() == 0
|
||||
|
||||
|
||||
async def aoeutest_podctl(host):
|
||||
from podctl.console_script import console_script
|
||||
console_script.options['debug'] = 'visit'
|
||||
console_script.options['debug'] = True
|
||||
|
||||
|
||||
from podctl.podfile import Podfile
|
||||
pod = Podfile.factory(__file__).pod
|
||||
|
||||
from podctl.proc import Proc
|
||||
|
||||
#await Proc('podctl', 'down')()
|
||||
#await Proc('podctl', 'build', 'ex')()
|
||||
#await Proc('podctl', '-d=cmd,out,visit', 'up', 'ex')()
|
||||
#assert host.podman('simple-ex').is_running
|
||||
##import time; time.sleep(5)
|
||||
#await Proc('podctl', 'down')()
|
||||
#assert 'simple-ex' not in [c.name for c in host.podman.get_containers()]
|
||||
#return
|
||||
|
||||
await pod.script('down')()
|
||||
await pod.script('build')('ex')
|
||||
await pod.script('up')('ex')
|
||||
assert host.podman('ex').is_running
|
||||
await pod.script('down')()
|
||||
assert 'simple-ex' not in [c.name for c in host.podman.get_containers()]
|
||||
@ -95,12 +95,15 @@ class Script:
|
||||
|
||||
async def run(self, *args, **kwargs):
|
||||
if self.unshare and os.getuid() != 0:
|
||||
from podctl.console_script import console_script
|
||||
# restart under buildah unshare environment !
|
||||
argv = [
|
||||
'buildah', 'unshare',
|
||||
sys.argv[0], # current podctl location
|
||||
] + console_script.parser.argv + [
|
||||
type(self).__name__.lower() # script name ?
|
||||
] + list(args)
|
||||
print('Executing', ' '.join(argv))
|
||||
pp = subprocess.Popen(
|
||||
argv,
|
||||
stderr=sys.stderr,
|
||||
|
||||
@ -11,4 +11,3 @@ from .pip import Pip # noqa
|
||||
from .run import Run # noqa
|
||||
from .template import Append, Template # noqa
|
||||
from .user import User # noqa
|
||||
from .uwsgi import uWSGI # noqa
|
||||
|
||||
@ -14,12 +14,12 @@ class Copy:
|
||||
self.owner = script.variable('user')
|
||||
|
||||
async def build(self, script):
|
||||
await script.run(f'sudo mkdir -p {self.dst}')
|
||||
await script.crexec(f'mkdir -p {self.dst}')
|
||||
for item in self.src:
|
||||
await script.append(f'cp -a {item} $mnt{self.dst}')
|
||||
await script.exec(f'cp -a {item} {script.mnt}{self.dst}')
|
||||
|
||||
if self.mode:
|
||||
await script.run(f'sudo chmod {self.mode} $mnt{self.dst}')
|
||||
await script.crexec(f'chmod {self.mode} {script.mnt}{self.dst}')
|
||||
|
||||
if self.owner:
|
||||
await script.run(f'sudo chown -R {self.owner} $mnt{self.dst}')
|
||||
await script.crexec(f'chown -R {self.owner} {script.mnt}{self.dst}')
|
||||
|
||||
@ -29,9 +29,9 @@ class Packages:
|
||||
install='apt-get -y --no-install-recommends install',
|
||||
),
|
||||
dnf=dict(
|
||||
update='dnf update',
|
||||
upgrade='dnf upgrade --exclude container-selinux --best --assumeyes', # noqa
|
||||
install='dnf install --exclude container-selinux --setopt=install_weak_deps=False --best --assumeyes', # noqa
|
||||
update='dnf makecache --assumeyes',
|
||||
upgrade='dnf upgrade --best --assumeyes --skip-broken', # noqa
|
||||
install='dnf install --setopt=install_weak_deps=False --best --assumeyes', # noqa
|
||||
),
|
||||
yum=dict(
|
||||
update='yum update',
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user