Copy shared libraries required by rustfmt

Our prebuilt rustfmt is now dynamically linked, so we need to copy .so
files into the Docker container for it to work.

Test: ./prepare_deployment.sh
Change-Id: I0bfd33bb477ab7352b6e13bb360e58c56c51f570
Reviewed-on: https://fuchsia-review.googlesource.com/c/fidlbolt/+/789187
Reviewed-by: Yifei Teng <yifeit@google.com>
diff --git a/prepare_deployment.sh b/prepare_deployment.sh
index d9a6236..b9c47e2 100755
--- a/prepare_deployment.sh
+++ b/prepare_deployment.sh
@@ -22,6 +22,7 @@
    This uses the following directory structure:
 
        ./deployment/bin        binaries (fidlc, fidl-format, etc.)
+       ./deployment/lib        shared libraries
        ./deployment/etc        configuration files
        ./deployment/fuchsia    parts of the fuchsia tree that have .fidl files
 
@@ -111,7 +112,7 @@
 step "Cleaning ./deployment"
 cd "$script_dir"
 rm -rf deployment/
-mkdir -p deployment/{bin,etc,fuchsia/{sdk/fidl,zircon}}
+mkdir -p deployment/{bin,lib,etc,fuchsia/{sdk/fidl,zircon}}
 
 step "Copying binaries"
 cp "${binaries[@]/#/$build_dir/host_x64/}" \
@@ -119,6 +120,11 @@
     "$PREBUILT_RUST_DIR/bin/rustfmt" \
     deployment/bin
 
+step "Copying shared libraries"
+ldd "$PREBUILT_RUST_DIR/bin/rustfmt" \
+    | awk -v f="$FUCHSIA_DIR" 'substr($3, 1, length(f)) == f { print $3; }' \
+    | xargs -I% cp % deployment/lib
+
 step "Copying FIDL libraries"
 find "$FUCHSIA_DIR/sdk/fidl" -mindepth 1 -maxdepth 1 -type d -print0 \
     | xargs -0 -I% cp -r % deployment/fuchsia/sdk/fidl