Earlier quoted context omitted.
You don't need buildkit for that; you can use multi-stage builds without buildkit to exclude your deb file from the final image.
I don’t find it satisfying: I can copy files from one stage to another, but I can’t install a .deb (or any other package for that matter). Copying a list of paths will break if the package changes, and it can’t easily do anything done by pre-install and post-install scripts (like changing a file, registering a GPG key, etc.) The official excuse from Docker is that “multi-stage builds cover that use”, but that’s not t…
I do not really consider this limitation a design flaw of Dockerfiles; this is more of a mismatch between Dockerfile functionality and what you want to do. Dockerfiles are not designed to execute general-purpose programs, so there is an assumption in the design of Dockerfiles that you know (more or less) which files you want to COPY ahead of time. It sounds like you want a mechanism for COPYing all filesystem changes resulting from a RUN instruction without having to know what those changes are ahead of time.
In the future, maybe a buildkit HLB language will provide a macro system that makes this sort of thing straightforward to implement.