The original post: /r/debian by /u/DeanMcGintySandsIII on 2024-12-19 20:08:15.

Sorry if this has been DtD.

Using Debian Bookworm for an embedded product. I’m writing a (lengthy) build script for generating a basic disk image to be duplicated across the product line.

Near the end, in an older script, my senior colleague included rm -rf "${ROOT_FOLDER}/var/cache" . While walking through the build script and occasionally backtracking, I’ve noticed this causing problems, notably with apt and debconf.

In Docker images I’ve seen (note: this is not for Docker), it’s common practice to do something like:

rm -rf "${ROOT_FOLDER}/var/lib/apt/lists"/* ;
rm -f "${ROOT_FOLDER}/var/cache/apt/archives"/*.deb \
    "${ROOT_FOLDER}/var/cache/apt/archives/partial"/*.deb \
    "${ROOT_FOLDER}/var/cache/apt"/*.bin ;

Anything else you would recommend?