From e39bbc8497b2c75466235341a4e13bcef37da5de Mon Sep 17 00:00:00 2001 From: CrazyMax <1951866+crazy-max@users.noreply.github.com> Date: Wed, 10 Jan 2024 10:03:57 +0100 Subject: [PATCH] xx-apt: print-source-file flag Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> --- README.md | 8 ++++++++ src/test-apt.bats | 9 +++++++++ src/xx-apt | 14 ++++++++++++++ 3 files changed, 31 insertions(+) diff --git a/README.md b/README.md index a3af70bd..1a24b8a2 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 4cde980a..8b0b9688 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 4b3e747a..bac13bbb 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*)