runners: use osbuild.api.setup_stdio
Each runner used the exact same copy of `setup_stdio`, which is now provided by `api.setup_stdio`. Use that and remove the code duplication.
This commit is contained in:
parent
58e9211d71
commit
71adfced70
5 changed files with 11 additions and 69 deletions
|
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from osbuild.util import jsoncomm
|
||||
import osbuild.api
|
||||
|
||||
|
||||
def ldconfig():
|
||||
|
|
@ -36,20 +36,8 @@ def nsswitch():
|
|||
pass
|
||||
|
||||
|
||||
def setup_stdio():
|
||||
with jsoncomm.Socket.new_client("/run/osbuild/api/osbuild") as client:
|
||||
req = {'method': 'setup-stdio'}
|
||||
client.send(req)
|
||||
msg, fds, _ = client.recv()
|
||||
for io in ['stdin', 'stdout', 'stderr']:
|
||||
target = getattr(sys, io)
|
||||
source = fds[msg[io]]
|
||||
os.dup2(source, target.fileno())
|
||||
fds.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_stdio()
|
||||
osbuild.api.setup_stdio()
|
||||
ldconfig()
|
||||
sysusers()
|
||||
tmpfiles()
|
||||
|
|
|
|||
|
|
@ -1,25 +1,12 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from osbuild.util import jsoncomm
|
||||
|
||||
|
||||
def setup_stdio():
|
||||
with jsoncomm.Socket.new_client("/run/osbuild/api/osbuild") as client:
|
||||
req = {'method': 'setup-stdio'}
|
||||
client.send(req)
|
||||
msg, fds, _ = client.recv()
|
||||
for io in ['stdin', 'stdout', 'stderr']:
|
||||
target = getattr(sys, io)
|
||||
source = fds[msg[io]]
|
||||
os.dup2(source, target.fileno())
|
||||
fds.close()
|
||||
import osbuild.api
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_stdio()
|
||||
osbuild.api.setup_stdio()
|
||||
|
||||
r = subprocess.run(sys.argv[1:], check=False)
|
||||
sys.exit(r.returncode)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from osbuild.util import jsoncomm
|
||||
import osbuild.api
|
||||
|
||||
|
||||
def ldconfig():
|
||||
|
|
@ -36,17 +36,6 @@ def nsswitch():
|
|||
pass
|
||||
|
||||
|
||||
def setup_stdio():
|
||||
with jsoncomm.Socket.new_client("/run/osbuild/api/osbuild") as client:
|
||||
req = {'method': 'setup-stdio'}
|
||||
client.send(req)
|
||||
msg, fds, _ = client.recv()
|
||||
for io in ['stdin', 'stdout', 'stderr']:
|
||||
target = getattr(sys, io)
|
||||
source = fds[msg[io]]
|
||||
os.dup2(source, target.fileno())
|
||||
fds.close()
|
||||
|
||||
def os_release():
|
||||
"""/usr/lib/os-release doesn't exist. The `redhat-release` package
|
||||
generates `/etc/os-release directly. To work around this, do the same here.
|
||||
|
|
@ -82,7 +71,7 @@ def python_alternatives():
|
|||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_stdio()
|
||||
osbuild.api.setup_stdio()
|
||||
ldconfig()
|
||||
sysusers()
|
||||
tmpfiles()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from osbuild.util import jsoncomm
|
||||
import osbuild.api
|
||||
|
||||
|
||||
def ldconfig():
|
||||
|
|
@ -36,17 +36,6 @@ def nsswitch():
|
|||
pass
|
||||
|
||||
|
||||
def setup_stdio():
|
||||
with jsoncomm.Socket.new_client("/run/osbuild/api/osbuild") as client:
|
||||
req = {'method': 'setup-stdio'}
|
||||
client.send(req)
|
||||
msg, fds, _ = client.recv()
|
||||
for io in ['stdin', 'stdout', 'stderr']:
|
||||
target = getattr(sys, io)
|
||||
source = fds[msg[io]]
|
||||
os.dup2(source, target.fileno())
|
||||
fds.close()
|
||||
|
||||
|
||||
def python_alternatives():
|
||||
"""/usr/bin/python3 is a symlink to /etc/alternatives/python3, which points
|
||||
|
|
@ -60,7 +49,7 @@ def python_alternatives():
|
|||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_stdio()
|
||||
osbuild.api.setup_stdio()
|
||||
ldconfig()
|
||||
sysusers()
|
||||
tmpfiles()
|
||||
|
|
|
|||
|
|
@ -3,7 +3,8 @@
|
|||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
from osbuild.util import jsoncomm
|
||||
|
||||
import osbuild.api
|
||||
|
||||
|
||||
def ldconfig():
|
||||
|
|
@ -36,20 +37,8 @@ def nsswitch():
|
|||
pass
|
||||
|
||||
|
||||
def setup_stdio():
|
||||
with jsoncomm.Socket.new_client("/run/osbuild/api/osbuild") as client:
|
||||
req = {'method': 'setup-stdio'}
|
||||
client.send(req)
|
||||
msg, fds, _ = client.recv()
|
||||
for io in ['stdin', 'stdout', 'stderr']:
|
||||
target = getattr(sys, io)
|
||||
source = fds[msg[io]]
|
||||
os.dup2(source, target.fileno())
|
||||
fds.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
setup_stdio()
|
||||
osbuild.api.setup_stdio()
|
||||
ldconfig()
|
||||
sysusers()
|
||||
tmpfiles()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue