Add multiarch specification to apt repo config.

TBR=phajdan.jr@chromium.org, thestig@chromium.org
BUG=591480
NOTRY=true
NOPRESUBMIT=true

Review URL: https://codereview.chromium.org/1759243002

Cr-Commit-Position: refs/heads/master@{#379305}
(cherry picked from commit 9f2c239a6ece2f510fac2f1be1ca1811f0deb9a4)

Review URL: https://codereview.chromium.org/1769533003

Cr-Commit-Position: refs/branch-heads/2623@{#578}
Cr-Branched-From: 92d77538a86529ca35f9220bd3cd512cbea1f086-refs/heads/master@{#369907}
diff --git a/chrome/installer/linux/common/apt.include b/chrome/installer/linux/common/apt.include
index 77d418c..aabca09 100644
--- a/chrome/installer/linux/common/apt.include
+++ b/chrome/installer/linux/common/apt.include
@@ -87,7 +87,7 @@
   ACTIVECONFIGS=$(grep -v "^[[:space:]]*\(#.*\)\?$" "$SOURCELIST" 2>/dev/null)
 
   # Check if the correct repository configuration is in there.
-  REPOMATCH=$(grep -E "^[[:space:]#]*\b($REPOCONFIG|$SSLREPOCONFIG)\b" "$SOURCELIST" \
+  REPOMATCH=$(grep -E "^[[:space:]#]*\b$REPOCONFIGREGEX\b" "$SOURCELIST" \
     2>/dev/null)
 
   # Check if the correct repository is disabled.
@@ -174,9 +174,9 @@
   find_apt_sources
   SOURCELIST="$APT_SOURCESDIR/@@PACKAGE@@.list"
   if [ -r "$SOURCELIST" ]; then
-    REPOLINE=$(grep -E "^[[:space:]]*#[[:space:]]*($REPOCONFIG|$SSLREPOCONFIG)[[:space:]]*# disabled on upgrade to .*" "$SOURCELIST")
+    REPOLINE=$(grep -E "^[[:space:]]*#[[:space:]]*$REPOCONFIGREGEX[[:space:]]*# disabled on upgrade to .*" "$SOURCELIST")
     if [ $? -eq 0 ]; then
-      sed -i -e "s,^[[:space:]]*#[[:space:]]*\($REPOCONFIG\|$SSLREPOCONFIG\)[[:space:]]*# disabled on upgrade to .*,\1," \
+      sed -i -e "s,^[[:space:]]*#[[:space:]]*\(.*\)[[:space:]]*# disabled on upgrade to .*,\1," \
         "$SOURCELIST"
       LOGGER=$(which logger 2> /dev/null)
       if [ "$LOGGER" ]; then
diff --git a/chrome/installer/linux/common/installer.include b/chrome/installer/linux/common/installer.include
index 68c6555e..386d487 100644
--- a/chrome/installer/linux/common/installer.include
+++ b/chrome/installer/linux/common/installer.include
@@ -73,7 +73,7 @@
     -e "s#@@MAINTNAME@@#${MAINTNAME}#g" \
     -e "s#@@MAINTMAIL@@#${MAINTMAIL}#g" \
     -e "s#@@REPOCONFIG@@#${REPOCONFIG}#g" \
-    -e "s#@@SSLREPOCONFIG@@#${SSLREPOCONFIG}#g" \
+    -e "s#@@REPOCONFIGREGEX@@#${REPOCONFIGREGEX}#g" \
     -e "s#@@SHORTDESC@@#${SHORTDESC}#g" \
     -e "s#@@FULLDESC@@#${FULLDESC}#g" \
     -e "s#@@DEFAULT_FLAGS@@#${DEFAULT_FLAGS:-}#g" \
diff --git a/chrome/installer/linux/common/variables.include b/chrome/installer/linux/common/variables.include
index 79340cd..be94314 100644
--- a/chrome/installer/linux/common/variables.include
+++ b/chrome/installer/linux/common/variables.include
@@ -3,4 +3,4 @@
 
 # sources.list setting for @@PACKAGE@@ updates.
 REPOCONFIG="@@REPOCONFIG@@"
-SSLREPOCONFIG="@@SSLREPOCONFIG@@"
+REPOCONFIGREGEX="@@REPOCONFIGREGEX@@"
diff --git a/chrome/installer/linux/debian/build.sh b/chrome/installer/linux/debian/build.sh
index bf84089..77bf7a9 100755
--- a/chrome/installer/linux/debian/build.sh
+++ b/chrome/installer/linux/debian/build.sh
@@ -236,8 +236,6 @@
 eval $(sed -e "s/^\([^=]\+\)=\(.*\)$/export \1='\2'/" \
   "${BUILDDIR}/installer/theme/BRANDING")
 
-REPOCONFIG="deb http://dl.google.com/linux/chrome/deb/ stable main"
-SSLREPOCONFIG="deb https://dl.google.com/linux/chrome/deb/ stable main"
 verify_channel
 
 # Some Debian packaging tools want these set.
@@ -314,11 +312,9 @@
 case "$TARGETARCH" in
   ia32 )
     export ARCHITECTURE="i386"
-    stage_install_debian
     ;;
   x64 )
     export ARCHITECTURE="amd64"
-    stage_install_debian
     ;;
   * )
     echo
@@ -327,5 +323,14 @@
     exit 1
     ;;
 esac
+BASEREPOCONFIG="dl.google.com/linux/chrome/deb/ stable main"
+# Only use the default REPOCONFIG if it's unset (e.g. verify_channel might have
+# set it to an empty string)
+REPOCONFIG="${REPOCONFIG-deb [arch=${ARCHITECTURE}] http://${BASEREPOCONFIG}}"
+# Allowed configs include optional HTTPS support and explicit multiarch
+# platforms.
+REPOCONFIGREGEX="deb (\\\\[arch=[^]]*\\\\b${ARCHITECTURE}\\\\b[^]]*\\\\]"
+REPOCONFIGREGEX+="[[:space:]]*)?https?://${BASEREPOCONFIG}"
+stage_install_debian
 
 do_package
diff --git a/chrome/installer/linux/rpm/build.sh b/chrome/installer/linux/rpm/build.sh
index 8ac54ef..4fb1ebb 100755
--- a/chrome/installer/linux/rpm/build.sh
+++ b/chrome/installer/linux/rpm/build.sh
@@ -288,7 +288,6 @@
   "${BUILDDIR}/installer/theme/BRANDING")
 
 REPOCONFIG="http://dl.google.com/linux/${PACKAGE#google-}/rpm/stable"
-SSLREPOCONFIG="https://dl.google.com/linux/${PACKAGE#google-}/rpm/stable"
 verify_channel
 export USR_BIN_SYMLINK_NAME="${PACKAGE}-${CHANNEL}"