Local package cache? #42

Open
opened 2 weeks ago by darkpenguin · 3 comments

Hi!
debootstrap has an option to cache downloaded packages:
--cache-dir=/var/cache/apt/archives
This caches downloaded packages on the host (not in the "guest"), which speeds up consecutive bootstrap runs.
Does mmdebstrap has some way to achieve a similar effect?

Hi! `debootstrap` has an option to cache downloaded packages: `--cache-dir=/var/cache/apt/archives` This caches downloaded packages on the host (not in the "guest"), which speeds up consecutive bootstrap runs. Does `mmdebstrap` has some way to achieve a similar effect?
josch commented 2 weeks ago
Owner

What the debootstrap --cache-dir option does is a layer violation. You have at least two options to do something similar in mmdebstrap:

  1. add a similar layer violation in the form of hook scripts which copy-in your debs before apt starts the download and which copy out the debs at the end of the run
  2. use a http cacher like apt-cacher or apt-cacher-ng

If you go the first route, feel free to share your scripts. If they are general-purpose enough I can include them in the hooks directory so that others can make use of them as well.

What the debootstrap `--cache-dir` option does is a layer violation. You have at least two options to do something similar in mmdebstrap: 1. add a similar layer violation in the form of hook scripts which copy-in your debs before apt starts the download and which copy out the debs at the end of the run 2. use a http cacher like apt-cacher or apt-cacher-ng If you go the first route, feel free to share your scripts. If they are general-purpose enough I can include them in the `hooks` directory so that others can make use of them as well.
Poster

Hm, instead of copy-in and copy-out, I would just bind-mount the directory. But then it has to be unmounted if the process is interrupted due to an error or a SIGINT. Oh, I see the docs; if at some point it installs everything in that directory, then this wouldn't work...

OK, that's fine, I was just wondering if there is already a solution I couldn't find. (Maybe the --cache-dir option should be added to the list of "debootstrap options that don't exist" in the readme file?)

Hm, instead of copy-in and copy-out, I would just bind-mount the directory. But then it has to be unmounted if the process is interrupted due to an error or a SIGINT. Oh, I see the docs; if at some point it installs everything in that directory, then this wouldn't work... OK, that's fine, I was just wondering if there is already a solution I couldn't find. (Maybe the `--cache-dir` option should be added to the list of "debootstrap options that don't exist" in the readme file?)
josch commented 2 weeks ago
Owner

No, mmdebstrap creates its own mount namespace, so everything gets unmounted automatically even if you should forget to unmount or if the process dies early. Have a look in /usr/share/mmdebstrap/hooks/file-mirror-automount for inspiration how an external file:// repository can be auto-mounted.

Also, you really should not mess with /var/lib/apt/archives. That directory is an implementation detail of apt and only apt should operate on it.

The best solution is really to set up a local apt proxy. There are various solutions to that problem so mmdebstrap does not have to add its own thing.

No, mmdebstrap creates its own mount namespace, so everything gets unmounted automatically even if you should forget to unmount or if the process dies early. Have a look in `/usr/share/mmdebstrap/hooks/file-mirror-automount` for inspiration how an external `file://` repository can be auto-mounted. Also, you *really* should not mess with `/var/lib/apt/archives`. That directory is an implementation detail of apt and only apt should operate on it. The best solution is really to set up a local apt proxy. There are various solutions to that problem so mmdebstrap does not have to add its own thing.
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: josch/mmdebstrap#42
Loading…
There is no content yet.