portage: Switch sdk_to_archive over to using `mount()`

This cleans up a workaround where we were ignoring some files and
directories that were created by the container set up.

BUG=b:308661552
TEST=BOARD=brya bazel build  @portage//internal/sdk/stage2:tarball

Change-Id: Ib6a1a4f38a1134fc2fce95efcd046619bd59282e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/bazel/+/5532401
Tested-by: Raul Rangel <rrangel@chromium.org>
Reviewed-by: Shuhei Takahashi <nya@chromium.org>
Commit-Queue: Raul Rangel <rrangel@chromium.org>
diff --git a/portage/bin/sdk_to_archive/src/main.rs b/portage/bin/sdk_to_archive/src/main.rs
index 2923b0b..f63390b 100644
--- a/portage/bin/sdk_to_archive/src/main.rs
+++ b/portage/bin/sdk_to_archive/src/main.rs
@@ -5,8 +5,8 @@
 use anyhow::{bail, Context, Result};
 use clap::Parser;
 use cliutil::cli_main;
-use container::{enter_mount_namespace, CommonArgs, ContainerSettings};
-use fileutil::SafeTempDirBuilder;
+use container::{enter_mount_namespace, ContainerSettings};
+use fileutil::{resolve_symlink_forest, SafeTempDirBuilder};
 use runfiles::Runfiles;
 
 use std::path::PathBuf;
@@ -15,8 +15,9 @@
 #[derive(Parser, Debug)]
 #[clap()]
 struct Cli {
-    #[command(flatten)]
-    common: CommonArgs,
+    /// Adds a file system layer to be added to the archive.
+    #[arg(long)]
+    pub layer: Vec<PathBuf>,
 
     /// A path where the tarball is written.
     #[arg(long, required = true)]
@@ -51,11 +52,12 @@
 
     let mut settings = ContainerSettings::new();
     settings.set_mutable_base_dir(mutable_base_dir.path());
-    settings.apply_common_args(&args.common)?;
 
-    let container = settings.prepare()?;
+    for layer in args.layer {
+        settings.push_layer(&resolve_symlink_forest(&layer)?)?;
+    }
 
-    let root_dir = container.root_dir();
+    let mount = settings.mount()?;
 
     let mut command = Command::new(fakefs);
     command.arg("--preload");
@@ -69,7 +71,7 @@
     command.arg(&args.output);
 
     command.arg("-C");
-    command.arg(root_dir);
+    command.arg(mount.path());
 
     // Ensure reproducible output.
     command.arg("--format=gnu");
@@ -77,13 +79,6 @@
     command.arg("--mtime=1970-01-01 00:00:00Z");
     command.arg("--numeric-owner");
 
-    // Exclude files and directories crated by the container.
-    command.arg("--exclude=.setup.sh");
-    command.arg("--exclude=./dev");
-    command.arg("--exclude=./host");
-    command.arg("--exclude=./proc");
-    command.arg("--exclude=./sys");
-
     command.arg(".");
 
     command.env("ZSTD_NBTHREADS", "0");