From 354721f1ff807bf9370eb02f047bf8c6d7a3b673 Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Tue, 3 May 2016 20:40:58 -0400 Subject: [PATCH 1/3] Switch from sh to bash to match Servo style guide Originally, I restricted these scripts to pure sh to avoid too many compatibility issues between Linux and OS X, but I've changed my mind and now prefer using bash to gain a few nice features. --- .travis/dispatch.sh | 9 +++++---- .travis/install_salt.sh | 13 +++++++------ .travis/setup_salt_roots.sh | 3 ++- tests/lint/shebang.py | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/.travis/dispatch.sh b/.travis/dispatch.sh index 815c2c64..18a5687a 100755 --- a/.travis/dispatch.sh +++ b/.travis/dispatch.sh @@ -1,7 +1,8 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -o errexit set -o nounset +set -o pipefail travis_fold_start () { printf "travis_fold:start:$1\n" @@ -31,14 +32,14 @@ run_salt () { } -if [ "${SALT_NODE_ID}" = "test" ]; then +if [[ "${SALT_NODE_ID}" == "test" ]]; then # Using .travis.yml to specify Python 3.5 to be preinstalled, just to check printf "Using $(python3 --version) at $(which python3)\n" # Run test suite separately for parallelism ./test.py else - if [ "${SALT_FROM_SCRATCH}" = "true" ]; then + if [[ "${SALT_FROM_SCRATCH}" == "true" ]]; then run_salt 'scratch' else git fetch origin master:master @@ -51,7 +52,7 @@ else # Only run tests against the new configuration # TODO: don't hard-code this - if [ "${SALT_NODE_ID}" = "servo-master1" ]; then + if [[ "${SALT_NODE_ID}" == "servo-master1" ]]; then ./test.py sls.buildbot.master sls.nginx fi fi diff --git a/.travis/install_salt.sh b/.travis/install_salt.sh index 3bd73aad..870e85a5 100755 --- a/.travis/install_salt.sh +++ b/.travis/install_salt.sh @@ -1,11 +1,12 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -o errexit set -o nounset +set -o pipefail install_salt () { # Ensure that pinned versions match as closely as possible - if [ "${OS_NAME}" = "linux" ]; then + if [[ "${OS_NAME}" == "linux" ]]; then printf "$0: installing salt for Linux\n" # Use Trusty (Ubuntu 14.04) on Travis # Don't autostart services @@ -14,7 +15,7 @@ install_salt () { printf 'deb http://repo.saltstack.com/apt/ubuntu/14.04/amd64/archive/2015.5.8 trusty main\n' | sudo tee /etc/apt/sources.list.d/saltstack.list >/dev/null sudo apt-get -y update sudo apt-get -y install salt-minion=2015.5.8+ds-1 - elif [ "${OS_NAME}" = "osx" ]; then + elif [[ "${OS_NAME}" == "osx" ]]; then printf "$0: installing salt for Mac OS X\n" brew update brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/3461c9c74b2f3aba9a6fbd7165823c81dc2b4792/Formula/saltstack.rb @@ -63,16 +64,16 @@ while true; do esac done -if [ "$#" -lt 1 ]; then +if [[ "$#" -lt 1 ]]; then printf >&2 "usage: $0 [-c [-F]] [--] os_name\n" exit 1 fi OS_NAME="$1" -if [ -z "${CONFIGURE_ONLY}" ]; then +if [[ -z "${CONFIGURE_ONLY}" ]]; then install_salt fi -if [ -n "${TEMPORARY_CONFIG_DIR}" ]; then +if [[ -n "${TEMPORARY_CONFIG_DIR}" ]]; then configure_salt fi diff --git a/.travis/setup_salt_roots.sh b/.travis/setup_salt_roots.sh index a58c2e03..dac0082b 100755 --- a/.travis/setup_salt_roots.sh +++ b/.travis/setup_salt_roots.sh @@ -1,7 +1,8 @@ -#!/usr/bin/env sh +#!/usr/bin/env bash set -o errexit set -o nounset +set -o pipefail setup_salt_roots () { sudo rm -rf /srv/salt diff --git a/tests/lint/shebang.py b/tests/lint/shebang.py index 6746eaa0..de03b937 100644 --- a/tests/lint/shebang.py +++ b/tests/lint/shebang.py @@ -11,7 +11,7 @@ INTERPRETERS = { 'py': 'python3', - 'sh': 'sh' + 'sh': 'bash' } From f3ceb830b9fafe31077cd9ee4f5691a3268f2ecd Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Thu, 5 May 2016 00:36:12 -0400 Subject: [PATCH 2/3] Simplify ARM triples Previouly, we had 'name', 'symlink_name', and 'download_name'. - We are changing the S3 URL scheme to make 'download_name' redundant. - 'symlink_name' referred to the full target triple, and has been replaced with just 'triple'. - 'name' referred to an ambiguously shortened triple (which omitted the vendor field of 'unknown'), which is used by Ubuntu, and has been replaced with 'ubuntu_triple'. Most of the references have been switched to use just 'triple', which is the most specific identifier, with 'ubuntu_triple' used where necessary (references to the /usr/bin/* cross-compilation binaries, and references to the lib, usr/lib, and usr/include dirs extracted from the ARM rootfs tarballs). e Please enter the commit message for your changes. Lines starting --- servo-build-dependencies/arm.sls | 28 ++++++++++++++-------------- servo-build-dependencies/map.jinja | 10 ++++------ 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/servo-build-dependencies/arm.sls b/servo-build-dependencies/arm.sls index e5ffeae9..fb5ffde5 100644 --- a/servo-build-dependencies/arm.sls +++ b/servo-build-dependencies/arm.sls @@ -33,24 +33,24 @@ arm-dependencies: {% for target in arm.targets %} -libs-{{ target.name }}: +libs-{{ target.triple }}: archive.extracted: - - name: {{ common.servo_home }}/rootfs-trusty-{{ target.name }}/{{ target.version }} - - source: https://servo-rust.s3.amazonaws.com/ARM/{{ target.download_name }}/{{ target.version }}/{{ target.download_name }}-{{ target.version }}.tgz + - name: {{ common.servo_home }}/rootfs-trusty-{{ target.triple }}/{{ target.version }} + - source: https://servo-rust.s3.amazonaws.com/ARM/{{ target.triple }}-trusty-libs/{{ target.version }}/{{ target.triple }}-trusty-libs-{{ target.version }}.tgz - source_hash: sha512={{ target.sha512 }} - archive_format: tar - archive_user: servo {% for binary in binaries %} -{{ common.servo_home }}/bin/{{ target.symlink_name }}-{{ binary }}: +{{ common.servo_home }}/bin/{{ target.triple }}-{{ binary }}: file.symlink: - - target: /usr/bin/{{ target.name }}-{{ binary }} + - target: /usr/bin/{{ target.ubuntu_triple }}-{{ binary }} - makedirs: True - require: - - archive: libs-{{ target.name }} + - archive: libs-{{ target.triple }} {% endfor %} -{{ common.servo_home }}/rootfs-trusty-{{ target.name }}/{{ target.version }}: +{{ common.servo_home }}/rootfs-trusty-{{ target.triple }}/{{ target.version }}: file.directory: - user: servo - group: servo @@ -58,9 +58,9 @@ libs-{{ target.name }}: - file_mode: 644 - makedirs: True - require: - - archive: libs-{{ target.name }} + - archive: libs-{{ target.triple }} -{{ common.servo_home }}/rootfs-trusty-{{ target.name }}: +{{ common.servo_home }}/rootfs-trusty-{{ target.triple }}: file.directory: - user: servo - group: servo @@ -69,14 +69,14 @@ libs-{{ target.name }}: - makedirs: True - clean: True - require: - - file: {{ common.servo_home }}/rootfs-trusty-{{ target.name }}/{{ target.version }} + - file: {{ common.servo_home }}/rootfs-trusty-{{ target.triple }}/{{ target.version }} {% for root in ['usr/include', 'usr/lib', 'lib'] %} -/{{ root }}/{{ target.name }}: +/{{ root }}/{{ target.ubuntu_triple }}: file.symlink: - - target: {{ common.servo_home }}/rootfs-trusty-{{ target.name }}/{{ target.version }}/{{ root }}/{{ target.name }} + - target: {{ common.servo_home }}/rootfs-trusty-{{ target.triple }}/{{ target.version }}/{{ root }}/{{ target.ubuntu_triple }} - require: - - archive: libs-{{ target.name }} + - archive: libs-{{ target.triple }} {% endfor %} {% endfor %} @@ -92,6 +92,6 @@ libs-{{ target.name }}: - require: {% for target in arm.targets %} {% for binary in binaries %} - - file: {{ common.servo_home }}/bin/{{ target.symlink_name }}-{{ binary }} + - file: {{ common.servo_home }}/bin/{{ target.triple }}-{{ binary }} {% endfor %} {% endfor %} diff --git a/servo-build-dependencies/map.jinja b/servo-build-dependencies/map.jinja index 5205e0eb..0cdb4e2f 100644 --- a/servo-build-dependencies/map.jinja +++ b/servo-build-dependencies/map.jinja @@ -16,16 +16,14 @@ set arm = { 'targets': [ { - 'name': 'arm-linux-gnueabihf', - 'download_name': 'armhf-trusty-libs', - 'symlink_name': 'arm-unknown-linux-gnueabihf', + 'triple': 'arm-unknown-linux-gnueabihf', + 'ubuntu_triple': 'arm-linux-gnueabihf', 'version': 'v2', 'sha512': '9273c980b45f2b8602afb98f904582b7de749cab5d388d834c085c95387f3423f330f30d85ce6e5ad55ebdd68fdd03602d3b6db23da07fb2f6dcafb429e79ac7' }, { - 'name': 'aarch64-linux-gnu', - 'download_name': 'arm64-trusty-libs', - 'symlink_name': 'aarch64-unknown-linux-gnu', + 'triple': 'aarch64-unknown-linux-gnu', + 'ubuntu_triple': 'aarch64-linux-gnu', 'version': 'v2', 'sha512': 'a08a90f8a91d644c9e8d7af7fe50fca8a92cdbe5dcbe5faebc16333c9429acd1f487add66a847b64f83ed87ee8e14d5b71efc0a3dba35657f527e649e6e3e35c' } From 2a8cfb446b5c0a0bb41f678be26e0440a911d2aa Mon Sep 17 00:00:00 2001 From: Aneesh Agrawal Date: Tue, 3 May 2016 19:18:29 -0400 Subject: [PATCH 3/3] Add script to upload ARM tarballs correctly We keep uploading them to the wrong place on accident. --- scripts/upload-arm.sh | 61 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100755 scripts/upload-arm.sh diff --git a/scripts/upload-arm.sh b/scripts/upload-arm.sh new file mode 100755 index 00000000..923ef37c --- /dev/null +++ b/scripts/upload-arm.sh @@ -0,0 +1,61 @@ +#!/usr/bin/env bash + +set -o errexit +set -o nounset +set -o pipefail + + +usage () { + printf "usage: $0 \n" + printf "\n" + printf "example: $0 ./armhf-trusty-libs.tgz arm32 v3\n" +} + + +upload () { + local -r local_filename="$1" + local -r arch="$2" + local -r version="$3" + + if [[ "${arch}" == "arm32" ]]; then + local -r triple="arm-unknown-linux-gnueabihf" + elif [[ "${arch}" == "arm64" ]]; then + local -r triple="aarch64-unknown-linux-gnu" + else + printf >&2 "$0: assert: unknown arch $2 passed to upload()\n" + return 1 + fi + + local -r remote_location="s3://servo-rust/ARM/${triple}-trusty-libs/${version}/${triple}-trusty-libs-${version}.tgz" + printf "Uploading ${local_filename} to ${remote_location}. Proceed? [Y/n]" + local proceed + read proceed + if [[ "${proceed}" == "N" || "${proceed}" == "n" ]]; then + printf "Upload aborted.\n" + return 0 + fi + s3cmd put "${local_filename}" "${remote_location}" +} + +main () { + if [[ "$#" != 3 ]]; then + usage >&2 + exit 1 + fi + if [[ ! -e "$1" ]]; then + printf >&2 "$0: $1 does not exist for uploading\n" + exit 1 + fi + if [[ "$2" != "arm32" && "$2" != "arm64" ]]; then + printf >&2 "$0: unknown arch $2, please specify either arm32 or arm64\n" + exit 1 + fi + if [[ "$3" != v* ]]; then + printf >&2 "$0: version $3 must start with a v\n" + exit 1 + fi + + upload "$@" +} + +main "$@"