From 9e1a71e57b61b0b20f1e8fc951e22f35836d773c Mon Sep 17 00:00:00 2001 From: Colin Casey Date: Mon, 18 Mar 2024 19:03:09 -0300 Subject: [PATCH] Support source parts directory --- .github/workflows/ci.yml | 3 ++- CHANGELOG.md | 1 + Makefile | 7 ++++++- bin/compile | 4 +++- test/fixtures/custom-repository-heroku-24/Aptfile | 2 ++ test/run | 6 ++++++ 6 files changed, 20 insertions(+), 3 deletions(-) create mode 100644 test/fixtures/custom-repository-heroku-24/Aptfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aaf0c67..958dad1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,9 +13,10 @@ jobs: runs-on: ubuntu-22.04 container: image: heroku/heroku:${{ matrix.stack_number }}-build + options: --user root strategy: matrix: - stack_number: ["20", "22"] + stack_number: ["20", "22", "24"] env: STACK: heroku-${{ matrix.stack_number }} steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 1cda33f..fa7e501 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## Unreleased - Warn when Aptfile contains no packages ([#126](https://github.com/heroku/heroku-buildpack-apt/pull/126)) +- Support sources parts directory for Heroku-24 compatibility ([#119](https://github.com/heroku/heroku-buildpack-apt/pull/119)) ## 2024-03-14 diff --git a/Makefile b/Makefile index cc13917..5dd5e97 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,13 @@ -test: heroku-22-build heroku-20-build +test: heroku-24-build heroku-22-build heroku-20-build shellcheck: @shellcheck -x bin/compile bin/detect bin/release bin/report +heroku-24-build: + @echo "Running tests in docker (heroku-24-build)..." + @docker run --user root -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-24" heroku/heroku:24-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;' + @echo "" + heroku-22-build: @echo "Running tests in docker (heroku-22-build)..." @docker run -v $(shell pwd):/buildpack:ro --rm -it -e "STACK=heroku-22" heroku/heroku:22-build bash -c 'cp -r /buildpack /buildpack_test; cd /buildpack_test/; test/run;' diff --git a/bin/compile b/bin/compile index c10cdf1..711690a 100755 --- a/bin/compile +++ b/bin/compile @@ -53,6 +53,7 @@ echo "$STACK" > "$CACHE_DIR/.apt/STACK" APT_CACHE_DIR="$CACHE_DIR/apt/cache" APT_STATE_DIR="$CACHE_DIR/apt/state" APT_SOURCELIST_DIR="$CACHE_DIR/apt/sources" # place custom sources.list here +APT_SOURCEPARTS_DIR="$APT_SOURCELIST_DIR/sources.list.d" APT_SOURCES="$APT_SOURCELIST_DIR/sources.list" @@ -75,6 +76,7 @@ else mkdir -p "$APT_SOURCELIST_DIR" # make dir for sources cp -f "$BUILD_DIR/Aptfile" "$APT_CACHE_DIR/Aptfile" cat "/etc/apt/sources.list" > "$APT_SOURCES" # no cp here + cp -R "/etc/apt/sources.list.d" "$APT_SOURCEPARTS_DIR" # add custom repositories from Aptfile to sources.list # like>> :repo:deb http://cz.archive.ubuntu.com/ubuntu artful main universe if grep -q -e "^:repo:" "$BUILD_DIR/Aptfile"; then @@ -85,7 +87,7 @@ fi APT_OPTIONS=("-o" "debug::nolocking=true" "-o" "dir::cache=$APT_CACHE_DIR" "-o" "dir::state=$APT_STATE_DIR") # Override the use of /etc/apt/sources.list (sourcelist) and /etc/apt/sources.list.d/* (sourceparts). -APT_OPTIONS+=("-o" "dir::etc::sourcelist=$APT_SOURCES" "-o" "dir::etc::sourceparts=/dev/null") +APT_OPTIONS+=("-o" "dir::etc::sourcelist=$APT_SOURCES" "-o" "dir::etc::sourceparts=$APT_SOURCEPARTS_DIR") topic "Updating apt caches" apt-get "${APT_OPTIONS[@]}" update 2>&1 | indent diff --git a/test/fixtures/custom-repository-heroku-24/Aptfile b/test/fixtures/custom-repository-heroku-24/Aptfile new file mode 100644 index 0000000..6f33d3e --- /dev/null +++ b/test/fixtures/custom-repository-heroku-24/Aptfile @@ -0,0 +1,2 @@ +:repo:deb http://us.archive.ubuntu.com/ubuntu/ noble multiverse +fasttracker2 diff --git a/test/run b/test/run index 6718ba7..162704e 100755 --- a/test/run +++ b/test/run @@ -25,6 +25,8 @@ testReportPackageNames() { } testCompileCustomPackageUrl() { + # no custom package out for noble yet + if [[ "$STACK" == "heroku-24" ]]; then return 0; fi declare -A download_urls=( [heroku-20]="https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb" [heroku-22]="https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb" @@ -39,6 +41,8 @@ testCompileCustomPackageUrl() { } testReportCustomPackageUrl() { + # no custom package out for noble yet + if [[ "$STACK" == "heroku-24" ]]; then return 0; fi declare -A download_urls=( [heroku-20]="https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6-1/wkhtmltox_0.12.6-1.focal_amd64.deb" [heroku-22]="https://github.com/wkhtmltopdf/packaging/releases/download/0.12.6.1-2/wkhtmltox_0.12.6.1-2.jammy_amd64.deb" @@ -54,6 +58,7 @@ testCompileCustomRepository() { declare -A ubuntu_release_names=( [heroku-20]="focal" [heroku-22]="jammy" + [heroku-24]="noble" ) compile "custom-repository-$STACK" assertCaptured "Adding custom repositories" @@ -70,6 +75,7 @@ testReportCustomRepository() { declare -A ubuntu_release_names=( [heroku-20]="focal" [heroku-22]="jammy" + [heroku-24]="noble" ) report "custom-repository-$STACK" assertCaptured "packages: \"fasttracker2\""