From 68101c6629efa21d65a276583ced05fce8e06373 Mon Sep 17 00:00:00 2001 From: Robert Jackson Date: Tue, 2 Jan 2018 10:14:25 -0500 Subject: [PATCH] Remove `s3-put` and `cached-npm` scripts. These have not been used for some time and are obsolete (they predate Travis' ability to have `cache:` in `.travis.yml`). --- bin/cached-npm | 55 ------------------------------------- bin/s3-put | 73 -------------------------------------------------- 2 files changed, 128 deletions(-) delete mode 100755 bin/cached-npm delete mode 100755 bin/s3-put diff --git a/bin/cached-npm b/bin/cached-npm deleted file mode 100755 index 5c7795bb9f6..00000000000 --- a/bin/cached-npm +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env bash -# Usage: cached-npm install -# -# After running `npm`, caches the `node_modules` directory to S3. -# On the next run, restores the cached directory before running `npm`. -# When `package.json` changes, the cache gets rebuilt. -# -# Requirements: -# - package.json -# - TRAVIS_REPO_SLUG -# - TRAVIS_NODE_VERSION -# - S3_BUILD_CACHE_BUCKET -# - script/s3-put -# - npm -# - curl -# -# Author: Mislav Marohnić - -set -e - -compute_md5() { - local output="$(openssl md5)" - echo "${output##* }" -} - -download() { - curl --tcp-nodelay -qsfL "$1" -o "$2" -} - -script_dir=$(dirname "${BASH_SOURCE[0]}") -bundle_path="node_modules npm_cache" -cache_busting_hash="$(compute_md5 < package.json)" -cache_name="npm-${TRAVIS_NODE_VERSION}-${cache_busting_hash}.tgz" -fetch_url="https://${S3_BUILD_CACHE_BUCKET}.s3.amazonaws.com/${TRAVIS_REPO_SLUG}/${cache_name}" - -if download "$fetch_url" "$cache_name"; then - echo "Reusing cached bundle ${cache_name}" - tar xzf "$cache_name" -fi - -NPM_CONFIG_CACHE=./npm_cache npm "$@" - -if [ ! -f "$cache_name" ]; then - if [ -z "$S3_SECRET_ACCESS_KEY" ] || [ -z "$S3_ACCESS_KEY_ID" ] - then - echo "Enviroment variables not set. Exiting..." - exit 0 - fi - - echo "Caching \`${bundle_path}' to S3" - tar czf "$cache_name" $bundle_path - $script_dir/s3-put "$cache_name" "${S3_BUILD_CACHE_BUCKET}:${TRAVIS_REPO_SLUG}/${cache_name}" -fi - -# vim: filetype=sh diff --git a/bin/s3-put b/bin/s3-put deleted file mode 100755 index 4f8a142603b..00000000000 --- a/bin/s3-put +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env bash -# Usage: s3-put [:] [] -# -# Uploads a file to the Amazon S3 service. -# Outputs the URL for the newly uploaded file. -# -# Requirements: -# - S3_ACCESS_KEY_ID -# - S3_SECRET_ACCESS_KEY -# - openssl -# - curl -# -# Author: Mislav Marohnić - -set -e - -authorization() { - local signature="$(string_to_sign | hmac_sha1 | base64)" - echo "AWS ${S3_ACCESS_KEY_ID?}:${signature}" -} - -hmac_sha1() { - openssl dgst -binary -sha1 -hmac "${S3_SECRET_ACCESS_KEY?}" -} - -base64() { - openssl enc -base64 -} - -bin_md5() { - openssl dgst -binary -md5 -} - -string_to_sign() { - echo "$http_method" - echo "$content_md5" - echo "$content_type" - echo "$date" - echo "x-amz-acl:$acl" - printf "/$bucket/$remote_path" -} - -date_string() { - LC_TIME=C date "+%a, %d %h %Y %T %z" -} - -file="$1" -bucket="${2%%:*}" -remote_path="${2#*:}" -content_type="$3" - -if [ -z "$remote_path" ] || [ "$remote_path" = "$bucket" ]; then - remote_path="${file##*/}" -fi - -http_method=PUT -acl="public-read" -content_md5="$(bin_md5 < "$file" | base64)" -date="$(date_string)" - -url="https://$bucket.s3.amazonaws.com/$remote_path" - -curl -qsSf -T "$file" \ - -H "Authorization: $(authorization)" \ - -H "x-amz-acl: $acl" \ - -H "Date: $date" \ - -H "Content-MD5: $content_md5" \ - -H "Content-Type: $content_type" \ - "$url" - -echo "$url" - -# vim: filetype=sh