Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a way to set apt preferences #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,31 @@ jobs:
test -f debian/artifacts/test_1_amd64.buildinfo
test -f debian/artifacts/test_1_amd64.changes

extra-apt-preferences:
needs: [setup-hook]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: cat test/Makefile_extra-preferences >>test/Makefile
- uses: ./
env:
DEB_BUILD_OPTIONS: noautodbgsym
with:
buildpackage-opts: --build=binary --no-sign
extra-apt-preferences: |
Package: *
Pin: origin deb.debian.org
Pin-Priority: 900
setup-hook: |
apt-get update # Called here manually only for testing purposes!
! apt-cache policy | grep -B3 'origin deb.debian.org' | grep -q '900'
source-dir: test
- run: |
dpkg --info debian/artifacts/test_1_amd64.deb
dpkg --contents debian/artifacts/test_1_amd64.deb | grep ./usr/bin/mybin
test -f debian/artifacts/test_1_amd64.buildinfo
test -f debian/artifacts/test_1_amd64.changes

full-build:
runs-on: ubuntu-latest
steps:
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,16 @@ deb822 style, see

Optional and empty by default.

#### `extra-apt-preferences`
Extra APT preferences to configure package priorities in the build environment.

This allows you to pin packages from specific sources or set priorities to control
package selection during installation or upgrades. The preferences should be
provided in a format supported by APT, typically as entries in Package, Pin, and
Pin-Priority fields. For more details, see `man apt_preferences`.

Optional and empty by default.

#### `extra-repo-keys`
Extra keys for APT to trust in the build environment. Useful in combination
with [`extra-repos`](#extra-repos).
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ inputs:
extra-repos:
description: Extra APT repositories to configure in the build environment (one-line-style or deb822-style format)
required: false
extra-apt-preferences:
description: Extra APT preferences fragments file to configure the priorities between multiple feeds
required: false
host-arch:
description: Foreign architecture to setup cross-building for
required: false
Expand All @@ -58,6 +61,7 @@ runs:
INPUT_EXTRA_DOCKER_ARGS: ${{ inputs.extra-docker-args }}
INPUT_EXTRA_REPO_KEYS: ${{ inputs.extra-repo-keys }}
INPUT_EXTRA_REPOS: ${{ inputs.extra-repos }}
INPUT_EXTRA_APT_PREFERENCES: ${{ inputs.extra-apt-preferences }}
INPUT_HOST_ARCH: ${{ inputs.host-arch }}
INPUT_SETUP_HOOK: ${{ inputs.setup-hook }}
INPUT_SOURCE_DIR: ${{ inputs.source-dir }}
Expand Down
2 changes: 2 additions & 0 deletions scripts/install_build_deps
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ else
fi
printf "%s\n" "$INPUT_EXTRA_REPOS" >"/etc/apt/sources.list.d/build-deb-action${extra_repos_ext}"

printf "%s\n" "$INPUT_EXTRA_APT_PREFERENCES" > "/etc/apt/preferences.d/extra-preferences.pref"

apt-get update

# shellcheck disable=SC2086
Expand Down
2 changes: 2 additions & 0 deletions scripts/run
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ env \
--unset=INPUT_BEFORE_BUILD_HOOK \
--unset=INPUT_EXTRA_REPO_KEYS \
--unset=INPUT_EXTRA_REPOS \
--unset=INPUT_EXTRA_APT_PREFERENCES \
--unset=INPUT_SETUP_HOOK \
>"$env_file"

Expand All @@ -127,6 +128,7 @@ container_id=$(
--env=GITHUB_ACTION_PATH=/github/action \
--env=GITHUB_WORKSPACE=/github/workspace \
--env=INPUT_EXTRA_REPOS \
--env=INPUT_EXTRA_APT_PREFERENCES \
--mount="type=bind,src=${GITHUB_ACTION_PATH},dst=/github/action,ro" \
--mount="type=bind,src=${build_dir},dst=/github/build" \
--mount="type=bind,src=${GITHUB_WORKSPACE},dst=/github/workspace" \
Expand Down
4 changes: 4 additions & 0 deletions test/Makefile_extra-preferences
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

.PHONY: test
test:
apt-cache policy | grep -B3 'origin deb.debian.org' | grep -q '900'