Bug 1291365 - Refactor install-mercurial.sh to detect OS version; r=dustin
authorGregory Szorc <gps@mozilla.com>
Tue, 02 Aug 2016 11:30:24 -0700
changeset 308576 62bd3cf6661dc4027b0401c5004e1384499ac989
parent 308575 c891bc425e26157476f1b707d85eae74e8a9fd73
child 308577 df3c13ea7d3eef0d751d2c020bb4d90c3dbdbc1e
push id31158
push usergszorc@mozilla.com
push dateMon, 08 Aug 2016 19:10:32 +0000
treeherderautoland@470f72a4827c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdustin
bugs1291365
milestone51.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1291365 - Refactor install-mercurial.sh to detect OS version; r=dustin Currently, install-mercurial.sh only supports Ubuntu 16.04. In preparation for supporting other distros, we add code for performing OS/distro detection. MozReview-Commit-ID: 9a6pp1Qprcr
testing/docker/recipes/install-mercurial.sh
--- a/testing/docker/recipes/install-mercurial.sh
+++ b/testing/docker/recipes/install-mercurial.sh
@@ -2,35 +2,55 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 # This script installs and configures Mercurial.
 
 set -e
 
-# ASSERTION: We are running Ubuntu 16.04.
+# Detect OS.
+if [ -f /etc/lsb-release ]; then
+    . /etc/lsb-release
+
+    if [ "${DISTRIB_ID}" = "Ubuntu" -a "${DISTRIB_RELEASE}" = "16.04" ]; then
+        HG_DEB=1
+        HG_DIGEST=7b1fc1217e0dcaeea852b0af2dc559b1aafb704fbee7e29cbec75af57bacb84910a7ec92b5c33f04ee98f23b3a57f1fa451173fe7c8a96f58faefe319dc7dde1
+        HG_SIZE=44878
+        HG_FILENAME=mercurial_3.8.4_amd64.deb
+
+        HG_COMMON_DIGEST=b476e2612e7495a1c7c5adfd84511aa7479e26cc9070289513ec705fbfc4c61806ce2dbcceca0e63f2e80669be416f3467a3cebb522dcb8a6aeb62cdd3df82f2
+        HG_COMMON_SIZE=1818422
+        HG_COMMON_FILENAME=mercurial-common_3.8.4_all.deb
+    fi
+fi
+
+if [ -n "${HG_DEB}" ]; then
 tooltool_fetch <<EOF
 [
 {
-    "size": 44878,
-    "digest": "7b1fc1217e0dcaeea852b0af2dc559b1aafb704fbee7e29cbec75af57bacb84910a7ec92b5c33f04ee98f23b3a57f1fa451173fe7c8a96f58faefe319dc7dde1",
+    "size": ${HG_SIZE},
+    "digest": "${HG_DIGEST}",
     "algorithm": "sha512",
-    "filename": "mercurial_3.8.4_amd64.deb"
+    "filename": "${HG_FILENAME}"
 },
 {
-    "size": 1818422,
-    "digest": "b476e2612e7495a1c7c5adfd84511aa7479e26cc9070289513ec705fbfc4c61806ce2dbcceca0e63f2e80669be416f3467a3cebb522dcb8a6aeb62cdd3df82f2",
+    "size": ${HG_COMMON_SIZE},
+    "digest": "${HG_COMMON_DIGEST}",
     "algorithm": "sha512",
-    "filename": "mercurial-common_3.8.4_all.deb"
+    "filename": "${HG_COMMON_FILENAME}"
 }
 ]
 EOF
 
-dpkg -i mercurial-common_3.8.4_all.deb mercurial_3.8.4_amd64.deb
+    dpkg -i ${HG_COMMON_FILENAME} ${HG_FILENAME}
+else
+    echo "Do not know how to install Mercurial on this OS"
+    exit 1
+fi
 
 mkdir -p /usr/local/mercurial
 cd /usr/local/mercurial
 tooltool_fetch <<'EOF'
 [
 {
     "size": 11849,
     "digest": "c88d9b8afd6649bd28bbacfa654ebefec8087a01d1662004aae088d485edeb03a92df1193d1310c0369d7721f475b974fcd4a911428ec65936f7e40cf1609c49",