mirror of
https://github.com/openSUSE/osc.git
synced 2024-12-28 02:36:15 +01:00
Merge branch 'fix_chroot_procfs' of https://github.com/lethliel/osc
Mount proc during "osc chroot". Eventually, we should implement "osc chroot" via the obs-build script.
This commit is contained in:
commit
c2fc655557
@ -9,6 +9,7 @@ from . import cmdln
|
|||||||
from . import conf
|
from . import conf
|
||||||
from . import oscerr
|
from . import oscerr
|
||||||
import sys
|
import sys
|
||||||
|
import signal
|
||||||
import time
|
import time
|
||||||
import imp
|
import imp
|
||||||
import inspect
|
import inspect
|
||||||
@ -6283,6 +6284,7 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
osc chroot [OPTS] (REPOSITORY = build_repository (config option), ARCH = hostarch, BUILD_DESCR is detected automatically)
|
osc chroot [OPTS] (REPOSITORY = build_repository (config option), ARCH = hostarch, BUILD_DESCR is detected automatically)
|
||||||
${cmd_option_list}
|
${cmd_option_list}
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if len(args) > 3:
|
if len(args) > 3:
|
||||||
raise oscerr.WrongArgs('Too many arguments')
|
raise oscerr.WrongArgs('Too many arguments')
|
||||||
if conf.config['build-type'] and conf.config['build-type'] != "lxc":
|
if conf.config['build-type'] and conf.config['build-type'] != "lxc":
|
||||||
@ -6336,13 +6338,38 @@ Please submit there instead, or use --nodevelproject to force direct submission.
|
|||||||
sucmd = suwrapper.split()[0]
|
sucmd = suwrapper.split()[0]
|
||||||
suargs = ' '.join(suwrapper.split()[1:])
|
suargs = ' '.join(suwrapper.split()[1:])
|
||||||
if suwrapper.startswith('su '):
|
if suwrapper.startswith('su '):
|
||||||
|
mntproc = [sucmd, '%s mount -n -tproc none %s/proc' % (suargs, buildroot)]
|
||||||
|
umntproc = [sucmd, '%s umount %s/proc' % (suargs, buildroot)]
|
||||||
cmd = [sucmd, '%s chroot "%s" su - %s' % (suargs, buildroot, user)]
|
cmd = [sucmd, '%s chroot "%s" su - %s' % (suargs, buildroot, user)]
|
||||||
else:
|
else:
|
||||||
|
mntproc = [sucmd, 'mount', '-n', '-tproc' , 'none', '%s/proc' % buildroot]
|
||||||
|
umntproc = [sucmd, 'umount', '%s/proc' % buildroot]
|
||||||
cmd = [sucmd, 'chroot', buildroot, 'su', '-', user]
|
cmd = [sucmd, 'chroot', buildroot, 'su', '-', user]
|
||||||
if suargs:
|
if suargs:
|
||||||
|
mntproc[1:1] = suargs.split()
|
||||||
|
umntproc[1:1] = suargs.split()
|
||||||
cmd[1:1] = suargs.split()
|
cmd[1:1] = suargs.split()
|
||||||
|
|
||||||
|
#signal handler for chroot procfs umount
|
||||||
|
def umount_proc(signum = None, frame = None, ret=1):
|
||||||
|
subprocess.call(umntproc)
|
||||||
|
sys.exit(ret)
|
||||||
|
for sig in [signal.SIGTERM, signal.SIGINT, signal.SIGHUP, signal.SIGQUIT]:
|
||||||
|
signal.signal(sig, umount_proc)
|
||||||
|
|
||||||
|
print('mounting proc: %s' % ' '.join(mntproc))
|
||||||
|
mount_err = -1
|
||||||
|
mount_err = subprocess.call(mntproc)
|
||||||
|
if mount_err > 0:
|
||||||
|
print('There was an error mounting proc. Please check mountpoints in chroot')
|
||||||
print('running: %s' % ' '.join(cmd))
|
print('running: %s' % ' '.join(cmd))
|
||||||
os.execvp(sucmd, cmd)
|
retval = 0
|
||||||
|
try:
|
||||||
|
retval = subprocess.call(cmd)
|
||||||
|
finally:
|
||||||
|
if not mount_err or mount_err == 32:
|
||||||
|
print('unmounting %s/proc ...' % buildroot)
|
||||||
|
umount_proc(ret=retval)
|
||||||
|
|
||||||
|
|
||||||
@cmdln.option('', '--csv', action='store_true',
|
@cmdln.option('', '--csv', action='store_true',
|
||||||
|
Loading…
Reference in New Issue
Block a user