Merge commit 'fa3a97f2efb870d71b6507ac8fe512dcaa30e8f2' into cos-sdk

Merging 17615.0.0 into cos-sdk. Getting cos-sdk up to date in advance of
the ChromeOS update.

BUG=b/277779682
TEST=presubmit
RELEASE_NOTE=None

Change-Id: Ied8ce8f890feb132f6dbc4aa942266120eafb322
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass
index 8dc6d85..c494e49 100644
--- a/eclass/python-utils-r1.eclass
+++ b/eclass/python-utils-r1.eclass
@@ -182,7 +182,7 @@
 			python_is_python3 "${impl}" && return 0
 			return
 		# unify value style to allow lax matching
-		elif [[ ${impl/./_} == ${pattern/./_} ]]; then
+		elif [[ ${impl/./_} == ${pattern/./_} || ${impl} == python${pattern/./_} ]]; then
 			return 0
 		fi
 	done
@@ -807,13 +807,24 @@
 		d=${sitedir#${SYSROOT}}/${python_moduleroot//.//}
 	fi
 
-	(
-		insopts -m 0644
-		insinto "${d}"
-		doins -r "${@}" || return ${?}
-	)
-
-	python_optimize "${ED%/}/${d}"
+	if [[ ${EBUILD_PHASE} == install ]]; then
+		(
+			insopts -m 0644
+			insinto "${d}"
+			doins -r "${@}" || return ${?}
+		)
+		python_optimize "${ED%/}/${d}"
+	elif [[ -n ${BUILD_DIR} ]]; then
+		local dest=${BUILD_DIR}/install${EPREFIX}/${d}
+		mkdir -p "${dest}" || die
+		cp -pR "${@}" "${dest}/" || die
+		(
+			cd "${dest}" &&
+			chmod -R a+rX "${@##*/}"
+		) || die
+	else
+		die "${FUNCNAME} can only be used in src_install or with BUILD_DIR set"
+	fi
 }
 
 # @FUNCTION: python_doheader