servo: Merge #14403 - Fix brew formula update (from paulrouget:fixBrew); r=aneeshusa

Fix https://github.com/servo/saltfs/issues/535

I decided to merge update_brew within upload_nightly.

I hope this will fix the brew formula upadte.

Source-Repo: https://github.com/servo/servo
Source-Revision: 207f9a5d3bb59cfc20b4455531325a3eb5a5ccf3
This commit is contained in:
Paul Rouget 2017-01-05 19:59:18 -08:00
parent 31c11f55f7
commit 55fe4d2c1f
3 changed files with 44 additions and 54 deletions

View File

@ -34,7 +34,6 @@ mac-nightly:
- ./mach package --release
- ./etc/ci/upload_nightly.sh mac
- ./etc/ci/upload_nightly.sh macbrew
- ./etc/ci/update_brew.sh
linux-rel-intermittent:
- ./mach build --release

View File

@ -1,48 +0,0 @@
#!/usr/bin/env bash
# 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/.
set -o errexit
set -o nounset
set -o pipefail
SCRIPTDIR=${PWD}/$(dirname ${0})
cd "${SCRIPTDIR}/../.."
PACKAGEPATH=$(ls -t target/brew/servo-????-??-??.tar.gz | head -n 1)
PACKAGENAME=$(basename ${PACKAGEPATH})
REGEX="s/servo-.*\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\).tar.gz/\1.\2.\3/p"
VERSION=$(echo ${PACKAGENAME}| sed -n "${REGEX}")
SHA=$(shasum -a 256 ${PACKAGEPATH} | sed -e 's/ .*//')
# See upload_nightly.sh
PACKAGEURL="https://download.servo.org/nightly/macbrew/${PACKAGENAME}"
if [[ -z ${VERSION} ]]; then
echo "Package doesn't havent the right format: ${PACKAGENAME}"
exit 1
fi
TMP_DIR=$(mktemp -d -t homebrew-servo)
cd ${TMP_DIR}
echo ${TMP_DIR}
echo "Cloning"
git clone https://github.com/servo/homebrew-servo.git
cd homebrew-servo
# Not using "/" as it's used in PACKAGEURL
cat ${SCRIPTDIR}/servo-binary-formula.rb.in | sed \
"s|PACKAGEURL|${PACKAGEURL}|g
s|SHA|${SHA}|g
s|VERSION|${VERSION}|g" > Formula/servo-bin.rb
git add ./Formula/servo-bin.rb
git commit -m "Version bump: ${VERSION}"
git push -qf \
"https://${TOKEN}@github.com/servo/homebrew-servo.git" master \
>/dev/null 2>&1
rm -rf ${TMP_DIR}

View File

@ -16,9 +16,8 @@ usage() {
upload() {
local nightly_filename nightly_timestamp
nightly_timestamp="$(date -u +"%Y-%m-%dT%H-%M-%SZ")"
nightly_filename="${nightly_timestamp}-$(basename "${2}")"
local nightly_filename
nightly_filename="${4}-$(basename "${2}")"
local -r nightly_upload_dir="s3://servo-builds/nightly/${1}"
local -r package_upload_path="${nightly_upload_dir}/${nightly_filename}"
s3cmd --mime-type="application/octet-stream" \
@ -26,6 +25,41 @@ upload() {
s3cmd cp "${package_upload_path}" "${nightly_upload_dir}/servo-latest.${3}"
}
update_brew() {
echo "Updating brew formula"
local package_url sha version script_dir tmp_dir nightly_filename
nightly_filename="${2}-$(basename "${1}")"
package_url="https://download.servo.org/nightly/macbrew/${nightly_filename}"
sha="$(shasum -a 256 "${1}" | sed -e 's/ .*//')"
# This will transform a timestamp (2016-12-13T08-01-10Z for example)
# into a valid brew version number (2016.12.13).
version="$(echo "${2}" | \
sed -n 's/\([0-9]\{4\}\)-\([0-9]\{2\}\)-\([0-9]\{2\}\).*/\1.\2.\3/p')"
script_dir="${PWD}/$(dirname "${0}")"
tmp_dir="$(mktemp -d -t homebrew-servo.XXXXX)"
git -C "${tmp_dir}" clone https://github.com/servo/homebrew-servo.git .
# Not using "/" as it's used in PACKAGEURL
sed "s|PACKAGEURL|${package_url}|g
s|SHA|${sha}|g
s|VERSION|${version}|g" \
< "${script_dir}/servo-binary-formula.rb.in" \
> "${tmp_dir}/Formula/servo-bin.rb"
git -C "${tmp_dir}" add ./Formula/servo-bin.rb
git -C "${tmp_dir}" commit -m "Version bump: ${version}"
git -C "${tmp_dir}" push -qf \
"https://${GITHUB_HOMEBREW_TOKEN}@github.com/servo/homebrew-servo.git" \
master >/dev/null 2>&1
rm -rf "${tmp_dir}"
}
main() {
if (( "${#}" != 1 )); then
@ -33,8 +67,9 @@ main() {
return 1
fi
local platform package extension
local platform package extension nightly_timestamp
platform="${1}"
nightly_timestamp="$(date -u +"%Y-%m-%dT%H-%M-%SZ")"
if [[ "${platform}" == "android" ]]; then
extension=apk
@ -60,7 +95,11 @@ main() {
# Lack of quotes on package allows glob expansion
# Note that this is not robust in the case of embedded spaces
# TODO(aneeshusa): make this glob robust using e.g. arrays or Python
upload "${platform}" ${package} "${extension}"
upload "${platform}" ${package} "${extension}" "${nightly_timestamp}"
if [[ "${platform}" == "macbrew" ]]; then
update_brew ${package} "${nightly_timestamp}"
fi
}
main "${@}"