Repository navigation
stage_binaries.sh: skip package files that are not on disk - #1002
Conversation
|
Welcome @tiffanny29631! |
| for elem in "${elems[@]}"; do | ||
| path="${path}/${elem}" | ||
| if [[ ! -e "${staging}${path}" ]]; then | ||
| if [[ ! -e "${path}" && ! -L "${path}" ]]; then |
There was a problem hiding this comment.
Discussion: stage_one_package() already filters the manifest:
dpkg -L "${pkg}" | grep_allow_nomatch -vE '(/\.|/usr/share/(man|doc|.*-completion))'Could the filter be updated to include the unnecessary files?
Otherwise:
- stage_one_file is also the path for user-requested -f files, so this makes -f /typo/path silently succeed instead of failing the build. Can we keep -f strict in stage_files()?
- Nits: return 0 rather than continue (deeper paths can't exist if the prefix doesn't exist), and a debug logging "skipping nonexistent path ..." so this isn't invisible.
There was a problem hiding this comment.
Thanks, good points. I've reworked it:
Moved the check into stage_one_package() and reverted the stage_one_file() change, so explicit -f/-b paths still fail on a typo. I verified that -f /typo/path still fails the build.
It now skips the whole file (no per-element loop) and logs via DBG.
On extending the grep filter instead: what gets dropped depends on each image's dpkg path-exclude config. debian:trixie-slim drops /usr/share/lintian, /usr/share/locale, /usr/share/info, etc., and other minimal bases drop different sets, so the filter would need updating for each base. Checking for existence on the dpkg-manifest path handles all of them without touching the user-specified paths.
Minimal Debian base images (e.g. debian:trixie-slim) use dpkg
path-exclude rules (/etc/dpkg/dpkg.cfg.d/) to drop files such as
/usr/share/lintian/*, but `dpkg -L` still lists them.
stage_one_package() hands those paths to stage_one_file(), which falls
through to `cp -lpP` and fails the build:
cp: cannot stat '/usr/share/lintian/overrides/base-files': No such file or directory
Skip (with a debug log) files from a package manifest that do not exist.
Explicitly requested files (-f) and binaries (-b) still go straight to
stage_one_file() and fail loudly if missing.
Signed-off-by: tiffanny29631 <peip@google.com>
|
/lgtm |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: thockin, tiffanny29631 The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Minimal Debian base images (e.g.
debian:trixie-slim) drop files via dpkgpath-excluderules in/etc/dpkg/dpkg.cfg.d/, butdpkg -Lstill lists them.stage_one_package()passes those paths tostage_one_file(), which falls through tocp -lpPand fails. Repro: running the Dockerfile.in staging command (/stage_binaries.sh -o /staging -p base-files ...) insidedebian:trixie-slimfails withcp: cannot stat '/usr/share/lintian/overrides/base-files': No such file or directory
This skips, with a
DBGlog, package-manifest files that don't exist. Explicit-f/-bpaths still go straight tostage_one_file()and fail loudly if missing.Tested by running the Dockerfile.in staging command on
debian:trixie-slimand on another minimal Debian base (both previously failed, now pass), plus a bogus-fpath (still fails). shellcheck clean.