Fix arch-specific paths in the artifact archival code

After switching to the ChromiumOS-compatible architecture names
some of the paths in the kernel tree were rendered invalid because
of the mismatch between the CrOS arch name (x86_64) and the kernel
tree one (x86). As a fix do additional translation of the arch name
to fix the paths.

Change-Id: I4aceb5de53861460a9f0ce357c1a4e939d9ddd95
Reviewed-on: https://cos-review.googlesource.com/c/cos/tools/+/32340
Cloud-Build: GCB Service account <228075978874@cloudbuild.gserviceaccount.com>
Reviewed-by: Meena Shanmugam <meenashanmugam@google.com>
Tested-by: Oleksandr Tymoshenko <ovt@google.com>
diff --git a/src/cmd/cos_kernel_devenv/devenv.sh b/src/cmd/cos_kernel_devenv/devenv.sh
index ab173c0..75bbcd8 100755
--- a/src/cmd/cos_kernel_devenv/devenv.sh
+++ b/src/cmd/cos_kernel_devenv/devenv.sh
@@ -318,11 +318,21 @@
 tar_kernel_headers() {
   local -r version=$(kmake "$@" -s kernelrelease)
   local -r tmpdir="$(mktemp -d)"
+  local arch_dir
+  case "${KERNEL_ARCH}" in
+    x86_64) arch_dir="x86" ;;
+    arm64)  arch_dir="arm64" ;;
+    *)
+      echo "Unknown kernel architecture: ${KERNEL_ARCH}"
+      exit $RETCODE_ERROR
+      ;;
+  esac
+
   (
     find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl
     find arch/*/include include scripts -type f -o -type l
-    find "arch/${KERNEL_ARCH}" -name module.lds -o -name Kbuild.platforms -o -name Platform
-    find "arch/${KERNEL_ARCH}" -name include -o -name scripts -type d | while IFS='' read -r line; do
+    find "arch/${arch_dir}" -name module.lds -o -name Kbuild.platforms -o -name Platform
+    find "arch/${arch_dir}" -name include -o -name scripts -type d | while IFS='' read -r line; do
       find "${line}" -type f
     done
   ) > "${tmpdir}/hdrsrcfiles"
@@ -332,7 +342,7 @@
     if [[ -d tools/objtool ]]; then
       find tools/objtool -type f -executable
     fi
-    find "arch/${KERNEL_ARCH}/include" Module.symvers System.map \
+    find "arch/${arch_dir}/include" Module.symvers System.map \
       include scripts .config \
       -type f ! -name "*.cmd"  ! -name "*.o"
   ) > "${tmpdir}/hdrobjfiles"