diff --git a/README.md b/README.md index a3af70b..1a24b8a 100644 --- a/README.md +++ b/README.md @@ -134,6 +134,14 @@ ARG TARGETPLATFORM RUN xx-apt-get install -y libc6-dev zlib1g-dev ``` +> [!NOTE] +> `--print-source-file` flag can be used with `xx-apt` to print the path of the +> main [Apt sources configuration file](https://manpages.debian.org/bookworm/apt/sources.list.5.en.html): +> ```dockerfile +> # debian +> RUN xx-apt --print-source-file +> ``` + Installing two meta-libraries, `xx-c-essentials`, `xx-cxx-essentials` is also allowed that expand the minimum necessary packages for either base image. ## `xx-verify` - Verifying compilation results diff --git a/src/test-apt.bats b/src/test-apt.bats index 4cde980..8b0b968 100755 --- a/src/test-apt.bats +++ b/src/test-apt.bats @@ -219,3 +219,12 @@ load 'assert' run apt show wget-notexist assert_failure } + +@test "print-source-file" { + run xx-apt --print-source-file + assert_success + assert_output --partial "/etc/apt/sources.list" + + run test -e "$(xx-apt --print-source-file)" + assert_success +} diff --git a/src/xx-apt b/src/xx-apt index 4b3e747..bac13bb 100755 --- a/src/xx-apt +++ b/src/xx-apt @@ -38,6 +38,20 @@ exitnolinux() { fi } +n=$# +for a in "$@"; do + if [ $# = $n ]; then set --; fi + case "$a" in + "--print-source-file") + aptsourcesfile + exit 0 + ;; + *) + set -- "$@" "$a" + ;; + esac +done + # these are not supported yet case "${TARGETARCH}" in mips*)