diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-12 14:19:13 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2015-12-12 14:19:13 +0200 |
commit | 440ebdc157e35568abcd98b7c983d4ea9313d75f (patch) | |
tree | e104220962b64104e3d50421f17faf6b517d4e86 /build/install/rule.cxx | |
parent | ad4120afce8c7bc4001fc0173a0ff7611ec0198d (diff) |
Implement sudo support in install module
Diffstat (limited to 'build/install/rule.cxx')
-rw-r--r-- | build/install/rule.cxx | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/build/install/rule.cxx b/build/install/rule.cxx index 3f8c16a..eb48bbe 100644 --- a/build/install/rule.cxx +++ b/build/install/rule.cxx @@ -213,6 +213,7 @@ namespace build struct install_dir { dir_path dir; + string sudo; string cmd; //@@ VAR type const_strings_value options {nullptr}; string mode; @@ -226,7 +227,13 @@ namespace build { path reld (relative (d)); - cstrings args {base.cmd.c_str (), "-d"}; + cstrings args; + + if (!base.sudo.empty ()) + args.push_back (base.sudo.c_str ()); + + args.push_back (base.cmd.c_str ()); + args.push_back ("-d"); if (base.options.d != nullptr) //@@ VAR config::append_options (args, base.options); @@ -267,7 +274,12 @@ namespace build path reld (relative (base.dir)); path relf (relative (t.path ())); - cstrings args {base.cmd.c_str ()}; + cstrings args; + + if (!base.sudo.empty ()) + args.push_back (base.sudo.c_str ()); + + args.push_back (base.cmd.c_str ()); if (base.options.d != nullptr) //@@ VAR config::append_options (args, base.options); @@ -347,10 +359,11 @@ namespace build // if (var != nullptr) { - if (auto l = s[*var + ".cmd"]) r.cmd = as<string> (*l); - if (auto l = s[*var + ".mode"]) r.mode = as<string> (*l); + if (auto l = s[*var + ".sudo"]) r.sudo = as<string> (*l); + if (auto l = s[*var + ".cmd"]) r.cmd = as<string> (*l); + if (auto l = s[*var + ".mode"]) r.mode = as<string> (*l); if (auto l = s[*var + ".dir_mode"]) r.dir_mode = as<string> (*l); - if (auto l = s[*var + ".options"]) r.options = as<strings> (*l); + if (auto l = s[*var + ".options"]) r.options = as<strings> (*l); } // Set defaults for unspecified components. |