diff options
author | Richard Maw <richard.maw@codethink.co.uk> | 2013-08-13 16:30:06 +0000 |
---|---|---|
committer | Richard Maw <richard.maw@codethink.co.uk> | 2013-08-15 15:44:48 +0000 |
commit | b43a0b8ed9a26ff8a39189eb1b4534a1418326a9 (patch) | |
tree | 1b5d34e7b93f59cde79ac79901be51147481d55a | |
parent | e59ade699e91764ae02d63b853ae7f3bc6c1c3d4 (diff) | |
download | morph-b43a0b8ed9a26ff8a39189eb1b4534a1418326a9.tar.gz |
stagingarea: use invert_paths to bind-mount ro
This improves upon the logic by allowing subdirectories to be
marked as writable.
This is not needed in its state here, but it will be built upon.
It also does not attempt to make symlinks read-only, since the symlink
resolution is done before chrooting, so there will be dangling links,
which cause linux-user-chroot to fail during the bootstrap.
This also uses the --chdir option of linux-user-chroot instead of
running a shell script to cd and run the command.
-rw-r--r-- | morphlib/stagingarea.py | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/morphlib/stagingarea.py b/morphlib/stagingarea.py index 3d756df7..63d145c3 100644 --- a/morphlib/stagingarea.py +++ b/morphlib/stagingarea.py @@ -287,18 +287,18 @@ class StagingArea(object): else: cwd = '/' - do_not_mount_dirs = [self.builddirname, self.destdirname, - 'dev', 'proc', 'tmp'] - - real_argv = ['linux-user-chroot'] - for d in os.listdir(self.dirname): - if d not in do_not_mount_dirs: - if os.path.isdir(os.path.join(self.dirname, d)): - real_argv += ['--mount-readonly', '/'+d] + do_not_mount_dirs = [os.path.join(self.dirname, d) + for d in (self.builddirname, + self.destdirname, + 'dev', 'proc', 'tmp')] + + real_argv = ['linux-user-chroot', '--chdir', cwd] + for d in morphlib.fsutils.invert_paths(os.walk(self.dirname), + do_not_mount_dirs): + if not os.path.islink(d): + real_argv += ['--mount-readonly', self.relative(d)] real_argv += [self.dirname] - real_argv += ['sh', '-c', 'cd "$1" && shift && exec "$@"', '--', - cwd] real_argv += argv try: |