From 2da6777d14a1cf600891cdeee6202d692eae48f9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Sun, 13 Aug 2017 13:29:54 +0200 Subject: Implement support for chroot'ed install (aka DESTDIR) For example: b config.install.root=/usr config.install.chroot=/tmp/install The difference between doing just config.install.root=/tmp/install/usr is that everything is installed "as if" into /usr. So, for example, pkg-config files will contain -I/usr/include, -L/usr/lib, etc. --- build2/install/init.cxx | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'build2/install/init.cxx') diff --git a/build2/install/init.cxx b/build2/install/init.cxx index 0e8118a..757d4ef 100644 --- a/build2/install/init.cxx +++ b/build2/install/init.cxx @@ -178,11 +178,11 @@ namespace build2 // Enter module variables. // + auto& vp (var_pool.rw (rs)); + // Note that the set_dir() calls below enter some more. // { - auto& v (var_pool.rw (rs)); - // Note: not overridable. // // The install variable is a path, not dir_path, since it can be used @@ -191,9 +191,9 @@ namespace build2 // way we distinguish between the two is via the presence/absence of // the trailing directory separator. // - v.insert ("install", variable_visibility::target); - v.insert ("install.mode", variable_visibility::project); - v.insert ("install.subdirs", variable_visibility::project); + vp.insert ("install", variable_visibility::target); + vp.insert ("install.mode", variable_visibility::project); + vp.insert ("install.subdirs", variable_visibility::project); } // Register our alias and file rules. @@ -249,6 +249,21 @@ namespace build2 set_dir (s, rs, "doc", dir_path (dir_doc) /= n, true); set_dir (s, rs, "man", dir_man); set_dir (s, rs, "man1", dir_man1); + + // Support for chroot'ed install (aka DESTDIR). + // + { + auto& var (vp.insert ( "install.chroot")); + auto& cvar (vp.insert ("config.install.chroot", true)); + + value& v (rs.assign (var)); + + if (s) + { + if (lookup l = config::optional (rs, cvar)) + v = cast (l); // Strip abs_dir_path. + } + } } // Configure "installability" for built-in target types. -- cgit v1.1