Remove unnecessary files when installing.

We don't need the stub shared libraries since the platform build
already generates those, and we don't want the Android.bp files (we
should start purging these as part of the NDK build, but we don't
right now).

Test: Re-ran previous update command, verified no changes.
Bug: None
Change-Id: I544cf272d262e4b8fa638165d8202b3538fb0772
diff --git a/update.py b/update.py
index 9627904..aab8630 100755
--- a/update.py
+++ b/update.py
@@ -35,6 +35,11 @@
     subprocess.check_call(cmd)
 
 
+def remove(path):
+    logger().debug('remove `%s`', path)
+    os.remove(path)
+
+
 def fetch_artifact(branch, build, pattern):
     fetch_artifact_path = '/google/data/ro/projects/android/fetch_artifact'
     cmd = [fetch_artifact_path, '--branch', branch, '--target=linux',
@@ -85,6 +90,20 @@
             os.unlink(artifact)
 
 
+def remove_unneeded_files(install_dir):
+    for path, _dirs, files in os.walk(os.path.join(install_dir, 'platforms')):
+        for file_name in files:
+            if file_name.endswith('.so'):
+                file_path = os.path.join(path, file_name)
+                remove(file_path)
+
+    for path, _dirs, files in os.walk(os.path.join(install_dir, 'sources')):
+        for file_name in files:
+            if file_name == 'Android.bp':
+                file_path = os.path.join(path, file_name)
+                remove(file_path)
+
+
 def make_symlinks(install_dir):
     old_dir = os.getcwd()
     os.chdir(os.path.join(THIS_DIR, install_dir, 'platforms'))
@@ -149,6 +168,7 @@
         start_branch(args.build)
     remove_old_release(install_dir)
     install_new_release(args.branch, args.build, install_dir)
+    remove_unneeded_files(install_dir)
     make_symlinks(install_dir)
     commit(args.branch, args.build, install_dir)