diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-01-09 11:55:18 +0000 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-01-09 11:55:18 +0000 |
commit | 923a88bd72b466779474544c278d22f4344259b2 (patch) | |
tree | 2dbf675ade1a2bdf04050159e14b1ddefec6a897 /morphlib/builder.py | |
parent | c6ea285f9e1b67923d85ccc5b52e84fad1852dcd (diff) | |
download | morph-923a88bd72b466779474544c278d22f4344259b2.tar.gz |
run ldconfig when it's necessary
Actually, run it whenever it _may_ be necessary. It's fast
enough that it's worth running even when not strictly necessary,
such as when unpacking a chunk that does not contain shared
libraries.
Diffstat (limited to 'morphlib/builder.py')
-rw-r--r-- | morphlib/builder.py | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/morphlib/builder.py b/morphlib/builder.py index 1add2835..c3e3b727 100644 --- a/morphlib/builder.py +++ b/morphlib/builder.py @@ -25,6 +25,30 @@ import urlparse import morphlib +def ldconfig(ex, rootdir): + '''Run ldconfig for the filesystem below ``rootdir``. + + Essentially, ``rootdir`` specifies the root of a new system. + Only directories below it are considered. + + ``etc/ld.so.conf`` below ``rootdir`` is assumed to exist and + be populated by the right directories, and should assume + the root directory is ``rootdir``. Example: if ``rootdir`` + is ``/tmp/foo``, then ``/tmp/foo/etc/ld.so.conf`` should + contain ``/lib``, not ``/tmp/foo/lib``. + + The ldconfig found via ``$PATH`` is used, not the one in ``rootdir``, + since in bootstrap mode that might not yet exist, the various + implementations should be compatible enough. + + ''' + + logging.debug('Running ldconfig for %s' % rootdir) + conf = os.path.join(rootdir, 'etc', 'ld.so.conf') + cache = os.path.join(rootdir, 'etc', 'ld.so.cache') + ex.runv(['ldconfig', '-f', conf, '-C', cache, '-r', rootdir]) + + class BinaryBlob(object): def __init__(self, morph, repo, ref): @@ -368,11 +392,13 @@ class System(BinaryBlob): self.build_watch.stop('mount-filesystem') # Unpack all strata into filesystem. + # Also, run ldconfig. self.build_watch.start('unpack-strata') for name, filename in self.built: self.msg('unpack %s from %s' % (name, filename)) self.ex.runv(['tar', '-C', mount_point, '-xf', filename], as_root=True) + ldconfig(ex, mount_point) self.build_watch.stop('unpack-strata') # Create fstab. @@ -549,11 +575,13 @@ class Builder(object): self.msg('Unpacking chunk %s onto system' % chunk_name) ex = morphlib.execute.Execute('/', self.msg) morphlib.bins.unpack_binary(chunk_filename, '/', ex, as_root=True) + ldconfig(ex, '/') else: self.msg('Unpacking chunk %s into staging' % chunk_name) ex = morphlib.execute.Execute(staging_dir, self.msg) morphlib.bins.unpack_binary(chunk_filename, staging_dir, ex, as_root=True) + ldconfig(ex, staging_dir) def get_morph_from_git(self, repo, ref, filename): morph_text = morphlib.git.get_morph_text(repo, ref, filename) |