Skip to content

Commit

Permalink
Revert "Adds --disable-sandbox to esy b (and esy-build-package)"
Browse files Browse the repository at this point in the history
This reverts commit df516af.
  • Loading branch information
ManasJayanth authored and jordwalke committed Oct 15, 2019
1 parent 1badd89 commit 2334202
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 136 deletions.
8 changes: 2 additions & 6 deletions bin/Project.re
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,6 @@ let makeProject = (makeSolved, projcfg: ProjectConfig.t) => {
RunAsync.ofBosError(
EsyBuildPackage.Config.make(
~globalStorePrefix,
~disableSandbox=false,
~storePath,
~localStorePath=EsyInstall.SandboxSpec.storePath(projcfg.spec),
~projectPath=projcfg.spec.path,
Expand Down Expand Up @@ -717,15 +716,13 @@ let buildDependencies =
};
};

let buildPackage =
(~quiet, ~disableSandbox, ~buildOnly, projcfg, sandbox, plan, pkg) => {
let buildPackage = (~quiet, ~buildOnly, projcfg, sandbox, plan, pkg) => {
checkSymlinks();
let () =
Logs.info(m =>
m(
"running:@[<v>@;%s build-package (disable-sandbox: %s)\\@;%a@]",
"running:@[<v>@;%s build-package \\@;%a@]",
projcfg.ProjectConfig.mainprg,
string_of_bool(disableSandbox),
PackageId.pp,
pkg.Package.id,
)
Expand All @@ -735,7 +732,6 @@ let buildPackage =
~force=true,
~quiet,
~buildOnly,
~disableSandbox,
sandbox,
plan,
pkg.id,
Expand Down
1 change: 0 additions & 1 deletion bin/Project.rei
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ let buildDependencies:
let buildPackage:
(
~quiet: bool,
~disableSandbox: bool,
~buildOnly: bool,
ProjectConfig.t,
BuildSandbox.t,
Expand Down
34 changes: 5 additions & 29 deletions bin/esy.re
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,6 @@ let build =
~skipStalenessCheck=false,
mode,
pkgarg,
disableSandbox,
cmd,
proj: Project.t,
) => {
Expand All @@ -486,7 +485,6 @@ let build =
Project.buildPackage(
~quiet=true,
~buildOnly,
~disableSandbox,
proj.projcfg,
fetched.Project.sandbox,
plan,
Expand Down Expand Up @@ -549,10 +547,9 @@ let execEnv = (asJson, pkgarg, proj: Project.t) =>
(),
);

let exec = (mode, chdir, pkgarg, disableSandbox, cmd, proj: Project.t) => {
let exec = (mode, chdir, pkgarg, cmd, proj: Project.t) => {
open RunAsync.Syntax;
let%bind () =
build(~buildOnly=false, mode, PkgArg.root, disableSandbox, None, proj);
let%bind () = build(~buildOnly=false, mode, PkgArg.root, None, proj);
let f = pkg =>
Project.execCommand(
~checkIfDependenciesAreBuilt=false, /* not needed as we build an entire sandbox above */
Expand Down Expand Up @@ -1385,12 +1382,11 @@ let printHeader = (~spec=?, name) =>

let default = (chdir, cmdAndPkg, proj: Project.t) => {
open RunAsync.Syntax;
let disableSandbox = false;
let%lwt fetched = Project.fetched(proj);
switch (fetched, cmdAndPkg) {
| (Ok(_), None) =>
let%lwt () = printHeader(~spec=proj.projcfg.spec, "esy");
build(BuildDev, PkgArg.root, disableSandbox, None, proj);
build(BuildDev, PkgArg.root, None, proj);
| (Ok(_), Some((None, cmd))) =>
switch (Scripts.find(Cmd.getTool(cmd), proj.scripts)) {
| Some(script) => runScript(script, Cmd.getArgs(cmd), proj)
Expand All @@ -1405,7 +1401,7 @@ let default = (chdir, cmdAndPkg, proj: Project.t) => {
let%bind () = solveAndFetch(proj);
let%bind (proj, files) = Project.make(proj.projcfg);
let%bind () = Project.write(proj, files);
build(BuildDev, PkgArg.root, disableSandbox, None, proj);
build(BuildDev, PkgArg.root, None, proj);
| (Error(_) as err, Some((None, cmd))) =>
switch (Scripts.find(Cmd.getTool(cmd), proj.scripts)) {
| Some(script) => runScript(script, Cmd.getArgs(cmd), proj)
Expand Down Expand Up @@ -1503,16 +1499,7 @@ let commandsConfig = {

let commands = {
let buildCommand = {
let run =
(
mode,
pkgarg,
disableSandbox,
install,
skipStalenessCheck,
cmd,
proj,
) => {
let run = (mode, pkgarg, install, skipStalenessCheck, cmd, proj) => {
let () =
switch (cmd) {
| None =>
Expand All @@ -1527,7 +1514,6 @@ let commandsConfig = {
~skipStalenessCheck,
mode,
pkgarg,
disableSandbox,
cmd,
proj,
);
Expand All @@ -1543,11 +1529,6 @@ let commandsConfig = {
const(run)
$ modeTerm
$ pkgTerm
$ Arg.(
value
& flag
& info(["disable-sandbox"], ~doc="Disables sandbox")
)
$ Arg.(
value
& flag
Expand Down Expand Up @@ -1612,11 +1593,6 @@ let commandsConfig = {
$ modeTerm
$ chdirTerm
$ pkgTerm
$ Arg.(
value
& flag
& info(["disable-sandbox"], ~doc="Disables sandbox")
)
$ Cli.cmdTerm(
~doc="Command to execute within the sandbox environment.",
~docv="COMMAND",
Expand Down
2 changes: 1 addition & 1 deletion esy-build-package/Build.re
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ let configureBuild = (~cfg: Config.t, plan: Plan.t) => {
};
Ok({Sandbox.allowWrite: allowWrite});
};
Sandbox.init(config, ~noSandbox=cfg.disableSandbox);
Sandbox.init(config);
};

return({
Expand Down
19 changes: 2 additions & 17 deletions esy-build-package/Config.re
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ type t = {
globalStorePrefix: EsyLib.Path.t,
storePath: EsyLib.Path.t,
localStorePath: EsyLib.Path.t,
disableSandbox: bool,
};

type config = t;
Expand Down Expand Up @@ -47,15 +46,7 @@ let rec configureStorePath = (cfg, globalStorePrefix) => {
return(path);
};

let make =
(
~globalStorePrefix,
~storePath,
~projectPath,
~localStorePath,
~disableSandbox,
(),
) => {
let make = (~globalStorePrefix, ~storePath, ~projectPath, ~localStorePath, ()) => {
open Run;
let%bind storePath = configureStorePath(storePath, globalStorePrefix);
let%bind () =
Expand All @@ -74,13 +65,7 @@ let make =
};
};
let%bind () = initStore(localStorePath);
return({
projectPath,
globalStorePrefix,
storePath,
localStorePath,
disableSandbox,
});
return({projectPath, globalStorePrefix, storePath, localStorePath});
};

let render = (cfg, v) => {
Expand Down
2 changes: 0 additions & 2 deletions esy-build-package/Config.rei
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ type t =
globalStorePrefix: Fpath.t,
storePath: Fpath.t,
localStorePath: Fpath.t,
disableSandbox: bool,
};

let pp: Fmt.t(t);
Expand All @@ -25,7 +24,6 @@ let make:
~storePath: storePathConfig,
~projectPath: Fpath.t,
~localStorePath: Fpath.t,
~disableSandbox: bool,
unit
) =>
Run.t(t, _);
Expand Down
17 changes: 5 additions & 12 deletions esy-build-package/Sandbox.re
Original file line number Diff line number Diff line change
Expand Up @@ -115,21 +115,14 @@ module NoSandbox = {
};
};

let init = (config: config, ~noSandbox) =>
if (noSandbox) {
NoSandbox.sandboxExec(config);
} else {
switch (EsyLib.System.Platform.host) {
| Windows => Windows.sandboxExec(config)
| Darwin => Darwin.sandboxExec(config)
| _ => NoSandbox.sandboxExec(config)
};
let init = (config: config) =>
switch (EsyLib.System.Platform.host) {
| Windows => Windows.sandboxExec(config)
| Darwin => Darwin.sandboxExec(config)
| _ => NoSandbox.sandboxExec(config)
};

let exec = (~env, sandbox: sandbox, cmd) => {
/* print_endline(Astring.String.Map.get("PATH", env)); */
/* print_endline(Astring.String.Map.get("LD_LIBRARY_PATH", env)); */
/* print_endline(Astring.String.Map.get("PKG_CONFIG_PATH", env)); */
let result = sandbox(~env, cmd);
(result: result(_, err) :> Run.t(_, _));
};
2 changes: 1 addition & 1 deletion esy-build-package/Sandbox.rei
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ type config = {allowWrite: list(pattern)};
type sandbox;

/* Init sandbox */
let init: (config, ~noSandbox: bool) => Run.t(sandbox, _);
let init: config => Run.t(sandbox, _);

/* Exec command in the sandbox. */
let exec:
Expand Down
27 changes: 3 additions & 24 deletions esy-build-package/bin/esyBuildPackageCommand.re
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ type commonOpts = {
localStorePath: option(Fpath.t),
projectPath: option(Fpath.t),
logLevel: option(Logs.level),
disableSandbox: bool,
};

let setupLog = (style_renderer, level) => {
Expand All @@ -27,7 +26,7 @@ let setupLog = (style_renderer, level) => {

let createConfig = (copts: commonOpts) => {
open Run;
let {globalStorePrefix, localStorePath, projectPath, disableSandbox, _} = copts;
let {globalStorePrefix, localStorePath, projectPath, _} = copts;
let%bind currentPath = Bos.OS.Dir.current();
let projectPath = Option.orDefault(~default=currentPath, projectPath);
let storePath =
Expand All @@ -46,7 +45,6 @@ let createConfig = (copts: commonOpts) => {
~localStorePath=
Option.orDefault(~default=projectPath / "_store", localStorePath),
~projectPath,
~disableSandbox,
(),
);
};
Expand Down Expand Up @@ -244,33 +242,15 @@ let () = {
& info(["plan", "p"], ~env, ~docs, ~docv="PATH", ~doc)
);
};
let disableSandbox = {
let doc = "Disables sandboxing and builds the package without. CAUTION: this can be dangerous";
Arg.(value & flag & info(["disable-sandbox"], ~docs, ~doc));
};
let setupLogT =
Term.(
const(setupLog)
$ Fmt_cli.style_renderer()
$ Logs_cli.level(~env=Arg.env_var("ESY__LOG"), ())
);
let parse =
(
projectPath,
globalStorePrefix,
localStorePath,
planPath,
logLevel,
disableSandbox,
) => {
{
projectPath,
globalStorePrefix,
localStorePath,
planPath,
logLevel,
disableSandbox,
};
(projectPath, globalStorePrefix, localStorePath, planPath, logLevel) => {
{projectPath, globalStorePrefix, localStorePath, planPath, logLevel};
};
Term.(
const(parse)
Expand All @@ -279,7 +259,6 @@ let () = {
$ localStorePath
$ planPath
$ setupLogT
$ disableSandbox
);
};
/* Command terms */
Expand Down
33 changes: 4 additions & 29 deletions esy-build/BuildSandbox.re
Original file line number Diff line number Diff line change
Expand Up @@ -1097,8 +1097,7 @@ let makeSymlinksToStore = (sandbox, task) => {
return();
};

let buildTask =
(~quiet=?, ~buildOnly=?, ~logPath=?, ~disableSandbox=?, sandbox, task) => {
let buildTask = (~quiet=?, ~buildOnly=?, ~logPath=?, sandbox, task) => {
open RunAsync.Syntax;
let%lwt () = Logs_lwt.debug(m => m("build %a", Task.pp, task));
let plan = Task.plan(task);
Expand All @@ -1109,7 +1108,6 @@ let buildTask =
~quiet?,
~buildOnly?,
~logPath?,
~disableSandbox?,
sandbox.cfg,
plan,
)
Expand All @@ -1127,41 +1125,18 @@ let buildTask =
};

let buildOnly =
(
~force,
~quiet=?,
~buildOnly=?,
~logPath=?,
~disableSandbox=?,
sandbox,
plan,
id,
) =>
(~force, ~quiet=?, ~buildOnly=?, ~logPath=?, sandbox, plan, id) =>
RunAsync.Syntax.(
switch (Plan.get(plan, id)) {
| Some(task) =>
if (!force) {
if%bind (isBuilt(sandbox, task)) {
return();
} else {
buildTask(
~quiet?,
~buildOnly?,
~logPath?,
~disableSandbox?,
sandbox,
task,
);
buildTask(~quiet?, ~buildOnly?, ~logPath?, sandbox, task);
};
} else {
buildTask(
~quiet?,
~buildOnly?,
~logPath?,
~disableSandbox?,
sandbox,
task,
);
buildTask(~quiet?, ~buildOnly?, ~logPath?, sandbox, task);
}
| None => RunAsync.return()
}
Expand Down
1 change: 0 additions & 1 deletion esy-build/BuildSandbox.rei
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ let buildOnly:
~quiet: bool=?,
~buildOnly: bool=?,
~logPath: Path.t=?,
~disableSandbox: bool=?,
t,
Plan.t,
PackageId.t
Expand Down

0 comments on commit 2334202

Please sign in to comment.