Bindmount /etc/lsb-release into bubblewrap

Things like pip use lsb_release, so it is helpful to include this in
bubblewrap.  This conditionally includes similar files on both
debuntu and fedora.

Change-Id: Ibfed3ace26163da6484966e348e757f7268811f0
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
Co-Authored-By: James E. Blair <jeblair@redhat.com>
This commit is contained in:
Paul Belanger 2017-08-02 16:48:36 -04:00 committed by James E. Blair
parent 8316762e1d
commit 5d993ed71d
1 changed files with 12 additions and 5 deletions

View File

@ -22,6 +22,7 @@ import pwd
import shlex
import subprocess
import sys
import re
from typing import Dict, List # flake8: noqa
@ -73,6 +74,7 @@ class BubblewrapDriver(Driver, WrapperInterface):
log = logging.getLogger("zuul.BubblewrapDriver")
mounts_map = {'rw': [], 'ro': []} # type: Dict[str, List]
release_file_re = re.compile('^\W+-release$')
def __init__(self):
self.bwrap_command = self._bwrap_command()
@ -170,11 +172,16 @@ class BubblewrapDriver(Driver, WrapperInterface):
'--file', '{gid_fd}', '/etc/group',
]
if os.path.isdir('/lib64'):
bwrap_command.extend(['--ro-bind', '/lib64', '/lib64'])
if os.path.isfile('/etc/nsswitch.conf'):
bwrap_command.extend(['--ro-bind', '/etc/nsswitch.conf',
'/etc/nsswitch.conf'])
for path in ['/lib64',
'/etc/nsswitch.conf',
'/etc/lsb-release.d',
]:
if os.path.exists(path):
bwrap_command.extend(['--ro-bind', path, path])
for fn in os.listdir('/etc'):
if self.release_file_re.match(fn):
path = os.path.join('/etc', fn)
bwrap_command.extend(['--ro-bind', path, path])
return bwrap_command