Одна из стратегий, которая могла бы работать, заключалась в том, чтобы установить (с опцией --bind) общую папку в кеш-память chroot. Этот кеш находится в /var/cache/apt/archives/
. Используя этот метод, он сделает так, чтобы любая команда, выполняемая apt, работала с общим локальным архивом.
sudo mount --bind ~/builds/cache <chroot location>/var/cache/apt/archives
sudo mount --bind ~/builds/cache <another chroot location>/var/cache/apt/archives
, это создало бы ~ / builds / cache и оба архива chroot, работающие с одним и тем же каталогом.
sudo mount --bind /var/cache/apt/archives <chroot location>/var/cache/apt/archives
sudo mount --bind /var/cache/apt/archives <another chroot location>/var/cache/apt/archives
Подобно первому, но теперь основная установка и оба chroots будут использовать один и тот же apt-архив, т. е. apt in все три будут выглядеть в одном месте для загруженных файлов .deb.
(Я думал, что пакеты не заботятся непосредственно о выпуске ubuntu, а также о версиях связанных пакетов. Поэтому вам может не понадобиться беспокоиться о отдельные папки для каждой версии, и вы даже можете использовать архив пакетов локальной установки.)
Наконец, и что важно, в разделе об очистке chroot при подготовке для окончательной сборки вы не хотите запускать apt clean. Так как apt теперь использует одну и ту же папку для всех chroots setup таким образом, apt clean по существу очищает архив для всех chroots сразу. Вместо этого внутри chroot запустите:
umount /var/cache/apt/archives
Это будет эффективно «apt clean» архива только из chroot, где выполняется команда, оставив общую папку нетронутой.
[d11 ] Bind mounts manual infoНиже приведена прямая копия с страницы man mount. Пожалуйста, взгляните на это, чтобы получить полное объяснение mount -bind и, возможно, увидеть другие способы использования bind.
The bind mounts.
Since Linux 2.4.0 it is possible to remount part of the file
hierarchy somewhere else. The call is:
mount --bind olddir newdir
or by using this fstab entry:
/olddir /newdir none bind
After this call the same contents are accessible in two places.
One can also remount a single file (on a single file). It's
also possible to use the bind mount to create a mountpoint from
a regular directory, for example:
mount --bind foo foo
The bind mount call attaches only (part of) a single filesystem,
not possible submounts. The entire file hierarchy including
submounts is attached a second place by using:
mount --rbind olddir newdir
Note that the filesystem mount options will remain the same as
those on the original mount point, and cannot be changed by
passing the -o option along with --bind/--rbind. The mount
options can be changed by a separate remount command, for exam‐
ple:
mount --bind olddir newdir
mount -o remount,ro newdir
Note that the behavior of the remount operation depends on the
/etc/mtab file. The first command stores the 'bind' flag in the
/etc/mtab file and the second command reads the flag from the
file. If you have a system without the /etc/mtab file or if you
explicitly define source and target for the remount command
(then mount(8) does not read /etc/mtab), then you have to use
the bind flag (or option) for the remount command too. For
example:
mount --bind olddir newdir
mount -o remount,ro,bind olddir newdir
Note that remount,ro,bind will create a read-only mountpoint
(VFS entry), but the original filesystem superblock will still
be writable, meaning that the olddir will be writable, but the
newdir will be read-only.