From fec5653b9354e287de43516e421b028c3b0923bd Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Fri, 15 Jan 2021 18:33:46 +0000 Subject: [PATCH 1/6] Add a changelog (#78) Since for the check changelog check (added in #56) to pass, we actually need a changelog to which we can add entries. I've backfilled recent changes based on the Git history. The buildpack doesn't tag versions, so I've used dates only. Closes W-8726144. --- CHANGELOG.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..5daaff2 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,28 @@ +# APT Buildpack Changelog + +## Unreleased + + +## 2019-10-17 + +- Flush the cache on stack change ([#58](https://github.com/heroku/heroku-buildpack-apt/pull/58)). + +## 2019-09-06 + +- Stop using `force-yes` with newer version of apt-get ([#51](https://github.com/heroku/heroku-buildpack-apt/pull/51)). + +## 2019-06-11 + +- Prevent APT using source lists from `/etc/apt/sources.list.d/` ([#46](https://github.com/heroku/heroku-buildpack-apt/pull/46)). + +## 2019-06-10 + +- Add support for comments in `Aptfile` ([#24](https://github.com/heroku/heroku-buildpack-apt/pull/24)). + +## 2017-09-13 + +- Add support for custom repositories ([#18](https://github.com/heroku/heroku-buildpack-apt/pull/18)). + +## 2016 and earlier + +See the [Git log](https://github.com/heroku/heroku-buildpack-apt/commits/40883f0cb8e8ddb2876ca8be5d25ade4ff9617b1). From e8b8cde755ef8cd02bfeea43a443e87f26a8f307 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Fri, 15 Jan 2021 18:50:39 +0000 Subject: [PATCH 2/6] Fail the build if apt-get or curl errors (#79) Enables the bash `pipefail` mode, which ensures that a failure in a command prior to a pipe correctly causes the script to exit 1. Without this, failures during the `apt-get` and `curl` invocations were ignored and the compile marked as a success. At best this leads to confusing errors in later buildpacks (if build time dependencies are missing), and at worst this could cause runtime failures for packages not used during the build, but required by the app at runtime. Enabling `pipefail` mode required a change to the custom repositories feature, to prevent the build exiting 1 when `grep -s -e "^:repo:"` found no matches (ie when no custom repositories are specified). In addition, the `--show-error` and `--fail` flags have been added to the `curl` call, otherwise non-HTTP 200 exit codes are ignored and the compile similarly marked as successful when it should not have been. Fixes #47. Fixes W-8722791. --- CHANGELOG.md | 4 +++- bin/compile | 10 ++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5daaff2..326c20d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,9 @@ # APT Buildpack Changelog -## Unreleased +## 2021-01-15 +- Fail the build if `apt-get` or `curl` errors ([#79](https://github.com/heroku/heroku-buildpack-apt/pull/79)). +- Only try to add custom repositories when some are defined in `Aptfile` ([#79](https://github.com/heroku/heroku-buildpack-apt/pull/79)). ## 2019-10-17 diff --git a/bin/compile b/bin/compile index af544c2..3b20c2a 100755 --- a/bin/compile +++ b/bin/compile @@ -2,7 +2,7 @@ # bin/compile # fail fast -set -e +set -eo pipefail # debug # set -x @@ -67,8 +67,10 @@ else cat "/etc/apt/sources.list" > "$APT_SOURCES" # no cp here # add custom repositories from Aptfile to sources.list # like>> :repo:deb http://cz.archive.ubuntu.com/ubuntu artful main universe - topic "Adding custom repositories" - cat $BUILD_DIR/Aptfile | grep -s -e "^:repo:" | sed 's/^:repo:\(.*\)\s*$/\1/g' >> $APT_SOURCES + if grep -q -e "^:repo:" $BUILD_DIR/Aptfile; then + topic "Adding custom repositories" + cat $BUILD_DIR/Aptfile | grep -s -e "^:repo:" | sed 's/^:repo:\(.*\)\s*$/\1/g' >> $APT_SOURCES + fi fi APT_OPTIONS="-o debug::nolocking=true -o dir::cache=$APT_CACHE_DIR -o dir::state=$APT_STATE_DIR" @@ -84,7 +86,7 @@ for PACKAGE in $(cat $BUILD_DIR/Aptfile | grep -v -s -e '^#' | grep -v -s -e "^: PACKAGE_FILE=$APT_CACHE_DIR/archives/$PACKAGE_NAME.deb topic "Fetching $PACKAGE" - curl -s -L -z $PACKAGE_FILE -o $PACKAGE_FILE $PACKAGE 2>&1 | indent + curl --silent --show-error --fail -L -z $PACKAGE_FILE -o $PACKAGE_FILE $PACKAGE 2>&1 | indent else topic "Fetching .debs for $PACKAGE" apt-get $APT_OPTIONS -y $APT_FORCE_YES -d install --reinstall $PACKAGE | indent From f4178795746695a205d5c4ba0d481c6a4eb0780f Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Thu, 21 Jan 2021 16:03:04 +0000 Subject: [PATCH 3/6] Check Changelog: Use commit body skip messages instead (#81) Cluttering up the commit title with `[skip changelog]` is suboptimal. This switches to the approach used by the Python buildpack. --- .github/workflows/check_changelog.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/check_changelog.yml b/.github/workflows/check_changelog.yml index 0d1139f..282bf46 100644 --- a/.github/workflows/check_changelog.yml +++ b/.github/workflows/check_changelog.yml @@ -1,13 +1,17 @@ name: Check Changelog on: - pull_request: - types: [opened, reopened, edited, synchronize] + pull_request: + types: [opened, reopened, edited, synchronize] + jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - name: Check that CHANGELOG is touched - run: | - cat $GITHUB_EVENT_PATH | jq .pull_request.title | grep -i '\[\(\(changelog skip\)\|\(ci skip\)\)\]' || git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md + check-changelog: + runs-on: ubuntu-latest + if: | + !contains(github.event.pull_request.body, '[skip changelog]') && + !contains(github.event.pull_request.body, '[changelog skip]') && + !contains(github.event.pull_request.body, '[skip ci]') + steps: + - uses: actions/checkout@v1 + - name: Check that CHANGELOG is touched + run: git diff remotes/origin/${{ github.base_ref }} --name-only | grep CHANGELOG.md From a338a17d1fc5dc444162939630e0c46f368ce787 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Thu, 21 Jan 2021 16:04:45 +0000 Subject: [PATCH 4/6] Docs: Make the example more obviously an example (#80) In a recent support ticket, a user had copied the example `:repo:` line into their `Aptfile`, which previously referred to the now obsolete "artful" Ubuntu LTS release. This caused the build to fail after #79, when previously the error was ignored. This PR makes the example more clearly just an example, and emphasises that using a custom repository is only necessary if using packages from outside the standard Ubuntu repository. In addition, the bogus `pg` Gem example was removed, since `libpq-dev` is part of the stack image, so we should not be encouraging people to install it unnecessarily. --- README.md | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/README.md b/README.md index 515a9ec..b1e201b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,13 @@ Added ability to also specify custom repositories through **:repo:** in `Aptfile This buildpack is not meant to be used on its own, and instead should be in used in combination with Heroku's [multiple buildpack support](https://devcenter.heroku.com/articles/using-multiple-buildpacks-for-an-app). -Include a list of apt package names to be installed in a file named `Aptfile` +Include a list of apt package names to be installed in a file named `Aptfile`. + +To find out what packages are available, see: + + +See the [Heroku Stacks](https://devcenter.heroku.com/articles/stack) documention for which +Ubuntu LTS version is used by each Heroku stack. ## Example @@ -29,25 +35,13 @@ heroku buildpacks:add --index 1 https://github.com/heroku/heroku-buildpack-apt #### Aptfile # you can list packages - libpq-dev + libexample-dev + # or include links to specific .deb files - http://downloads.sourceforge.net/project/wkhtmltopdf/0.12.1/wkhtmltox-0.12.1_linux-precise-amd64.deb - # or add custom apt repos - :repo:deb http://cz.archive.ubuntu.com/ubuntu artful main universe - -#### Gemfile - - source "https://rubygems.org" - gem "pg" - -### Check out the PG library version - - $ heroku run bash -a apt-pg-test - ~ $ irb - irb(main):001:0> require "pg" - => true - irb(main):002:0> PG::version_string - => "PG 0.15.1" + https://downloads.example.com/example.deb + + # or add custom apt repos (only required if using packages outside of the standard Ubuntu APT repositories) + :repo:deb https://apt.example.com/ example-distro main ## License From 7a57b478223abaeeb8750dcc48a4414cdc7cc6b3 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Wed, 10 Mar 2021 10:38:56 +0000 Subject: [PATCH 5/6] Output a helpful error message when no Aptfile is found (#87) The error message is output to `stderr` otherwise it won't be shown. Closes GUS-W-8799411. Refs #86. --- CHANGELOG.md | 4 ++++ bin/detect | 6 ++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 326c20d..c70da68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # APT Buildpack Changelog +## Unreleased + +- Output a helpful error message when no `Aptfile` is found ([#87](https://github.com/heroku/heroku-buildpack-apt/pull/87)). + ## 2021-01-15 - Fail the build if `apt-get` or `curl` errors ([#79](https://github.com/heroku/heroku-buildpack-apt/pull/79)). diff --git a/bin/detect b/bin/detect index c5e4eb4..6d92e28 100755 --- a/bin/detect +++ b/bin/detect @@ -2,7 +2,9 @@ # bin/detect if [ -f $1/Aptfile ]; then - echo "Apt" && exit 0 + echo "Apt" + exit 0 else - echo "no" && exit 1 + echo "Could not find an 'Aptfile'! Please ensure it exists and is checked into Git." >&2 + exit 1 fi From 0a778933873c3b4c4e5f046db41890ea609afb74 Mon Sep 17 00:00:00 2001 From: Ed Morley <501702+edmorley@users.noreply.github.com> Date: Wed, 10 Mar 2021 11:05:03 +0000 Subject: [PATCH 6/6] Update changelog for 2021-03-10 release (#88) To pick up #87. Refs GUS-W-8799411. --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index c70da68..b24fd59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,9 @@ ## Unreleased + +## 2021-03-10 + - Output a helpful error message when no `Aptfile` is found ([#87](https://github.com/heroku/heroku-buildpack-apt/pull/87)). ## 2021-01-15