From 8d96c2baaed87a53432c5e4e2947423d3ebaab1e Mon Sep 17 00:00:00 2001 From: Pierre Fenoll Date: Sun, 15 Apr 2018 19:07:09 +0200 Subject: Fail if curl call fails (#276) * Yay HTTPS on erlang.org! * issue-275: fail if curl fails * issue-275: forgot to remove tmp curled file --- README.md | 8 ++++---- kerl | 19 ++++++++++++++----- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e94ad16..cde4550 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ kerl [![TravisCI build status](https://travis-ci.org/kerl/kerl.svg?branch=master)](https://travis-ci.org/kerl/kerl) [![CircleCI](https://circleci.com/gh/kerl/kerl.svg?style=svg)](https://circleci.com/gh/kerl/kerl) ==== -Easy building and installing of [Erlang/OTP](http://www.erlang.org) instances. +Easy building and installing of [Erlang/OTP](https://www.erlang.org) instances. Kerl aims to be shell agnostic and its only dependencies, excluding what's required to actually build Erlang/OTP, are `curl` and `git`. @@ -57,7 +57,7 @@ Kerl keeps tracks of the releases it downloads, builds and installs, allowing easy installations to new destinations (without complete rebuilding) and easy switches between Erlang/OTP installations. -By default, kerl downloads source tarballs from the [official Erlang website](http://www.erlang.org), but +By default, kerl downloads source tarballs from the [official Erlang website](https://www.erlang.org), but you can tell kerl to download tarballs of Erlang source code from the tags pushed to the [official source code](https://github.com/erlang/otp) by setting `KERL_BUILD_BACKEND=git` @@ -380,7 +380,7 @@ Glossary Here are the abstractions kerl is handling: -- **releases**: Erlang/OTP releases from [erlang.org](http://erlang.org) +- **releases**: Erlang/OTP releases from [erlang.org](https://erlang.org) - **builds**: the result of configuring and compiling releases or git repositories @@ -406,7 +406,7 @@ Creates a named build either from an official Erlang/OTP release or from a git r You can specify the configure options to use when building Erlang/OTP with the `KERL_CONFIGURE_OPTIONS` variable, either in your $HOME/.kerlrc file or prepending it to the command line. Full list of all options can be in -[Erlang documentation](http://erlang.org/doc/installation_guide/INSTALL.html#Advanced-configuration-and-build-of-ErlangOTP_Configuring). +[Erlang documentation](https://erlang.org/doc/installation_guide/INSTALL.html#Advanced-configuration-and-build-of-ErlangOTP_Configuring). $ KERL_CONFIGURE_OPTIONS=--enable-hipe kerl build 19.2 19.2-hipe diff --git a/kerl b/kerl index e561866..27906f3 100755 --- a/kerl +++ b/kerl @@ -27,7 +27,7 @@ unset ERL_TOP KERL_VERSION='1.8.2' DOCSH_GITHUB_URL='https://github.com/erszcz/docsh.git' -ERLANG_DOWNLOAD_URL='http://www.erlang.org/download' +ERLANG_DOWNLOAD_URL='https://www.erlang.org/download' KERL_CONFIG_STORAGE_FILENAME='.kerl_config' if [ -z "$HOME" ]; then @@ -211,10 +211,19 @@ get_git_releases() { } get_tarball_releases() { - curl -f -q -L -s $ERLANG_DOWNLOAD_URL/ | \ - sed $SED_OPT -e 's/^.*<[aA] [hH][rR][eE][fF]=\"otp_src_([-0-9A-Za-z_.]+)\.tar\.gz\">.*$/\1/' \ - -e '/^R1|^[0-9]/!d' | \ - sed -e 's/^R\(.*\)/\1:R\1/' | sed -e 's/^\([^\:]*\)$/\1-z:\1/' | sort | cut -d: -f2 + tmp="$(mktemp /tmp/kerl.XXXXXX)" + if [ 200 = "$(curl -qsL --output "$tmp" --write-out '%{http_code}' $ERLANG_DOWNLOAD_URL/)" ]; then + sed $SED_OPT \ + -e 's/^.*<[aA] [hH][rR][eE][fF]=\"otp_src_([-0-9A-Za-z_.]+)\.tar\.gz\">.*$/\1/' \ + -e '/^R1|^[0-9]/!d' "$tmp" \ + | sed -e 's/^R\(.*\)/\1:R\1/' \ + | sed -e 's/^\([^\:]*\)$/\1-z:\1/' \ + | sort | cut -d: -f2 + rm "$tmp" + return 0 + fi + rm "$tmp" + exit 1 } update_checksum_file() { -- cgit v1.2.3